diff --git a/Makefile b/Makefile index 0e2de85f1..ca63de283 100644 --- a/Makefile +++ b/Makefile @@ -582,6 +582,7 @@ bin_modules-$(CONFIG_ZSTD) += zstd bin_modules-$(CONFIG_E2FSPROGS) += e2fsprogs bin_modules-$(CONFIG_EXFATPROGS) += exfatprogs bin_modules-$(CONFIG_IOTOOLS) += iotools +bin_modules-$(CONFIG_NVMUTIL) += nvmutil $(foreach m, $(bin_modules-y), \ $(call map,initrd_bin_add,$(call bins,$m)) \ @@ -593,7 +594,7 @@ $(foreach m, $(modules-y), \ ) # -# hack to build cbmem from coreboot +# hack to build cbmem and ifdtool from coreboot # this must be built *AFTER* musl, but since coreboot depends on other things # that depend on musl it should be ok. # @@ -602,11 +603,17 @@ ifeq ($(CONFIG_COREBOOT),y) $(eval $(call initrd_bin_add,$(COREBOOT_UTIL_DIR)/cbmem/cbmem)) #$(eval $(call initrd_bin_add,$(COREBOOT_UTIL_DIR)/superiotool/superiotool)) #$(eval $(call initrd_bin_add,$(COREBOOT_UTIL_DIR)/inteltool/inteltool)) +ifeq ($(CONFIG_NVMUTIL),y) +#NVMUTIL(nvm) is applied on ifdtool extracted gbe.bin from a flashrom backup under Heads. +# We consequently need ifdtool packed under initrd with cross-compiler +$(eval $(call initrd_bin_add,$(COREBOOT_UTIL_DIR)/ifdtool/ifdtool)) +endif endif $(COREBOOT_UTIL_DIR)/cbmem/cbmem \ $(COREBOOT_UTIL_DIR)/superiotool/superiotool \ $(COREBOOT_UTIL_DIR)/inteltool/inteltool \ +$(COREBOOT_UTIL_DIR)/ifdtool/ifdtool \ : $(build)/$(coreboot_base_dir)/.canary musl-cross +$(call do,MAKE,$(notdir $@),\ $(MAKE) -C "$(dir $@)" $(CROSS_TOOLS) \ diff --git a/boards/UNTESTED_t520-hotp-maximized/UNTESTED_t520-hotp-maximized.config b/boards/UNTESTED_t520-hotp-maximized/UNTESTED_t520-hotp-maximized.config index cd3752942..e7e5af840 100644 --- a/boards/UNTESTED_t520-hotp-maximized/UNTESTED_t520-hotp-maximized.config +++ b/boards/UNTESTED_t520-hotp-maximized/UNTESTED_t520-hotp-maximized.config @@ -18,6 +18,7 @@ CONFIG_LINUX_E1000E=y CONFIG_CRYPTSETUP=y CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y +CONFIG_NVMUTIL=y CONFIG_GPG2=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y diff --git a/boards/UNTESTED_t530-dgpu-hotp-maximized/UNTESTED_t530-dgpu-hotp-maximized.config b/boards/UNTESTED_t530-dgpu-hotp-maximized/UNTESTED_t530-dgpu-hotp-maximized.config index 2bee0e424..b5b31a090 100644 --- a/boards/UNTESTED_t530-dgpu-hotp-maximized/UNTESTED_t530-dgpu-hotp-maximized.config +++ b/boards/UNTESTED_t530-dgpu-hotp-maximized/UNTESTED_t530-dgpu-hotp-maximized.config @@ -21,6 +21,7 @@ CONFIG_LINUX_E1000E=y CONFIG_CRYPTSETUP2=y CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y +CONFIG_NVMUTIL=y CONFIG_GPG2=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y diff --git a/boards/UNTESTED_w530-dgpu-K1000m-hotp-maximized/UNTESTED_w530-dgpu-K1000m-hotp-maximized.config b/boards/UNTESTED_w530-dgpu-K1000m-hotp-maximized/UNTESTED_w530-dgpu-K1000m-hotp-maximized.config index e008d6f59..9d7173023 100644 --- a/boards/UNTESTED_w530-dgpu-K1000m-hotp-maximized/UNTESTED_w530-dgpu-K1000m-hotp-maximized.config +++ b/boards/UNTESTED_w530-dgpu-K1000m-hotp-maximized/UNTESTED_w530-dgpu-K1000m-hotp-maximized.config @@ -21,6 +21,7 @@ CONFIG_LINUX_E1000E=y CONFIG_CRYPTSETUP2=y CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y +CONFIG_NVMUTIL=y CONFIG_GPG2=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y diff --git a/boards/UNTESTED_w530-dgpu-K2000m-hotp-maximized/UNTESTED_w530-dgpu-K2000m-hotp-maximized.config b/boards/UNTESTED_w530-dgpu-K2000m-hotp-maximized/UNTESTED_w530-dgpu-K2000m-hotp-maximized.config index b006a12c9..884567a98 100644 --- a/boards/UNTESTED_w530-dgpu-K2000m-hotp-maximized/UNTESTED_w530-dgpu-K2000m-hotp-maximized.config +++ b/boards/UNTESTED_w530-dgpu-K2000m-hotp-maximized/UNTESTED_w530-dgpu-K2000m-hotp-maximized.config @@ -21,6 +21,7 @@ CONFIG_LINUX_E1000E=y CONFIG_CRYPTSETUP2=y CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y +CONFIG_NVMUTIL=y CONFIG_GPG2=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y diff --git a/boards/t420-hotp-maximized/t420-hotp-maximized.config b/boards/t420-hotp-maximized/t420-hotp-maximized.config index d248c8c3b..3a426f4aa 100644 --- a/boards/t420-hotp-maximized/t420-hotp-maximized.config +++ b/boards/t420-hotp-maximized/t420-hotp-maximized.config @@ -22,6 +22,7 @@ CONFIG_LINUX_E1000E=y CONFIG_CRYPTSETUP2=y CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y +CONFIG_NVMUTIL=y CONFIG_GPG2=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y diff --git a/boards/t430-hotp-maximized/t430-hotp-maximized.config b/boards/t430-hotp-maximized/t430-hotp-maximized.config index 0a09feb11..2f51066f4 100644 --- a/boards/t430-hotp-maximized/t430-hotp-maximized.config +++ b/boards/t430-hotp-maximized/t430-hotp-maximized.config @@ -20,6 +20,7 @@ CONFIG_LINUX_E1000E=y CONFIG_CRYPTSETUP2=y CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y +CONFIG_NVMUTIL=y CONFIG_GPG2=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y diff --git a/boards/w530-hotp-maximized/w530-hotp-maximized.config b/boards/w530-hotp-maximized/w530-hotp-maximized.config index 76a6691a6..00bca3792 100644 --- a/boards/w530-hotp-maximized/w530-hotp-maximized.config +++ b/boards/w530-hotp-maximized/w530-hotp-maximized.config @@ -21,6 +21,7 @@ CONFIG_LINUX_E1000E=y CONFIG_CRYPTSETUP2=y CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y +CONFIG_NVMUTIL=y CONFIG_GPG2=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y diff --git a/boards/x220-hotp-maximized/x220-hotp-maximized.config b/boards/x220-hotp-maximized/x220-hotp-maximized.config index 905da3c27..bb424dde1 100644 --- a/boards/x220-hotp-maximized/x220-hotp-maximized.config +++ b/boards/x220-hotp-maximized/x220-hotp-maximized.config @@ -22,6 +22,7 @@ CONFIG_LINUX_E1000E=y CONFIG_CRYPTSETUP2=y CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y +CONFIG_NVMUTIL=y CONFIG_GPG2=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y diff --git a/boards/x230-hotp-maximized/x230-hotp-maximized.config b/boards/x230-hotp-maximized/x230-hotp-maximized.config index 040d99905..89643bc77 100644 --- a/boards/x230-hotp-maximized/x230-hotp-maximized.config +++ b/boards/x230-hotp-maximized/x230-hotp-maximized.config @@ -24,6 +24,7 @@ CONFIG_LINUX_E1000E=y CONFIG_CRYPTSETUP2=y CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y +CONFIG_NVMUTIL=y CONFIG_GPG2=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y diff --git a/boards/x230-hotp-maximized_usb-kb/x230-hotp-maximized_usb-kb.config b/boards/x230-hotp-maximized_usb-kb/x230-hotp-maximized_usb-kb.config index a2e616600..60a05358d 100644 --- a/boards/x230-hotp-maximized_usb-kb/x230-hotp-maximized_usb-kb.config +++ b/boards/x230-hotp-maximized_usb-kb/x230-hotp-maximized_usb-kb.config @@ -23,6 +23,7 @@ export CONFIG_USB_KEYBOARD_REQUIRED=y CONFIG_CRYPTSETUP2=y CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y +CONFIG_NVMUTIL=y CONFIG_GPG2=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y diff --git a/boards/x230-maximized/x230-maximized.config b/boards/x230-maximized/x230-maximized.config index 58a81476d..7b8b837d5 100644 --- a/boards/x230-maximized/x230-maximized.config +++ b/boards/x230-maximized/x230-maximized.config @@ -24,6 +24,7 @@ CONFIG_LINUX_E1000E=y CONFIG_CRYPTSETUP2=y CONFIG_FLASHROM=y CONFIG_FLASHTOOLS=y +CONFIG_NVMUTIL=y CONFIG_GPG2=y CONFIG_KEXEC=y CONFIG_UTIL_LINUX=y diff --git a/modules/coreboot b/modules/coreboot index a066b058e..d51be5d64 100644 --- a/modules/coreboot +++ b/modules/coreboot @@ -136,11 +136,13 @@ else $(coreboot-toolchain_module)_target := -f Makefile.nobuild endif +# We delete ifdtool here so its rebuilt (nvmutil builds it with musl-cross-make to be packed under initrd) $(coreboot_module)_configure := \ mkdir -p "$(build)/$(coreboot_dir)" \ && $(call install_config,$(pwd)/$(CONFIG_COREBOOT_CONFIG),$(build)/$(coreboot_dir)/.config) \ && echo 'CONFIG_LOCALVERSION="$(BRAND_NAME)-$(HEADS_GIT_VERSION)"' >> $(build)/$(coreboot_dir)/.config \ && echo 'CONFIG_MAINBOARD_SMBIOS_PRODUCT_NAME="$(BOARD)"' >> $(build)/$(coreboot_dir)/.config \ + && rm -rf $(build)/$(coreboot_base_dir)/util/ifdtool/ifdtool \ && $(MAKE) olddefconfig \ -C "$(build)/$(coreboot_base_dir)" \ obj="$(build)/$(coreboot_dir)" \ diff --git a/modules/nvmutil b/modules/nvmutil new file mode 100644 index 000000000..06fb1090f --- /dev/null +++ b/modules/nvmutil @@ -0,0 +1,24 @@ +modules-$(CONFIG_NVMUTIL) += nvmutil + +nvmutil_depends := $(musl_dep) + +nvmutil_version := 20240126 +nvmutil_dir := nvmutil-tools-$(nvmutil_version) +nvmutil_tar := $(nvmutil_version).tar.gz +nvmutil_url := https://codeberg.org/libreboot/lbmk/archive/$(nvmutil_tar) +nvmutil_hash := 8708f38c0c41f05bf6637c32a64e2c04ca5cf6fc175ccdde4cbd518e498d55c9 + +#Ugly hack. We pass two make -C here for nvmutil, only second one is taken into consideration +nvmutil_target := \ + $(CROSS_TOOLS) -C $(build)/$(nvmutil_dir)/util/nvmutil \ + && $(CROSS_TOOLS) $(MAKE) -C $(build)/$(coreboot_base_dir)/util/ifdtool \ + +nvmutil_output := \ + util/nvmutil/nvm \ + +nvmutil_libraries := \ + +# We remove built ifdtool artifact here so that coreboot/nvmutil module rebuilds it +nvmutil_configure := \ + rm -rf $(build)/$(coreboot_base_dir)/util/ifdtool/ifdtool \ +