From 56c59af8619815aab55f67040b7d2eb7023e0399 Mon Sep 17 00:00:00 2001 From: Adrien 'neox' Bourmault Date: Thu, 5 Dec 2024 00:46:14 +0100 Subject: [PATCH] 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 Acked-by: Denis 'GNUtoo' Carikli --- .gitignore | 1 + resources/coreboot/README.debug | 16 +++++++++ resources/packages/rom_images/clean | 2 ++ resources/packages/roms_helper/boot | 54 +++++++++++++++++++++++++---- 4 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 resources/coreboot/README.debug diff --git a/.gitignore b/.gitignore index 44ed301..5ab9469 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ /TODO /TODO/ /bin/ +/bin-dbg/ /bucts/ /build_error /compile diff --git a/resources/coreboot/README.debug b/resources/coreboot/README.debug new file mode 100644 index 0000000..d61b9d3 --- /dev/null +++ b/resources/coreboot/README.debug @@ -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. diff --git a/resources/packages/rom_images/clean b/resources/packages/rom_images/clean index cac6922..57d5cc4 100755 --- a/resources/packages/rom_images/clean +++ b/resources/packages/rom_images/clean @@ -4,6 +4,7 @@ # # Copyright (C) 2014, 2015 Leah Rowe # Copyright (C) 2015 Klemens Nanni +# Copyright (C) 2024 Adrien Bourmault # # 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 @@ -27,5 +28,6 @@ set -u -e # Delete the ROM images rm -Rf "bin/" +rm -Rf "bin-dbg/" printf "Deleted the bin/ directory containing the ROM images.\n\n" diff --git a/resources/packages/roms_helper/boot b/resources/packages/roms_helper/boot index 5c2f909..6316f04 100755 --- a/resources/packages/roms_helper/boot +++ b/resources/packages/roms_helper/boot @@ -5,6 +5,7 @@ # Copyright (C) 2020,2021 Leah Rowe # Copyright (C) 2021 Vitali64 # Copyright (C) 2023, 2024 Denis 'GNUtoo' Carikli +# Copyright (C) 2024 Adrien Bourmault # # 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 @@ -49,7 +50,6 @@ if [ ! -f "resources/coreboot/${board}/board.cfg" ]; then exit 1 fi - # Workaround to grub's slow boot grub_scan_disk="undefined" # both: scan ata and ahci (slow), there is ata and ahci too # as an option @@ -129,6 +129,7 @@ if [ "${payload_memtest}" = "y" ]; then fi romdir="bin/${board}" +dbgdir="bin-dbg/${board}" cbdir="coreboot/${board}" if [ "${board}" != "${cbtree}" ]; then cbdir="coreboot/${cbtree}" @@ -181,8 +182,10 @@ if [ ! -f "${seavgabiosrom}" ] \ 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}/" -rm -f "${romdir}"/* +rm -f "${romdir}"/* "${dbgdir}"/* if [ "${payload_grub}" = "y" ] || [ "${payload_seabios_withgrub}" = "y" ]; then if [ -f "payload/grub/grub_usqwerty.cfg" ]; then @@ -359,6 +362,17 @@ mkRomsWithGrub() { tmprompath="${1}" displaymode="${2}" 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 mv "$(make_seabios_rom "${tmprompath}" "seabios.elf" "${seabios_opromloadonly}" "${cbfstool}")" "${tmprompath}" @@ -393,7 +407,7 @@ mkRomsWithGrub() { firstpayloadname="seabios" fi - newrompath="${romdir}/${firstpayloadname}_${board}_${displaymode}_${keymap}.rom" + newrompath="${romdest}/${name_prefix}${firstpayloadname}_${board}_${displaymode}_${keymap}.rom" moverom "${tmpgrubrom}" "${newrompath}" "${romtype}" rm -f "${tmpgrubrom}" done @@ -403,6 +417,10 @@ mkRomsWithGrub() { mkRoms() { cbcfgpath="${1}" displaymode="${2}" + destdir=${3} + kind="${4}" + romdest=${romdir} + name_prefix="" if [ ! -f "${cbcfgpath}" ]; then printf "'%s' does not exist. Skipping build for %s %s %s\n" \ @@ -410,6 +428,14 @@ mkRoms() { return 0 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}" if [ "${displaymode}" = "txtmode" ] && [ "${payload_memtest}" = "y" ]; then @@ -419,26 +445,40 @@ mkRoms() { if [ "${payload_seabios}" = "y" ]; then if [ "${payload_seabios_withgrub}" = "n" ]; then 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}" rm -f "${tmpseabiosrom}" else tmprom=$(mktemp -t coreboot_rom.XXXXXXXXXX) cp "${corebootrom}" "${tmprom}" - mkRomsWithGrub "${tmprom}" "${displaymode}" "seabios_withgrub" + mkRomsWithGrub "${tmprom}" "${displaymode}" "seabios_withgrub" ${kind} rm -f "${tmprom}" fi fi if [ "${payload_grub}" = "y" ]; then - mkRomsWithGrub "${corebootrom}" "${displaymode}" "grub" + mkRomsWithGrub "${corebootrom}" "${displaymode}" "grub" ${kind} fi } for displaymode in corebootfb txtmode; do 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 (