packages: roms_helper: boot: add support for debug configuration

When a computer does not boot at all or the result is only a deep black screen,
a very useful option can be to use a serial connector to get UART debug console
and read it, looking for any useful hint. However, enabling UART debug console
with a sufficient level of details slows down the boot process in most cases.

This commit adds the capability to build debug images, using a special
configuration file for coreboot with debug options. This is a simplistic way
that works for now, but should be improved later on.

These debug images will be generated in the bin-dbg/ directory instead
of bin/ where regular images are located.

Signed-off-by: Adrien 'neox' Bourmault <neox@gnu.org>
Acked-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
This commit is contained in:
Adrien Bourmault 2024-12-05 00:46:14 +01:00
parent fe30ffd6ee
commit 56c59af861
Signed by: neox
GPG Key ID: 57BC26A3687116F6
4 changed files with 66 additions and 7 deletions

1
.gitignore vendored
View File

@ -11,6 +11,7 @@
/TODO /TODO
/TODO/ /TODO/
/bin/ /bin/
/bin-dbg/
/bucts/ /bucts/
/build_error /build_error
/compile /compile

View File

@ -0,0 +1,16 @@
GNU Boot also builds some debug images that are shipped in separate
debug archives (like gnuboot-0.1-rc3_x200_8mb_debug.tar.xz).
The debug images have the following differences with the regular
images:
- The serial port is enabled, its speed is set to 115200, and the
Coreboot debug level is set to 7. It's possible to bring it up to 8
without recompiling the image by modifying the cmos.default file
inside the image. In addition POST codes are also printed on the
serial port.
- When the computer has a Coreboot build setting for that (all
computers but QEMU have that), memory debugging is enabled. This can
help diagnose RAM compatibility issues to potentially fix them in
Coreboot.

View File

@ -4,6 +4,7 @@
# #
# Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org> # Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org>
# Copyright (C) 2015 Klemens Nanni <contact@autoboot.org> # Copyright (C) 2015 Klemens Nanni <contact@autoboot.org>
# Copyright (C) 2024 Adrien Bourmault <neox@gnu.org>
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -27,5 +28,6 @@ set -u -e
# Delete the ROM images # Delete the ROM images
rm -Rf "bin/" rm -Rf "bin/"
rm -Rf "bin-dbg/"
printf "Deleted the bin/ directory containing the ROM images.\n\n" printf "Deleted the bin/ directory containing the ROM images.\n\n"

View File

