From c0017c73578a91c4a40bf033f641ce293cd3df2e Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 3 Nov 2024 02:41:41 +0000 Subject: Experimental U-Boot payload (32-bit dtb, U-Boot) NOTE: Support added for xarch target x86_64-elf, but U-Boot failed to build with this error: OBJCOPY lib/efi_loader/helloworld.efi x86_64-elf-objcopy: lib/efi_loader/helloworld_efi.so: invalid bfd target make[2]: *** [scripts/Makefile.lib:476: lib/efi_loader/helloworld.efi] Error 1 Since I'm building U-Boot for x86_64 *on* an x86-64 host, and since that is currently the recommended type of machine to use for lbmk development, and since the other x86 payloads currently don't cross compile anyway, this is an acceptable compromise for now. This is because at present, I'm not making U-Boot the primary payload on x86, instead preferring to chain it from GRUB and SeaBIOS. The target.cfg file for x86 u-boot shows xarch/xtree commented. Uncomment these to compile on crossgcc instead of hostcc. I mention 64-bit because I initially did this first, but decided to do 32-bit first. I'll work on the 64-bit one next (SPL). It's only enabled in QEMU for now. Signed-off-by: Leah Rowe --- include/lib.sh | 19 +++++++++++++++++-- include/rom.sh | 23 ++++++++++++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/lib.sh b/include/lib.sh index c5df639c..9a5faabb 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -209,9 +209,24 @@ vendor_checksum() cbfs() { + fRom="$1" # image to operate on + fAdd="$2" # file to add + fName="$3" # filename when added in CBFS + ccmd="add-payload" && [ $# -gt 3 ] && ccmd="add" - lzma="-c lzma" && [ $# -gt 3 ] && lzma="-t raw" - x_ "$cbfstool" "$1" $ccmd -f "$2" -n "$3" $lzma + lzma="-c lzma" && [ $# -gt 3 ] && [ $# -lt 5 ] && lzma="-t $4" + + # hack. TODO: do it better. this whole function is cursed + if [ $# -gt 4 ]; then + # add flat binary for U-Boot (u-boot.bin) on x86 + if [ "$5" = "0x1110000" ]; then + ccmd="add-flat-binary" + lzma="-c lzma -l 0x1110000 -e 0x1110000" + fi + fi + + "$cbfstool" "$fRom" $ccmd -f "$fAdd" -n "$fName" $lzma || \ + $err "CBFS fail: $fRom $ccmd -f '$fAdd' -n '$fName' $lzma"; : } mk() diff --git a/include/rom.sh b/include/rom.sh index 1d7be098..d04e9ee4 100644 --- a/include/rom.sh +++ b/include/rom.sh @@ -111,6 +111,7 @@ mkcorebootbin() [ "$payload_memtest" = "y" ] || payload_memtest="n" [ "$(uname -m)" = "x86_64" ] || payload_memtest="n" + if $dry grep "CONFIG_PAYLOAD_NONE=y" "$defconfig"; then [ "$payload_seabios" = "y" ] && pname="seabios" && \ $dry add_seabios @@ -136,6 +137,8 @@ add_seabios() [ "$payload_memtest" = "y" ] && cbfs "$tmprom" \ "elf/memtest86plus/memtest.bin" img/memtest + [ "$payload_uboot_i386" = "y" ] && $dry add_uboot + [ "$payload_grub" = "y" ] && add_grub cprom && [ "$payload_grub" = "y" ] && pname="seagrub" && mkseagrub; : @@ -159,12 +162,26 @@ mkseagrub() add_uboot() { - ubdir="elf/u-boot/$target/$uboot_config" + # TODO: re-work to allow each coreboot target to say which ub tree + # instead of hardcoding as in the current logic below: + + ubcbfsargs="" + [ "$payload_uboot_i386" = "y" ] && \ + ubcbfsargs="-l 0x1110000 -e 0x1110000" + + ubpath="fallback/payload" + [ "$payload_uboot_i386" = "y" ] && ubpath="u-boot" + + ubtarget="$target" + [ "$payload_uboot_i386" = "y" ] && ubtarget="i386coreboot" + + ubdir="elf/u-boot/$ubtarget/$uboot_config" ubootelf="$ubdir/u-boot.elf" && [ ! -f "$ubootelf" ] && \ ubootelf="$ubdir/u-boot" - [ -f "$ubootelf" ] || $err "cb/$target: Can't find u-boot" + [ "$payload_uboot_i386" = "y" ] && ubootelf="$ubdir/u-boot-dtb.bin" - cbfs "$tmprom" "$ubootelf" "fallback/payload"; cprom + [ -f "$ubootelf" ] || $err "cb/$ubtarget: Can't find u-boot" + cbfs "$tmprom" "$ubootelf" "$ubpath" $ubcbfsargs; cprom } cprom() -- cgit v1.2.1