2023-06-13 11:09:01 +00:00
|
|
|
#!/usr/bin/env sh
|
2021-05-18 12:56:12 +00:00
|
|
|
|
|
|
|
# helper script: create ROM images for a given mainboard
|
|
|
|
#
|
2023-05-10 01:48:34 +00:00
|
|
|
# Copyright (C) 2020,2021,2023 Leah Rowe <info@minifree.org>
|
2023-06-13 11:09:01 +00:00
|
|
|
# Copyright (C) 2021,2022 Ferass El Hafidi
|
|
|
|
# <vitali64pmemail@protonmail.com>
|
2022-11-14 00:51:12 +00:00
|
|
|
# Copyright (C) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
|
2022-08-26 12:06:45 +00:00
|
|
|
# Copyright (C) 2022 Alper Nebi Yasak <alpernebiyasak@gmail.com>
|
2023-08-21 17:35:06 +00:00
|
|
|
# Copyright (C) 2023 Riku Viitanen <riku.viitanen@protonmail.com>
|
2021-05-18 12:56:12 +00:00
|
|
|
#
|
|
|
|
# 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 <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
|
|
|
set -u -e
|
|
|
|
|
2023-08-23 17:56:31 +00:00
|
|
|
. "include/err.sh"
|
consolidate u-boot/seabios/coreboot build scripts
See file:
resources/scripts/build/defconfig/for
It is based on:
resources/scripts/build/payload/u-boot
The u-boot payload script has been deleted, as has the
seabios payload script; the build/boot/roms logic has
been heavily simplified too, by removing the logic for
building of elf files based on defconfig.
SeaBIOS, U-Boot and coreboot all use defconfig-type
infrastructure for their build systems, and they are
fundamentally the *same* in how to compile each codebase,
at least in an lbmk context, regardless of actual (and
very huge) differences in these codebases.
Several hundred sources-lines of code have been eliminated
by this change, drastically simplifying everything; U-Boot
payload compiling also now errors out when a single build
fails, instead of continuing. Also: build/boot/roms no longer
re-compiles a coreboot target that was already compiled,
which is the same behaviour observed for payloads.
(this means you must now manually delete a target, when you
wish to re-build it; the build/boot/roms logic now more or
less just runs cbfstool; blobutil is handled from
build/defconfig/for)
ALSO: Since crossgcc is now handled by build/defconfig/for, not
build/boot/roms, standalone compiling of u-boot is now possible.
This has been tested. You compile it like so:
./build defconfig for u-boot
or specific trees, e.g.
./build defconfig for u-boot default
One other consequence of this patch is that re-building the same
ROM image is now much faster, because the same builds are re-used
unless deleted. This could be useful when testing grub.cfg changes,
for example, if that's all you change. With things like ccache used
(not yet used robustly in lbmk), this could speed things up more,
depending on the codebase.
This patch demonstrates the raw power of lbmk; it is a very
simple and highly efficient build system, and now much more so!
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-17 22:27:30 +00:00
|
|
|
|
2023-09-03 14:00:18 +00:00
|
|
|
read projectname < projectname
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-09-04 01:36:41 +00:00
|
|
|
cfgsdir="config/coreboot"
|
2023-08-28 08:42:20 +00:00
|
|
|
|
2023-06-25 10:45:40 +00:00
|
|
|
blobs_required=""
|
|
|
|
|
consolidate u-boot/seabios/coreboot build scripts
See file:
resources/scripts/build/defconfig/for
It is based on:
resources/scripts/build/payload/u-boot
The u-boot payload script has been deleted, as has the
seabios payload script; the build/boot/roms logic has
been heavily simplified too, by removing the logic for
building of elf files based on defconfig.
SeaBIOS, U-Boot and coreboot all use defconfig-type
infrastructure for their build systems, and they are
fundamentally the *same* in how to compile each codebase,
at least in an lbmk context, regardless of actual (and
very huge) differences in these codebases.
Several hundred sources-lines of code have been eliminated
by this change, drastically simplifying everything; U-Boot
payload compiling also now errors out when a single build
fails, instead of continuing. Also: build/boot/roms no longer
re-compiles a coreboot target that was already compiled,
which is the same behaviour observed for payloads.
(this means you must now manually delete a target, when you
wish to re-build it; the build/boot/roms logic now more or
less just runs cbfstool; blobutil is handled from
build/defconfig/for)
ALSO: Since crossgcc is now handled by build/defconfig/for, not
build/boot/roms, standalone compiling of u-boot is now possible.
This has been tested. You compile it like so:
./build defconfig for u-boot
or specific trees, e.g.
./build defconfig for u-boot default
One other consequence of this patch is that re-building the same
ROM image is now much faster, because the same builds are re-used
unless deleted. This could be useful when testing grub.cfg changes,
for example, if that's all you change. With things like ccache used
(not yet used robustly in lbmk), this could speed things up more,
depending on the codebase.
This patch demonstrates the raw power of lbmk; it is a very
simple and highly efficient build system, and now much more so!
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-17 22:27:30 +00:00
|
|
|
board=""
|
|
|
|
ubdir=""
|
2023-09-04 01:36:41 +00:00
|
|
|
kmapdir="config/grub/keymap"
|
2022-11-14 00:51:12 +00:00
|
|
|
displaymodes=""
|
|
|
|
payloads=""
|
|
|
|
keyboard_layouts=""
|
2021-11-27 19:06:32 +00:00
|
|
|
|
2023-09-08 22:48:06 +00:00
|
|
|
grub_timeout=""
|
2023-05-10 01:48:34 +00:00
|
|
|
grub_scan_disk="undefined"
|
2023-08-16 20:34:21 +00:00
|
|
|
tree="undefined"
|
2021-05-18 12:56:12 +00:00
|
|
|
arch="undefined"
|
2023-05-10 01:48:34 +00:00
|
|
|
|
2021-05-18 12:56:12 +00:00
|
|
|
# Disable all payloads by default.
|
2023-08-16 20:34:21 +00:00
|
|
|
# target.cfg files have to specifically enable [a] payload(s)
|
2021-05-18 12:56:12 +00:00
|
|
|
payload_grub="n"
|
2023-05-12 20:53:06 +00:00
|
|
|
payload_grub_withseabios="n" # seabios chainloaded from grub
|
2021-05-18 12:56:12 +00:00
|
|
|
payload_seabios="n"
|
2023-05-12 20:53:06 +00:00
|
|
|
payload_seabios_withgrub="n" # i386-coreboot grub from SeaBIOS boot menu
|
2021-11-01 02:51:10 +00:00
|
|
|
payload_memtest="n"
|
2022-08-26 14:14:57 +00:00
|
|
|
payload_uboot="n"
|
|
|
|
uboot_config="undefined"
|
2023-08-28 08:42:20 +00:00
|
|
|
|
|
|
|
romdir=""
|
|
|
|
cbdir=""
|
|
|
|
cbfstool=""
|
|
|
|
corebootrom=""
|
consolidate u-boot/seabios/coreboot build scripts
See file:
resources/scripts/build/defconfig/for
It is based on:
resources/scripts/build/payload/u-boot
The u-boot payload script has been deleted, as has the
seabios payload script; the build/boot/roms logic has
been heavily simplified too, by removing the logic for
building of elf files based on defconfig.
SeaBIOS, U-Boot and coreboot all use defconfig-type
infrastructure for their build systems, and they are
fundamentally the *same* in how to compile each codebase,
at least in an lbmk context, regardless of actual (and
very huge) differences in these codebases.
Several hundred sources-lines of code have been eliminated
by this change, drastically simplifying everything; U-Boot
payload compiling also now errors out when a single build
fails, instead of continuing. Also: build/boot/roms no longer
re-compiles a coreboot target that was already compiled,
which is the same behaviour observed for payloads.
(this means you must now manually delete a target, when you
wish to re-build it; the build/boot/roms logic now more or
less just runs cbfstool; blobutil is handled from
build/defconfig/for)
ALSO: Since crossgcc is now handled by build/defconfig/for, not
build/boot/roms, standalone compiling of u-boot is now possible.
This has been tested. You compile it like so:
./build defconfig for u-boot
or specific trees, e.g.
./build defconfig for u-boot default
One other consequence of this patch is that re-building the same
ROM image is now much faster, because the same builds are re-used
unless deleted. This could be useful when testing grub.cfg changes,
for example, if that's all you change. With things like ccache used
(not yet used robustly in lbmk), this could speed things up more,
depending on the codebase.
This patch demonstrates the raw power of lbmk; it is a very
simple and highly efficient build system, and now much more so!
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-17 22:27:30 +00:00
|
|
|
seavgabiosrom="elf/seabios/default/libgfxinit/vgabios.bin"
|
2023-09-04 23:50:08 +00:00
|
|
|
grub_background="background1280x800.png"
|
2023-06-25 10:45:40 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
initmode=""
|
|
|
|
displaymode=""
|
|
|
|
cbcfg=""
|
|
|
|
targetdir=""
|
|
|
|
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
grubelf="elf/grub/grub.elf"
|
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
main()
|
|
|
|
{
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case ${1} in
|
|
|
|
-d)
|
|
|
|
displaymodes="${displaymodes}${2}"
|
|
|
|
shift ;;
|
|
|
|
-p)
|
|
|
|
payloads="${payloads}${2}"
|
|
|
|
shift ;;
|
|
|
|
-k)
|
|
|
|
keyboard_layouts="${keyboard_layouts}${2}"
|
|
|
|
shift ;;
|
|
|
|
*)
|
|
|
|
board=${1} ;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
printf "\n\nboard %s, kb %s, displaymode %s, payloads %s\n" \
|
|
|
|
"${board}" "${keyboard_layouts}" "${displaymodes}" "${payloads}"
|
|
|
|
|
|
|
|
configure_target
|
|
|
|
build_dependencies
|
|
|
|
|
|
|
|
build_target
|
|
|
|
}
|
|
|
|
|
|
|
|
configure_target()
|
|
|
|
{
|
|
|
|
targetdir="${cfgsdir}/${board}"
|
|
|
|
|
|
|
|
[ -d "${targetdir}" ] || \
|
|
|
|
err "Target not defined: ${board}"
|
|
|
|
|
|
|
|
[ -f "${targetdir}/target.cfg" ] || \
|
|
|
|
err "Missing target.cfg for target: ${board}"
|
|
|
|
|
|
|
|
# Override the above defaults using target.cfg
|
|
|
|
. "${targetdir}/target.cfg"
|
|
|
|
|
|
|
|
[ "${grub_scan_disk}" = "undefined" ] && \
|
|
|
|
grub_scan_disk="both"
|
|
|
|
[ "${grub_scan_disk}" != "both" ] && \
|
|
|
|
[ "${grub_scan_disk}" != "ata" ] && \
|
|
|
|
[ "${grub_scan_disk}" != "ahci" ] && \
|
|
|
|
grub_scan_disk="both"
|
|
|
|
|
|
|
|
[ "${tree}" = "undefined" ] && \
|
|
|
|
err "Target '${board}' defines no tree. Skipping build."
|
|
|
|
[ "${arch}" = "undefined" ] && \
|
|
|
|
err "Target '${board}' defines no arch. Skipping build."
|
|
|
|
|
|
|
|
[ "${payload_memtest}" != "y" ] && \
|
|
|
|
payload_memtest="n"
|
|
|
|
[ "${payload_grub_withseabios}" = "y" ] && \
|
|
|
|
payload_grub="y"
|
|
|
|
if [ "${payload_grub_withseabios}" = "y" ]; then
|
|
|
|
payload_seabios="y"
|
|
|
|
payload_seabios_withgrub="y"
|
|
|
|
fi
|
|
|
|
[ "${payload_seabios_withgrub}" = "y" ] && \
|
|
|
|
payload_seabios="y"
|
|
|
|
|
|
|
|
# The reverse logic must not be applied. If SeaBIOS-with-GRUB works,
|
|
|
|
# that doesn't mean GRUB-withSeaBIOS will. For example, the board
|
|
|
|
# might have a graphics card whose vga rom coreboot doesn't execute
|
|
|
|
if [ "${payload_grub}" != "y" ] && \
|
|
|
|
[ "${payload_seabios}" != "y" ] && \
|
|
|
|
[ "${payload_uboot}" != "y" ]; then
|
|
|
|
for configfile in "${targetdir}/config/"*; do
|
|
|
|
[ -e "${configfile}" ] || continue
|
|
|
|
err "target '${board}' defines no payload"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
[ "${payload_uboot}" != "n" ] && [ "${payload_uboot}" != "y" ] && \
|
|
|
|
payload_uboot="n"
|
|
|
|
[ "${payload_uboot}" = "y" ] && [ "${uboot_config}" = "undefined" ] && \
|
|
|
|
uboot_config="default"
|
|
|
|
|
|
|
|
[ "${blobs_required}" != "n" ] && [ "${blobs_required}" != "y" ] && \
|
|
|
|
blobs_required="y"
|
|
|
|
|
|
|
|
# Override all payload directives with cmdline args
|
|
|
|
if [ ! -z ${payloads} ]; then
|
2023-09-09 22:31:20 +00:00
|
|
|
printf "setting payloads %s\n" "$payloads"
|
2023-08-28 08:42:20 +00:00
|
|
|
payload_grub="n"
|
|
|
|
payload_grub_withseabios="n" # seabios chainloaded from grub
|
|
|
|
payload_seabios="n"
|
|
|
|
payload_seabios_withgrub="n" # i386-coreboot grub from SeaBIOS
|
|
|
|
payload_uboot="n"
|
|
|
|
payload_memtest="n"
|
|
|
|
|
|
|
|
for payload in ${payloads} ; do
|
|
|
|
eval "payload_${payload}=y"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
build_dependencies()
|
|
|
|
{
|
|
|
|
romdir="bin/${board}"
|
|
|
|
cbdir="coreboot/${board}"
|
|
|
|
[ "${board}" = "${tree}" ] || \
|
|
|
|
cbdir="coreboot/${tree}"
|
|
|
|
cbfstool="cbutils/${tree}/cbfstool"
|
|
|
|
corebootrom="${cbdir}/build/coreboot.rom"
|
|
|
|
|
|
|
|
./build coreboot utils ${tree} || err "cannot build cbutils/${tree}"
|
|
|
|
|
|
|
|
build_dependency_seabios
|
|
|
|
|
|
|
|
memtest_bin="memtest86plus/build${arch#*_}/memtest.bin"
|
|
|
|
[ "${payload_memtest}" != "y" ] || [ -f "${memtest_bin}" ] || \
|
|
|
|
./handle make file -b ${memtest_bin%/*} || \
|
|
|
|
err "cannot build memtest86+"
|
|
|
|
|
|
|
|
rm -f "${romdir}"/* || err "cannot: rm -f \"${romdir}\"/*"
|
2023-06-25 10:45:40 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
build_dependency_grub
|
|
|
|
build_dependency_uboot
|
|
|
|
}
|
|
|
|
|
|
|
|
build_dependency_seabios()
|
|
|
|
{
|
|
|
|
[ "${payload_seabios}" = "y" ] || return 0
|
|
|
|
|
|
|
|
if [ ! -f "${seavgabiosrom}" ] \
|
|
|
|
|| [ ! -f elf/seabios/default/libgfxinit/bios.bin.elf ] \
|
|
|
|
|| [ ! -f elf/seabios/default/vgarom/bios.bin.elf ] \
|
|
|
|
|| [ ! -f elf/seabios/default/normal/bios.bin.elf ]; then
|
2023-08-27 11:24:05 +00:00
|
|
|
./handle make config -b seabios || \
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
err "cannot build seabios"
|
2023-08-28 08:42:20 +00:00
|
|
|
fi
|
|
|
|
}
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
build_dependency_grub()
|
|
|
|
{
|
|
|
|
[ "${payload_grub}" != "y" ] && \
|
|
|
|
[ "${payload_seabios_withgrub}" != "y" ] && return 0
|
2023-05-12 23:13:54 +00:00
|
|
|
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
rebuild_grub="n"
|
|
|
|
[ ! -f "${grubelf}" ] && rebuild_grub="y"
|
|
|
|
for keymapfile in "${kmapdir}"/*.gkb; do
|
|
|
|
[ "${rebuild_grub}" = "y" ] || break
|
2023-08-21 18:41:49 +00:00
|
|
|
[ -f "${keymapfile}" ] || continue
|
2023-05-12 23:13:54 +00:00
|
|
|
|
|
|
|
keymap="${keymapfile##*/}"
|
|
|
|
keymap="${keymap%.gkb}"
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
[ ! -f "elf/grub/keymap_${keymap}.cfg" ] && \
|
|
|
|
rebuild_grub="y" && break
|
2023-05-12 23:13:54 +00:00
|
|
|
done
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
if [ "${rebuild_grub}" = "y" ]; then
|
|
|
|
./build grub payload || \
|
|
|
|
err "build_dependency_grub: cannot build grub payload"
|
|
|
|
fi
|
2023-08-28 08:42:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
build_dependency_uboot()
|
|
|
|
{
|
|
|
|
[ "${payload_uboot}" = "y" ] || return 0
|
2023-05-12 15:55:45 +00:00
|
|
|
|
2023-08-27 11:24:05 +00:00
|
|
|
./handle make config -b u-boot ${board} || \
|
much, much stricter, more verbose error handling
lbmk is much more likely to crash now, in error conditions,
which is a boon for further auditing.
also: in "fetch", remove the downloaded program
if fail() was called.
this would also be done for gnulib, when downloading
grub, but done in such a way that gnulib goes first.
where calls to err write "ERROR" in the string, they
no longer say "ERROR" because the "err" function itself
now does that automatically.
also: listmodes/listoptions (in "lbmk") now reports an
error if no scripts and/or directories are found.
also: where a warning is given, but not an error, i've
gone through in some places and redirected the output
to stderr, not stdout
as part of error checks: running anything as root, except
for the "./build dependencies *" commands, is no longer
permitted and lbmk will throw an error
mrc downloads: debugfs output no longer redirected to /dev/null,
and stderr no longer redirected to stdout. everything is verbose.
certain non-error states are also more verbose. for example,
patch_rom in blobs/inject will now state when injection succeeds
certain actual errors(bugs) were fixed:
for example, build/release/roms now correctly prepares the blobs
hash files for a given target, containing only the files and
checksums in the list. Previously, a printf message was included.
Now, with this new code: blobutil/inject rightly verifies hashes.
doing all of this in one giant patch is cleaner
than 100 patches changing each file. even this is yet part
of a much larger audit going on in the Libreboot project.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-24 19:19:41 +00:00
|
|
|
err "cannot build u-boot target: ${board}"
|
consolidate u-boot/seabios/coreboot build scripts
See file:
resources/scripts/build/defconfig/for
It is based on:
resources/scripts/build/payload/u-boot
The u-boot payload script has been deleted, as has the
seabios payload script; the build/boot/roms logic has
been heavily simplified too, by removing the logic for
building of elf files based on defconfig.
SeaBIOS, U-Boot and coreboot all use defconfig-type
infrastructure for their build systems, and they are
fundamentally the *same* in how to compile each codebase,
at least in an lbmk context, regardless of actual (and
very huge) differences in these codebases.
Several hundred sources-lines of code have been eliminated
by this change, drastically simplifying everything; U-Boot
payload compiling also now errors out when a single build
fails, instead of continuing. Also: build/boot/roms no longer
re-compiles a coreboot target that was already compiled,
which is the same behaviour observed for payloads.
(this means you must now manually delete a target, when you
wish to re-build it; the build/boot/roms logic now more or
less just runs cbfstool; blobutil is handled from
build/defconfig/for)
ALSO: Since crossgcc is now handled by build/defconfig/for, not
build/boot/roms, standalone compiling of u-boot is now possible.
This has been tested. You compile it like so:
./build defconfig for u-boot
or specific trees, e.g.
./build defconfig for u-boot default
One other consequence of this patch is that re-building the same
ROM image is now much faster, because the same builds are re-used
unless deleted. This could be useful when testing grub.cfg changes,
for example, if that's all you change. With things like ccache used
(not yet used robustly in lbmk), this could speed things up more,
depending on the codebase.
This patch demonstrates the raw power of lbmk; it is a very
simple and highly efficient build system, and now much more so!
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-17 22:27:30 +00:00
|
|
|
ubdir="elf/u-boot/${board}/${uboot_config}"
|
|
|
|
ubootelf="${ubdir}/u-boot.elf"
|
|
|
|
[ ! -f "${ubootelf}" ] && [ -f "${ubdir}/u-boot.bin" ] && \
|
|
|
|
ubootelf="${ubdir}/u-boot.bin"
|
2023-08-28 08:42:20 +00:00
|
|
|
if [ ! -f "${ubootelf}" ]; then
|
consolidate u-boot/seabios/coreboot build scripts
See file:
resources/scripts/build/defconfig/for
It is based on:
resources/scripts/build/payload/u-boot
The u-boot payload script has been deleted, as has the
seabios payload script; the build/boot/roms logic has
been heavily simplified too, by removing the logic for
building of elf files based on defconfig.
SeaBIOS, U-Boot and coreboot all use defconfig-type
infrastructure for their build systems, and they are
fundamentally the *same* in how to compile each codebase,
at least in an lbmk context, regardless of actual (and
very huge) differences in these codebases.
Several hundred sources-lines of code have been eliminated
by this change, drastically simplifying everything; U-Boot
payload compiling also now errors out when a single build
fails, instead of continuing. Also: build/boot/roms no longer
re-compiles a coreboot target that was already compiled,
which is the same behaviour observed for payloads.
(this means you must now manually delete a target, when you
wish to re-build it; the build/boot/roms logic now more or
less just runs cbfstool; blobutil is handled from
build/defconfig/for)
ALSO: Since crossgcc is now handled by build/defconfig/for, not
build/boot/roms, standalone compiling of u-boot is now possible.
This has been tested. You compile it like so:
./build defconfig for u-boot
or specific trees, e.g.
./build defconfig for u-boot default
One other consequence of this patch is that re-building the same
ROM image is now much faster, because the same builds are re-used
unless deleted. This could be useful when testing grub.cfg changes,
for example, if that's all you change. With things like ccache used
(not yet used robustly in lbmk), this could speed things up more,
depending on the codebase.
This patch demonstrates the raw power of lbmk; it is a very
simple and highly efficient build system, and now much more so!
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-17 22:27:30 +00:00
|
|
|
err "Could not find u-boot build for board, ${board}"
|
2023-08-28 08:42:20 +00:00
|
|
|
fi
|
|
|
|
}
|
2023-05-12 20:53:06 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
build_target()
|
|
|
|
{
|
|
|
|
for x in "normal" "vgarom" "libgfxinit"; do
|
|
|
|
initmode="${x}"
|
|
|
|
hmode="vesafb"
|
|
|
|
[ "${initmode}" = "vgarom" ] || hmode="corebootfb"
|
|
|
|
modes="${hmode} txtmode"
|
|
|
|
[ -z ${displaymodes} ] || modes="${displaymodes}"
|
|
|
|
for y in ${modes}; do
|
|
|
|
displaymode="${y}"
|
|
|
|
[ "${initmode}" = "normal" ] && \
|
|
|
|
[ "$displaymode" != "txtmode" ] && continue
|
|
|
|
cbcfg="${targetdir}/config/${initmode}_${displaymode}"
|
|
|
|
[ "${initmode}" = "normal" ] && cbcfg="${cbcfg%_*}"
|
|
|
|
build_roms "${cbcfg}" "${displaymode}" "${initmode}"
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
# Main ROM building function. This calls all other functions below
|
|
|
|
build_roms()
|
|
|
|
{
|
|
|
|
cbcfg="${1}"
|
|
|
|
displaymode="${2}"
|
|
|
|
initmode="${3}"
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
[ ! -f "${cbcfg}" ] && \
|
|
|
|
printf "'%s' does not exist. Skipping build for %s %s %s\n" \
|
|
|
|
"${cbcfg}" "${board}" "${displaymode}" "${initmode}" \
|
|
|
|
1>&2 && return 0
|
2023-05-12 20:53:06 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
./handle make config -b coreboot ${board} || \
|
|
|
|
err "build_roms: cannot build coreboot for target: ${board}"
|
2021-10-30 20:22:27 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
_corebootrom="elf/coreboot/${board}/${initmode}_${displaymode}"
|
|
|
|
[ "${initmode}" = "normal" ] && \
|
|
|
|
_corebootrom="${_corebootrom%_${displaymode}}"
|
|
|
|
_corebootrom="${_corebootrom}/coreboot.rom"
|
|
|
|
corebootrom="$(mktemp -t coreboot_rom.XXXXXXXXXX)"
|
|
|
|
cp "${_corebootrom}" "${corebootrom}" || \
|
|
|
|
err "build_roms: cannot copy rom"
|
coreboot: re-add asus kgpe-d16/kcma-d8/kfsn4-dre
Libreboot 20220710 was the last release to support these
boards. I plan to eventually port code differences between
D8/D16 to Dasharo, for KCMA-D8 support in Dasharo, to then
use in Libreboot for both KCMA-D8 and KGPE-D16, but I have
no plans to update the KFSN4-DRE code, at least for now.
Libreboot 20220710 used coreboot 4.11, whereas this patch
makes use of coreboot 4.11_branch; the crossgcc toolchains
no longer compile on modern distros, so I spent time patching
those (tested in Debian Sid, will also work on Arch Linux and
so on).
The acpica downloads now fail, in 4.11_branch, because Intel
made some changes upstream for these tarball downloads. Newer
coreboot works around this by grabbing tarballs from github,
itself a non-ideal solution, but I digress; this patch changes
coreboot crossgcc (in 4.11_branch) to download the acpica
tarball from libreboot rsync, where I've added it.
This patch also re-introduces the PIKE2008 fix, where empty
option ROMs for these are inserted into CBFS. This prevents
SeaBIOS from loading the real option ROMs, which would cause
SeaBIOS to hang. This means that SAS drives are not supported
in SeaBIOS, for these boards in Libreboot.
I previously said, in the Censored Libreboot c20230710
announcement, that I would *only* merge D8/D16 when I've
added Dasharo support to Libreboot, and use that, but the
work to make coreboot 4.11_branch compile is something I'm
quite proud of and I see no reason to exclude from lbmk
master branch.
Honestly, there's not much different than 4.11, code-wise.
I *probably* won't use 4.11_branch for the next Libreboot
release, on D8/D16. By then, I might have Dasharo integrated
in lbmk instead. We shall see.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-07-16 02:18:58 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
[ "${payload_memtest}" != "y" ] || \
|
|
|
|
"${cbfstool}" "${corebootrom}" add-payload \
|
|
|
|
-f "${memtest_bin}" -n img/memtest -c lzma || \
|
|
|
|
err "build_roms: cannot add img/memtest to coreboot rom"
|
2023-05-12 20:53:06 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
[ "${payload_seabios}" = "y" ] && \
|
|
|
|
build_seabios_roms
|
2023-05-12 20:53:06 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
[ "${payload_grub}" != "y" ] || \
|
|
|
|
build_grub_roms "${corebootrom}" "${initmode}" \
|
|
|
|
"${displaymode}" "grub" || \
|
|
|
|
err "build_roms: build_grub_roms failed"
|
|
|
|
|
|
|
|
if [ "${payload_uboot}" = "y" ]; then
|
|
|
|
build_uboot_roms
|
2023-05-10 01:48:34 +00:00
|
|
|
fi
|
|
|
|
}
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
build_seabios_roms()
|
|
|
|
{
|
|
|
|
if [ "${payload_seabios_withgrub}" = "y" ]; then
|
|
|
|
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
cp "${corebootrom}" "${tmprom}" || \
|
|
|
|
err "build_seabios_roms: cannot copy to tmprom"
|
2023-08-28 08:42:20 +00:00
|
|
|
build_grub_roms "${tmprom}" "${initmode}" \
|
|
|
|
"${displaymode}" "seabios_withgrub" || \
|
|
|
|
err "build_roms: cannot build grub roms, seabios w/grub"
|
|
|
|
rm -f "${tmprom}" || err "build_roms: can't remove tmprom"
|
|
|
|
else
|
|
|
|
x=${corebootrom}
|
|
|
|
y=${initmode}
|
2023-09-10 14:05:19 +00:00
|
|
|
t=$(mkSeabiosRom "$x" "fallback/payload" "$y") || \
|
|
|
|
err "build_seabios_roms: cannot build tmprom"
|
2023-08-28 08:42:20 +00:00
|
|
|
if [ "${initmode}" = "normal" ]; then
|
|
|
|
newrompath="${romdir}/seabios_${board}_"
|
|
|
|
newrompath="${newrompath}${initmode}.rom"
|
|
|
|
else
|
|
|
|
newrompath="${romdir}/seabios_${board}_"
|
|
|
|
newrompath="${newrompath}${initmode}_"
|
|
|
|
newrompath="${newrompath}${displaymode}.rom"
|
|
|
|
fi
|
2023-05-10 01:48:34 +00:00
|
|
|
|
2023-08-31 20:12:35 +00:00
|
|
|
moverom "${t}" "${newrompath}" || \
|
2023-08-28 08:42:20 +00:00
|
|
|
err "build_roms: cannot copy rom"
|
|
|
|
rm -f "${t}" || err "cannot rm ${t}"
|
|
|
|
fi
|
2023-06-25 10:45:40 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
}
|
2023-05-10 01:48:34 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
# Make separate ROM images with GRUB payload, for each supported keymap
|
|
|
|
build_grub_roms() {
|
|
|
|
tmprompath="${1}"
|
|
|
|
initmode="${2}"
|
|
|
|
displaymode="${3}"
|
|
|
|
firstpayloadname="${4}" # allow values: grub, seabios, seabios_withgrub
|
2023-05-10 01:48:34 +00:00
|
|
|
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
grubelf_cbfs="fallback/payload"
|
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
x=${tmprompath}
|
|
|
|
y=${initmode}
|
|
|
|
if [ "${payload_grub_withseabios}" = "y" ] && \
|
|
|
|
[ "${firstpayloadname}" = "grub" ]; then
|
2023-09-10 14:05:19 +00:00
|
|
|
mv "$(mkSeabiosRom "${x}" "seabios.elf" "${y}")" \
|
|
|
|
"${tmprompath}" || \
|
|
|
|
err "build_grub_roms: cannot move tmp rom (seabios.elf)"
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
elif [ "${payload_seabios_withgrub}" = "y" ] && \
|
2023-08-28 08:42:20 +00:00
|
|
|
[ "${firstpayloadname}" != "grub" ]; then
|
|
|
|
mv "$(mkSeabiosRom "${x}" "fallback/payload" "$y")" \
|
|
|
|
"${tmprompath}" || \
|
|
|
|
err "build_grub_roms: cannot move SeaBIOS ROM to tmprom"
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
grubelf_cbfs="img/grub2"
|
2023-08-28 08:42:20 +00:00
|
|
|
fi
|
2023-06-25 10:45:40 +00:00
|
|
|
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
# we only need insert grub.elf once, for each coreboot config:
|
|
|
|
"${cbfstool}" "${tmprompath}" add-payload -f "${grubelf}" \
|
|
|
|
-n ${grubelf_cbfs} -c lzma || \
|
|
|
|
err "build_grub_roms: cannot add grub payload to tmprom"
|
|
|
|
|
|
|
|
# we only need insert background.png once, for each coreboot config:
|
|
|
|
if [ "${displaymode}" = "vesafb" ] || \
|
|
|
|
[ "${displaymode}" = "corebootfb" ]; then
|
2023-09-04 23:50:08 +00:00
|
|
|
backgroundfile="config/grub/background/${grub_background}"
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
"${cbfstool}" "${tmprompath}" add -f ${backgroundfile} \
|
|
|
|
-n background.png -t raw || \
|
|
|
|
err "build_grub_roms: cannot add background.png to tmprom"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
2023-09-08 22:48:06 +00:00
|
|
|
tmpcfg=$(mktemp -t coreboot_rom.XXXXXXXXXX) ||
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
err "mkGrubRom: cannot create temporary scan.cfg"
|
|
|
|
printf "set grub_scan_disk=\"%s\"\n" "${grub_scan_disk}" > \
|
2023-09-08 22:48:06 +00:00
|
|
|
"${tmpcfg}" || \
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
err "mkGrubRom: cannot insert into temporary scan.cfg"
|
2023-09-08 23:02:34 +00:00
|
|
|
[ "${grub_scan_disk}" = "both" ] || \
|
|
|
|
"${cbfstool}" "${tmprompath}" add -f "${tmpcfg}" -n scan.cfg \
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
-t raw || err "mkGrubROM: cannot insert scan.cfg into CBFS"
|
2023-09-08 22:48:06 +00:00
|
|
|
printf "set timeout=%s\n" "${grub_timeout}" > "${tmpcfg}" || \
|
|
|
|
err "mkGrubRom: cannot insert into temporary timeout.cfg"
|
|
|
|
[ -z "${grub_timeout}" ] || \
|
|
|
|
"${cbfstool}" "${tmprompath}" add -f "${tmpcfg}" -n timeout.cfg \
|
|
|
|
-t raw || err "mkGrubROM: cannot insert timeout.cfg into CBFS"
|
2023-09-08 23:02:00 +00:00
|
|
|
rm -f "${tmpcfg}" || err "cannot delete tmpcfg"
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
keymaps=""
|
|
|
|
if [ -z ${keyboard_layouts} ]; then
|
|
|
|
for kmapfile in "${kmapdir}"/*; do
|
|
|
|
keymaps="${keymaps} ${kmapfile}"
|
|
|
|
done
|
|
|
|
else
|
|
|
|
for keymapname in ${keyboard_layouts}; do
|
|
|
|
keymaps="${keymaps} ${kmapdir}/${keymapname}.gkb"
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
for keymapfile in ${keymaps}; do
|
2023-09-09 22:31:20 +00:00
|
|
|
printf "keymaps is %s, keymapfile is %s\n" \
|
|
|
|
"${keymaps}" "${keymapfile}"
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
[ -f "${keymapfile}" ] || continue
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
keymap="${keymapfile##*/}"
|
|
|
|
keymap="${keymap%.gkb}"
|
2022-12-09 11:50:03 +00:00
|
|
|
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
tmpgrubrom="$(mkGrubRom "${keymap}" "${tmprompath}")"
|
2023-05-12 20:53:06 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
if [ "${initmode}" = "normal" ]; then
|
|
|
|
newrompath="${romdir}/${firstpayloadname}_${board}_"
|
|
|
|
newrompath="${newrompath}${initmode}_${keymap}.rom"
|
|
|
|
else
|
|
|
|
newrompath="${romdir}/${firstpayloadname}_${board}_"
|
|
|
|
newrompath="${newrompath}${initmode}_${displaymode}_"
|
|
|
|
newrompath="${newrompath}${keymap}.rom"
|
|
|
|
fi
|
2023-08-31 20:12:35 +00:00
|
|
|
moverom "${tmpgrubrom}" "${newrompath}" || \
|
2023-08-28 08:42:20 +00:00
|
|
|
err "build_grub_roms, moverom"
|
|
|
|
rm -f "${tmpgrubrom}" || err "rm tmpgrubrom, build_grub_roms"
|
|
|
|
done
|
2022-08-26 14:14:57 +00:00
|
|
|
}
|
|
|
|
|
2021-05-18 12:56:12 +00:00
|
|
|
# make a rom in /tmp/ and then print the path of that ROM
|
2023-06-25 10:45:40 +00:00
|
|
|
mkGrubRom() {
|
2021-05-18 12:56:12 +00:00
|
|
|
target_keymap="${1}"
|
|
|
|
target_cbrom="${2}"
|
|
|
|
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
keymapcfg="elf/grub/keymap_${target_keymap}.cfg"
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-08-23 18:56:01 +00:00
|
|
|
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX) || \
|
|
|
|
err "mkGrubRom: cannot create tmprom"
|
|
|
|
cp "${target_cbrom}" "${tmprom}" || \
|
|
|
|
err "mkGrubRom: cannot copy to tmprom"
|
2021-05-18 12:56:12 +00:00
|
|
|
|
grub: all one grub.elf containing keymaps and cfg
new behaviour:
* grub.cfg and grubtest.cfg no longer inserted to cbfs
* grub.cfg in memdisk instead
* grub.cfg in memdisk defers to cbfs/grub.cfg if added
(not added by default, anymore)
* does not defer to grubtest.cfg even if available
* only shows link to grubtest.cfg if available,
as a menuentry item
keymaps:
if /keymap.gkb exists in cbfs, it uses that by default,
but by default this isn't added. instead, it looks for
a file named keymap.cfg and sources that, which then
sets the keymap to one that is located under memdisk.
this file is inserted for each rom, per layout.
if keymap.gkb and keymap.cfg both absent, grub.cfg in
memdisk shall defer to usqwerty as the default keymap
grub_scan_disk: grub.cfg looks for cbfs file "scan.cfg"
and sources that if found, which will be inserted with
the string: set grub_scandisk=setting_goes_here (based
on target.cfg, generated by build/boot/roms automatically).
If no scan.cfg is found, it defaults to "both"
The "background.png" file remains unchanged, and present in
CBFS, used by grub.cfg if present (and it is, by default)
This change actually *saves* space in CBFS, due to compression,
and means that the grub.cfg is now compressed heavily. This
is also safer, because now the user overrides grub.cfg by
adding it, and they can still add grubtest.cfg for testing
first. If they accidentally delete both configs from cbfs,
Libreboot will fall back to the one in memdisk which would
presumably not be deleted.
This also means that lbmk can now more easily be used by
other build systems, that just want the GRUB part to re-use
in their own project. For example, people who want to build
custom coreboot images without using Libreboot's build system.
This change also *speeds* up the build process considerably,
on the parts where ROM images are copied. It's less than half
a second now, whereas previously it took about 30-45 seconds
for ROM images to copy, because of grub.elf being re-added in
each ROM via cbfstool, where compression is used; I believe
the compression part is what caused slowness.
Much, much faster, more versatile builds.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-28 17:10:35 +00:00
|
|
|
"${cbfstool}" "${tmprom}" add -f "${keymapcfg}" -n keymap.cfg -t raw \
|
|
|
|
|| err "mkGrubRom: cannot add keymap.cfg to tmprom"
|
2021-10-30 23:54:53 +00:00
|
|
|
|
2021-05-18 12:56:12 +00:00
|
|
|
printf "%s\n" "${tmprom}"
|
|
|
|
}
|
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
# make a rom in /tmp/ and then print the path of that ROM
|
|
|
|
mkSeabiosRom() {
|
|
|
|
target_cbrom="${1}" # rom to insert seabios in. will not be touched
|
|
|
|
# (a tmpfile will be made instead)
|
|
|
|
target_seabios_cbfs_path="${2}" # e.g. fallback/payload
|
|
|
|
target_initmode="${3}" # e.g. libgfxinit
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
target_seabioself="elf/seabios/default/${target_initmode}/bios.bin.elf"
|
2023-06-25 10:45:40 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
cp "${target_cbrom}" "${tmprom}" || \
|
|
|
|
err "mkSeabiosRom: cannot copy to tmprom"
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
"${cbfstool}" "${tmprom}" add-payload -f "${target_seabioself}" \
|
|
|
|
-n ${target_seabios_cbfs_path} -c lzma || \
|
|
|
|
err "mkSeabiosRom: can't add payload, ${target_seabioself}, to rom"
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
"${cbfstool}" "${tmprom}" add-int -i 3000 -n etc/ps2-keyboard-spinup \
|
|
|
|
|| err "mkSeabiosRom: cbfs add-int etc/ps2-keyboard-spinup 3000"
|
2023-05-10 01:48:34 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
if [ "${target_initmode}" = "normal" ] || \
|
|
|
|
[ "${target_initmode}" = "libgfxinit" ]; then
|
|
|
|
"${cbfstool}" "${tmprom}" add-int -i 2 \
|
|
|
|
-n etc/pci-optionrom-exec || \
|
|
|
|
err "mkSeabiosRom: cbfs add-int etc/pci-optionrom-exec 2"
|
|
|
|
elif [ "${target_initmode}" = "vgarom" ]; then # coreboot executes it
|
|
|
|
"${cbfstool}" "${tmprom}" add-int -i 0 \
|
|
|
|
-n etc/pci-optionrom-exec || \
|
|
|
|
err "mkSeabiosRom: cbfs add-int etc/pci-optionrom-exec 0"
|
|
|
|
fi # for undefined modes, don't add this integer. use SeaBIOS defaults
|
2023-06-25 10:45:40 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
"${cbfstool}" "${tmprom}" add-int -i 0 -n etc/optionroms-checksum || \
|
|
|
|
err "mkSeabiosRom: cbfs add-int etc/optionroms-checksum 0"
|
2023-06-25 10:45:40 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
[ "${target_initmode}" != "libgfxinit" ] || \
|
|
|
|
"${cbfstool}" "${tmprom}" add -f "${seavgabiosrom}" \
|
|
|
|
-n vgaroms/seavgabios.bin -t raw || \
|
|
|
|
err "mkSeabiosRom: cbfs add-raw vgaroms/seavgabios.bin"
|
|
|
|
|
|
|
|
printf "%s\n" "${tmprom}"
|
2021-05-18 12:56:12 +00:00
|
|
|
}
|
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
build_uboot_roms()
|
consolidate u-boot/seabios/coreboot build scripts
See file:
resources/scripts/build/defconfig/for
It is based on:
resources/scripts/build/payload/u-boot
The u-boot payload script has been deleted, as has the
seabios payload script; the build/boot/roms logic has
been heavily simplified too, by removing the logic for
building of elf files based on defconfig.
SeaBIOS, U-Boot and coreboot all use defconfig-type
infrastructure for their build systems, and they are
fundamentally the *same* in how to compile each codebase,
at least in an lbmk context, regardless of actual (and
very huge) differences in these codebases.
Several hundred sources-lines of code have been eliminated
by this change, drastically simplifying everything; U-Boot
payload compiling also now errors out when a single build
fails, instead of continuing. Also: build/boot/roms no longer
re-compiles a coreboot target that was already compiled,
which is the same behaviour observed for payloads.
(this means you must now manually delete a target, when you
wish to re-build it; the build/boot/roms logic now more or
less just runs cbfstool; blobutil is handled from
build/defconfig/for)
ALSO: Since crossgcc is now handled by build/defconfig/for, not
build/boot/roms, standalone compiling of u-boot is now possible.
This has been tested. You compile it like so:
./build defconfig for u-boot
or specific trees, e.g.
./build defconfig for u-boot default
One other consequence of this patch is that re-building the same
ROM image is now much faster, because the same builds are re-used
unless deleted. This could be useful when testing grub.cfg changes,
for example, if that's all you change. With things like ccache used
(not yet used robustly in lbmk), this could speed things up more,
depending on the codebase.
This patch demonstrates the raw power of lbmk; it is a very
simple and highly efficient build system, and now much more so!
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-17 22:27:30 +00:00
|
|
|
{
|
2023-08-28 08:42:20 +00:00
|
|
|
x=${corebootrom}
|
|
|
|
y=${uboot_config}
|
|
|
|
z=${cbfstool}
|
|
|
|
tmprom="$(mkUbootRom "$x" "fallback/payload" "$y" "$z")"
|
2023-08-28 12:51:17 +00:00
|
|
|
newrompath="${romdir}/uboot_payload_${board}_${initmode}_${displaymode}.rom"
|
2023-08-28 08:42:20 +00:00
|
|
|
[ "${initmode}" = "normal" ] && \
|
|
|
|
newrompath="${romdir}/uboot_payload_${board}_${initmode}.rom"
|
2023-08-31 20:12:35 +00:00
|
|
|
moverom "${tmprom}" "${newrompath}" || \
|
2023-08-28 08:42:20 +00:00
|
|
|
err "build_roms: moverom fail (u-boot)"
|
|
|
|
rm -f "${tmprom}" || \
|
|
|
|
err "build_roms: cannot rm u-boot rom"
|
|
|
|
}
|
2021-05-18 12:56:12 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
# make a rom in /tmp/ and then print the path of that ROM
|
|
|
|
mkUbootRom() {
|
|
|
|
target_cbrom="${1}" # rom to insert u-boot in. it 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}"
|
build/boot/roms: Support removing microcode
From now on, the following rules are available for all
mainboards, in resources/coreboot/boardname/board.cfg:
* blobs_required="n" or "y"
* microcode_required="n" or "y"
The blobs setting, if set to "n", simply renames filename.rom to
filename_noblobs.rom.
The microcode setting, if set to "n", copies the ROM (with or
without _noblobs) to filename_nomicrocode.rom (if blobs="n",
it would be filename_noblobs_nomicrocode.rom).
Where "nomicrocode" is set, ROMs with microcode will still be
provided by lbmk and in relesase, but ROMs will also be provided
alongside it that lacks any microcode updates.
If the *original* ROM already lacks microcode updates, then the
original ROM will be *renamed* to include "nomicrocode" in the name.
This is done on images for ARM platforms, for instance, where
microcode is never used whatsoever.
Example filenames now generated:
seabios_e6400_4mb_libgfxinit_corebootfb_noblobs_nomicrocode.rom
seabios_e6400_4mb_libgfxinit_corebootfb_noblobs.rom
seabios_withgrub_hp8300usdt_16mb_libgfxinit_corebootfb_colemak_nomicrocode.rom
seabios_withgrub_hp8300usdt_16mb_libgfxinit_corebootfb_colemak.rom
uboot_payload_gru_kevin_libgfxinit_corebootfb_noblobs_nomicrocode.rom
A vocal minority of people were not happy with some of the changes
made in Libreboot last year, including on existing supported
hardware from before those changes were made. I did this before the
last release, out of respect:
https://libreboot.org/news/gm45microcode.html
(re-add mitigations for no-microcode setup on GM45)
This new change is done as an further, extended courtesy. Tested
and works fine. (testing using cbfstool-print)
Actual Libreboot policy about binary blobs is nuanced. See:
https://libreboot.org/news/policy.html (reduction policy) and:
https://libreboot.org/freedom-status.html (implementation)
Well, the status page talks about descriptor vs non-descriptor
on Intel platforms, and where me_cleaner is used (on platforms
that need Intel ME firmware), it regards the descriptored setups
to be blob-free if coreboot does not require binary blobs.
In this paradigm, microcode updates are not considered to be
binary blobs, because they aren't technically software, they're
more like config files that just turn certain features on or off
within the CPU.
However, for lbmk purposes, "noblobs" means that, after the ROM
is fully ready to flash on the chip, there will be no blobs in
it (except microcode). So for example, an X200 that does not
require ME firmware is considered blob-free under this paradigm,
even though Libreboot policy regards X230 as equally libre when
me_cleaner is used; in this setup, ROMs will not contain "blobfree"
in the filename, for X230 (as one example).
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-06-18 13:12:31 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
target_ubdir="elf/u-boot/${board}/${target_uboot_config}"
|
|
|
|
target_ubootelf="${target_ubdir}/u-boot.elf"
|
|
|
|
[ -f "${target_ubootelf}" ] || \
|
|
|
|
target_ubootelf="${target_ubdir}/u-boot.bin"
|
|
|
|
[ -f "${target_ubootelf}" ] || \
|
|
|
|
err "mkUbootRom: ${board}: cant find u-boot build"
|
2023-08-20 23:40:35 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
|
2021-11-01 02:51:10 +00:00
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
cp "${target_cbrom}" "${tmprom}" || \
|
|
|
|
err "mkUbootRom: cannot copy to tmprom"
|
|
|
|
"${cbfstool}" "${tmprom}" add-payload -f "${target_ubootelf}" \
|
|
|
|
-n ${target_uboot_cbfs_path} -c lzma || \
|
|
|
|
err "mkUbootRom: cannot add u-boot to tmprom"
|
|
|
|
|
|
|
|
printf "%s\n" "${tmprom}"
|
|
|
|
}
|
|
|
|
|
|
|
|
# it is assumed that no other work will be done on the ROM
|
|
|
|
# after calling this function. therefore this function is "final"
|
|
|
|
moverom() {
|
2023-08-31 20:12:35 +00:00
|
|
|
rompath="${1}"
|
|
|
|
newrompath="${2}"
|
2023-08-28 08:42:20 +00:00
|
|
|
|
|
|
|
printf "\nCreating new ROM image: %s\n" "${newrompath}"
|
|
|
|
|
2023-09-04 13:54:36 +00:00
|
|
|
[ -d "${newrompath%/*}" ] || mkdir -p "${newrompath%/*}/" || \
|
|
|
|
err "moverom: cannot create rom directory: \"${newrompath%/*}\""
|
|
|
|
|
only remove microcode in build/release/roms
libreboot's build system, lbmk, *is* available to use
in releases aswell (use the _src tarball), but it is
mostly intended for development, in lbmk.git
well, there's not much point wasting time / disk space
generating no-microcode roms within lbmk
they should be generated only at release time, alongside
the default ones
this patch implements that, thus speeding up the build
process and saving disk usage during development
the other alternative was to add a new option in
build/boot/roms, -m, that would opt in to removing them,
but this is extra complexity for something that is ill
advised and only provided to appease certain people
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-31 21:00:13 +00:00
|
|
|
[ "${blobs_required}" = "n" ] && \
|
|
|
|
newrompath="${newrompath%.rom}_noblobs.rom"
|
2023-08-28 08:42:20 +00:00
|
|
|
|
only remove microcode in build/release/roms
libreboot's build system, lbmk, *is* available to use
in releases aswell (use the _src tarball), but it is
mostly intended for development, in lbmk.git
well, there's not much point wasting time / disk space
generating no-microcode roms within lbmk
they should be generated only at release time, alongside
the default ones
this patch implements that, thus speeding up the build
process and saving disk usage during development
the other alternative was to add a new option in
build/boot/roms, -m, that would opt in to removing them,
but this is extra complexity for something that is ill
advised and only provided to appease certain people
Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-08-31 21:00:13 +00:00
|
|
|
cp "${rompath}" "${newrompath}" || err "moverom: can't copy rom"
|
2021-05-18 12:56:12 +00:00
|
|
|
}
|
|
|
|
|
2023-08-28 08:42:20 +00:00
|
|
|
main $@
|