src/coreboot: switch to lib/modules.nix-style Kconfig

This commit drops the verbatim `.config` files for coreboot that
were previously in the repository and converts them to NixOS-style
module configurations.

The big benefit of doing this is that the perl script in nixpkgs
that handles this will check to make sure that coreboot's Kconfig
machinery isn't silently ignoring any of our settings.  It also
makes this configuration easier for end-users to customize.
master
Adam Joseph 2 years ago
parent 4391f2fb0f
commit 88d20a5f63

@ -1,9 +1,10 @@
{ lib { lib
, nixpkgsOnBuildForBuild , nixpkgsOnBuildForBuild
, nixpkgsOnBuildForHost
, coreboot-toolchain ? throw "missing" , coreboot-toolchain ? throw "missing"
, payload ? throw "you must provide a coreboot payload (Linux kernel image or FIT)" , payload ? throw "you must provide a coreboot payload (Linux kernel image or FIT)"
, fmap ? throw "you must provide an FMAP (flash chip partition table)" , 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 <nixpkgs/lib/modules.nix>-style structuredConfig"
, initramfs_image # path to the initramfs `cpio` archive , initramfs_image # path to the initramfs `cpio` archive
, iasl ? null # a specific iasl to use, if needed , iasl ? null # a specific iasl to use, if needed
, console_loglevel ? "6" # 8=SPEW, 7=DEBUG, 6=INFO , console_loglevel ? "6" # 8=SPEW, 7=DEBUG, 6=INFO
@ -100,38 +101,64 @@ stdenv.mkDerivation {
postPatch = '' postPatch = ''
patchShebangs . 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 = [ nativeBuildInputs = [
git git
python3 python3
ncurses ncurses
nixpkgsOnBuildForBuild.perl # for generate-config.pl
] ++ coreboot-toolchain; ] ++ coreboot-toolchain;
enableParallelBuilding = false; # does not work enableParallelBuilding = false; # does not work
# FIXME: use the nixpkgs `kernel/manual-config.nix` machinery here passAsFile = [ "structuredConfig" ];
structuredConfig = (lib.evalModules {
modules = [
(import <nixpkgs/nixos/modules/system/boot/kernel_config.nix>)
{
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; '' configurePhase = assert uart-for-console == null || lib.isInt uart-for-console; ''
runHook preConfigure runHook preConfigure
cp ${config} .config make config < /dev/null
chmod +w .config
sed -i 's/^CONFIG_DEFAULT_CONSOLE_LOGLEVEL//' .config DEBUG=1 \
echo 'CONFIG_DEFAULT_CONSOLE_LOGLEVEL_${console_loglevel}=y' >> .config ignoreConfigErrors=0 \
echo 'CONFIG_DEFAULT_CONSOLE_LOGLEVEL=${console_loglevel}' >> .config MAKE_FLAGS="" \
sed -i 's/^CONFIG_LINUX_COMMAND_LINE//' .config ARCH="${nixpkgsOnBuildForHost.stdenv.hostPlatform.linuxArch}" \
echo 'CONFIG_LINUX_COMMAND_LINE="${linux-command-line}"' >> .config HOSTCC=$HOSTCC \
sed -i 's/^CONFIG_FMDFILE=.*//' .config HOSTCXX=$HOSTCXX \
echo 'CONFIG_FMDFILE="${fmap}"' >> .config SRC=. \
sed -i 's/^CONFIG_PAYLOAD_FILE=.*//' .config BUILD_ROOT=$(pwd) \
echo 'CONFIG_PAYLOAD_FILE="${payload}"' >> .config KERNEL_CONFIG=$structuredConfigPath \
sed -i 's/^CONFIG_LINUX_INITRD=.*//' .config perl -w ${<nixpkgs/pkgs/os-specific/linux/kernel/generate-config.pl>}
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
'' + ''
runHook postConfigure runHook postConfigure
''; '';
@ -165,4 +192,6 @@ stdenv.mkDerivation {
runHook postInstall runHook postInstall
''; '';
passthru = { inherit config; };
} }

@ -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

@ -1,6 +1,7 @@
{ lib ? import <nixpkgs/lib> { lib ? import <nixpkgs/lib>
, common_amd64 , common_amd64
}: }:
{ {
overlays = common_amd64.overlays ++ [(final: prev: { overlays = common_amd64.overlays ++ [(final: prev: {
@ -18,23 +19,46 @@
console-device = "ttyS1"; console-device = "ttyS1";
coreboot = final.lib.makeOverridable (prev.coreboot.override { coreboot = (prev.coreboot.override {
iasl = final.iasl_20180531; iasl = final.iasl_20180531;
payload = "${final.kernel}/bzImage"; payload = "${final.kernel}/bzImage";
coreboot-toolchain = with final.coreboot-toolchain; [ x64 i386 ]; coreboot-toolchain = with final.coreboot-toolchain; [ x64 i386 ];
fmap = ./custom.fmap; 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 = uart-for-console =
if final.console-device == "ttyS0" then 0 # IDC ribbon-cable header on the motherboarod 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 == "ttyS1" then 1 # DB9 connector on rear I/O panel; omitted from some board variants
else if final.console-device == null then null else if final.console-device == null then null
else throw "am1i currently supports only `null` and `ttyS{0,1}` for `console-device`"; else throw "am1i currently supports only `null` and `ttyS{0,1}` for `console-device`";
}).overrideAttrs (a: { }).overrideAttrs (a: {
/*
postConfigure = (a.postConfigure or "") + ''
echo CONFIG_VGA_BIOS_FILE=\"${./kabini-vgabios.rom}\" >> .config
'';
*/
postInstall = (a.postInstall or "") + '' postInstall = (a.postInstall or "") + ''
cp src/mainboard/asus/am1i-a/cmos.layout $out/ cp src/mainboard/asus/am1i-a/cmos.layout $out/
''; '';

@ -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

@ -33,6 +33,7 @@ let
"drivers/net/wireless/marvell/mwifiex/mwifiex_pcie.ko" "drivers/net/wireless/marvell/mwifiex/mwifiex_pcie.ko"
"drivers/net/wireless/marvell/mwifiex/mwifiex.ko" "drivers/net/wireless/marvell/mwifiex/mwifiex.ko"
]; ];
in { in {
overlays = common_arm64.overlays ++ [(final: prev: { overlays = common_arm64.overlays ++ [(final: prev: {
@ -74,18 +75,50 @@ in {
fit = final.nixpkgsOnBuildForBuild.callPackage (import ./fit) { fit = final.nixpkgsOnBuildForBuild.callPackage (import ./fit) {
inherit (final) initramfs kernel; inherit (final) initramfs kernel;
}; };
in final.lib.makeOverridable (prev.coreboot.override { in (prev.coreboot.override {
payload = "${fit}/Image.fit"; payload = "${fit}/Image.fit";
fmap = ./custom.fmap; 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 ]; coreboot-toolchain = with final.coreboot-toolchain; [ aarch64 ];
initramfs_image = null; # it is part of the FIT image
uart-for-console = uart-for-console =
if final.console-device == "ttyS2" then 0 if final.console-device == "ttyS2" then 0
else if final.console-device == null then null else if final.console-device == null then null
else throw "gru-kevin currently supports only `null` and `ttyS2` for `console-device`"; else throw "gru-kevin currently supports only `null` and `ttyS2` for `console-device`";
}).overrideAttrs (a: { }).overrideAttrs (a: {
postConfigure = '' postConfigure = ''
echo CONFIG_ARM64_BL31_EXTERNAL_FILE=\"${atf}/bl31.elf\" >> .config
mkdir -p 3rdparty/arm-trusted-firmware/plat/rockchip/common/include/ mkdir -p 3rdparty/arm-trusted-firmware/plat/rockchip/common/include/
ln -s ${atf}/plat_params.h 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/ mkdir -p 3rdparty/arm-trusted-firmware/plat/rockchip/rk3399/include/shared/

@ -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

@ -43,11 +43,46 @@
# TODO: use a NixOS-style structuredConfig for this. # TODO: use a NixOS-style structuredConfig for this.
cmos-default = null; cmos-default = null;
coreboot = final.lib.makeOverridable (prev.coreboot.override { coreboot = (prev.coreboot.override {
iasl = final.iasl_20180531; iasl = final.iasl_20180531;
payload = "${final.kernel}/bzImage"; payload = "${final.kernel}/bzImage";
fmap = ./custom.fmap; 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 ]; coreboot-toolchain = with final.coreboot-toolchain; [ x64 i386 ];
uart-for-console = uart-for-console =
if final.console-device == "ttyS0" then 0 # the DB9 connector on the rear panel if final.console-device == "ttyS0" then 0 # the DB9 connector on the rear panel

Loading…
Cancel
Save