coreboot/util
Varadarajan Narayanan 0dcea61e7c cbfstool: Add multi ELF support
The current QCOM fixup function qualcomm_find_hash() assumes only one
ELF will be loaded by the primary boot loader and the bootblock is one
of the segments of that ELF.

However, the primary boot loader for QCOM X1P42100 SoC loads multiple
ELFs for QC_SEC, TME Sequencer, TME FW and bootblock. This change
updates the fixup functionality to handle bootblock being a separate
ELF.

If the bootblock offset does not fit within the first ELF, then the
fixup function understands that it is a multi ELF.

Additionally, it ensures the bootblock ELF uses MBN v7 format.

BUG=b:420542130

TEST=1. Create a image.serial.bin and ensure it boots on X1P42100
2. Used the following script to verify the hash
#! /bin/bash

image=/build/bluey/firmware/image-bluey.serial.bin
bin=/tmp/bb.bin
seg=/tmp/bb.seg
hash=/tmp/bb.hash

#
# Bootblock is the final ELF of the multi ELF. Hopefully
# there is no other ELF in ${image}. Get the offset of the
# final ELF in ${image} and get it out
#

bb_offset=`od -Ad -w4 -tx4 ${image} | grep 464c457f | tail -1 | cut -f1 -d ' '`

dd if=${image} of=${bin} skip=1 bs=${bb_offset} &> /dev/null

#
# The last two segments of the bootblock ELF have the actual
# executable and the hash. 'LOAD' is the executable segment and
# the other is the hash segment. Get their offsets and convert
# to decimal.
#
offs=`readelf -lW ${bin} | tail -2 | awk '{print $1" "$2" "$5}'`
offs=(`printf "%s %u %u %s %u %u" ${offs}`)

#
# Get the executable and hash segments
#
if [ ${offs[0]} = "LOAD" ]; then
        first=${seg}
        second=${hash}
else
        first=${hash}
        second=${seg}
fi

dd if=${bin} skip=${offs[1]} bs=1 count=${offs[2]} of=${first} &> /dev/null
dd if=${bin} skip=${offs[4]} bs=1 count=${offs[5]} of=${second} &> /dev/null

#
# Find the SHA384 hash for the executable segment
#
sha=`sha384sum ${seg} | cut -f1 -d ' ' | sed 's/../& /g'`

echo ===================================================
echo Expected hash:
echo
echo ${sha} | fold -w48
echo ===================================================
echo
hexdump -C ${hash} | grep -A4 "`echo ${sha} | cut -f1-4 -d ' '`"


