summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>2022-08-26 17:14:57 +0300
committerAlper Nebi Yasak <alpernebiyasak@gmail.com>2022-08-28 13:09:52 +0300
commit61ede99832424718200bddd2826eae4bda2c3c7a (patch)
treec24894f8b997a367aa2555c65ce5908e325a2453
parenta69855f7e448b2f3f8947982ddd793d64914a011 (diff)
build/roms: Support using U-Boot as a coreboot payload
This enables embedding U-Boot into the coreboot roms as the payload. For now, the ELF file generated by enabling CONFIG_REMAKE_ELF is used, which includes the U-Boot binary and the board-specific device-tree file. It might be better to use the FIT payload support for U-Boot, but that was reportedly broken and is not tested yet. Coreboot boards can specify payload_uboot="y" in their board.cfg to enable building a rom with U-Boot as the payload, which is built from the U-Boot board with the same name. Boards can further specify a uboot_config option, to choose which board-specific config file U-Boot should be built with. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
-rwxr-xr-xresources/scripts/build/boot/roms_helper62
1 files changed, 61 insertions, 1 deletions
diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper
index 8b9ca358..deb40d57 100755
--- a/resources/scripts/build/boot/roms_helper
+++ b/resources/scripts/build/boot/roms_helper
@@ -64,6 +64,8 @@ payload_seabios="n"
payload_seabios_withgrub="n" # i386-coreboot grub accessible from SeaBIOS boot menu
seabios_opromloadonly="0"
payload_memtest="n"
+payload_uboot="n"
+uboot_config="undefined"
# Override the above defaults using board.cfg
source "resources/coreboot/${board}/board.cfg"
@@ -110,7 +112,7 @@ fi
# NOTE: reverse logic must not be applied. If SeaBIOS-with-GRUB works, that doesn't
# necessarily mean GRUB-with-SeaBIOS will work nicely. for example, the board might
# only have an add-on GPU available, where it's recommended to boot SeaBIOS first
-if [ "${payload_grub}" != "y" ] && [ "${payload_seabios}" != "y" ]; then
+if [ "${payload_grub}" != "y" ] && [ "${payload_seabios}" != "y" ] && [ "${payload_uboot}" != "y" ]; then
while true; do
for configfile in "resources/coreboot/${board}/config/"*; do
if [ -f "${configfile}" ]; then
@@ -122,6 +124,16 @@ if [ "${payload_grub}" != "y" ] && [ "${payload_seabios}" != "y" ]; then
done
fi
+if [ "${payload_uboot}" != "n" ] && \
+ [ "${payload_uboot}" != "y" ]; then
+ payload_uboot="n"
+fi
+
+if [ "${payload_uboot}" = "y" ] && \
+ [ "${uboot_config}" = "undefined" ]; then
+ uboot_config="default"
+fi
+
if [ "${payload_memtest}" = "y" ]; then
if [ ! -f "memtest86plus/memtest" ]; then
./build module memtest86plus
@@ -216,6 +228,21 @@ if [ "${payload_grub}" = "y" ] || [ "${payload_seabios_withgrub}" = "y" ]; then
done
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"
+ else
+ ubootelf="payload/u-boot/${board}/${uboot_config}/u-boot.elf"
+ fi
+
+ if [ ! -f "${ubootelf}" ]; then
+ 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}"
+ fi
+fi
+
# it is assumed that no other work will be done on the ROM
# after calling this function. therefore this function is "final"
moverom() {
@@ -326,6 +353,28 @@ make_seabios_rom() {
}
# make a rom in /tmp/ and then print the path of that ROM
+make_uboot_payload_rom() {
+ target_cbrom="${1}" # rom to insert u-boot in. this rom won't be touched
+ # a tmpfile will be made instead
+ target_uboot_cbfs_path="${2}" # e.g. fallback/payload
+ target_uboot_config="${3}"
+ cbfstool_path="${4}"
+
+ if [ "${target_uboot_config}" = "default" ]; then
+ target_ubootelf="payload/u-boot/${board}/u-boot.elf"
+ else
+ target_ubootelf="payload/u-boot/${board}/${target_uboot_config}/u-boot.elf"
+ fi
+
+ tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
+
+ cp "${target_cbrom}" "${tmprom}"
+ "${cbfstool}" "${tmprom}" add-payload -f "${target_ubootelf}" -n ${target_uboot_cbfs_path} -c lzma
+
+ printf "%s\n" "${tmprom}"
+}
+
+# make a rom in /tmp/ and then print the path of that ROM
make_grubrom_from_keymap() {
target_keymap="${1}"
target_cbrom="${2}"
@@ -455,6 +504,17 @@ mkRoms() {
if [ "${payload_grub}" = "y" ]; then
mkRomsWithGrub "${corebootrom}" "${initmode}" "${displaymode}" "grub"
fi
+
+ if [ "${payload_uboot}" = "y" ]; then
+ tmpubootrom="$(make_uboot_payload_rom "${corebootrom}" "fallback/payload" "${uboot_config}" "${cbfstool}")"
+ if [ "${initmode}" = "normal" ]; then
+ newrompath="${romdir}/uboot_payload_${board}_${initmode}.rom"
+ else
+ newrompath="${romdir}/uboot_payload_${board}_${initmode}_${displaymode}.rom"
+ fi
+ moverom "${tmpubootrom}" "${newrompath}" "${romtype}"
+ rm -f "${tmpubootrom}"
+ fi
}
initmode="libgfxinit"