Skip to content

Commit

Permalink
- Addition of nvmutil (nvm) from osboot project to play with gbe (Tha…
Browse files Browse the repository at this point in the history
…nks @githubisnonfree!)

- Addition of ifdtool from coreboot project to extract gbe
- CONFIG_NVMUTIL in board config adds both ifdtool and nvmutil into initrd

Manually tested (working!):
- backup rom from: `flashrom -p internal -r /tmp/backup.rom`
- go to that dir: `cd /tmp`
- extract gbe from ifdtool on backup.rom: `ifdtool -x backup.rom`
- source shell functions: `. /etc/functions`
- show current PHY mac address: `nvm showmac flashregion_3_gbe.bin`
- generate mac address from sourced shell functions: `newmac=$(generate_random_mac_address)`
- show new mac: `echo $newmac`
- change mac from nvmtool on extracted gbe: `nvm flashregion_3_gbe.bin setmac $newmac`
- insert modified gbe into backup.rom.new with ifdtool: `ifdtool -i gbe:flashregion_3_gbe.bin backup.rom`
- flash back modified gbe only through flashrom: `flashrom -p internal --ifd -i gbe -w backup.rom.new`
  • Loading branch information
tlaurion committed Aug 2, 2022
1 parent 21505aa commit 6283a3f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ bin_modules-$(CONFIG_FBWHIPTAIL) += fbwhiptail
bin_modules-$(CONFIG_HOTPKEY) += hotp-verification
bin_modules-$(CONFIG_MSRTOOLS) += msrtools
bin_modules-$(CONFIG_NKSTORECLI) += nkstorecli
bin_modules-$(CONFIG_NVMUTIL) += nvmutil

$(foreach m, $(bin_modules-y), \
$(call map,initrd_bin_add,$(call bins,$m)) \
Expand All @@ -451,7 +452,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.
#
Expand All @@ -460,11 +461,16 @@ 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.
$(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) \
Expand Down
1 change: 1 addition & 0 deletions boards/x230-hotp-maximized/x230-hotp-maximized.config
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions modules/nvmutil
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
modules-$(CONFIG_NVMUTIL) += nvmutil

nvmutil_depends := $(musl_dep)

nvmutil_version := 20220802
nvmutil_dir := nvmutil-tools-$(nvmutil_version)
nvmutil_tar := $(nvmutil_version).tar.gz
nvmutil_url := https://notabug.org/osboot/nvmutil/archive/$(nvmutil_tar)
nvmutil_hash := 9c82964c073bf38abcd64e9d394308fe88c92f1f828f4a1933284c972818493b

nvmutil_target := \
$(CROSS_TOOLS) \
CFLAGS="-I$(INSTALL)/include" \
LDFLAGS="-L$(INSTALL)/lib" \

nvmutil_output := \
nvm \

nvmutil_libraries := \

nvmutil_configure :=

0 comments on commit 6283a3f

Please sign in to comment.