build/roms: Support using "u-boot" ELF file as U-Boot payload

U-Boot runtime configuration is done with a device-tree file, which is
built alongside the executable in the upstream build system, and must be
available to U-Boot at runtime.

This device-tree is normally not linked into the default "u-boot" ELF
file. So far we have been handling it by re-creating a "u-boot.elf" from
the raw binary parts by setting REMAKE_ELF, and using that as the
coreboot payload. Unfortunately, that fails to build for x86 boards,
more specificly the "coreboot" boards upstream.

It's also possible (but discouraged) to set OF_EMBED to embed the
device-tree file into the U-Boot itself, in which case we could use the
"u-boot" file as the payload on the "coreboot" boards. Add support for
using the "u-boot" file as the payload if "u-boot.elf" doesn't exist.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
fsdg20230625
Alper Nebi Yasak 2022-12-09 14:50:03 +03:00
parent 6cabcec51d
commit 1c62b003ad
1 changed files with 16 additions and 7 deletions

View File

@ -268,14 +268,17 @@ if [ "${payload_grub}" = "y" ] || [ "${payload_seabios_withgrub}" = "y" ]; then
fi
if [ "${payload_uboot}" = "y" ]; then
if [ "${uboot_config}" = "default" ] && \
[ -f "payload/u-boot/${board}/u-boot.elf" ]; then
ubootelf="payload/u-boot/${board}/u-boot.elf"
if [ "${uboot_config}" = "default" ]; then
ubdir="payload/u-boot/${board}"
else
ubootelf="payload/u-boot/${board}/${uboot_config}/u-boot.elf"
ubdir="payload/u-boot/${board}/${uboot_config}"
fi
if [ ! -f "${ubootelf}" ]; then
if [ -f "${ubdir}/u-boot.elf" ]; then
ubootelf="${ubdir}/u-boot.elf"
elif [ -f "${ubdir}/u-boot" ]; then
ubootelf="${ubdir}/u-boot"
else
printf "Required U-Boot payloads not yet built. Building now:\n"
rm -Rf "payload/u-boot/${board}" # just in case
./build payload u-boot "${board}"
@ -397,9 +400,15 @@ make_uboot_payload_rom() {
cbfstool_path="${4}"
if [ "${target_uboot_config}" = "default" ]; then
target_ubootelf="payload/u-boot/${board}/u-boot.elf"
target_ubdir="payload/u-boot/${board}"
else
target_ubootelf="payload/u-boot/${board}/${target_uboot_config}/u-boot.elf"
target_ubdir="payload/u-boot/${board}/${target_uboot_config}"
fi
if [ -f "${target_ubdir}/u-boot.elf" ]; then
target_ubootelf="${target_ubdir}/u-boot.elf"
elif [ -f "${target_ubdir}/u-boot" ]; then
target_ubootelf="${target_ubdir}/u-boot"
fi
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)