diff --git a/src/coreboot/default.nix b/src/coreboot/default.nix index 096b1e6..07306ce 100644 --- a/src/coreboot/default.nix +++ b/src/coreboot/default.nix @@ -1,9 +1,10 @@ { lib , nixpkgsOnBuildForBuild +, nixpkgsOnBuildForHost , coreboot-toolchain ? throw "missing" , payload ? throw "you must provide a coreboot payload (Linux kernel image or FIT)" , fmap ? throw "you must provide an FMAP (flash chip partition table)" -, config ? throw "you must provide a coreboot .config file" +, config ? throw "you must provide a -style structuredConfig" , initramfs_image # path to the initramfs `cpio` archive , iasl ? null # a specific iasl to use, if needed , console_loglevel ? "6" # 8=SPEW, 7=DEBUG, 6=INFO @@ -100,38 +101,64 @@ stdenv.mkDerivation { postPatch = '' patchShebangs . + + # (from nixpkgs kernel/generic.nix): patch kconfig to print "###" + # after every question so that generate-config.pl from the generic + # builder can answer them. + sed -e '/fflush(stdout);/i\printf("###");' -i util/kconfig/conf.c + + # don't print the "grouping subheadings", because they confuse + # nixpkgs' perl script + sed -i 's/printf(.*indent.*menu_get_prompt.*;//' util/kconfig/conf.c ''; nativeBuildInputs = [ git python3 ncurses + nixpkgsOnBuildForBuild.perl # for generate-config.pl ] ++ coreboot-toolchain; enableParallelBuilding = false; # does not work - # FIXME: use the nixpkgs `kernel/manual-config.nix` machinery here + passAsFile = [ "structuredConfig" ]; + structuredConfig = (lib.evalModules { + modules = [ + (import ) + { + settings = with lib.kernel; config // { + "DEFAULT_CONSOLE_LOGLEVEL_${toString console_loglevel}" = lib.mkForce yes; + DEFAULT_CONSOLE_LOGLEVEL = lib.mkForce (freeform (toString console_loglevel)); + FMDFILE = lib.mkForce (freeform "${fmap}"); + PAYLOAD_FILE = lib.mkForce (freeform "${payload}"); + LINUX_COMMAND_LINE = lib.mkForce (freeform "${linux-command-line}"); + } // lib.optionalAttrs (initramfs_image != null) { + LINUX_INITRD = lib.mkForce (freeform "${initramfs_image}"); + } // lib.optionalAttrs (uart-for-console != null) { + UART_FOR_CONSOLE = lib.mkForce (freeform "${builtins.toString uart-for-console}"); + } // lib.optionalAttrs (iasl != null) { + ANY_TOOLCHAIN = lib.mkForce yes; + }; + _file = "structuredExtraConfig"; + } + ]; + }).config.intermediateNixConfig; + configurePhase = assert uart-for-console == null || lib.isInt uart-for-console; '' runHook preConfigure - cp ${config} .config - chmod +w .config - sed -i 's/^CONFIG_DEFAULT_CONSOLE_LOGLEVEL//' .config - echo 'CONFIG_DEFAULT_CONSOLE_LOGLEVEL_${console_loglevel}=y' >> .config - echo 'CONFIG_DEFAULT_CONSOLE_LOGLEVEL=${console_loglevel}' >> .config - sed -i 's/^CONFIG_LINUX_COMMAND_LINE//' .config - echo 'CONFIG_LINUX_COMMAND_LINE="${linux-command-line}"' >> .config - sed -i 's/^CONFIG_FMDFILE=.*//' .config - echo 'CONFIG_FMDFILE="${fmap}"' >> .config - sed -i 's/^CONFIG_PAYLOAD_FILE=.*//' .config - echo 'CONFIG_PAYLOAD_FILE="${payload}"' >> .config - sed -i 's/^CONFIG_LINUX_INITRD=.*//' .config - echo 'CONFIG_LINUX_INITRD="${initramfs_image}"' >> .config - sed -i 's/^CONFIG_UART_FOR_CONSOLE=.*//' .config - '' + lib.optionalString (uart-for-console != null) '' - echo 'CONFIG_UART_FOR_CONSOLE=${builtins.toString uart-for-console}' >> .config - '' + lib.optionalString (iasl != null) '' - echo CONFIG_ANY_TOOLCHAIN=y >> .config - '' + '' + make config < /dev/null + + DEBUG=1 \ + ignoreConfigErrors=0 \ + MAKE_FLAGS="" \ + ARCH="${nixpkgsOnBuildForHost.stdenv.hostPlatform.linuxArch}" \ + HOSTCC=$HOSTCC \ + HOSTCXX=$HOSTCXX \ + SRC=. \ + BUILD_ROOT=$(pwd) \ + KERNEL_CONFIG=$structuredConfigPath \ + perl -w ${} + runHook postConfigure ''; @@ -165,4 +192,6 @@ stdenv.mkDerivation { runHook postInstall ''; + + passthru = { inherit config; }; } diff --git a/src/platform/am1i/coreboot.config b/src/platform/am1i/coreboot.config deleted file mode 100644 index 24aa2b9..0000000 --- a/src/platform/am1i/coreboot.config +++ /dev/null @@ -1,26 +0,0 @@ -CONFIG_CBFS_PREFIX="prefix" - -CONFIG_VENDOR_ASUS=y -CONFIG_BOARD_ASUS_AM1I_A=y - -CONFIG_COREBOOT_ROMSIZE_KB_16384=y -CONFIG_COREBOOT_ROMSIZE_KB=16384 -CONFIG_ROM_SIZE=0x1000000 - -CONFIG_VGA_BIOS=y -CONFIG_VGA_BIOS_FILE="vgabios.bin" -CONFIG_VGA_BIOS_ID="1002,9830" -CONFIG_CBFS_SIZE=8387272 - -CONFIG_PAYLOAD_LINUX=y -CONFIG_PAYLOAD_OPTIONS="" -CONFIG_COMPRESS_SECONDARY_PAYLOAD=y - -# CONFIG_CONSOLE_CBMEM is not set -# CONFIG_DRIVERS_INTEL_WIFI is not set -# CONFIG_HUDSON_XHCI_ENABLE is not set -# CONFIG_ON_DEVICE_ROM_LOAD is not set -# CONFIG_POST_DEVICE is not set -# CONFIG_POST_IO is not set -CONFIG_DEFAULT_CONSOLE_LOGLEVEL=7 -CONFIG_HWBASE_DEBUG_CB=y diff --git a/src/platform/am1i/default.nix b/src/platform/am1i/default.nix index 0044d1c..4263e76 100644 --- a/src/platform/am1i/default.nix +++ b/src/platform/am1i/default.nix @@ -1,6 +1,7 @@ { lib ? import , common_amd64 }: + { overlays = common_amd64.overlays ++ [(final: prev: { @@ -18,23 +19,46 @@ console-device = "ttyS1"; - coreboot = final.lib.makeOverridable (prev.coreboot.override { + coreboot = (prev.coreboot.override { iasl = final.iasl_20180531; payload = "${final.kernel}/bzImage"; coreboot-toolchain = with final.coreboot-toolchain; [ x64 i386 ]; fmap = ./custom.fmap; - config = ./coreboot.config; + config = with lib.kernel; { + CBFS_PREFIX = lib.mkForce (freeform "prefix"); + + VENDOR_ASUS = lib.mkForce yes; + BOARD_ASUS_AM1I_A = lib.mkForce yes; + + COREBOOT_ROMSIZE_KB_16384 = lib.mkForce yes; + COREBOOT_ROMSIZE_KB = lib.mkForce (freeform (toString (16 * 1024))); + ROM_SIZE = lib.mkForce (freeform "0x1000000"); + + CBFS_SIZE = lib.mkForce (freeform "0x7FFAC8"); + + PAYLOAD_LINUX = lib.mkForce yes; + PAYLOAD_OPTIONS = lib.mkForce (freeform ""); + COMPRESS_SECONDARY_PAYLOAD = lib.mkForce yes; + + CONSOLE_CBMEM = lib.mkForce no; + DRIVERS_INTEL_WIFI = lib.mkForce no; + HUDSON_XHCI_ENABLE = lib.mkForce no; + ON_DEVICE_ROM_LOAD = lib.mkForce no; + POST_DEVICE = lib.mkForce no; + POST_IO = lib.mkForce no; + + DEFAULT_CONSOLE_LOGLEVEL = lib.mkForce (freeform "7"); + ONBOARD_VGA_IS_PRIMARY = lib.mkForce yes; + + MAINBOARD_SMBIOS_MANUFACTURER = lib.mkForce (freeform "ASUS"); + MAINBOARD_SMBIOS_PRODUCT_NAME = lib.mkForce (freeform "AM1I-A"); + }; uart-for-console = if final.console-device == "ttyS0" then 0 # IDC ribbon-cable header on the motherboarod else if final.console-device == "ttyS1" then 1 # DB9 connector on rear I/O panel; omitted from some board variants else if final.console-device == null then null else throw "am1i currently supports only `null` and `ttyS{0,1}` for `console-device`"; }).overrideAttrs (a: { - /* - postConfigure = (a.postConfigure or "") + '' - echo CONFIG_VGA_BIOS_FILE=\"${./kabini-vgabios.rom}\" >> .config - ''; - */ postInstall = (a.postInstall or "") + '' cp src/mainboard/asus/am1i-a/cmos.layout $out/ ''; diff --git a/src/platform/kevin/coreboot.config b/src/platform/kevin/coreboot.config deleted file mode 100644 index 4dce442..0000000 --- a/src/platform/kevin/coreboot.config +++ /dev/null @@ -1,25 +0,0 @@ -CONFIG_CBFS_PREFIX="prefix" - -# maybe set this -CONFIG_LOCALVERSION="" - -CONFIG_VENDOR_GOOGLE=y -CONFIG_BOARD_GOOGLE_KEVIN=y -CONFIG_SOC_ROCKCHIP_RK3399=y -# CONFIG_RK3399_SPREAD_SPECTRUM_DDR is not set - -CONFIG_CBFS_SIZE=7138520 -CONFIG_ROM_SIZE=0x1000000 -CONFIG_COREBOOT_ROMSIZE_KB_16384=y - -CONFIG_CONSOLE_SERIAL=y -CONFIG_BOOTBLOCK_CONSOLE=y - -# CONFIG_CONSOLE_CBMEM is not set - -CONFIG_TPM_DEACTIVATE=y - -CONFIG_PAYLOAD_FIT=y -CONFIG_PAYLOAD_FIT_SUPPORT=y -# CONFIG_COMPRESS_SECONDARY_PAYLOAD is not set -CONFIG_DEBUG_CBFS=y diff --git a/src/platform/kevin/default.nix b/src/platform/kevin/default.nix index 800174a..7a56204 100644 --- a/src/platform/kevin/default.nix +++ b/src/platform/kevin/default.nix @@ -33,6 +33,7 @@ let "drivers/net/wireless/marvell/mwifiex/mwifiex_pcie.ko" "drivers/net/wireless/marvell/mwifiex/mwifiex.ko" ]; + in { overlays = common_arm64.overlays ++ [(final: prev: { @@ -74,18 +75,50 @@ in { fit = final.nixpkgsOnBuildForBuild.callPackage (import ./fit) { inherit (final) initramfs kernel; }; - in final.lib.makeOverridable (prev.coreboot.override { + in (prev.coreboot.override { payload = "${fit}/Image.fit"; fmap = ./custom.fmap; - config = ./coreboot.config; + config = with lib.kernel; { + CBFS_PREFIX = lib.mkForce (freeform "prefix"); + + # maybe set this + LOCALVERSION = lib.mkForce (freeform ""); + + VENDOR_GOOGLE = lib.mkForce yes; + BOARD_GOOGLE_KEVIN = lib.mkForce yes; + SOC_ROCKCHIP_RK3399 = lib.mkForce yes; + + # maybe enable this + #RK3399_SPREAD_SPECTRUM_DDR = lib.mkForce yes; + + CBFS_SIZE = lib.mkForce (freeform "0x6CECD8"); + ROM_SIZE = lib.mkForce (freeform "0x${lib.toHexString (16 * 1024 * 1024)}"); + COREBOOT_ROMSIZE_KB_16384 = lib.mkForce yes; + + CONSOLE_SERIAL = lib.mkForce yes; + #BOOTBLOCK_CONSOLE = lib.mkForce yes; + + TPM_DEACTIVATE = lib.mkForce yes; + + PAYLOAD_FIT = lib.mkForce yes; + PAYLOAD_FIT_SUPPORT = lib.mkForce yes; + COMPRESS_SECONDARY_PAYLOAD = lib.mkForce no; + DEBUG_CBFS = lib.mkForce yes; + + # maybe enable this + CONSOLE_CBMEM = lib.mkForce no; + COLLECT_TIMESTAMPS = lib.mkForce no; + + ARM64_BL31_EXTERNAL_FILE = lib.mkForce (freeform "${atf}/bl31.elf"); + }; coreboot-toolchain = with final.coreboot-toolchain; [ aarch64 ]; + initramfs_image = null; # it is part of the FIT image uart-for-console = if final.console-device == "ttyS2" then 0 else if final.console-device == null then null else throw "gru-kevin currently supports only `null` and `ttyS2` for `console-device`"; }).overrideAttrs (a: { postConfigure = '' - echo CONFIG_ARM64_BL31_EXTERNAL_FILE=\"${atf}/bl31.elf\" >> .config mkdir -p 3rdparty/arm-trusted-firmware/plat/rockchip/common/include/ ln -s ${atf}/plat_params.h 3rdparty/arm-trusted-firmware/plat/rockchip/common/include/ mkdir -p 3rdparty/arm-trusted-firmware/plat/rockchip/rk3399/include/shared/ diff --git a/src/platform/kgpe/coreboot.config b/src/platform/kgpe/coreboot.config deleted file mode 100644 index 7048470..0000000 --- a/src/platform/kgpe/coreboot.config +++ /dev/null @@ -1,34 +0,0 @@ -CONFIG_CBFS_PREFIX="prefix" - -# "Enable this option if coreboot shall read options from the "CMOS" -# NVRAM instead of using hard-coded values." -CONFIG_USE_OPTION_TABLE=y - -CONFIG_BOARD_ASUS_KGPE_D16=y -CONFIG_VENDOR_ASUS=y - -# might want to customize these -CONFIG_MAINBOARD_VENDOR="ASUS" -CONFIG_MAINBOARD_VERSION="1.0" -CONFIG_MAINBOARD_SERIAL_NUMBER="123456789" -CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME="KGPE-D16" -CONFIG_MAINBOARD_SMBIOS_MANUFACTURER="ASUS" - -CONFIG_CBFS_SIZE=8387584 -CONFIG_COREBOOT_ROMSIZE_KB_16384=y - -CONFIG_NO_POST=y - -CONFIG_PAYLOAD_LINUX=y -CONFIG_PAYLOAD_OPTIONS="" -CONFIG_COMPRESS_SECONDARY_PAYLOAD=y - -# CONFIG_CONSOLE_CBMEM is not set -# CONFIG_CONSOLE_CBMEM_BUFFER_SIZE is not set -# CONFIG_COLLECT_TIMESTAMPS is not set -# CONFIG_COLLECT_TIMESTAMPS_TSC is not set -# CONFIG_DRIVERS_INTEL_WIFI is not set -# CONFIG_EXT_CONF_SUPPORT is not set -# CONFIG_ONBOARD_VGA_IS_PRIMARY is not set - - diff --git a/src/platform/kgpe/default.nix b/src/platform/kgpe/default.nix index 2abf4df..2aab9b9 100644 --- a/src/platform/kgpe/default.nix +++ b/src/platform/kgpe/default.nix @@ -43,11 +43,46 @@ # TODO: use a NixOS-style structuredConfig for this. cmos-default = null; - coreboot = final.lib.makeOverridable (prev.coreboot.override { + coreboot = (prev.coreboot.override { iasl = final.iasl_20180531; payload = "${final.kernel}/bzImage"; fmap = ./custom.fmap; - config = ./coreboot.config; + config = with lib.kernel; { + CBFS_PREFIX = lib.mkForce (freeform "prefix"); + + # (freeform "Enable this option if coreboot shall read options from the "CMOS" + # NVRAM instead of using hard-coded values." + USE_OPTION_TABLE = lib.mkForce yes; + + 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-toolchain = with final.coreboot-toolchain; [ x64 i386 ]; uart-for-console = if final.console-device == "ttyS0" then 0 # the DB9 connector on the rear panel