{ lib , common_amd64 }: { overlays = common_amd64.overlays ++ [(final: prev: { platform_name = "kgpe"; kernel = final.lib.makeOverridable (prev.kernel.override { config = ./linux.config; buildTargets = [ "bzImage" ]; }).overrideAttrs (a: { postInstall = (a.postInstall or "") + '' cp arch/x86_64/boot/bzImage $out ''; }); userspace = prev.userspace.overrideAttrs (a: { postInstall = (a.postInstall or "") + '' mkdir -p $out/etc cp ${final.coreboot.src}/src/mainboard/asus/kgpe-d16/cmos.layout $out/etc/ cp ${final.coreboot.src}/src/mainboard/asus/kgpe-d16/cmos.default $out/etc/ ''; }); # microcode updates are needed only for Opteron 63xx # # TODO: check processor type at boot time and refuse to boot # insecure configurations? (63xx without microcode) microcode-blob = null; console-device = "ttyS0"; # the DB9 connector on the rear panel # This contains the default values written into the # battery-backed nvram when you boot with the recovery jumper # installed (which is something you should do the first time you # boot with ownerboot/coreboot). If you want to customize these # values, copy `src/mainboard/asus/kgpe-d16/cmos.default` out of # coreboot and edit to suit your tastes. # # TODO: use a NixOS-style structuredConfig for this. cmos-default = null; coreboot = (prev.coreboot.override { iasl = final.iasl_20180531; payload = "${final.kernel}/bzImage"; fmap = ./custom.fmap; config = with lib.kernel; { CBFS_PREFIX = lib.mkForce (freeform "prefix"); # Upstream describes this option as "Enable this option if # coreboot shall read options from the CMOS NVRAM instead of # using hard-coded values." # # The RTC_BOOT_BYTE (which controls normal/fallback) # indicator is always taken from CMOS NVRAM, regardless of # how this option is set. When set to `no`, no other parts # of the CMOS NVRAM are read or written. # # On KGPE-D16 I have found that USE_OPTION_TABLE=yes is # frustratingly flaky and unstable; about 1 in 20 boots will # hang in the PNP device enumeration. Apparently during SMP # boot, multiple cores attempt to access the (single) CMOS # NVRAM concurrently, causing massive headaches. Please # don't turn this option on unless you are willing to deal # with extreme frustration. # USE_OPTION_TABLE = lib.mkForce no; BOARD_ASUS_KGPE_D16 = lib.mkForce yes; VENDOR_ASUS = lib.mkForce yes; # might want to customize these MAINBOARD_VENDOR = lib.mkForce (freeform "ASUS"); MAINBOARD_VERSION = lib.mkForce (freeform "1.0"); MAINBOARD_SERIAL_NUMBER = lib.mkForce (freeform "123456789"); MAINBOARD_SMBIOS_PRODUCT_NAME = lib.mkForce (freeform "KGPE-D16"); MAINBOARD_SMBIOS_MANUFACTURER = lib.mkForce (freeform "ASUS"); CBFS_SIZE = lib.mkForce (freeform "0x7FFC00"); COREBOOT_ROMSIZE_KB_16384 = lib.mkForce yes; NO_POST = lib.mkForce yes; PAYLOAD_LINUX = lib.mkForce yes; PAYLOAD_OPTIONS = lib.mkForce (freeform ""); COMPRESS_SECONDARY_PAYLOAD = lib.mkForce yes; CPU_MICROCODE_CBFS_GENERATE = lib.mkForce yes; CPU_MICROCODE_MULTIPLE_FILES = lib.mkForce yes; CPU_UCODE_BINARIES = lib.mkForce (freeform ""); COLLECT_TIMESTAMPS = lib.mkForce no; DRIVERS_INTEL_WIFI = lib.mkForce no; EXT_CONF_SUPPORT = lib.mkForce no; CONSOLE_CBMEM = lib.mkForce no; ONBOARD_VGA_IS_PRIMARY = lib.mkForce no; # Coreboot on some versions of the kgpe-d16 will hang during # PNP enumeration approximately ~10% of the time during PNP # enumeration (before DRAM init); starting the watchdog from # the romstage ensures that the machine will always finish # booting, although it may take two (or in rare cases three) # attempts. You absolutely want this for unattended servers. USE_WATCHDOG_ON_BOOT = lib.mkForce yes; }; coreboot-toolchain = with final.coreboot-toolchain; [ x64 i386 ]; uart-for-console = if final.console-device == "ttyS0" then 0 # the DB9 connector on the rear panel else if final.console-device == "ttyS1" then 1 # the IDC header on the motherboard else if final.console-device == null then null else throw "kgpe currently supports only `null` and `ttyS{0,1}` for `console-device`"; }).overrideAttrs (a: { postConfigure = if final.microcode-blob != null then '' echo CONFIG_CPU_MICROCODE_MULTIPLE_FILES=y >> .config '' else '' echo CONFIG_CPU_MICROCODE_CBFS_NONE=y >> .config ''; preBuild = final.lib.optionalString (final.microcode-blob != null) '' mkdir -p 3rdparty/blobs/cpu/amd/family_15h/ ln -sfT ${final.microcode-blob} \ 3rdparty/blobs/cpu/amd/family_15h/microcode_amd_fam15h.bin mkdir -p 3rdparty/blobs/cpu/amd/family_10h-family_14h/ touch 3rdparty/blobs/cpu/amd/family_10h-family_14h/microcode_amd.bin '' + final.lib.optionalString (final.cmos-default != null) '' cp ${final.cmos-default} src/mainboard/asus/kgpe-d16/cmos.default ''; postInstall = (a.postInstall or "") + '' cp src/mainboard/asus/kgpe-d16/cmos.layout $out/ cp src/mainboard/asus/kgpe-d16/cmos.default $out/ ''; }); })]; }