From 773d2deaca05cdee754ef4ec79bae9ddd1f3383c Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Fri, 2 May 2025 17:05:56 +0100 Subject: NEW MAINBOARD: Dell Precision T1700 SFF and MT This is similar to the 9020SFF, but this board has ECC support. However, the native raminit isn't used here, even though it is otherwise compatible, because the native init doesn't do ECC yet. The broadwell mrc.bin has ECC support, which is also used on the HP EliteBook 820 G2. The MRC for broadwell can be used on haswell boards such as the T1700. Add both the SFF and MT variants. Since these are identical to the 9020 variants, except for slightly different PCH enabling ECC, we can just re-use the 9020 port without issue. We *could* add a variant to coreboot, for T1700, but there is not really any pressing need. It is simply the 9020sff/mt with mrc.bin Signed-off-by: Leah Rowe --- include/inject.sh | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 6b316729..e5282861 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -86,6 +86,8 @@ getfiles() "$E6400_VGA_DL_url_bkup" "$E6400_VGA_DL_hash" "$CONFIG_VGA_BIOS_FILE" [ -z "$CONFIG_HAVE_MRC" ] || fetch "mrc" "$MRC_url" "$MRC_url_bkup" \ "$MRC_hash" "$CONFIG_MRC_FILE" + [ -n "$CONFIG_REFCODE_BLOB_FILE" ] && fetch "refcode" "$MRC_url" \ + "$MRC_url_bkup" "$MRC_hash" "$CONFIG_REFCODE_BLOB_FILE" [ -z "$CONFIG_LENOVO_TBFW_BIN" ] || fetch "tbfw" "$TBFW_url" \ "$TBFW_url_bkup" "$TBFW_hash" "$CONFIG_LENOVO_TBFW_BIN" # -- cgit v1.2.1 From d18d1c2cae2c1c43c56d5c10adb469266d1eb08b Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 3 May 2025 04:16:10 +0100 Subject: lbmk: unified execution on find commands We have a lot of places in lbmk where the output of find is used, and then some function is executed on the result. This is messy, and bloats several of these functions. Now this is unified, into a new function: fx_ What fx_ does is execute a given function, for each result found, with the arguments for a find command appended. For example: find -name ".git" If you wanted to do: foo "$arg" Where "arg" is a search result from find, and you wanted to execute "foo" on each one, you would do: fx_ foo -name ".git" The find utility does have an -exec feature, but I've found that it only works for executables, not functions. fx_ does not return errors, so "foo" in this example would have to do its own error handling. Signed-off-by: Leah Rowe --- include/inject.sh | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index e5282861..0886adc8 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -282,19 +282,18 @@ extract_tbfw() { chkvars TBFW_size # size in bytes, matching TBFW's flash IC x_ mkdir -p tmp - x_ rm -f tmp/tb.bin - find "$appdir" -type f -name "TBT.bin" > "tmp/tb.txt" || \ - $err "extract_tbfw $_dest: Can't extract TBT.bin - $dontflash" - while read -r f; do - [ -f "$f" ] || continue - [ -L "$f" ] && continue - x_ cp "$f" "tmp/tb.bin" - break - done < "tmp/tb.txt" + + x_ rm -f tmp/tb.bin && fx_ copy_tbfw "$appdir" -type f -name "TBT.bin" + x_ dd if=/dev/null of=tmp/tb.bin bs=1 seek=$TBFW_size x_ cp "tmp/tb.bin" "$_dest" } +copy_tbfw() +{ + [ -f "$1" ] && [ ! -L "$1" ] && x_ cp "$1" "tmp/tb.bin" && return 1; : +} + extract_fspm() { copy_fsp M; : @@ -419,16 +418,10 @@ patch_release_roms() hashfile="$_hashes" && break; : done - x_ mkdir -p "tmp" && [ -L "tmp/rom.list" ] && \ - $err "'$archive' -> tmp/rom.list is a symlink - $dontflash" - - find "$tmpromdir" -maxdepth 1 -type f -name "*.rom" > "tmp/rom.list" \ - || $err "'$archive' -> Can't make tmp/rom.list - $dontflash" + x_ mkdir -p "tmp" if readkconfig; then - while read -r _xrom ; do - process_release_rom "$_xrom" || break - done < "tmp/rom.list" + fx_ prep_rom "$tmpromdir" -maxdepth 1 -type f -name "*.rom" [ "$nukemode" != "nuke" ] || \ printf "Make sure you inserted vendor files: %s\n" \ "$vguide" > "$tmpromdir/README.md" || : @@ -462,7 +455,7 @@ patch_release_roms() "$archive" || $err "'$archive' -> Can't overwrite - $dontflash"; : } -process_release_rom() +prep_rom() { _xrom="$1" _xromname="${1##*/}" @@ -578,13 +571,7 @@ modify_mac() [ "$new_mac" != "restore" ] && x_ make -C util/nvmutil && \ x_ "$nvm" tmp/gbe setmac "$new_mac" - find "$tmpromdir" -maxdepth 1 -type f -name "*.rom" > "tmp/rom.list" \ - || $err "'$archive' -> Can't make tmp/rom.list - $dontflash" - - while read -r _xrom; do - e "$_xrom" f && xchanged="y" && x_ \ - "$ifdtool" $ifdprefix -i GbE:tmp/gbe "$_xrom" -O "$_xrom" - done < "tmp/rom.list" + fx_ newmac "$tmpromdir" -maxdepth 1 -type f -name "*.rom" printf "\nGbE NVM written to '%s':\n" "$archive" x_ "$nvm" tmp/gbe dump | grep -v "bytes read from file" || : @@ -593,3 +580,9 @@ modify_mac() printf "\nDefault GbE file '%s' written, unmodified.\n" \ "${CONFIG_GBE_BIN_PATH##*../}"; : } + +newmac() +{ + e "$1" f && xchanged="y" && x_ \ + "$ifdtool" $ifdprefix -i GbE:tmp/gbe "$1" -O "$1"; : +} -- cgit v1.2.1 From 47762c84ad0f5e2a6fbe5ceec0bff623239e1e9a Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 3 May 2025 05:25:11 +0100 Subject: lib.sh: add fe_ which is fx_ but err on find In the mk script, we need fx_ to not return errors on the find command, since it's searching a bunch of directories where some of them may not exist. All other instances where fx_ is used, must return an error if the directory being searched doesn't exist. For this, fe_() is introduced, which does the same as fx_ but with this much stricter check. Signed-off-by: Leah Rowe --- include/inject.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 0886adc8..2e821d86 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -283,7 +283,7 @@ extract_tbfw() chkvars TBFW_size # size in bytes, matching TBFW's flash IC x_ mkdir -p tmp - x_ rm -f tmp/tb.bin && fx_ copy_tbfw "$appdir" -type f -name "TBT.bin" + x_ rm -f tmp/tb.bin && fe_ copy_tbfw "$appdir" -type f -name "TBT.bin" x_ dd if=/dev/null of=tmp/tb.bin bs=1 seek=$TBFW_size x_ cp "tmp/tb.bin" "$_dest" @@ -421,7 +421,7 @@ patch_release_roms() x_ mkdir -p "tmp" if readkconfig; then - fx_ prep_rom "$tmpromdir" -maxdepth 1 -type f -name "*.rom" + fe_ prep_rom "$tmpromdir" -maxdepth 1 -type f -name "*.rom" [ "$nukemode" != "nuke" ] || \ printf "Make sure you inserted vendor files: %s\n" \ "$vguide" > "$tmpromdir/README.md" || : @@ -571,7 +571,7 @@ modify_mac() [ "$new_mac" != "restore" ] && x_ make -C util/nvmutil && \ x_ "$nvm" tmp/gbe setmac "$new_mac" - fx_ newmac "$tmpromdir" -maxdepth 1 -type f -name "*.rom" + fe_ newmac "$tmpromdir" -maxdepth 1 -type f -name "*.rom" printf "\nGbE NVM written to '%s':\n" "$archive" x_ "$nvm" tmp/gbe dump | grep -v "bytes read from file" || : -- cgit v1.2.1 From fcc52b986e7612d8bb53e9b51f305c62f611a35b Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 3 May 2025 05:32:01 +0100 Subject: init.sh: unified handling of ./tmp not to be confused with /tmp we use ./tmp inside the lbmk work directory, for large files, because /tmp might not be very big, or might be a tmpfs Signed-off-by: Leah Rowe --- include/inject.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 2e821d86..26bcd02f 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -148,8 +148,6 @@ extract_intel_me() chkvars ME11delta ME11version ME11sku ME11pch [ "$ME11bootguard" = "y" ] && x_ ./mk -f deguard - x_ mkdir -p tmp - extract_intel_me_bruteforce if [ "$ME11bootguard" = "y" ]; then apply_me11_deguard_mod @@ -281,7 +279,6 @@ extract_sch5545ec() extract_tbfw() { chkvars TBFW_size # size in bytes, matching TBFW's flash IC - x_ mkdir -p tmp x_ rm -f tmp/tb.bin && fe_ copy_tbfw "$appdir" -type f -name "TBT.bin" @@ -418,8 +415,6 @@ patch_release_roms() hashfile="$_hashes" && break; : done - x_ mkdir -p "tmp" - if readkconfig; then fe_ prep_rom "$tmpromdir" -maxdepth 1 -type f -name "*.rom" [ "$nukemode" != "nuke" ] || \ @@ -551,7 +546,6 @@ insert() elif [ "$nukemode" = "nuke" ]; then x_ "$cbfstool" "$rom" remove -n "$cbfsname" elif [ "$_t" = "stage" ]; then # the only stage we handle is refcode - x_ mkdir -p tmp x_ rm -f "tmp/refcode" "$rmodtool" -i "$_dest" -o "tmp/refcode" || "!reloc refcode" "$cbfstool" "$rom" add-stage -f "tmp/refcode" -n "$cbfsname" \ @@ -567,7 +561,7 @@ modify_mac() { [ -n "$CONFIG_GBE_BIN_PATH" ] || return 1 - x_ mkdir -p tmp && x_ cp "${CONFIG_GBE_BIN_PATH##*../}" tmp/gbe + x_ cp "${CONFIG_GBE_BIN_PATH##*../}" tmp/gbe [ "$new_mac" != "restore" ] && x_ make -C util/nvmutil && \ x_ "$nvm" tmp/gbe setmac "$new_mac" -- cgit v1.2.1 From 44a1cc9ef85626a0d45c7b838a3637ec9f316540 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 3 May 2025 06:23:10 +0100 Subject: util/nvmutil: use x, not ?, for random characters A user reported that '?' causes an error on zsh. See: https://codeberg.org/libreboot/lbmk/issues/261 For example: ./mk inject libreboot-XXXXXX.tar.xz setmac ??:??:??:??:??:?? The user got: zsh: no matches found: ??:??:??:??:??:?? The mitigation here is to double-quote, e.g.: ./mk inject libreboot-XXXXXX.tar.xz setmac "??:??:??:??:??:??" However, a lot of people won't do that. Therefore, I will retain the current behaviour but support x/X for randomness. Now lbmk uses x by default, instead. I will now update the documentation, accordingly. Signed-off-by: Leah Rowe --- include/inject.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 26bcd02f..beaebf4d 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -328,7 +328,7 @@ inject() eval "`setvars "" nukemode new_mac xchanged`" archive="$1"; - new_mac="??:??:??:??:??:??" + new_mac="xx:xx:xx:xx:xx:xx" [ $# -gt 1 ] && case "$2" in nuke) -- cgit v1.2.1 From 308df9ca4061e66ca1bdfb4c5c23cc4153d3ce31 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 3 May 2025 06:28:14 +0100 Subject: inject.sh: always re-build nvmutil it's not a lot of code, and takes less than a second. the previous change uses x instead of ?, but this would cause an error if the nvmutil was already built, because the makefile might cause a build to be skipped. therefore, force a re-build to mitigate the error. Signed-off-by: Leah Rowe --- include/inject.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index beaebf4d..8fb0a34e 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -562,7 +562,8 @@ modify_mac() [ -n "$CONFIG_GBE_BIN_PATH" ] || return 1 x_ cp "${CONFIG_GBE_BIN_PATH##*../}" tmp/gbe - [ "$new_mac" != "restore" ] && x_ make -C util/nvmutil && \ + [ "$new_mac" != "restore" ] && x_ make -C util/nvmutil clean && \ + x_ make -C util/nvmutil && \ x_ "$nvm" tmp/gbe setmac "$new_mac" fe_ newmac "$tmpromdir" -maxdepth 1 -type f -name "*.rom" -- cgit v1.2.1 From 0b09d970732cb396f1868c41ee9842b4a96f0c36 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 3 May 2025 06:35:48 +0100 Subject: inject.sh: Only build nvmutil once Signed-off-by: Leah Rowe --- include/inject.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 8fb0a34e..0aefc210 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -341,6 +341,11 @@ inject() esac [ "$new_mac" = "keep" ] && new_mac="" + if [ -n "$new_mac" ] && [ "$new_mac" != "restore" ]; then + x_ make -C util/nvmutil clean + x_ make -C util/nvmutil + fi + check_release "$archive" || $err "'$archive' is not a release archive" readcfg && need_files="y" @@ -562,8 +567,7 @@ modify_mac() [ -n "$CONFIG_GBE_BIN_PATH" ] || return 1 x_ cp "${CONFIG_GBE_BIN_PATH##*../}" tmp/gbe - [ "$new_mac" != "restore" ] && x_ make -C util/nvmutil clean && \ - x_ make -C util/nvmutil && \ + [ -n "$new_mac" ] && [ "$new_mac" != "restore" ] && \ x_ "$nvm" tmp/gbe setmac "$new_mac" fe_ newmac "$tmpromdir" -maxdepth 1 -type f -name "*.rom" -- cgit v1.2.1 From 00d22f20829251f55cd2e859d6fae9a61220c072 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 3 May 2025 06:53:25 +0100 Subject: lbmk: Unified local ./tmp handling Make it an absolute directory, relative to xbmktmp. Signed-off-by: Leah Rowe --- include/inject.sh | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 0aefc210..805415ef 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -14,7 +14,7 @@ hashfiles="vendorhashes blobhashes" # blobhashes for backwards compatibility dontflash="!!! AN ERROR OCCURED! Please DO NOT flash if injection failed. !!!" vfix="DO_NOT_FLASH_YET._FIRST,_INJECT_FILES_VIA_INSTRUCTIONS_ON_LIBREBOOT.ORG_" vguide="https://libreboot.org/docs/install/ivy_has_common.html" -tmpromdel="$xbmkpwd/tmp/DO_NOT_FLASH" +tmpromdel="$xbmklocal/DO_NOT_FLASH" nvm="util/nvmutil/nvm" ifdtool="elf/ifdtool/default/ifdtool" @@ -142,7 +142,7 @@ extract_intel_me() cdir="$xbmkpwd/$appdir" _me="$xbmkpwd/$_dest" - _metmp="$xbmkpwd/tmp/me.bin" + _metmp="$xbmklocal/me.bin" mfs="" && [ "$ME11bootguard" = "y" ] && mfs="--whitelist MFS" && \ chkvars ME11delta ME11version ME11sku ME11pch @@ -280,15 +280,17 @@ extract_tbfw() { chkvars TBFW_size # size in bytes, matching TBFW's flash IC - x_ rm -f tmp/tb.bin && fe_ copy_tbfw "$appdir" -type f -name "TBT.bin" + tbtmp="$xbmklocal/tb.bin" + x_ rm -f "$tbtmp" && fe_ copy_tbfw "$appdir" -type f -name "TBT.bin" - x_ dd if=/dev/null of=tmp/tb.bin bs=1 seek=$TBFW_size - x_ cp "tmp/tb.bin" "$_dest" + x_ dd if=/dev/null of="$tbtmp" bs=1 seek=$TBFW_size + x_ cp "$tbtmp" "$_dest" } copy_tbfw() { - [ -f "$1" ] && [ ! -L "$1" ] && x_ cp "$1" "tmp/tb.bin" && return 1; : + [ -f "$1" ] && [ ! -L "$1" ] && x_ cp "$1" "$xbmklocal/tb.bin" && \ + return 1; : } extract_fspm() @@ -409,7 +411,7 @@ readcfg() patch_release_roms() { has_hashes="n" - tmpromdir="tmp/DO_NOT_FLASH/bin/$board" + tmpromdir="$xbmklocal/DO_NOT_FLASH/bin/$board" remkdir "${tmpromdir%"/bin/$board"}" x_ tar -xf "$archive" -C "${tmpromdir%"/bin/$board"}" @@ -551,10 +553,10 @@ insert() elif [ "$nukemode" = "nuke" ]; then x_ "$cbfstool" "$rom" remove -n "$cbfsname" elif [ "$_t" = "stage" ]; then # the only stage we handle is refcode - x_ rm -f "tmp/refcode" - "$rmodtool" -i "$_dest" -o "tmp/refcode" || "!reloc refcode" - "$cbfstool" "$rom" add-stage -f "tmp/refcode" -n "$cbfsname" \ - -t stage || $err "$rom: !add ref" + x_ rm -f "$xbmklocal/refcode" + "$rmodtool" -i "$_dest" -o "$xbmklocal/refcode" || "!reloc ref" + "$cbfstool" "$rom" add-stage -f "$xbmklocal/refcode" \ + -n "$cbfsname" -t stage || $err "$rom: !add ref" else "$cbfstool" "$rom" add -f "$_dest" -n "$cbfsname" \ -t $_t $_offset || $err "$rom !add $_t ($_dest)" @@ -566,14 +568,14 @@ modify_mac() { [ -n "$CONFIG_GBE_BIN_PATH" ] || return 1 - x_ cp "${CONFIG_GBE_BIN_PATH##*../}" tmp/gbe + x_ cp "${CONFIG_GBE_BIN_PATH##*../}" "$xbmklocal/gbe" [ -n "$new_mac" ] && [ "$new_mac" != "restore" ] && \ - x_ "$nvm" tmp/gbe setmac "$new_mac" + x_ "$nvm" "$xbmklocal/gbe" setmac "$new_mac" fe_ newmac "$tmpromdir" -maxdepth 1 -type f -name "*.rom" printf "\nGbE NVM written to '%s':\n" "$archive" - x_ "$nvm" tmp/gbe dump | grep -v "bytes read from file" || : + x_ "$nvm" "$xbmklocal/gbe" dump | grep -v "bytes read from file" || : [ "$new_mac" = "restore" ] && \ printf "\nDefault GbE file '%s' written, unmodified.\n" \ @@ -583,5 +585,5 @@ modify_mac() newmac() { e "$1" f && xchanged="y" && x_ \ - "$ifdtool" $ifdprefix -i GbE:tmp/gbe "$1" -O "$1"; : + "$ifdtool" $ifdprefix -i GbE:"$xbmklocal/gbe" "$1" -O "$1"; : } -- cgit v1.2.1 From 8de0ed811fb9bc48659f95918a36317f24be3d8e Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 3 May 2025 07:17:21 +0100 Subject: inject.sh: Stricter TBFW handling Don't copy it until it has been padded properly. Otherwise, erroneous padding would result in an error, and who knows what would be left in vendorfiles/ ? Signed-off-by: Leah Rowe --- include/inject.sh | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 805415ef..c5e41f6d 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -278,19 +278,23 @@ extract_sch5545ec() # https://pcsupport.lenovo.com/us/en/products/laptops-and-netbooks/thinkpad-t-series-laptops/thinkpad-t480-type-20l5-20l6/20l5/solutions/ht508988 extract_tbfw() { - chkvars TBFW_size # size in bytes, matching TBFW's flash IC - - tbtmp="$xbmklocal/tb.bin" - x_ rm -f "$tbtmp" && fe_ copy_tbfw "$appdir" -type f -name "TBT.bin" - - x_ dd if=/dev/null of="$tbtmp" bs=1 seek=$TBFW_size - x_ cp "$tbtmp" "$_dest" + chkvars TBFW_size + fe_ copy_tbfw "$appdir" -type f -name "TBT.bin" + [ -f "$_dest" ] || $err "$board: Could not extract tbfw"; : } copy_tbfw() { - [ -f "$1" ] && [ ! -L "$1" ] && x_ cp "$1" "$xbmklocal/tb.bin" && \ - return 1; : + [ -f "$1" ] || return 0 + [ -L "$1" ] && return 0 + + tbtmp="$xbmklocal/tb.bin" + x_ rm -f "$tbtmp" + + x_ dd if=/dev/null of="$1" bs=1 seek=$TBFW_size + x_ mv "$1" "$_dest" + + return 1 } extract_fspm() -- cgit v1.2.1 From bf569d2b4dcbf8efc648da1a87803eefd4b892dc Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 3 May 2025 07:20:48 +0100 Subject: inject.sh: Remove redundant code in copy_tbfw We don't use the tbtmp variable anymore, in this function. Signed-off-by: Leah Rowe --- include/inject.sh | 3 --- 1 file changed, 3 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index c5e41f6d..b0f3f502 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -288,9 +288,6 @@ copy_tbfw() [ -f "$1" ] || return 0 [ -L "$1" ] && return 0 - tbtmp="$xbmklocal/tb.bin" - x_ rm -f "$tbtmp" - x_ dd if=/dev/null of="$1" bs=1 seek=$TBFW_size x_ mv "$1" "$_dest" -- cgit v1.2.1 From 72f4412a52df60bd2d3f01a4c8dc138334ffe434 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 3 May 2025 13:15:40 +0100 Subject: inject.sh: simplified fsp extraction we know that _dest is always what's set in the coreboot config, without the ../../../ in it, so just copy both files in a single function, and call the function twice. if both files are done on the first call, the second call will be skipped. if only the first file was done on the first call, running the download script again will skip the first one, and grab the second one. this also avoids having to run the decat function twice, in most cases, so it's a tiny optimisation. this optimisation only works if both fsp files (s and m) are to be extracted into the same directory, which is the case anyway, and this will always be the case. Signed-off-by: Leah Rowe --- include/inject.sh | 51 +++++++++++++-------------------------------------- 1 file changed, 13 insertions(+), 38 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index b0f3f502..a9d1350a 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -95,9 +95,9 @@ getfiles() # therefore, handle them separately, in case one of them is libre; if # one of them was, the path wouldn't be set. # - [ -z "$CONFIG_FSP_M_FILE" ] || fetch "fspm" "$CONFIG_FSP_FD_PATH" \ + [ -z "$CONFIG_FSP_M_FILE" ] || fetch "fsp" "$CONFIG_FSP_FD_PATH" \ "$CONFIG_FSP_FD_PATH" "$FSPFD_hash" "$CONFIG_FSP_M_FILE" copy - [ -z "$CONFIG_FSP_S_FILE" ] || fetch "fsps" "$CONFIG_FSP_FD_PATH" \ + [ -z "$CONFIG_FSP_S_FILE" ] || fetch "fsp" "$CONFIG_FSP_FD_PATH" \ "$CONFIG_FSP_FD_PATH" "$FSPFD_hash" "$CONFIG_FSP_S_FILE" copy; : } @@ -111,14 +111,12 @@ fetch() [ "$5" = "/dev/null" ] && return 0 _dl="$XBMK_CACHE/file/$dlsum" - if [ "$dl_type" = "fspm" ] || [ "$dl_type" = "fsps" ]; then - # HACK: if grabbing fsp from coreboot, fix the path for lbmk - for _cdl in dl dl_bkup; do - eval "$_cdl=\"\${$_cdl##*../}\"; _cdp=\"\$$_cdl\"" - [ -f "$_cdp" ] || _cdp="$cbdir/$_cdp" - [ -f "$_cdp" ] && eval "$_cdl=\"$_cdp\"" - done - fi + # HACK: if grabbing fsp from coreboot, fix the path for lbmk + [ "$dl_type" = "fsp" ] && for _cdl in dl dl_bkup; do + eval "$_cdl=\"\${$_cdl##*../}\"; _cdp=\"\$$_cdl\"" + [ -f "$_cdp" ] || _cdp="$cbdir/$_cdp" + [ -f "$_cdp" ] && eval "$_cdl=\"$_cdp\"" + done; : dlop="curl" && [ $# -gt 5 ] && dlop="$6" xbmkget "$dl" "$dl_bkup" "$_dl" "$dlsum" "$dlop" @@ -205,12 +203,9 @@ apply_me11_deguard_mod() extract_archive() { - if [ $# -gt 2 ]; then - if [ "$3" = "fspm" ] || [ "$3" = "fsps" ]; then - decat_fspfd "$1" "$2" - return 0 - fi - fi + [ $# -gt 2 ] && [ "$3" = "fsp" ] && x_ python \ + "$cbdir/3rdparty/fsp/Tools/SplitFspBin.py" split -f "$1" -o "$2" \ + -n "Fsp.fd" && return 0 innoextract "$1" -d "$2" || python "$pfs_extract" "$1" -e || 7z x \ "$1" -o"$2" || unar "$1" -o "$2" || unzip "$1" -d "$2" || return 1 @@ -219,15 +214,6 @@ extract_archive() $err "!mv '${_dl}_extracted' '$2' - $dontflash"; : } -decat_fspfd() -{ - _fspfd="$1" - _fspdir="$2" - _fspsplit="$cbdir/3rdparty/fsp/Tools/SplitFspBin.py" - - x_ $python "$_fspsplit" split -f "$_fspfd" -o "$_fspdir" -n "Fsp.fd" -} - extract_kbc1126ec() { x_ e "$kbc1126_ec_dump" f @@ -294,20 +280,9 @@ copy_tbfw() return 1 } -extract_fspm() -{ - copy_fsp M; : -} - -extract_fsps() -{ - copy_fsp S; : -} - -# this copies the fsp s/m; re-base is handled by ./mk inject -copy_fsp() +extract_fsp() { - x_ cp "$appdir/Fsp_$1.fd" "$_dest" + x_ cp "$appdir/"Fsp_*.fd "${_dest%/*}" } fail_inject() -- cgit v1.2.1 From 5499ae66bd8e7c36fd6f298b68365d39672a2cfa Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 3 May 2025 13:35:28 +0100 Subject: inject.sh: simplify extract_archive() Signed-off-by: Leah Rowe --- include/inject.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index a9d1350a..a200981f 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -210,8 +210,7 @@ extract_archive() innoextract "$1" -d "$2" || python "$pfs_extract" "$1" -e || 7z x \ "$1" -o"$2" || unar "$1" -o "$2" || unzip "$1" -d "$2" || return 1 - [ ! -d "${_dl}_extracted" ] || cp -R "${_dl}_extracted" "$2" || \ - $err "!mv '${_dl}_extracted' '$2' - $dontflash"; : + [ ! -d "${_dl}_extracted" ] || x_ cp -R "${_dl}_extracted" "$2"; : } extract_kbc1126ec() -- cgit v1.2.1 From 46b968a6e859ca7a0406c1c446ff1a53d74ad887 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 3 May 2025 13:49:49 +0100 Subject: inject.sh: minor code cleanup Signed-off-by: Leah Rowe --- include/inject.sh | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index a200981f..9bfda2db 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -228,9 +228,7 @@ extract_kbc1126ec() ) || $err "$board: can't extract kbc1126 ec firmware - $dontflash" x_ e "$appdir/ec.bin.fw1" f && x_ e "$appdir/ec.bin.fw2" f - - cp "$appdir/"ec.bin.fw* "${_dest%/*}/" || \ - $err "!cp 1126ec $_dest - $dontflash"; : + x_ cp "$appdir/"ec.bin.fw* "${_dest%/*}/" } extract_e6400vga() @@ -318,10 +316,8 @@ inject() esac [ "$new_mac" = "keep" ] && new_mac="" - if [ -n "$new_mac" ] && [ "$new_mac" != "restore" ]; then - x_ make -C util/nvmutil clean - x_ make -C util/nvmutil - fi + [ -n "$new_mac" ] && [ "$new_mac" != "restore" ] && \ + x_ make -C util/nvmutil clean && x_ make -C util/nvmutil check_release "$archive" || $err "'$archive' is not a release archive" @@ -510,11 +506,10 @@ insert() _offset="" - if [ "$_t" = "fsp" ]; then - [ $# -gt 3 ] && _offset="$4" - else - [ $# -gt 3 ] && _offset="-b $4" && [ -z "$4" ] && \ - $err "insert $*, $rom: offset given but empty (undefined)" + if [ "$_t" = "fsp" ] && [ $# -gt 3 ]; then + _offset="$4" + elif [ $# -gt 3 ] && _offset="-b $4" && [ -z "$4" ]; then + $err "insert $*, $rom: offset given but empty (undefined)" fi [ "$nukemode" = "nuke" ] || x_ e "$_dest" f @@ -551,10 +546,6 @@ modify_mac() printf "\nGbE NVM written to '%s':\n" "$archive" x_ "$nvm" "$xbmklocal/gbe" dump | grep -v "bytes read from file" || : - - [ "$new_mac" = "restore" ] && \ - printf "\nDefault GbE file '%s' written, unmodified.\n" \ - "${CONFIG_GBE_BIN_PATH##*../}"; : } newmac() -- cgit v1.2.1 From 439020fbda5ca7862bf2eaf4d59ab68aae230c33 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 4 May 2025 08:47:56 +0100 Subject: inject.sh: remove useless comment block Signed-off-by: Leah Rowe --- include/inject.sh | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 9bfda2db..d956cdd1 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -90,11 +90,6 @@ getfiles() "$MRC_url_bkup" "$MRC_hash" "$CONFIG_REFCODE_BLOB_FILE" [ -z "$CONFIG_LENOVO_TBFW_BIN" ] || fetch "tbfw" "$TBFW_url" \ "$TBFW_url_bkup" "$TBFW_hash" "$CONFIG_LENOVO_TBFW_BIN" - # - # in the future, we might have libre fsp-s and then fsp-m. - # therefore, handle them separately, in case one of them is libre; if - # one of them was, the path wouldn't be set. - # [ -z "$CONFIG_FSP_M_FILE" ] || fetch "fsp" "$CONFIG_FSP_FD_PATH" \ "$CONFIG_FSP_FD_PATH" "$FSPFD_hash" "$CONFIG_FSP_M_FILE" copy [ -z "$CONFIG_FSP_S_FILE" ] || fetch "fsp" "$CONFIG_FSP_FD_PATH" \ -- cgit v1.2.1 From b19c4f8f674b04fdaa0b07b2c43766a76545ed09 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 4 May 2025 08:50:23 +0100 Subject: inject.sh: tidy up TBFW handling Signed-off-by: Leah Rowe --- include/inject.sh | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index d956cdd1..837f34c1 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -256,20 +256,14 @@ extract_sch5545ec() # https://pcsupport.lenovo.com/us/en/products/laptops-and-netbooks/thinkpad-t-series-laptops/thinkpad-t480-type-20l5-20l6/20l5/solutions/ht508988 extract_tbfw() { - chkvars TBFW_size - fe_ copy_tbfw "$appdir" -type f -name "TBT.bin" + chkvars TBFW_size && fe_ copy_tbfw "$appdir" -type f -name "TBT.bin" [ -f "$_dest" ] || $err "$board: Could not extract tbfw"; : } copy_tbfw() { - [ -f "$1" ] || return 0 - [ -L "$1" ] && return 0 - - x_ dd if=/dev/null of="$1" bs=1 seek=$TBFW_size - x_ mv "$1" "$_dest" - - return 1 + [ -f "$1" ] && [ ! -L "$1" ] && x_ dd if=/dev/null of="$1" bs=1 \ + seek=$TBFW_size && x_ mv "$1" "$_dest" && return 1; : } extract_fsp() -- cgit v1.2.1 From 54291ebb7209c314bb52f507bc6a1ecf2a28fbc9 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 4 May 2025 09:56:21 +0100 Subject: lbmk: MUCH safer err function Don't directly call a variable. Call a function that checks the variable instead. The new err function also checks whether an exit was actually done, and exits 1 if not. If an exit was done by the given function, but the exit was zero, this is also corrected to perform an exit 1. This fixes a longstanding design flaw of lbmk. Signed-off-by: Leah Rowe --- include/inject.sh | 78 +++++++++++++++++++++++++++---------------------------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 837f34c1..e2987aad 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -41,7 +41,7 @@ eval "`setvars "" has_hashes EC_hash DL_hash DL_url_bkup MRC_refcode_gbe vcfg \ download() { - [ $# -gt 0 ] || $err "No argument given" + [ $# -gt 0 ] || err "No argument given" export PATH="$PATH:/sbin" board="$1" && readcfg && readkconfig && bootstrap && getfiles; : } @@ -116,22 +116,22 @@ fetch() dlop="curl" && [ $# -gt 5 ] && dlop="$6" xbmkget "$dl" "$dl_bkup" "$_dl" "$dlsum" "$dlop" - rm -Rf "${_dl}_extracted" || $err "!rm ${_ul}_extracted. $dontflash" + rm -Rf "${_dl}_extracted" || err "!rm ${_ul}_extracted. $dontflash" e "$_dest" f && return 0 x_ mkdir -p "${_dest%/*}" remkdir "$appdir" extract_archive "$_dl" "$appdir" "$dl_type" || \ - [ "$dl_type" = "e6400vga" ] || $err "$_dest $dl_type: !extract" + [ "$dl_type" = "e6400vga" ] || err "$_dest $dl_type: !extract" eval "extract_$dl_type" set -u -e - e "$_dest" f missing && $err "!extract_$dl_type. $dontflash"; : + e "$_dest" f missing && err "!extract_$dl_type. $dontflash"; : } extract_intel_me() { - e "$mecleaner" f not && $err "$cbdir: me_cleaner missing. $dontflash" + e "$mecleaner" f not && err "$cbdir: me_cleaner missing. $dontflash" cdir="$xbmkpwd/$appdir" _me="$xbmkpwd/$_dest" @@ -145,7 +145,7 @@ extract_intel_me() if [ "$ME11bootguard" = "y" ]; then apply_me11_deguard_mod else - mv "$_metmp" "$_me" || $err "!mv $_metmp $_me - $dontflash" + mv "$_metmp" "$_me" || err "!mv $_metmp $_me - $dontflash" fi } @@ -160,7 +160,7 @@ extract_intel_me_bruteforce() set +u +e ( [ "${cdir#/a}" != "$cdir" ] && cdir="${cdir#/}" - cd "$cdir" || $err "extract_intel_me: !cd \"$cdir\" - $dontflash" + cd "$cdir" || err "extract_intel_me: !cd \"$cdir\" - $dontflash" for i in *; do e "$_metmp" f && break [ -L "$i" ] && continue @@ -182,7 +182,7 @@ extract_intel_me_bruteforce() cd "$cdir" || : done ) || : - rm -Rf "$sdir" || $err "extract_intel_me: !rm -Rf $sdir - $dontflash" + rm -Rf "$sdir" || err "extract_intel_me: !rm -Rf $sdir - $dontflash" } apply_me11_deguard_mod() @@ -193,7 +193,7 @@ apply_me11_deguard_mod() --version "$ME11version" \ --pch "$ME11pch" --sku "$ME11sku" --fake-fpfs data/fpfs/zero \ --input "$_metmp" --output "$_me" - ) || $err "Error running deguard for $_me - $dontflash" + ) || err "Error running deguard for $_me - $dontflash" } extract_archive() @@ -216,11 +216,11 @@ extract_kbc1126ec() mv Rompaq/68*.BIN ec.bin || : if [ ! -f "ec.bin" ]; then unar -D ROM.CAB Rom.bin || unar -D Rom.CAB Rom.bin || \ - unar -D 68*.CAB Rom.bin || $err "kbc1126 unar failed" + unar -D 68*.CAB Rom.bin || err "kbc1126 unar failed" x_ mv Rom.bin ec.bin fi x_ e ec.bin f && x_ "$kbc1126_ec_dump" ec.bin - ) || $err "$board: can't extract kbc1126 ec firmware - $dontflash" + ) || err "$board: can't extract kbc1126 ec firmware - $dontflash" x_ e "$appdir/ec.bin.fw1" f && x_ e "$appdir/ec.bin.fw2" f x_ cp "$appdir/"ec.bin.fw* "${_dest%/*}/" @@ -235,7 +235,7 @@ extract_e6400vga() x_ cd "$appdir" x_ e "bios.bin" f "$e6400_unpack" bios.bin || printf "TODO: fix dell extract util\n" - ) || $err "can't extract e6400 vga rom - $dontflosh" + ) || err "can't extract e6400 vga rom - $dontflosh" x_ cp "$appdir/$E6400_VGA_romname" "$_dest" } @@ -248,7 +248,7 @@ extract_sch5545ec() _sch5545ec_fw="$_sch5545ec_fw/54 D386BEB8-4B54-4E69-94F5-06091F67E0D3" _sch5545ec_fw="$_sch5545ec_fw/0 Raw section/body.bin" # <-- this! - "$uefiextract" "$_bios" || $err "sch5545 !extract - $dontflash" + "$uefiextract" "$_bios" || err "sch5545 !extract - $dontflash" x_ cp "$_sch5545ec_fw" "$_dest" } @@ -257,7 +257,7 @@ extract_sch5545ec() extract_tbfw() { chkvars TBFW_size && fe_ copy_tbfw "$appdir" -type f -name "TBT.bin" - [ -f "$_dest" ] || $err "$board: Could not extract tbfw"; : + [ -f "$_dest" ] || err "$board: Could not extract tbfw"; : } copy_tbfw() @@ -284,11 +284,11 @@ fail_inject() inject() { need_files="n" - err="fail_inject" + xbmk_err="fail_inject" remkdir "$tmpromdel" set +u +e - [ $# -lt 1 ] && $err "No options specified. - $dontflash" + [ $# -lt 1 ] && err "No options specified. - $dontflash" eval "`setvars "" nukemode new_mac xchanged`" archive="$1"; @@ -300,15 +300,15 @@ inject() nukemode="nuke" ;; setmac) [ $# -gt 2 ] && new_mac="$3" && \ - [ -z "$new_mac" ] && $err "Empty MAC address specified" ;; - *) $err "Unrecognised inject mode: '$2'" + [ -z "$new_mac" ] && err "Empty MAC address specified" ;; + *) err "Unrecognised inject mode: '$2'" esac [ "$new_mac" = "keep" ] && new_mac="" [ -n "$new_mac" ] && [ "$new_mac" != "restore" ] && \ x_ make -C util/nvmutil clean && x_ make -C util/nvmutil - check_release "$archive" || $err "'$archive' is not a release archive" + check_release "$archive" || err "'$archive' is not a release archive" readcfg && need_files="y" if [ "$need_files" = "y" ] || [ -n "$new_mac" ]; then @@ -324,20 +324,20 @@ inject() check_release() { - [ -L "$archive" ] && $err "'$archive' is a symlink. $dontflash" + [ -L "$archive" ] && err "'$archive' is a symlink. $dontflash" e "$archive" f missing && return 1 archivename="`basename "$archive"`" - [ -z "$archivename" ] && $err "Can't determine archive name. $dontflash" + [ -z "$archivename" ] && err "Can't determine archive name. $dontflash" case "$archivename" in *_src.tar.xz) - $err "'$archive' is a src archive, silly!" ;; + err "'$archive' is a src archive, silly!" ;; grub_*|seagrub_*|custom_*|seauboot_*|seabios_withgrub_*) return 1 ;; *.tar.xz) _stripped_prefix="${archivename#*_}" board="${_stripped_prefix%.tar.xz}" ;; - *) $err "'$archive': could not detect board type - $dontflash" + *) err "'$archive': could not detect board type - $dontflash" esac; : } @@ -355,8 +355,8 @@ readcfg() [ -z "$vcfg" ] && return 1 vfile="config/vendor/$vcfg/pkg.cfg" - [ -L "$vfile" ] && $err "'$archive', '$board': $vfile is a symlink" - [ -f "$vfile" ] || $err "'$archive', '$board': $vfile doesn't exist" + [ -L "$vfile" ] && err "'$archive', '$board': $vfile is a symlink" + [ -f "$vfile" ] || err "'$archive', '$board': $vfile doesn't exist" cbdir="src/coreboot/$tree" cbfstool="elf/cbfstool/$tree/cbfstool" @@ -394,14 +394,14 @@ patch_release_roms() ( [ "$need_files" = "y" ] || exit 0 - cd "$tmpromdir" || $err "patch '$archive': can't cd $tmpromdir" + cd "$tmpromdir" || err "patch '$archive': can't cd $tmpromdir" # NOTE: For compatibility with older rom releases, defer to sha1 if [ "$has_hashes" = "y" ] && [ "$nukemode" != "nuke" ]; then sha512sum --status -c "$hashfile" || \ x_ sha1sum --status -c "$hashfile" x_ rm -f "$hashfile" fi - ) || $err "'$archive' -> Can't verify vendor hashes. $dontflash" + ) || err "'$archive' -> Can't verify vendor hashes. $dontflash" [ -z "$new_mac" ] || modify_mac || printf "\nGbE not defined\n" 1>&2 @@ -411,10 +411,10 @@ patch_release_roms() ( x_ cd "${tmpromdir%"/bin/$board"}" mkrom_tarball "bin/$board" - ) || $err "Cannot re-generate '$archive' - $dontflash" + ) || err "Cannot re-generate '$archive' - $dontflash" mv "${tmpromdir%"/bin/$board"}/bin/${relname}_${board}.tar.xz" \ - "$archive" || $err "'$archive' -> Can't overwrite - $dontflash"; : + "$archive" || err "'$archive' -> Can't overwrite - $dontflash"; : } prep_rom() @@ -425,16 +425,16 @@ prep_rom() [ "$nukemode" = "nuke" ] && _xromnew="${_xrom%/*}/$vfix${_xrom##*/}" e "$_xrom" f missing && return 0 - [ -z "${_xromname#"$vfix"}" ] && $err "$_xromname / $vfix: name match" + [ -z "${_xromname#"$vfix"}" ] && err "$_xromname / $vfix: name match" # Remove the prefix and 1-byte pad if [ "$nukemode" != "nuke" ] && \ [ "${_xromname#"$vfix"}" != "$_xromname" ]; then - xromsize="$(expr $(stat -c '%s' "$_xrom") - 1)" || $err "!int" - [ $xromsize -lt 524288 ] && $err "too small, $xromsize: $_xrom" + xromsize="$(expr $(stat -c '%s' "$_xrom") - 1)" || err "!int" + [ $xromsize -lt 524288 ] && err "too small, $xromsize: $_xrom" x_ dd if="$_xrom" of="$_xromnew" bs=$xromsize count=1 - rm -f "$_xrom" || $err "Can't rm $_xrom - $dontflash" + rm -f "$_xrom" || err "Can't rm $_xrom - $dontflash" _xrom="$_xromnew" fi @@ -445,7 +445,7 @@ prep_rom() [ "$nukemode" != "nuke" ] && return 0 # Rename the file, prefixing a warning saying not to flash - cat "$_xrom" config/data/coreboot/0 > "$_xromnew" || $err "!pad $_xrom" + cat "$_xrom" config/data/coreboot/0 > "$_xromnew" || err "!pad $_xrom" x_ rm -f "$_xrom" } @@ -498,7 +498,7 @@ insert() if [ "$_t" = "fsp" ] && [ $# -gt 3 ]; then _offset="$4" elif [ $# -gt 3 ] && _offset="-b $4" && [ -z "$4" ]; then - $err "insert $*, $rom: offset given but empty (undefined)" + err "insert $*, $rom: offset given but empty (undefined)" fi [ "$nukemode" = "nuke" ] || x_ e "$_dest" f @@ -506,19 +506,19 @@ insert() if [ "$cbfsname" = "IFD" ]; then [ "$nukemode" = "nuke" ] || "$ifdtool" $ifdprefix -i \ $_t:$_dest "$rom" -O "$rom" || \ - $err "failed: insert '$_t' '$_dest' on '$rom'" + err "failed: insert '$_t' '$_dest' on '$rom'" [ "$nukemode" != "nuke" ] || "$ifdtool" $ifdprefix --nuke $_t \ - "$rom" -O "$rom" || $err "$rom: !nuke IFD/$_t" + "$rom" -O "$rom" || err "$rom: !nuke IFD/$_t" elif [ "$nukemode" = "nuke" ]; then x_ "$cbfstool" "$rom" remove -n "$cbfsname" elif [ "$_t" = "stage" ]; then # the only stage we handle is refcode x_ rm -f "$xbmklocal/refcode" "$rmodtool" -i "$_dest" -o "$xbmklocal/refcode" || "!reloc ref" "$cbfstool" "$rom" add-stage -f "$xbmklocal/refcode" \ - -n "$cbfsname" -t stage || $err "$rom: !add ref" + -n "$cbfsname" -t stage || err "$rom: !add ref" else "$cbfstool" "$rom" add -f "$_dest" -n "$cbfsname" \ - -t $_t $_offset || $err "$rom !add $_t ($_dest)" + -t $_t $_offset || err "$rom !add $_t ($_dest)" fi xchanged="y"; : } -- cgit v1.2.1 From 153dd76a82e98a7260424cf37d5a139fff39d2ab Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 5 May 2025 05:41:21 +0100 Subject: inject.sh: tidy up the deguard command Signed-off-by: Leah Rowe --- include/inject.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index e2987aad..0e81c63f 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -189,10 +189,9 @@ apply_me11_deguard_mod() { ( x_ cd src/deguard/ - x_ ./finalimage.py --delta "data/delta/$ME11delta" \ - --version "$ME11version" \ - --pch "$ME11pch" --sku "$ME11sku" --fake-fpfs data/fpfs/zero \ - --input "$_metmp" --output "$_me" + x_ ./finalimage.py --delta "data/delta/$ME11delta" --version \ + "$ME11version" --pch "$ME11pch" --sku "$ME11sku" --fake-fpfs \ + data/fpfs/zero --input "$_metmp" --output "$_me" ) || err "Error running deguard for $_me - $dontflash" } -- cgit v1.2.1 From eb882de94cbe78e575b97ced611a06553f94dbc7 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 5 May 2025 05:43:38 +0100 Subject: inject.sh: tidy up intel me handling Signed-off-by: Leah Rowe --- include/inject.sh | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 0e81c63f..c6c8c2d2 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -142,8 +142,12 @@ extract_intel_me() [ "$ME11bootguard" = "y" ] && x_ ./mk -f deguard extract_intel_me_bruteforce - if [ "$ME11bootguard" = "y" ]; then - apply_me11_deguard_mod + if [ "$ME11bootguard" = "y" ]; then ( + x_ cd src/deguard/ + x_ ./finalimage.py --delta "data/delta/$ME11delta" --version \ + "$ME11version" --pch "$ME11pch" --sku "$ME11sku" \ + --fake-fpfs data/fpfs/zero --input "$_metmp" --output "$_me" + ) || err "Error running deguard for $_me - $dontflash" else mv "$_metmp" "$_me" || err "!mv $_metmp $_me - $dontflash" fi @@ -185,16 +189,6 @@ extract_intel_me_bruteforce() rm -Rf "$sdir" || err "extract_intel_me: !rm -Rf $sdir - $dontflash" } -apply_me11_deguard_mod() -{ - ( - x_ cd src/deguard/ - x_ ./finalimage.py --delta "data/delta/$ME11delta" --version \ - "$ME11version" --pch "$ME11pch" --sku "$ME11sku" --fake-fpfs \ - data/fpfs/zero --input "$_metmp" --output "$_me" - ) || err "Error running deguard for $_me - $dontflash" -} - extract_archive() { [ $# -gt 2 ] && [ "$3" = "fsp" ] && x_ python \ -- cgit v1.2.1 From b7ca59debe6e9895485c9c54e820161cb572aebc Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 5 May 2025 06:00:23 +0100 Subject: inject.sh: Move FSP extraction only to extract_fsp Don't do FSP-specific extraction in extract_archive, as that is not what the latter is for. Signed-off-by: Leah Rowe --- include/inject.sh | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index c6c8c2d2..80a691f2 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -121,10 +121,10 @@ fetch() x_ mkdir -p "${_dest%/*}" remkdir "$appdir" - extract_archive "$_dl" "$appdir" "$dl_type" || \ + [ "$dl_type" = "fsp" ] || extract_archive "$_dl" "$appdir" || \ [ "$dl_type" = "e6400vga" ] || err "$_dest $dl_type: !extract" - eval "extract_$dl_type" + x_ extract_$dl_type "$_dl" "$appdir" set -u -e e "$_dest" f missing && err "!extract_$dl_type. $dontflash"; : } @@ -191,10 +191,6 @@ extract_intel_me_bruteforce() extract_archive() { - [ $# -gt 2 ] && [ "$3" = "fsp" ] && x_ python \ - "$cbdir/3rdparty/fsp/Tools/SplitFspBin.py" split -f "$1" -o "$2" \ - -n "Fsp.fd" && return 0 - innoextract "$1" -d "$2" || python "$pfs_extract" "$1" -e || 7z x \ "$1" -o"$2" || unar "$1" -o "$2" || unzip "$1" -d "$2" || return 1 @@ -261,7 +257,8 @@ copy_tbfw() extract_fsp() { - x_ cp "$appdir/"Fsp_*.fd "${_dest%/*}" + x_ python "$cbdir/3rdparty/fsp/Tools/SplitFspBin.py" split -f "$1" \ + -o "$2" -n "Fsp.fd" && x_ cp "$appdir/"Fsp_*.fd "${_dest%/*}" } fail_inject() -- cgit v1.2.1 From f4057d7daab0eb22954d376372a4dad9578f7ba0 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 5 May 2025 06:11:47 +0100 Subject: inject.sh extract_intel_me(): reduce indentation Signed-off-by: Leah Rowe --- include/inject.sh | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 80a691f2..9726c57e 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -142,15 +142,14 @@ extract_intel_me() [ "$ME11bootguard" = "y" ] && x_ ./mk -f deguard extract_intel_me_bruteforce - if [ "$ME11bootguard" = "y" ]; then ( - x_ cd src/deguard/ - x_ ./finalimage.py --delta "data/delta/$ME11delta" --version \ - "$ME11version" --pch "$ME11pch" --sku "$ME11sku" \ - --fake-fpfs data/fpfs/zero --input "$_metmp" --output "$_me" - ) || err "Error running deguard for $_me - $dontflash" - else - mv "$_metmp" "$_me" || err "!mv $_metmp $_me - $dontflash" - fi + [ "$ME11bootguard" != "y" ] && x_ mv "$_metmp" "$_me" && return 0 + + ( + x_ cd src/deguard/ + x_ ./finalimage.py --delta "data/delta/$ME11delta" --version \ + "$ME11version" --pch "$ME11pch" --sku "$ME11sku" \ + --fake-fpfs data/fpfs/zero --input "$_metmp" --output "$_me" + ) || err "Error running deguard for $_me - $dontflash"; : } extract_intel_me_bruteforce() -- cgit v1.2.1 From e4edc2194d3aaaf8319fe681475caae5562b351e Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 5 May 2025 06:21:04 +0100 Subject: inject.sh: Remove unnecessary check _dest is already checked in the calling function fetch(), after extract_tbfw() has been called. Signed-off-by: Leah Rowe --- include/inject.sh | 1 - 1 file changed, 1 deletion(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 9726c57e..667a03f8 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -245,7 +245,6 @@ extract_sch5545ec() extract_tbfw() { chkvars TBFW_size && fe_ copy_tbfw "$appdir" -type f -name "TBT.bin" - [ -f "$_dest" ] || err "$board: Could not extract tbfw"; : } copy_tbfw() -- cgit v1.2.1 From 61ec396ef6dbf3ce325f63791d634a78f45531a6 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 5 May 2025 06:26:38 +0100 Subject: inject.sh: simplify extract_intel_me_bruteforce() Signed-off-by: Leah Rowe --- include/inject.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 667a03f8..6aceb52c 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -165,9 +165,11 @@ extract_intel_me_bruteforce() [ "${cdir#/a}" != "$cdir" ] && cdir="${cdir#/}" cd "$cdir" || err "extract_intel_me: !cd \"$cdir\" - $dontflash" for i in *; do - e "$_metmp" f && break + c=0 && e "$_metmp" f && break [ -L "$i" ] && continue - if [ -f "$i" ]; then + [ -e "$i" ] || continue + [ -d "$i" ] && extract_intel_me_bruteforce "$cdir/$i" && c=1 + if [ $c -eq 0 ] && [ -f "$i" ]; then _r="-r" && [ -n "$mfs" ] && _r="" "$mecleaner" $mfs $_r -t -O "$sdir/vendorfile" \ -M "$_metmp" "$i" && break @@ -176,10 +178,6 @@ extract_intel_me_bruteforce() _7ztest="${_7ztest}a" extract_archive "$i" "$_7ztest" || continue extract_intel_me_bruteforce "$cdir/$_7ztest" - elif [ -d "$i" ]; then - extract_intel_me_bruteforce "$cdir/$i" - else - continue fi cdir="$1"; [ "${cdir#/a}" != "$cdir" ] && cdir="${cdir#/}" cd "$cdir" || : -- cgit v1.2.1 From 17d826d3a9614fea2bc87d8203b7f07fe4b7fb54 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 5 May 2025 20:38:19 +0100 Subject: lbmk: Replace err with much simpler implementation The current implementation is insanely over-engineered, and completely unnecessary. Signed-off-by: Leah Rowe --- include/inject.sh | 1 - 1 file changed, 1 deletion(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 6aceb52c..6caf8500 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -270,7 +270,6 @@ fail_inject() inject() { need_files="n" - xbmk_err="fail_inject" remkdir "$tmpromdel" set +u +e -- cgit v1.2.1 From 7585336b914d5d43ab85ba2f75fc5215be7782fb Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 5 May 2025 21:05:45 +0100 Subject: inject.sh: simplify kconfig scanning Use fe_ with a new function, scankconfig, to do the same thing. Not only is this simpler, it now also operates on all coreboot configs for a given target, whereas it previously only operated on the first one. This is useful for cases where one config might use a file that the other one does not; in practise, we don't do this yet, but it's a theoretical possibility Also: don't use the function check_defconfig, which is now redundant and has been removed. That function also conflicted with another function by the same name in mk, but fortunately didn't cause an issue in practise, due to how sh works; when vendor.sh was used, it was without running the tree commands, except under a separate lbmk instance. So this is a simplification, a feature enhancement and even a bug fix, all wrapped into one! Signed-off-by: Leah Rowe --- include/inject.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 6caf8500..fa6ac095 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -49,9 +49,8 @@ download() readkconfig() { x_ rm -f "$xbmktmp/cbcfg" - cbcfg="`check_defconfig "$boarddir"`" || for cbc in $cv; do - grep "$cbc" "$cbcfg" 1>>"$xbmktmp/cbcfg" 2>/dev/null || : - done + fe_ scankconfig "$boarddir/config" -type f + eval "`setcfg "$xbmktmp/cbcfg" 1`" for c in $cvchk; do @@ -63,6 +62,13 @@ readkconfig() return 1 } +scankconfig() +{ + for cbc in $cv; do + grep "$cbc" "$1" 1>>"$xbmktmp/cbcfg" 2>/dev/null || : + done +} + bootstrap() { x_ ./mk -f coreboot ${cbdir##*/} -- cgit v1.2.1 From 73074dedee33bfa66edfc9a19dd9625598911518 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 5 May 2025 21:13:28 +0100 Subject: inject.sh: Further simplified FSP extraction We don't need the copy command at all, since the files it copies are the only ones that the Python script does anyway, so now we just make that script output to the directory, directly, where these files must go. Signed-off-by: Leah Rowe --- include/inject.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index fa6ac095..5c5e1e1c 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -260,7 +260,7 @@ copy_tbfw() extract_fsp() { x_ python "$cbdir/3rdparty/fsp/Tools/SplitFspBin.py" split -f "$1" \ - -o "$2" -n "Fsp.fd" && x_ cp "$appdir/"Fsp_*.fd "${_dest%/*}" + -o "${_dest%/*}" -n "Fsp.fd" } fail_inject() -- cgit v1.2.1 From 4c1de1ad1267f74ed28cdb0a7c2cc06d52949dda Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 6 May 2025 04:49:56 +0100 Subject: inject.sh: remove unused function Signed-off-by: Leah Rowe --- include/inject.sh | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'include/inject.sh') diff --git a/include/inject.sh b/include/inject.sh index 5c5e1e1c..3cfe891c 100644 --- a/include/inject.sh +++ b/include/inject.sh @@ -263,16 +263,6 @@ extract_fsp() -o "${_dest%/*}" -n "Fsp.fd" } -fail_inject() -{ - [ -L "$tmpromdel" ] || [ ! -d "$tmpromdel" ] || \ - rm -Rf "$tmpromdel" || : - printf "\n\n%s\n\n" "$dontflash" 1>&2 - printf "WARNING: File '%s' was NOT modified.\n\n" "$archive" 1>&2 - printf "Please MAKE SURE vendor files are inserted before flashing\n\n" - err_ "$1" -} - inject() { need_files="n" -- cgit v1.2.1