summaryrefslogtreecommitdiff
path: root/resources/scripts/build/boot/roms_helper
diff options
context:
space:
mode:
Diffstat (limited to 'resources/scripts/build/boot/roms_helper')
-rwxr-xr-xresources/scripts/build/boot/roms_helper80
1 files changed, 73 insertions, 7 deletions
diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper
index a6b64316..951e19ba 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 <info@minifree.org>
# Copyright (C) 2021 Vitali64 <vitali64pmemail@protonmail.com>
+# Copyright (C) 2022 Alper Nebi Yasak <alpernebiyasak@gmail.com>
#
# 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
@@ -63,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"
@@ -109,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
@@ -121,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
@@ -150,13 +163,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-arm crossgcc-aarch64 CPUS=$(nproc) # This is for aarch64, doesn't apply to armv7
+ )
fi
if [ ! -f "${cbfstool}" ]; then
@@ -211,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() {
@@ -275,6 +307,7 @@ mkCoreboot() {
make distclean
)
cp "${cbcfgpath}" "${cbdir}"/.config
+ ./build module cbutils ${cbdir#coreboot/}
(
cd "${cbdir}"
make -j$(nproc)
@@ -321,6 +354,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}"
@@ -450,6 +505,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"