2023-10-26 21:11:40 +02:00
|
|
|
#!/usr/bin/env sh
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2024-05-26 02:54:36 +02:00
|
|
|
# Copyright (c) 2014-2016,2020-2021,2023-2024 Leah Rowe <leah@libreboot.org>
|
|
|
|
# Copyright (c) 2021-2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
|
|
|
# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
|
|
|
|
# Copyright (c) 2022-2023 Alper Nebi Yasak <alpernebiyasak@gmail.com>
|
|
|
|
# Copyright (c) 2023 Riku Viitanen <riku.viitanen@protonmail.com>
|
2023-10-26 21:11:40 +02:00
|
|
|
|
|
|
|
set -u -e
|
|
|
|
|
2024-05-26 13:10:27 +02:00
|
|
|
. "include/lib.sh"
|
2023-10-26 21:11:40 +02:00
|
|
|
|
2024-06-27 04:18:23 +02:00
|
|
|
tmprom="$TMPDIR/rom"
|
2024-06-23 01:15:19 +02:00
|
|
|
|
2023-10-26 21:11:40 +02:00
|
|
|
seavgabiosrom="elf/seabios/default/libgfxinit/vgabios.bin"
|
|
|
|
cfgsdir="config/coreboot"
|
2024-06-18 02:44:25 +02:00
|
|
|
rp2040src="src/pico-serprog"
|
2024-06-18 02:50:40 +02:00
|
|
|
rp2040x="$rp2040src/build/pico_serprog.uf2"
|
2024-05-26 02:54:36 +02:00
|
|
|
picosdk="src/pico-sdk"
|
2024-06-20 01:12:00 +02:00
|
|
|
rp2040dir="$picosdk/src/boards/include/boards"
|
2024-05-26 02:54:36 +02:00
|
|
|
stm32src="src/stm32-vserprog"
|
2024-06-18 02:50:40 +02:00
|
|
|
stm32x="$stm32src/stm32-vserprog.hex"
|
2024-06-20 01:12:00 +02:00
|
|
|
stm32dir="$stm32src/boards"
|
2023-10-26 21:11:40 +02:00
|
|
|
|
|
|
|
# Disable all payloads by default.
|
|
|
|
# target.cfg files have to specifically enable [a] payload(s)
|
2024-06-24 19:35:32 +02:00
|
|
|
pv="payload_uboot payload_seabios payload_memtest payload_grub"
|
2024-06-24 19:24:50 +02:00
|
|
|
v="romdir initmode displaymode targetdir tree release ubootelf"
|
roms: only support SeaBIOS/SeaGRUB on x86
Never, ever build images where GRUB is the primary payload.
These options have been removed from target.cfg handling:
* seabios_withgrub
* grub_withseabios
The "payload_grub" variable now does the same thing as
the old "seabios_withgrub" variable, if set.
The "grubonly" configuration is retained, and enabled by
default when SeaGRUB is enabled (non-grubonly also available).
Due to lbmk issue #216, it is no longer Libreboot policy to
make GRUB the primary payload on any board. GRUB's sheer size
and complexity, plus the large number of memory corruption issues
similar to it that *have* been fixed over the years, tells me
that GRUB is a liability when it is the primary payload.
SeaBIOS is a much safer payload to run as primary, on x86, due
to its smaller size and much more conservative development; it
is simply far less likely to break.
If GRUB breaks in the future, the user's machine is not
bricked. This is because SeaBIOS is the default payload.
Since I no longer wish to ever provide GRUB as a primary
payload, supporting it in lbmk adds needless bloat that
will later probably break anyway due to lack of testing,
so let's just assume SeaGRUB in all cases where the user
wants to use a GRUB payload.
You can mitigate potential security issues with SeaBIOS
by disabling option ROM execution, which can be done at
runtime by inserting integers into CBFS. The SeaBIOS
documentation says how to do this.
Libreboot's GRUB hardening guide still says how to add
a bootorder file in CBFS, making SeaBIOS only load GRUB
from CBFS, and nothing else. This, combined with the
disablement of option ROM execution (if using Intel
graphics), pretty much provides the same security benefits
as GRUB-as-primary, for example when setting a GRUB password
and GPG checks, with encrypted /boot as in the hardening guide.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-22 23:57:39 +02:00
|
|
|
v="$v board grub_scan_disk uboot_config grubtree grubelf tmpmv"
|
2024-06-22 05:06:07 +02:00
|
|
|
eval `setvars "n" $pv`
|
|
|
|
eval `setvars "" $v boards targets serdir ser`
|
2023-10-26 21:11:40 +02:00
|
|
|
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
while [ $# -gt 0 ]; do
|
2024-06-20 01:12:00 +02:00
|
|
|
if [ "$1" = "serprog" ]; then
|
2024-06-22 04:55:04 +02:00
|
|
|
[ $# -lt 2 ] && $err "serprog type not set"
|
|
|
|
[ "$2" != "rp2040" ] && [ "$2" != "stm32" ] && \
|
|
|
|
$err "invalid serprog type"
|
2024-06-20 01:12:00 +02:00
|
|
|
eval "x_ ./update trees -f \"\${${2}src##*/}\""
|
|
|
|
ser="$2" && shift 2 && continue
|
|
|
|
fi
|
2024-06-28 15:56:30 +02:00
|
|
|
[ "$1$ser" = "list" ] && x_ ls -1 config/coreboot && return 0
|
2024-06-28 15:57:07 +02:00
|
|
|
[ "$1" = "all" ] && shift 1 && continue
|
2024-06-14 15:19:44 +02:00
|
|
|
boards="$1 $boards"; shift 1
|
2023-10-26 21:11:40 +02:00
|
|
|
done
|
|
|
|
|
2024-06-20 01:12:00 +02:00
|
|
|
[ -n "$boards" ] || [ -n "$ser" ] || boards="$(ls -1 \
|
|
|
|
config/coreboot)" || $err "can't list coreboot boards"
|
|
|
|
|
|
|
|
[ -n "$ser" ] && \
|
2024-06-27 04:18:23 +02:00
|
|
|
eval "serlist \"\$${ser}dir\" > \"\$TMPDIR/ser\" || $err \"!ser\""
|
|
|
|
[ -n "$ser" ] && [ -z "$boards" ] && boards="$(cat "$TMPDIR/ser")"
|
2024-06-20 01:12:00 +02:00
|
|
|
|
2024-06-14 10:11:07 +02:00
|
|
|
for x in $boards; do
|
2024-06-20 01:12:00 +02:00
|
|
|
[ -n "$ser" ] && mkserprogfw "$ser" "$x"
|
|
|
|
[ -z "$ser" ] && [ -d "config/coreboot/$x/config" ] && \
|
2024-06-24 18:35:44 +02:00
|
|
|
configure_target "$x" && build_roms && \
|
2024-06-27 02:56:24 +02:00
|
|
|
[ -d "bin/$board" ] && targets="$targets, $x" && \
|
|
|
|
[ "$XBMK_RELEASE" = "y" ] && mkrom_tarball "bin/$x"
|
2024-06-14 10:11:07 +02:00
|
|
|
done
|
2023-10-26 21:11:40 +02:00
|
|
|
|
2024-06-25 01:12:18 +02:00
|
|
|
[ -n "$ser" ] && [ "$XBMK_RELEASE" = "y" ] && \
|
2024-06-20 01:12:00 +02:00
|
|
|
mkrom_tarball "bin/serprog_$ser" && return 0
|
|
|
|
|
|
|
|
[ -z "$ser" ] && [ -z "$targets" ] && $err "No images were compiled"
|
2024-06-24 18:41:43 +02:00
|
|
|
[ -z "$ser" ] && printf "ROMs built in bin/ for: %s\n" "${targets#, }"
|
2024-06-24 19:39:53 +02:00
|
|
|
[ -n "$ser" ] && printf "ROMs (serprog) built in bin/%s/\n" "$ser"
|
2024-06-24 18:42:58 +02:00
|
|
|
printf "Please flash from bin/, NOT elf/ - ALSO:\n%s\n" "$kbnotice"
|
2023-10-26 21:11:40 +02:00
|
|
|
}
|
|
|
|
|
2024-06-18 02:20:40 +02:00
|
|
|
mkserprogfw()
|
2024-05-09 14:52:49 +02:00
|
|
|
{
|
2024-06-20 01:12:00 +02:00
|
|
|
x_ mkdir -p "bin/serprog_$1"
|
2024-06-23 01:15:19 +02:00
|
|
|
[ "$1" = "rp2040" ] && x_ cmake -DPICO_BOARD="$2" \
|
|
|
|
-DPICO_SDK_PATH="$picosdk" -B "$rp2040src/build" "$rp2040src" && \
|
|
|
|
x_ cmake --build "$rp2040src/build"
|
|
|
|
[ "$1" = "stm32" ] && x_ make -C "$stm32src" libopencm3-just-make \
|
|
|
|
BOARD=$2 && x_ make -C "$stm32src" BOARD=$2
|
2024-06-18 02:50:40 +02:00
|
|
|
eval "x_ mv \"\$${1}x\" \"bin/serprog_$1/serprog_$2.\${${1}x##*.}\""
|
2024-05-09 14:52:49 +02:00
|
|
|
}
|
|
|
|
|
2024-06-16 01:53:21 +02:00
|
|
|
serlist()
|
2024-05-09 14:52:49 +02:00
|
|
|
{
|
2024-05-26 02:54:36 +02:00
|
|
|
basename -a -s .h "$1/"*.h || $err "$1: can't list boards"
|
2024-05-09 14:52:49 +02:00
|
|
|
}
|
|
|
|
|
2024-06-14 17:34:05 +02:00
|
|
|
configure_target()
|
2024-05-05 06:09:23 +02:00
|
|
|
{
|
2024-06-22 05:06:07 +02:00
|
|
|
eval `setvars "n" $pv`
|
|
|
|
eval `setvars "" $v`
|
2024-05-05 06:09:23 +02:00
|
|
|
|
2024-06-23 01:15:19 +02:00
|
|
|
board="$1"; targetdir="$cfgsdir/$board"; romdir="bin/$board"
|
2023-10-26 21:11:40 +02:00
|
|
|
|
|
|
|
# Override the above defaults using target.cfg
|
2024-06-22 03:35:25 +02:00
|
|
|
eval `setcfg "$targetdir/target.cfg"`
|
2023-10-26 21:11:40 +02:00
|
|
|
|
roms: only support SeaBIOS/SeaGRUB on x86
Never, ever build images where GRUB is the primary payload.
These options have been removed from target.cfg handling:
* seabios_withgrub
* grub_withseabios
The "payload_grub" variable now does the same thing as
the old "seabios_withgrub" variable, if set.
The "grubonly" configuration is retained, and enabled by
default when SeaGRUB is enabled (non-grubonly also available).
Due to lbmk issue #216, it is no longer Libreboot policy to
make GRUB the primary payload on any board. GRUB's sheer size
and complexity, plus the large number of memory corruption issues
similar to it that *have* been fixed over the years, tells me
that GRUB is a liability when it is the primary payload.
SeaBIOS is a much safer payload to run as primary, on x86, due
to its smaller size and much more conservative development; it
is simply far less likely to break.
If GRUB breaks in the future, the user's machine is not
bricked. This is because SeaBIOS is the default payload.
Since I no longer wish to ever provide GRUB as a primary
payload, supporting it in lbmk adds needless bloat that
will later probably break anyway due to lack of testing,
so let's just assume SeaGRUB in all cases where the user
wants to use a GRUB payload.
You can mitigate potential security issues with SeaBIOS
by disabling option ROM execution, which can be done at
runtime by inserting integers into CBFS. The SeaBIOS
documentation says how to do this.
Libreboot's GRUB hardening guide still says how to add
a bootorder file in CBFS, making SeaBIOS only load GRUB
from CBFS, and nothing else. This, combined with the
disablement of option ROM execution (if using Intel
graphics), pretty much provides the same security benefits
as GRUB-as-primary, for example when setting a GRUB password
and GPG checks, with encrypted /boot as in the hardening guide.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-22 23:57:39 +02:00
|
|
|
[ -z "$tree" ] && $err "$board: tree not defined"
|
2024-06-25 01:12:18 +02:00
|
|
|
[ "$XBMK_RELEASE" = "y" ] && [ "$release" = "n" ] && return 1
|
roms: only support SeaBIOS/SeaGRUB on x86
Never, ever build images where GRUB is the primary payload.
These options have been removed from target.cfg handling:
* seabios_withgrub
* grub_withseabios
The "payload_grub" variable now does the same thing as
the old "seabios_withgrub" variable, if set.
The "grubonly" configuration is retained, and enabled by
default when SeaGRUB is enabled (non-grubonly also available).
Due to lbmk issue #216, it is no longer Libreboot policy to
make GRUB the primary payload on any board. GRUB's sheer size
and complexity, plus the large number of memory corruption issues
similar to it that *have* been fixed over the years, tells me
that GRUB is a liability when it is the primary payload.
SeaBIOS is a much safer payload to run as primary, on x86, due
to its smaller size and much more conservative development; it
is simply far less likely to break.
If GRUB breaks in the future, the user's machine is not
bricked. This is because SeaBIOS is the default payload.
Since I no longer wish to ever provide GRUB as a primary
payload, supporting it in lbmk adds needless bloat that
will later probably break anyway due to lack of testing,
so let's just assume SeaGRUB in all cases where the user
wants to use a GRUB payload.
You can mitigate potential security issues with SeaBIOS
by disabling option ROM execution, which can be done at
runtime by inserting integers into CBFS. The SeaBIOS
documentation says how to do this.
Libreboot's GRUB hardening guide still says how to add
a bootorder file in CBFS, making SeaBIOS only load GRUB
from CBFS, and nothing else. This, combined with the
disablement of option ROM execution (if using Intel
graphics), pretty much provides the same security benefits
as GRUB-as-primary, for example when setting a GRUB password
and GPG checks, with encrypted /boot as in the hardening guide.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-22 23:57:39 +02:00
|
|
|
[ "$board" = "$tree" ] && return 1
|
|
|
|
|
2024-06-25 10:54:22 +02:00
|
|
|
x_ ./update trees -b coreboot $board
|
|
|
|
|
2024-06-23 01:15:19 +02:00
|
|
|
cbfstool="elf/cbfstool/$tree/cbfstool"
|
2024-06-28 15:51:32 +02:00
|
|
|
x_ ./update trees -b coreboot utils $tree
|
2024-06-23 01:15:19 +02:00
|
|
|
|
roms: only support SeaBIOS/SeaGRUB on x86
Never, ever build images where GRUB is the primary payload.
These options have been removed from target.cfg handling:
* seabios_withgrub
* grub_withseabios
The "payload_grub" variable now does the same thing as
the old "seabios_withgrub" variable, if set.
The "grubonly" configuration is retained, and enabled by
default when SeaGRUB is enabled (non-grubonly also available).
Due to lbmk issue #216, it is no longer Libreboot policy to
make GRUB the primary payload on any board. GRUB's sheer size
and complexity, plus the large number of memory corruption issues
similar to it that *have* been fixed over the years, tells me
that GRUB is a liability when it is the primary payload.
SeaBIOS is a much safer payload to run as primary, on x86, due
to its smaller size and much more conservative development; it
is simply far less likely to break.
If GRUB breaks in the future, the user's machine is not
bricked. This is because SeaBIOS is the default payload.
Since I no longer wish to ever provide GRUB as a primary
payload, supporting it in lbmk adds needless bloat that
will later probably break anyway due to lack of testing,
so let's just assume SeaGRUB in all cases where the user
wants to use a GRUB payload.
You can mitigate potential security issues with SeaBIOS
by disabling option ROM execution, which can be done at
runtime by inserting integers into CBFS. The SeaBIOS
documentation says how to do this.
Libreboot's GRUB hardening guide still says how to add
a bootorder file in CBFS, making SeaBIOS only load GRUB
from CBFS, and nothing else. This, combined with the
disablement of option ROM execution (if using Intel
graphics), pretty much provides the same security benefits
as GRUB-as-primary, for example when setting a GRUB password
and GPG checks, with encrypted /boot as in the hardening guide.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-22 23:57:39 +02:00
|
|
|
[ -n "$uboot_config" ] || uboot_config="default"
|
|
|
|
[ "$payload_uboot" = "y" ] || payload_seabios="y"
|
|
|
|
[ "$payload_grub" = "y" ] && payload_seabios="y"
|
|
|
|
[ "$payload_seabios" = "y" ] && [ -n "$payload_uboot" = "y" ] && \
|
|
|
|
$err "$board: U-Boot and SeaBIOS/GRUB are both enabled."
|
|
|
|
|
grub.cfg: use grub_scan_disk to set boot order
Previously, grub_scan_disk could set ata, ahci or "both",
which would make both be tried (ahci first). This worked
when we only dealt with ata and ahci devices, but now we
support nvme devices so the logic is inherently flawed.
Instead, use grub_scan_disk to store the boot order, e.g.:
grub_scan_disk="ahci nvme ata"
grub_scan_disk="nvme ata"
In the first example, it would make GRUB scan ahci first,
then nvme and then ata.
In the secontd example, it would make GRUB scan nvme first,
and then ata.
If "both" is set, or anything other than ahci/ata/nvme,
grub_scan_disk is now changed to "nvme ahci ata".
Actual grub_scan_disk entries in target.cfg files will now
be modified, to match each machine.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-05-27 21:16:49 +02:00
|
|
|
[ -z "$grub_scan_disk" ] && grub_scan_disk="nvme ahci ata"
|
2024-06-09 19:48:58 +02:00
|
|
|
|
make GRUB multi-tree and re-add xhci patches
The xHCI patches were removed because they caused issues
on Sandybridge-based Dell Latitude laptops. See:
https://codeberg.org/libreboot/lbmk/issues/216
The issue was not reported elsewhere, but we still don't
need xHCI support in Canoeboot's GRUB because none of the
available coreboot targets have xHCI support. However, we
may want it in the future and it helps to keep Canoeboot
in sync with Libreboot (this patch is adapted from lbmk).
Each given coreboot target can say which GRUB tree to use
by setting this in target.cfg:
grubtree="xhci"
In the above example, the "xhci" tree would be used. Some
generic GRUB config has been moved to config/data/grub/
and config/grub/ now looks like config/coreboot/ - also,
the grub.cfg file (named "payload" in each tree) is copied
to the GRUB source tree as ".config", then added to GRUB's
memdisk in the same way, as grub.cfg.
Several other design changes had to be made because of this:
* grub.cfg in memdisk no longer automatically jumps to one
in CBFS, but now shows a menuentry for it if available
* Certain commands in script/trees are disabled for GRUB,
such as *config make commands.
* gnulib is now defined in config/submodule/grub/, instead
of config/git/grub - and this mitigates an existing bug
where downloading gnulib first would make grub no longer
possible to download in lbmk.
There is another reason for merging this design change from
lbmk, and that reasoning also applies to lbmk. Specifically:
This change will enable per-board GRUB optimisation in the
future. For example, we hardcode what partitions and LVMs
GRUB scans because * is slow on ICH7-based machines, due
to GRUB's design. On other machines, * is reasonably fast,
for automatically enumerating the list of devices for boot.
Use of * (and other wildcards) could enable our GRUB payload
to automatically boot more distros, with minimal fuss. This
can be done at a later date, in subsequent revisions.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-02 00:01:30 +02:00
|
|
|
[ -n "$grubtree" ] || grubtree="default"
|
|
|
|
grubelf="elf/grub/$grubtree/payload/grub.elf"
|
|
|
|
|
roms: only support SeaBIOS/SeaGRUB on x86
Never, ever build images where GRUB is the primary payload.
These options have been removed from target.cfg handling:
* seabios_withgrub
* grub_withseabios
The "payload_grub" variable now does the same thing as
the old "seabios_withgrub" variable, if set.
The "grubonly" configuration is retained, and enabled by
default when SeaGRUB is enabled (non-grubonly also available).
Due to lbmk issue #216, it is no longer Libreboot policy to
make GRUB the primary payload on any board. GRUB's sheer size
and complexity, plus the large number of memory corruption issues
similar to it that *have* been fixed over the years, tells me
that GRUB is a liability when it is the primary payload.
SeaBIOS is a much safer payload to run as primary, on x86, due
to its smaller size and much more conservative development; it
is simply far less likely to break.
If GRUB breaks in the future, the user's machine is not
bricked. This is because SeaBIOS is the default payload.
Since I no longer wish to ever provide GRUB as a primary
payload, supporting it in lbmk adds needless bloat that
will later probably break anyway due to lack of testing,
so let's just assume SeaGRUB in all cases where the user
wants to use a GRUB payload.
You can mitigate potential security issues with SeaBIOS
by disabling option ROM execution, which can be done at
runtime by inserting integers into CBFS. The SeaBIOS
documentation says how to do this.
Libreboot's GRUB hardening guide still says how to add
a bootorder file in CBFS, making SeaBIOS only load GRUB
from CBFS, and nothing else. This, combined with the
disablement of option ROM execution (if using Intel
graphics), pretty much provides the same security benefits
as GRUB-as-primary, for example when setting a GRUB password
and GPG checks, with encrypted /boot as in the hardening guide.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-22 23:57:39 +02:00
|
|
|
[ "$payload_memtest" = "y" ] || payload_memtest="n"
|
2024-06-23 01:15:19 +02:00
|
|
|
[ "$(uname -m)" = "x86_64" ] || payload_memtest="n"; return 0
|
2023-10-26 21:11:40 +02:00
|
|
|
}
|
|
|
|
|
2024-06-24 18:35:44 +02:00
|
|
|
build_roms()
|
2023-10-26 21:11:40 +02:00
|
|
|
{
|
2024-05-26 02:54:36 +02:00
|
|
|
x_ rm -Rf "$romdir"
|
rebase cbmk 9429287 per lbmk c4d90087..f5b04fa5
cbmk 9429287 is the present canoeboot revision, on this day,
two commits after canoeboot 20231107
the cbmk revision was based on lbmk c4d90087, but lbmk
has developed a lot since, right up to f5b04fa5. lbmk
c4d90087 was four commits after libreboot 20231106
this patch brings cbmk up to date, versus lbmk f5b04fa5,
which is 135 commits after libreboot 20231106 (not 4)
therefore, the next canoeboot release shall import lbmk
changes made *after* lbmk revision f5b04fa5. good day!
In English (the above is for my reference, next time
I make a new canoeboot release):
This imports all of the numerous improvements from
Libreboot, sans the non-FSDG-compliant changes. You
can find a full list of such changes in the audit4 page:
https://libreboot.org/news/audit4.html
A full canoeboot-ised changelog will be available in
the next canoeboot release, with these and subsequent
changes. Most notable here is the update to the new
GRUB 2.12 release (instead of 2.12-rc1), and the
improvements Riku made to pico-serprog. And the build
system improvements from lbmk, such as improved, more
generic cmake and autoconf handling.
Canoeboot-specific changes: I also tweaked the deblob
logic, to make it less error-prone. The new design
changes imported into cbmk (based on latest lbmk) somewhat
broke the deblob logic; it was constantly reminding the
user that blobs.list was missing for coreboot,
at config/coreboot/blobs.list - coreboot is a multi-tree
project in both cbmk and lbmk, and the deblob logic was
tuned for single/multi, but was treating coreboot as both.
for simplicity, i removed the check for whether blobs.list
is present. this means that the operator must ensure that
these files are present, in any given revision, where they
are required on a given set of projects (and the files are
all present, in this update to cbmk)
Also of note: the grub.cfg improvements are included in this
cbmk update. The improved grub.cfg can find grub/syslinux
configs by default, not just grub anymore, also finds extlinux,
and will also find them on EFI System Partition - in addition,
UEFI-based install media is also more robust; although cbmk
doesn't provide UEFI configurations on x86, our GRUB palyoad
does still need to work with distro install media, and many
of them now use UEFI-based GRUB configurations in their
installation media, which just happen to work with our GRUB
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-01-02 12:37:25 +01:00
|
|
|
|
2024-06-24 19:24:50 +02:00
|
|
|
for cbcfg in "$targetdir/config/"*; do
|
|
|
|
[ -f "$cbcfg" ] || continue; cn="${cbcfg##*/}"; dt="${cn#*_}" \
|
|
|
|
&& [ "$dt" = "$cn" ] && dt="txtmode"; displaymode="$dt"
|
|
|
|
initmode="${cn%%_*}"; chkvars initmode displaymode
|
|
|
|
e "$cbcfg" f not || add_payloads
|
|
|
|
done; x_ rm -f "$tmprom"
|
2023-10-26 21:11:40 +02:00
|
|
|
}
|
|
|
|
|
2024-06-24 18:35:44 +02:00
|
|
|
add_payloads()
|
2023-10-26 21:11:40 +02:00
|
|
|
{
|
2024-06-23 01:15:19 +02:00
|
|
|
cbuild="$cbelfdir/$board/${initmode}_$displaymode"
|
|
|
|
[ "$initmode" = "normal" ] && cbuild="${cbuild%"_$displaymode"}"
|
|
|
|
x_ cp "$cbuild/coreboot.rom" "$tmprom"
|
2023-10-26 21:11:40 +02:00
|
|
|
|
2024-06-24 18:35:44 +02:00
|
|
|
[ "$payload_seabios" = "y" ] && add_seabios_payload
|
2024-06-23 01:15:19 +02:00
|
|
|
[ "$payload_uboot" = "y" ] || return 0
|
2024-05-26 02:54:36 +02:00
|
|
|
|
2024-06-24 18:35:44 +02:00
|
|
|
# add u-boot payload
|
2024-06-28 15:52:08 +02:00
|
|
|
x_ ./update trees -b u-boot $board
|
2024-06-24 19:30:48 +02:00
|
|
|
ubdir="elf/u-boot/$board/$uboot_config"; ubootelf="$ubdir/u-boot.elf" \
|
|
|
|
&& [ ! -f "$ubootelf" ] && ubootelf="$ubdir/u-boot"
|
2024-06-23 01:15:19 +02:00
|
|
|
[ -f "$ubootelf" ] || $err "$board: Can't find u-boot"
|
2024-06-19 15:11:54 +02:00
|
|
|
|
2024-06-23 01:15:19 +02:00
|
|
|
cbfs "$tmprom" "$ubootelf" "fallback/payload"
|
|
|
|
cprom "$romdir/uboot_payload_${board}_${initmode}_$displaymode.rom"
|
2023-10-26 21:11:40 +02:00
|
|
|
}
|
|
|
|
|
2024-06-24 18:35:44 +02:00
|
|
|
add_seabios_payload()
|
2024-06-23 01:15:19 +02:00
|
|
|
{
|
2024-05-26 02:54:36 +02:00
|
|
|
_seabioself="elf/seabios/default/$initmode/bios.bin.elf"
|
2024-06-23 01:15:19 +02:00
|
|
|
x_ ./update trees -b seabios
|
|
|
|
|
|
|
|
pstr="seabios" && [ "$payload_grub" = "y" ] && pstr="seabios_withgrub"
|
|
|
|
newrom="$romdir/${pstr}_${board}_$initmode.rom"
|
|
|
|
[ "$initmode" = "normal" ] || newrom="${newrom%.rom}_$displaymode.rom"
|
2023-10-26 21:11:40 +02:00
|
|
|
|
roms: only support SeaBIOS/SeaGRUB on x86
Never, ever build images where GRUB is the primary payload.
These options have been removed from target.cfg handling:
* seabios_withgrub
* grub_withseabios
The "payload_grub" variable now does the same thing as
the old "seabios_withgrub" variable, if set.
The "grubonly" configuration is retained, and enabled by
default when SeaGRUB is enabled (non-grubonly also available).
Due to lbmk issue #216, it is no longer Libreboot policy to
make GRUB the primary payload on any board. GRUB's sheer size
and complexity, plus the large number of memory corruption issues
similar to it that *have* been fixed over the years, tells me
that GRUB is a liability when it is the primary payload.
SeaBIOS is a much safer payload to run as primary, on x86, due
to its smaller size and much more conservative development; it
is simply far less likely to break.
If GRUB breaks in the future, the user's machine is not
bricked. This is because SeaBIOS is the default payload.
Since I no longer wish to ever provide GRUB as a primary
payload, supporting it in lbmk adds needless bloat that
will later probably break anyway due to lack of testing,
so let's just assume SeaGRUB in all cases where the user
wants to use a GRUB payload.
You can mitigate potential security issues with SeaBIOS
by disabling option ROM execution, which can be done at
runtime by inserting integers into CBFS. The SeaBIOS
documentation says how to do this.
Libreboot's GRUB hardening guide still says how to add
a bootorder file in CBFS, making SeaBIOS only load GRUB
from CBFS, and nothing else. This, combined with the
disablement of option ROM execution (if using Intel
graphics), pretty much provides the same security benefits
as GRUB-as-primary, for example when setting a GRUB password
and GPG checks, with encrypted /boot as in the hardening guide.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-06-22 23:57:39 +02:00
|
|
|
cbfs "$tmprom" "$_seabioself" "fallback/payload"
|
rebase cbmk 9429287 per lbmk c4d90087..f5b04fa5
cbmk 9429287 is the present canoeboot revision, on this day,
two commits after canoeboot 20231107
the cbmk revision was based on lbmk c4d90087, but lbmk
has developed a lot since, right up to f5b04fa5. lbmk
c4d90087 was four commits after libreboot 20231106
this patch brings cbmk up to date, versus lbmk f5b04fa5,
which is 135 commits after libreboot 20231106 (not 4)
therefore, the next canoeboot release shall import lbmk
changes made *after* lbmk revision f5b04fa5. good day!
In English (the above is for my reference, next time
I make a new canoeboot release):
This imports all of the numerous improvements from
Libreboot, sans the non-FSDG-compliant changes. You
can find a full list of such changes in the audit4 page:
https://libreboot.org/news/audit4.html
A full canoeboot-ised changelog will be available in
the next canoeboot release, with these and subsequent
changes. Most notable here is the update to the new
GRUB 2.12 release (instead of 2.12-rc1), and the
improvements Riku made to pico-serprog. And the build
system improvements from lbmk, such as improved, more
generic cmake and autoconf handling.
Canoeboot-specific changes: I also tweaked the deblob
logic, to make it less error-prone. The new design
changes imported into cbmk (based on latest lbmk) somewhat
broke the deblob logic; it was constantly reminding the
user that blobs.list was missing for coreboot,
at config/coreboot/blobs.list - coreboot is a multi-tree
project in both cbmk and lbmk, and the deblob logic was
tuned for single/multi, but was treating coreboot as both.
for simplicity, i removed the check for whether blobs.list
is present. this means that the operator must ensure that
these files are present, in any given revision, where they
are required on a given set of projects (and the files are
all present, in this update to cbmk)
Also of note: the grub.cfg improvements are included in this
cbmk update. The improved grub.cfg can find grub/syslinux
configs by default, not just grub anymore, also finds extlinux,
and will also find them on EFI System Partition - in addition,
UEFI-based install media is also more robust; although cbmk
doesn't provide UEFI configurations on x86, our GRUB palyoad
does still need to work with distro install media, and many
of them now use UEFI-based GRUB configurations in their
installation media, which just happen to work with our GRUB
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-01-02 12:37:25 +01:00
|
|
|
x_ "$cbfstool" "$tmprom" add-int -i 3000 -n etc/ps2-keyboard-spinup
|
|
|
|
|
|
|
|
z="2"; [ "$initmode" = "vgarom" ] && z="0"
|
|
|
|
x_ "$cbfstool" "$tmprom" add-int -i $z -n etc/pci-optionrom-exec
|
|
|
|
x_ "$cbfstool" "$tmprom" add-int -i 0 -n etc/optionroms-checksum
|
2024-06-23 01:15:19 +02:00
|
|
|
[ "$initmode" = "libgfxinit" ] && cbfs "$tmprom" "$seavgabiosrom" \
|
2024-06-15 21:22:19 +02:00
|
|
|
vgaroms/seavgabios.bin raw
|
2023-10-26 21:11:40 +02:00
|
|
|
|
2024-06-23 01:15:19 +02:00
|
|
|
if [ "$payload_grub" = "y" ]; then
|
|
|
|
x_ ./update trees -b grub $grubtree
|
|
|
|
cbfs "$tmprom" "$grubelf" "img/grub2"
|
|
|
|
printf "set grub_scan_disk=\"%s\"\n" "$grub_scan_disk" \
|
2024-06-27 04:18:23 +02:00
|
|
|
> "$TMPDIR/tmpcfg" || $err "$board: !insert scandisk"
|
|
|
|
cbfs "$tmprom" "$TMPDIR/tmpcfg" scan.cfg raw
|
2024-06-23 01:15:19 +02:00
|
|
|
fi
|
2023-10-26 21:11:40 +02:00
|
|
|
|
2024-06-23 01:15:19 +02:00
|
|
|
[ "$payload_memtest" = "y" ] && x_ ./update trees -b memtest86plus && \
|
|
|
|
cbfs "$tmprom" "elf/memtest86plus/memtest.bin" img/memtest
|
|
|
|
|
|
|
|
cprom "$newrom" && [ "$payload_grub" = "y" ] && \
|
|
|
|
cbfs "$tmprom" "$grubdata/bootorder" bootorder raw && \
|
|
|
|
cprom "${newrom%.rom}_grubfirst.rom"; return 0
|
2023-10-26 21:11:40 +02:00
|
|
|
}
|
|
|
|
|
2024-05-26 02:54:36 +02:00
|
|
|
cprom()
|
2023-10-26 21:11:40 +02:00
|
|
|
{
|
2024-06-23 01:15:19 +02:00
|
|
|
x_ mkdir -p "${1%/*}"; x_ cp "$tmprom" "$1"
|
2023-10-26 21:11:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
main $@
|