lib/cbmem_console,console: Resurrect CONSOLE_CBMEM_DUMP_TO_UART

Chromebooks normally run with non-serial enabled firmware because
writing to the UART console is very slow. This unfortunately makes
debugging boot errors more difficult. We tend to rely on port 80s and/or
the vboot recovery code.

When CONSOLE_CBMEM_DUMP_TO_UART is selected it will dump the entire
cbmem console to the UART whenever `vboot_reboot()` is called. We don't
incur any boot time penalty in the happy path, but still retain the
ability to access the logs when an error occurs.

The previous implementation was using a hard coded UART index and
`get_uart_baudrate` was always returning 0 since `CONFIG_TTYS0_BAUD`
wasn't defined. This change makes it so the UART console properties are
available when CONSOLE_CBMEM_DUMP_TO_UART is set. This results in the
following .config diff:

    +CONFIG_UART_FOR_CONSOLE=0
    +CONFIG_TTYS0_BASE=0x3f8
    +CONFIG_TTYS0_LCS=3
    +CONFIG_CONSOLE_SERIAL_115200=y
    +CONFIG_TTYS0_BAUD=115200

This functionality is especially helpful on Guybrush. PSP Verstage is
run on S0i3 resume. Today, if there is an error, the cbmem console is
lost since it lives in the PSP SRAM.

BUG=b:213828947, b:215599230
TEST=Build non-serial guybrush FW and verify no serial output happens in
happy path. Inject a vboot error and perform an S0i3 suspend/resume.
Verify CBMEM console gets dumped to the correct UART.

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
Change-Id: I997942204603362e51876a9ae25e493fe527437b
Reviewed-on: https://review.coreboot.org/c/coreboot/+/61305
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Raul E Rangel 2022-01-21 13:34:21 -07:00 committed by Felix Held
parent e8feab018b
commit 6ec3dd2e5c
2 changed files with 18 additions and 7 deletions

View File

@ -47,7 +47,7 @@ config FIXED_UART_FOR_CONSOLE
specific UART has to be used (e.g. when the platform code
performs dangerous configurations).
if CONSOLE_SERIAL
if CONSOLE_SERIAL || CONSOLE_CBMEM_DUMP_TO_UART
comment "I/O mapped, 8250-compatible"
depends on DRIVERS_UART_8250IO

View File

@ -171,16 +171,27 @@ POSTCAR_CBMEM_INIT_HOOK(cbmemc_reinit)
void cbmem_dump_console_to_uart(void)
{
u32 cursor;
unsigned int console_index;
if (!current_console)
return;
uart_init(0);
if (current_console->cursor & OVERFLOW)
console_index = get_uart_for_console();
uart_init(console_index);
if (current_console->cursor & OVERFLOW) {
for (cursor = current_console->cursor & CURSOR_MASK;
cursor < current_console->size; cursor++)
uart_tx_byte(0, current_console->body[cursor]);
for (cursor = 0; cursor < (current_console->cursor & CURSOR_MASK); cursor++)
uart_tx_byte(0, current_console->body[cursor]);
cursor < current_console->size; cursor++) {
if (current_console->body[cursor] == '\n')
uart_tx_byte(console_index, '\r');
uart_tx_byte(console_index, current_console->body[cursor]);
}
}
for (cursor = 0; cursor < (current_console->cursor & CURSOR_MASK); cursor++) {
if (current_console->body[cursor] == '\n')
uart_tx_byte(console_index, '\r');
uart_tx_byte(console_index, current_console->body[cursor]);
}
}
#endif