From 769f18f2f601dbf666d0f52f67f79b82e582909a Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Fri, 26 Aug 2022 15:06:45 +0300 Subject: build/roms: Fix building for ARMv7 and AArch64 boards The code that compiles coreboot crossgcc changes the working directory to the coreboot directory, and the following code cannot find the lbmk scripts that it needs to run. Compile ARMv7 and AArch64 cross compilers in a subshell like in the x86 case so the rest of the script can work. Signed-off-by: Alper Nebi Yasak --- resources/scripts/build/boot/roms_helper | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'resources/scripts/build/boot/roms_helper') diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper index a6b64316..28053367 100755 --- a/resources/scripts/build/boot/roms_helper +++ b/resources/scripts/build/boot/roms_helper @@ -4,6 +4,7 @@ # # Copyright (C) 2020,2021 Leah Rowe # Copyright (C) 2021 Vitali64 +# Copyright (C) 2022 Alper Nebi Yasak # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -150,13 +151,17 @@ if [ "${arch}" = "x86_32" ] || [ "${arch}" = "x86_64" ]; then ) fi elif [ "${arch}" = "ARMv7" ]; then - cat version > "${cbdir}/.coreboot-version" - cd "${cbdir}" - make crossgcc-arm CPUS=$(nproc) # This is for armv7, doesn't apply to aarch64 + ( + cat version > "${cbdir}/.coreboot-version" + cd "${cbdir}" + make crossgcc-arm CPUS=$(nproc) # This is for armv7, doesn't apply to aarch64 + ) elif [ "${arch}" = "AArch64" ]; then - cat version > "${cbdir}/.coreboot-version" - cd "${cbdir}" - make crossgcc-aarch64 CPUS=$(nproc) # This is for aarch64, doesn't apply to armv7 + ( + cat version > "${cbdir}/.coreboot-version" + cd "${cbdir}" + make crossgcc-aarch64 CPUS=$(nproc) # This is for aarch64, doesn't apply to armv7 + ) fi if [ ! -f "${cbfstool}" ]; then -- cgit v1.2.1 From a69855f7e448b2f3f8947982ddd793d64914a011 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Fri, 26 Aug 2022 16:16:56 +0300 Subject: build/roms: Build 32-bit crossgcc for AArch64 as well The 32-bit ARM cross compiler toolchain is used to build parts of arm-trusted-firmware needed by AArch64 boards, compile the toolchain for those boards as well. Signed-off-by: Alper Nebi Yasak --- resources/scripts/build/boot/roms_helper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'resources/scripts/build/boot/roms_helper') diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper index 28053367..8b9ca358 100755 --- a/resources/scripts/build/boot/roms_helper +++ b/resources/scripts/build/boot/roms_helper @@ -160,7 +160,7 @@ elif [ "${arch}" = "AArch64" ]; then ( cat version > "${cbdir}/.coreboot-version" cd "${cbdir}" - make crossgcc-aarch64 CPUS=$(nproc) # This is for aarch64, doesn't apply to armv7 + make crossgcc-arm crossgcc-aarch64 CPUS=$(nproc) # This is for aarch64, doesn't apply to armv7 ) fi -- cgit v1.2.1 From 61ede99832424718200bddd2826eae4bda2c3c7a Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Fri, 26 Aug 2022 17:14:57 +0300 Subject: 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 --- resources/scripts/build/boot/roms_helper | 62 +++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'resources/scripts/build/boot/roms_helper') 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() { @@ -325,6 +352,28 @@ make_seabios_rom() { printf "%s\n" "${tmprom}" } +# 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}" @@ -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" -- cgit v1.2.1 From 6d6bd5eee0cdb626fb5e054db08c8e6136cfe579 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Sat, 27 Aug 2022 21:25:43 +0300 Subject: build/roms: Rebuild cbutils module before starting coreboot build In recent coreboot versions, running distclean started to erase the cbfstool binary we built earlier in the util/cbfstool dir via the cbutils build script call. The coreboot build puts it in a different directory, and the roms build script can't find it when trying to add payloads to the roms. This doesn't make the script fail (because set -e is stupid like that), and the build appears to succeed if you don't look close enough to see the "cbfsutil not found" error. Build the coreboot utils we want at the places we want them after calling distclean, so that we can actually use cbfsutil and avoid silently-broken roms with newer coreboot versions. Signed-off-by: Alper Nebi Yasak --- resources/scripts/build/boot/roms_helper | 1 + 1 file changed, 1 insertion(+) (limited to 'resources/scripts/build/boot/roms_helper') diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper index deb40d57..951e19ba 100755 --- a/resources/scripts/build/boot/roms_helper +++ b/resources/scripts/build/boot/roms_helper @@ -307,6 +307,7 @@ mkCoreboot() { make distclean ) cp "${cbcfgpath}" "${cbdir}"/.config + ./build module cbutils ${cbdir#coreboot/} ( cd "${cbdir}" make -j$(nproc) -- cgit v1.2.1