From 4e3097b5e7b6b80dff3f76046f28e5816e877578 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Tue, 6 Dec 2022 19:52:00 +0300 Subject: build/roms: Disable U-Boot when not in payloads specified by cmdline When overriding which payloads will be built with the -p command line argument, the roms_helper script doesn't disable the U-Boot payload. Disable it in this case. Signed-off-by: Alper Nebi Yasak --- resources/scripts/build/boot/roms_helper | 1 + 1 file changed, 1 insertion(+) (limited to 'resources/scripts/build') diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper index bd1f3860..e2b152d9 100755 --- a/resources/scripts/build/boot/roms_helper +++ b/resources/scripts/build/boot/roms_helper @@ -159,6 +159,7 @@ if [ ! -z ${payloads} ]; then payload_grub_withseabios="n" # seabios chainloaded from grub payload_seabios="n" payload_seabios_withgrub="n" # i386-coreboot grub accessible from SeaBIOS boot menu + payload_uboot="n" seabios_opromloadonly="0" payload_memtest="n" -- cgit v1.2.1 From 9fb4ecec62b0430fa8e405d2133a4579020e522b Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Wed, 7 Dec 2022 21:41:33 +0300 Subject: build/roms: Don't build Memtest86+ when not specified by cmdline When overriding which payloads will be built with the -p command line argument, the roms_helper script builds the Memtest86+ payload before checking if it should be disabled. Move the build command after the command line override. Signed-off-by: Alper Nebi Yasak --- resources/scripts/build/boot/roms_helper | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'resources/scripts/build') diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper index e2b152d9..a59c4285 100755 --- a/resources/scripts/build/boot/roms_helper +++ b/resources/scripts/build/boot/roms_helper @@ -146,12 +146,6 @@ if [ "${payload_uboot}" = "y" ] && \ uboot_config="default" fi -if [ "${payload_memtest}" = "y" ]; then - if [ ! -f "memtest86plus/memtest" ]; then - ./build module memtest86plus - fi -fi - # Override all payload directives with cmdline args if [ ! -z ${payloads} ]; then echo "setting payloads $payloads" @@ -219,6 +213,12 @@ if [ ! -f "${seavgabiosrom}" ] \ fi fi +if [ "${payload_memtest}" = "y" ]; then + if [ ! -f "memtest86plus/memtest" ]; then + ./build module memtest86plus + fi +fi + [ -d "${romdir}/" ] || mkdir -p "${romdir}/" rm -f "${romdir}"/* -- cgit v1.2.1 From a586356164491f5895713fca713967218211219e Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Wed, 7 Dec 2022 19:31:36 +0300 Subject: build/roms: Build 32-bit crossgcc for AArch64 as well This re-applies commit a69855f7e448 ("Build 32-bit crossgcc for AArch64 as well") which was inexplicably reverted along with unrelated changes. Mention in a comment that building crossgcc-arm is necessary for AArch64. Signed-off-by: Alper Nebi Yasak --- resources/scripts/build/boot/roms_helper | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'resources/scripts/build') diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper index a59c4285..ff0681f3 100755 --- a/resources/scripts/build/boot/roms_helper +++ b/resources/scripts/build/boot/roms_helper @@ -194,7 +194,8 @@ 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 + # aarch64 needs armv7 toolchain for arm-trusted-firmware + make crossgcc-arm crossgcc-aarch64 CPUS=$(nproc) ) fi -- cgit v1.2.1 From bee5054077e8e178cb5dfe1b4ecd1b20d67ee93f Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Wed, 7 Dec 2022 20:53:18 +0300 Subject: build/roms: Make coreboot crossgcc usable for payloads and modules Add the coreboot-built cross-architecture toolchains to the PATH so that modules and payloads can use them. When building for a foreign-arch board, also export CROSS_COMPILE pointing to the appropriate prefix. Signed-off-by: Alper Nebi Yasak --- resources/scripts/build/boot/roms_helper | 14 ++++++++++++++ resources/scripts/build/payload/u-boot | 8 -------- 2 files changed, 14 insertions(+), 8 deletions(-) (limited to 'resources/scripts/build') diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper index ff0681f3..abec7402 100755 --- a/resources/scripts/build/boot/roms_helper +++ b/resources/scripts/build/boot/roms_helper @@ -184,12 +184,20 @@ if [ "${arch}" = "x86_32" ] || [ "${arch}" = "x86_64" ]; then # 32-bit ROM images, so we only need to worry about i386-elf ) fi + case "$(uname -m)" in + x86*|i*86|amd64) : ;; + *) export CROSS_COMPILE=i386-elf- ;; + esac 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 ) + case "$(uname -m)" in + arm|arm32|armv6*|armv7*) : ;; + *) export CROSS_COMPILE=arm-eabi- ;; + esac elif [ "${arch}" = "AArch64" ]; then ( cat version > "${cbdir}/.coreboot-version" @@ -197,8 +205,14 @@ elif [ "${arch}" = "AArch64" ]; then # aarch64 needs armv7 toolchain for arm-trusted-firmware make crossgcc-arm crossgcc-aarch64 CPUS=$(nproc) ) + case "$(uname -m)" in + arm64|aarch64) : ;; + *) export CROSS_COMPILE=aarch64-elf- ;; + esac fi +export PATH="$(pwd)/${cbdir}/util/crossgcc/xgcc/bin:$PATH" + if [ ! -f "${cbfstool}" ]; then ./build module cbutils ${cbtree} fi diff --git a/resources/scripts/build/payload/u-boot b/resources/scripts/build/payload/u-boot index 6c94a441..3ead3a6c 100755 --- a/resources/scripts/build/payload/u-boot +++ b/resources/scripts/build/payload/u-boot @@ -94,14 +94,6 @@ for board in "$@"; do continue fi - if [ "${arch}" = "x86_32" ] || [ "${arch}" = "x86_64" ]; then - export CROSS_COMPILE=x86_64-linux- - elif [ "${arch}" = "ARMv7" ]; then - export CROSS_COMPILE=arm-linux-gnueabi- - elif [ "${arch}" = "AArch64" ]; then - export CROSS_COMPILE=aarch64-linux-gnu- - fi - for config in "${board_dir}/config"/*; do if [ ! -f "${config}" ]; then printf "%s: Target %s has no configs to build for. Skipping build.\n" \ -- cgit v1.2.1 From 5b6bf2a82631f15ad8d3923520e678b9b0065302 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Wed, 7 Dec 2022 21:55:05 +0300 Subject: build/roms: Don't rebuild crossgcc if it was already built The roms_helper script skips building crossgcc-i386 if its target directory exists. Skip it for other architectures as well. Signed-off-by: Alper Nebi Yasak --- resources/scripts/build/boot/roms_helper | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'resources/scripts/build') diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper index abec7402..f533e6ab 100755 --- a/resources/scripts/build/boot/roms_helper +++ b/resources/scripts/build/boot/roms_helper @@ -175,36 +175,34 @@ if [ ! -d "${cbdir}" ]; then ./download coreboot ${cbtree} fi +cat version > "${cbdir}/.coreboot-version" + if [ "${arch}" = "x86_32" ] || [ "${arch}" = "x86_64" ]; then if [ ! -d "${cbdir}/util/crossgcc/xgcc/i386-elf/" ]; then - ( - cat version > "${cbdir}/.coreboot-version" - cd "${cbdir}" - make crossgcc-i386 CPUS=$(nproc) # even for 64-bit machines, coreboot builds - # 32-bit ROM images, so we only need to worry about i386-elf - ) + # Even for 64-bit machines, coreboot builds 32-bit ROM + # images, so we only need to worry about i386-elf + make -C "${cbdir}" crossgcc-i386 CPUS=$(nproc) fi case "$(uname -m)" in x86*|i*86|amd64) : ;; *) export CROSS_COMPILE=i386-elf- ;; esac 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 - ) + if [ ! -d "${cbdir}/util/crossgcc/xgcc/arm-eabi/" ]; then + make -C "${cbdir}" crossgcc-arm CPUS=$(nproc) + fi case "$(uname -m)" in arm|arm32|armv6*|armv7*) : ;; *) export CROSS_COMPILE=arm-eabi- ;; esac elif [ "${arch}" = "AArch64" ]; then - ( - cat version > "${cbdir}/.coreboot-version" - cd "${cbdir}" - # aarch64 needs armv7 toolchain for arm-trusted-firmware - make crossgcc-arm crossgcc-aarch64 CPUS=$(nproc) - ) + if [ ! -d "${cbdir}/util/crossgcc/xgcc/aarch64-elf/" ]; then + make -C "${cbdir}" crossgcc-aarch64 CPUS=$(nproc) + fi + # aarch64 also needs armv7 toolchain for arm-trusted-firmware + if [ ! -d "${cbdir}/util/crossgcc/xgcc/arm-eabi/" ]; then + make -C "${cbdir}" crossgcc-arm CPUS=$(nproc) + fi case "$(uname -m)" in arm64|aarch64) : ;; *) export CROSS_COMPILE=aarch64-elf- ;; -- cgit v1.2.1 From 1c62b003ad6014288114300de65844496dffaf72 Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Fri, 9 Dec 2022 14:50:03 +0300 Subject: 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 --- resources/scripts/build/boot/roms_helper | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'resources/scripts/build') diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper index f533e6ab..66a7be8f 100755 --- a/resources/scripts/build/boot/roms_helper +++ b/resources/scripts/build/boot/roms_helper @@ -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) -- cgit v1.2.1 From 0bd4fdbe5b9d9c93a522f1cd73e1053fba01b7fc Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Sat, 10 Dec 2022 00:26:35 +0300 Subject: dependencies/debian: Install dependencies for U-Boot U-Boot build dependencies are listed on their online documentation [1], but the listed Debian packages also include test-only dependencies. While installing dependencies, install the packages necessary to build U-Boot, except for the test-only ones I could identify. [1] https://u-boot.readthedocs.io/en/latest/build/gcc.html Signed-off-by: Alper Nebi Yasak --- resources/scripts/build/dependencies/debian | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'resources/scripts/build') diff --git a/resources/scripts/build/dependencies/debian b/resources/scripts/build/dependencies/debian index 4cebfe36..e69aa568 100755 --- a/resources/scripts/build/dependencies/debian +++ b/resources/scripts/build/dependencies/debian @@ -88,6 +88,11 @@ apt-get -y install libncurses5-dev doxygen iasl gdb flex bison build-essential g apt-get -y install fonts-unifont libopts25 libselinux1-dev autogen m4 autoconf help2man libopts25-dev libfont-freetype-perl automake autotools-dev build-essential bison flex libfuse-dev liblzma-dev gawk libdevmapper-dev libtool libfreetype6-dev +# U-Boot build dependencies +# ------------------------- + +apt-get -y install bc bison build-essential device-tree-compiler efitools flex libfdt-dev liblz4-tool libgnutls28-dev libncurses-dev libpython3-dev libsdl2-dev libssl-dev lz4 lzma lzma-alone openssl pkg-config python3 python3-distutils python3-pkg-resources python3-pycryptodome python3-pyelftools swig uuid-dev + # BucTS build dependencies (external script) # ------------------------------------------------------------ -- cgit v1.2.1 From 70435784ecfb9eb44455719aea65ac8ca9b7b08f Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Sat, 10 Dec 2022 00:43:19 +0300 Subject: build/clean: Add helper script to clean U-Boot builds Copy the resources/scripts/build/clean/crossgcc script and adapt it to run "make distclean" on U-Boot build trees. Some build artifacts persist after the run, so also run "git clean -fdx" if we can. Signed-off-by: Alper Nebi Yasak --- resources/scripts/build/clean/u-boot | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100755 resources/scripts/build/clean/u-boot (limited to 'resources/scripts/build') diff --git a/resources/scripts/build/clean/u-boot b/resources/scripts/build/clean/u-boot new file mode 100755 index 00000000..d6ae7193 --- /dev/null +++ b/resources/scripts/build/clean/u-boot @@ -0,0 +1,49 @@ +#!/usr/bin/env bash + +# helper script: clean the u-boot builds +# +# Copyright (C) 2014, 2015, 2016, 2020 Leah Rowe +# Copyright (C) 2015 Klemens Nanni +# 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# This script assumes that the current working directory is the root + +[ "x${DEBUG+set}" = 'xset' ] && set -v +set -u -e + +# clean u-boot builds (dependencies for 'build'): + +printf "Cleaning u-boot builds for all boards\n" + +[ ! -d "coreboot/" ] && exit 0 + +# clean u-boot (source archives preserved) +for board in u-boot/*; do + if [ "${board##*/}" = "u-boot" ]; then + continue + fi + if [ ! -d "${board}" ]; then + continue + fi + make -C "${board}/" distclean + + if [ -e "${board}/.git" ]; then + git -C "${board}" clean -fdx + fi +done + +printf "\n\n" -- cgit v1.2.1 From f079b83dd9c0953958fe5d84d0594d39b02122fe Mon Sep 17 00:00:00 2001 From: Alper Nebi Yasak Date: Tue, 6 Dec 2022 20:11:33 +0300 Subject: build/release/src: Include U-Boot sources in source archive Add U-Boot to the source release script's modules list so that it is included in source release tarballs. Don't include the unused upstream source and .git directories. Signed-off-by: Alper Nebi Yasak --- resources/scripts/build/release/src | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'resources/scripts/build') diff --git a/resources/scripts/build/release/src b/resources/scripts/build/release/src index 5f7358f3..8a75160d 100755 --- a/resources/scripts/build/release/src +++ b/resources/scripts/build/release/src @@ -53,7 +53,7 @@ mkdir -p "${srcdir}/" printf "%s" "${version}" > "${srcdir}"/version -modlist="coreboot flashrom grub memtest86plus seabios ich9utils me_cleaner" +modlist="coreboot flashrom grub memtest86plus seabios ich9utils me_cleaner u-boot" dirlist="resources" # do not add blobs directory here. it is handled below filelist="blobutil modify download build README.md COPYING Makefile update version versiondate projectname .gitcheck" @@ -107,6 +107,7 @@ done rm -Rf coreboot/coreboot/ rm -Rf .git* */.git* coreboot/*/.git* coreboot/*/3rdparty/*/.git* rm -Rf coreboot/*/util/nvidia/cbootimage/.git* + rm -Rf u-boot/u-boot/ u-boot/*/.git* ) ( -- cgit v1.2.1