@ -5,6 +5,7 @@
# Copyright (C) 2020,2021 Leah Rowe <info@minifree.org> # Copyright (C) 2020,2021 Leah Rowe <info@minifree.org>
# Copyright (C) 2021 Vitali64 <vitali64pmemail@protonmail.com> # Copyright (C) 2021 Vitali64 <vitali64pmemail@protonmail.com>
# Copyright (C) 2023, 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> # Copyright (C) 2023, 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
# Copyright (C) 2024 Adrien Bourmault <neox@gnu.org>
# #
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -49,7 +50,6 @@ if [ ! -f "resources/coreboot/${board}/board.cfg" ]; then
exit 1 exit 1
fi fi
# Workaround to grub's slow boot # Workaround to grub's slow boot
grub_scan_disk="undefined" # both: scan ata and ahci (slow), there is ata and ahci too grub_scan_disk="undefined" # both: scan ata and ahci (slow), there is ata and ahci too
# as an option # as an option
@ -129,6 +129,7 @@ if [ "${payload_memtest}" = "y" ]; then
fi fi
romdir="bin/${board}" romdir="bin/${board}"
dbgdir="bin-dbg/${board}"
cbdir="coreboot/${board}" cbdir="coreboot/${board}"
if [ "${board}" != "${cbtree}" ]; then if [ "${board}" != "${cbtree}" ]; then
cbdir="coreboot/${cbtree}" cbdir="coreboot/${cbtree}"
@ -181,8 +182,10 @@ if [ ! -f "${seavgabiosrom}" ] \
fi fi
fi fi
# create romdir if it does not exist, remove everything in it
# remove everything in dbgdir (if it exists), but do not create it (see later)
[ -d "${romdir}/" ] || mkdir -p "${romdir}/" [ -d "${romdir}/" ] || mkdir -p "${romdir}/"
rm -f "${romdir}"/* rm -f "${romdir}"/* "${dbgdir}"/*
if [ "${payload_grub}" = "y" ] || [ "${payload_seabios_withgrub}" = "y" ]; then if [ "${payload_grub}" = "y" ] || [ "${payload_seabios_withgrub}" = "y" ]; then
if [ -f "payload/grub/grub_usqwerty.cfg" ]; then if [ -f "payload/grub/grub_usqwerty.cfg" ]; then
@ -359,6 +362,17 @@ mkRomsWithGrub() {
tmprompath="${1}" tmprompath="${1}"
displaymode="${2}" displaymode="${2}"
firstpayloadname="${3}" # allow values: grub, seabios, seabios_withgrub firstpayloadname="${3}" # allow values: grub, seabios, seabios_withgrub
kind="${4}"
romdest=${romdir}
name_prefix=""
if [ "${kind}" = "${DEBUGIMG}" ]; then
# location for debug images is different from regular ones
romdest=${dbgdir}
# add "debug_" at the beginning of the file name
name_prefix="debug_"
fi
if [ "${payload_grub_withseabios}" = "y" ] && [ "${firstpayloadname}" = "grub" ]; then if [ "${payload_grub_withseabios}" = "y" ] && [ "${firstpayloadname}" = "grub" ]; then
mv "$(make_seabios_rom "${tmprompath}" "seabios.elf" "${seabios_opromloadonly}" "${cbfstool}")" "${tmprompath}" mv "$(make_seabios_rom "${tmprompath}" "seabios.elf" "${seabios_opromloadonly}" "${cbfstool}")" "${tmprompath}"
@ -393,7 +407,7 @@ mkRomsWithGrub() {
firstpayloadname="seabios" firstpayloadname="seabios"
fi fi
newrompath="${romdir}/${firstpayloadname}_${board}_${displaymode}_${keymap}.rom" newrompath="${romdest}/${name_prefix}${firstpayloadname}_${board}_${displaymode}_${keymap}.rom"
moverom "${tmpgrubrom}" "${newrompath}" "${romtype}" moverom "${tmpgrubrom}" "${newrompath}" "${romtype}"
rm -f "${tmpgrubrom}" rm -f "${tmpgrubrom}"
done done
@ -403,6 +417,10 @@ mkRomsWithGrub() {
mkRoms() { mkRoms() {
cbcfgpath="${1}" cbcfgpath="${1}"
displaymode="${2}" displaymode="${2}"
destdir=${3}
kind="${4}"
romdest=${romdir}
name_prefix=""
if [ ! -f "${cbcfgpath}" ]; then if [ ! -f "${cbcfgpath}" ]; then
printf "'%s' does not exist. Skipping build for %s %s %s\n" \ printf "'%s' does not exist. Skipping build for %s %s %s\n" \
@ -410,6 +428,14 @@ mkRoms() {
return 0 return 0
fi fi
if [ "${kind}" = "${DEBUGIMG}" ]; then
# location for debug images is different from regular ones
romdest=${dbgdir}
# add "debug_" at the beginning of the file name
name_prefix="debug_"
fi
mkCoreboot "${cbdir}" "${cbcfgpath}" mkCoreboot "${cbdir}" "${cbcfgpath}"
if [ "${displaymode}" = "txtmode" ] && [ "${payload_memtest}" = "y" ]; then if [ "${displaymode}" = "txtmode" ] && [ "${payload_memtest}" = "y" ]; then
@ -419,26 +445,40 @@ mkRoms() {
if [ "${payload_seabios}" = "y" ]; then if [ "${payload_seabios}" = "y" ]; then
if [ "${payload_seabios_withgrub}" = "n" ]; then if [ "${payload_seabios_withgrub}" = "n" ]; then
tmpseabiosrom="$(make_seabios_rom "${corebootrom}" "fallback/payload" "${seabios_opromloadonly}" "${cbfstool}")" tmpseabiosrom="$(make_seabios_rom "${corebootrom}" "fallback/payload" "${seabios_opromloadonly}" "${cbfstool}")"
newrompath="${romdir}/seabios_${board}_${displaymode}.rom" newrompath="${romdest}/${name_prefix}seabios_${board}_${displaymode}.rom"
moverom "${tmpseabiosrom}" "${newrompath}" "${romtype}" moverom "${tmpseabiosrom}" "${newrompath}" "${romtype}"
rm -f "${tmpseabiosrom}" rm -f "${tmpseabiosrom}"
else else
tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX) tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX)
cp "${corebootrom}" "${tmprom}" cp "${corebootrom}" "${tmprom}"
mkRomsWithGrub "${tmprom}" "${displaymode}" "seabios_withgrub" mkRomsWithGrub "${tmprom}" "${displaymode}" "seabios_withgrub" ${kind}
rm -f "${tmprom}" rm -f "${tmprom}"
fi fi
fi fi
if [ "${payload_grub}" = "y" ]; then if [ "${payload_grub}" = "y" ]; then
mkRomsWithGrub "${corebootrom}" "${displaymode}" "grub" mkRomsWithGrub "${corebootrom}" "${displaymode}" "grub" ${kind}
fi fi
} }
for displaymode in corebootfb txtmode; do for displaymode in corebootfb txtmode; do
cbcfgpath="resources/coreboot/${board}/config/${displaymode}" cbcfgpath="resources/coreboot/${board}/config/${displaymode}"
mkRoms "${cbcfgpath}" "${displaymode}" DEBUGIMG=1
REGULARIMG=0
# make regular image
mkRoms "${cbcfgpath}" "${displaymode}" ${romdir} ${REGULARIMG}
# check that a debug configuration exists
if [ -f "${cbcfgpath}.debug" ]; then
# create debug image directory, if it does not exist
[ -d "${dbgdir}/" ] || mkdir -p "${dbgdir}/"
# make debug image
mkRoms "${cbcfgpath}.debug" "${displaymode}" ${dbgdir} ${DEBUGIMG}
fi
done done
( (