Change-Id: If57ba0cc9a4f08b69d7712f27c215339307e73d4
Signed-off-by: Varadarajan Narayanan <vnarayan@qualcomm.corp-partner.google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/88148
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
Reviewed-by: Subrata Banik <subratabanik@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
2025-06-26 16:56:14 +00:00
..
abuild util/abuild: Fix checking of missing_arches 2025-05-23 19:54:29 +00:00
acpi
amdfwtool util/amdfwtool/amdfwtool.c: Remove APOB_NV src address check 2025-06-24 04:23:59 +00:00
amdtools util/amdtools: update K8 BKDG URL 2024-10-16 15:31:02 +00:00
apcb
archive
autoport util/autoport: Add function to create empty files 2025-05-07 14:50:02 +00:00
bincfg util: Rename Makefiles from .inc to .mk 2024-01-26 12:43:18 +00:00
board_status board_status/getrevision.sh: Ignore non-annotated tags 2025-02-14 17:10:47 +00:00
bucts
cavium
cbfstool cbfstool: Add multi ELF support 2025-06-26 16:56:14 +00:00
cbmem Revert "util/cbmem: Consolidate CBMEM and coreboot table access" 2025-06-09 19:16:53 +00:00
chromeos util/chromeos/crosfirmware: Increase lookahead when parsing bios_image 2025-03-12 12:41:35 +00:00
coreboot-configurator
crossgcc crossgcc/buildgcc: introduce RISCV_ISA_SPEC for RISC-V ISA specification 2025-06-19 01:55:23 +00:00
docker coreboot-sdk: Remove unnecessary files 2025-03-03 22:05:57 +00:00
dtd_parser
ectool
exynos
find_usbdebug util/find_usbdebug: Fix line indented with spaces instead of tabs 2025-01-20 03:23:48 +00:00
futility util: Rename Makefiles from .inc to .mk 2024-01-26 12:43:18 +00:00
fuzz-tests lib/jpeg: Replace decoder with Wuffs' implementation 2023-12-13 16:17:34 +00:00
genbuild_h genbuild_h: Fix and harden major/minor version parsing 2024-03-17 20:08:56 +00:00
gitconfig
goswid@567a1c99b0
hda-decoder util/hda-decoder: Add feature to print configuration defaults as verbs 2024-10-07 21:10:03 +00:00
ifdtool treewide: Remove remainders of ROM_BASE 2025-04-14 13:50:50 +00:00
intelmetool util/intelmetool: Print the address in map_physical errors in hex 2024-03-17 19:08:48 +00:00
intelp2m Documentation,util: Run util_readme.sh to regen *.md 2025-04-11 08:17:48 +00:00
inteltool inteltool: improve support for Elkhart Lake 2024-10-02 12:38:05 +00:00
intelvbttool
kbc1126
kconfig util/kconfig: Uprev to Linux 6.8's kconfig 2024-04-03 12:28:04 +00:00
lint util/lint: Add lint file for gofmt 2025-05-10 22:49:22 +00:00
liveiso util/liveiso/nixos/graphical: Preconfigure some Gnome settings 2024-08-14 15:33:38 +00:00
mainboard tree: Use true false for PcieRpLtrEnable[] 2025-02-03 06:15:03 +00:00
marvell util/marvell/doimage_mv: Update CFLAGS to CFLAGS_doimage 2024-10-14 15:26:38 +00:00
me_cleaner
mediatek util/mediatek: Add check-pi-img.py 2025-04-14 07:35:00 +00:00
mma
msrtool
nixshell util/nixshell: Add a dev shell for i386 arch 2024-03-14 18:15:51 +00:00
nvidia util/nvidia: Use c11 dialect 2024-05-29 08:19:15 +00:00
nvramtool Treewide: Fix incorrect SPDX license strings 2024-02-18 01:55:57 +00:00
pmh7tool
post
qemu mb/emulation/qemu-riscv: Change to -bios option 2024-03-05 18:57:29 +00:00
qualcomm util/qualcomm: Add script to concatenate ELF images 2025-06-26 14:30:49 +00:00
release util/release: Remove makefile.inc references from genrelnotes 2024-01-30 08:13:50 +00:00
riscv util/riscv: Add starfive Image building tool 2025-02-14 17:11:34 +00:00
rockchip
sconfig sconfig: Move (WEAK_)DEV_PTR from device.h to static.h 2024-11-10 10:35:44 +00:00
scripts update_submodules: Fix submodule path handling 2025-06-06 13:26:30 +00:00
smmstoretool util/smmstoretool: add uint64 data type 2024-06-14 14:19:46 +00:00
spd_tools util/spd_tools: Add Intel Panther Lake (PTL) platform 2024-08-09 09:24:18 +00:00
spdtool
spkmodem_recv
superiotool util/superiotool: Dump one more NCT6779D register 2025-05-13 14:51:45 +00:00
supermicro util: Rename Makefiles from .inc to .mk 2024-01-26 12:43:18 +00:00
testing Makefiles: Rename top-level Makefiles from .inc to .mk 2024-01-24 08:31:31 +00:00
uio_usbdebug
util_readme util/util_readme: Use HTML comments in generated output 2024-10-27 23:50:57 +00:00
vboot_list
vgabios tree: Drop duplicated <device/{path,resource}.h> 2024-04-12 04:24:20 +00:00
x86
xcompile xcompile: Use Walloc-size GCC option 2025-05-11 20:24:09 +00:00
README.md util/mediatek: Add check-pi-img.py 2025-04-14 07:35:00 +00:00

  • abuild - coreboot autobuild script builds coreboot images for all available targets. bash
  • acpi - Walk through all ACPI tables with their addresses. bash
  • amdfwtool - Create AMD Firmware combination C
  • amdtools Various tools for AMD processors
    • update_efs_spi_speed - Change SPI speed in binary. Bash
    • Tools to compare extended K8 memory settings.
    • k8-compare-pci-space.pl - Shows differences between values in PCI space and the default value. Perl
    • k8-interpret-extended-memory-settings.pl - Shows differences between memory controller values and the default value. Perl
    • k8-read-mem-settings.sh - Makes data files understood by the k8-interpret-extended-memory-settings script. Bash
    • parse-bkdg.pl - Make bkdg.data file used by above scripts. Perl
    • example_input - Sample input for the above scripts. Text
  • apcb - AMD PSP Control Block tools
    • apcb_edit.py - This tool allows patching an existing APCB binary with specific SPDs and GPIO selection pins. Python3
    • apcb_v3_edit.py - This tool allows patching an existing APCB v3 binary with up to 16 specific SPDs. Python3
  • archive - Concatenate files and create an archive C
  • autoport - Automated porting coreboot to Sandy Bridge/Ivy Bridge/Haswell platforms Go
  • bincfg - Compiler/Decompiler for data blobs with specs Lex Yacc
  • board_status - Tools to collect logs and upload them to the board status repository Bash Go
  • bucts - A tool to manipulate the BUC.TS bit on Intel targets. C
  • cavium - Devicetree_convert Tool to convert a DTB to a static C file Python
  • cbfstool
    • cbfstool - For manipulating CBFS file C
    • fmaptool - Converts plaintext fmd files into fmap blobs C
    • rmodtool - Creates rmodules C
    • ifwitool - For manipulating IFWI C
  • cbmem - CBMEM parser to read e.g. timestamps and console log C
  • chromeos - These scripts can be used to access ChromeOS resources, for example to extract System Agent reference code and other blobs (e.g. mrc.bin, refcode, VGA option roms) from a ChromeOS recovery image. C
  • crossgcc - A cross toolchain builder for -elf toolchains (ie. no libc support) Bash
  • docker - Dockerfiles for coreboot-sdk, coreboot-jenkins-node, coreboot.org-status and docs.coreboot.org Make
  • dtd_parser - DTD structure parser Python2
  • ectool - Dumps the RAM of a laptop's Embedded/Environmental Controller (EC). C
  • exynos - Computes and fills Exynos ROM checksum (for BL1 or BL2). Python3
  • find_usbdebug - Help find USB debug ports Bash
  • futility - Firmware utility for signing ChromeOS images Make
  • fuzz-tests - Create test cases that crash the jpeg code. C
  • genbuild_h - Generate build system definitions Shell
  • gitconfig - Initialize git repository submodules install git hooks Bash
  • hda-decoder - Dumps decoded HDA default configuration registers into a format which can be used in coreboot's verb table Go
  • ifdtool - Extract and dump Intel Firmware Descriptor information C
  • intelmetool - Dump interesting things about Management Engine even if hidden C
  • intelp2m - Convert the inteltool register dump to gpio.h with GPIO configuration for porting coreboot to your motherboard. Go
  • inteltool - Provides information about the Intel CPU/chipset hardware configuration (register contents, MSRs, etc). C
  • intelvbttool - Parse VBT from VGA BIOS C
  • kbc1126 - Tools used to dump the two blobs from the factory firmware of many HP laptops with 8051-based SMSC KBC1098/KBC1126 embedded controller and insert them to the firmware image. C
  • kconfig - Build system Make
  • lint - Source linter and linting rules Shell
  • nixos - A script and NixOS configuration files to create an ISO image for testing purposes and for working on firmware. Bash
  • mainboard - mainboard specific scripts
    • google - Directory for google mainboard specific scripts
  • marvell - Add U-Boot boot loader for Marvell ARMADA38X C
  • me_cleaner - Tool for partial deblobbing of Intel ME/TXE firmware images Python
  • mediatek
    • check-pi-img.py - Check PI_IMG firmware. Python3
    • gen-bl-img.py - Generate MediaTek bootloader header. Python3
  • mma - Memory Margin Analysis automation tests Bash
  • msrtool - Dumps chipset-specific MSR registers. C
  • nvidia - nvidia blob parsers
  • nvramtool - Reads and writes coreboot parameters and displaying information from the coreboot table in CMOS/NVRAM. C
  • pmh7tool - Dumps, reads and writes PMH7 registers on Lenovo ThinkPads. PMH7 is used for switching on and off the power of some devices on the board such as dGPU. C
  • post - Userspace utility that can be used to test POST cards. C
  • qemu - Makefile & comprehensive default config for QEMU Q35 emulation Make
  • qualcomm - cmm
    • CMM script to debug Qualcomm coreboot environments. CMM ipqheader
    • createxbl.py - Concatenates XBL segments into one ELF image Python
    • ipqheader.py - Returns a packed MBN header image with the specified base and size Python
    • mbncat.py - Generate ipq8064 uber SBL Python
    • mbn_tools.py - Contains all MBN Utilities for image generation Python
  • release - Generate coreboot release Bash
  • riscv
    • make-spike-elf.sh - Converts a flat file into an ELF, that can be passed to SPIKE, the RISC-V reference emulator.Bash
    • sifive-gpt.py - Wraps the bootblock in a GPT partition for SiFive's bootrom. Python3
  • rockchip - Generate Rockchip idblock bootloader. Python3
  • sconfig - coreboot device tree compiler Lex Yacc
  • scripts
    • capture_commands.sh - Write all commands from the build to a file. Shell
    • config - Manipulate options in a .config file from the command line Bash
    • cross-repo-cherrypick - Pull in patches from another tree from a gerrit repository. Shell
    • decode_spd.sh - Decodes Serial Presence Detect (SPD) files into various human readable formats. Bash
    • dts-to-fmd.sh -Converts a depthcharge fmap.dts into an fmaptool compatible .fmd format Bash
    • find_new_user_commits.sh - Finds new gerrit committers Bash
    • find-unused-kconfig-symbols.sh - Points out Kconfig variables that may be unused. There are some false positives, but it serves as a starting point Shell
    • gerrit-rebase - Applies all commits that from-branch has over to-branch, based on a common ancestor and gerrit meta-data Bash
    • get_maintainer.pl - Print selected MAINTAINERS information for the files modified in a patch or for a file Perl
    • maintainers.go - Build subsystem Maintainers Go
    • no-fsf-addresses.sh - Removes various FSF addresses from license headers Shell
    • parse-maintainers.pl - Script to alphabetize MAINTAINERS file Perl
    • rm_unused_code - Remove all code not used for a platform from the local git repository for auditing or release Bash
    • show_platforms.sh - Makes a list of platforms in the tree. Does not show variants. Shell
    • ucode_h_to_bin.sh - Microcode conversion tool Bash
    • update_submodules - Check all submodules for updates Bash
  • smmstoretool - Offline SMMSTORE variable modification tool C
  • spdtool - Dumps SPD ROMs from a given blob to separate files using known patterns and reserved bits. Useful for analysing firmware that holds SPDs on boards that have soldered down DRAM. python
  • spkmodem_recv - Decode spkmodem signals C
  • superiotool - A user-space utility to detect Super I/O of a mainboard and provide detailed information about the register contents of the Super I/O. C
  • supermicro - Tools for supermicro platforms
    • smcbiosinfo - Generates SMC biosinfo for BMC BIOS updates C
  • testing - coreboot test targets Make
  • uio_usbdebug - Debug coreboot's usbdebug driver inside a running operating system (only Linux at this time). C
  • util_readme - Creates README.md of description files in ./util subdirectories Bash
  • vboot_list - Tools to generate a list of vboot enabled devices to the documentation Bash
  • vgabios - emulated vga driver for qemu C
  • x86 - Generates 32-bit PAE page tables based on a CSV input file. Go
  • xcompile - Cross compile setup Bash