From 47802e7eb3955ff996b8af0e6daf8ab9b6e97ed0 Mon Sep 17 00:00:00 2001 From: Jacob Killelea Date: Fri, 18 Jul 2025 08:44:31 -0700 Subject: [PATCH] arm/raspberrypi: Specify an initial baud rate during startup * Fixes #5256. * Specify an initial baud rate to use during startup. After the PL011 code refactor in 0f421539598717a91cd7eee2b1cbf7ed32cb22f9, an initial baud rate is required. arm_pl011_first_open is called from boot_card and will fail without a baud rate specified. This can cause certain future uses of /dev/console, such as opening a shell, to fail. --- bsps/arm/raspberrypi/console/console-config.c | 3 ++- bsps/arm/raspberrypi/include/bsp/usart.h | 2 -- spec/build/bsps/arm/raspberrypi/grp.yml | 4 ++++ .../bsps/arm/raspberrypi/optminiuartbaud.yml | 19 +++++++++++++++++++ .../bsps/arm/raspberrypi/optpl011baud.yml | 19 +++++++++++++++++++ 5 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 spec/build/bsps/arm/raspberrypi/optminiuartbaud.yml create mode 100644 spec/build/bsps/arm/raspberrypi/optpl011baud.yml diff --git a/bsps/arm/raspberrypi/console/console-config.c b/bsps/arm/raspberrypi/console/console-config.c index 0af09e1361..2c2c993dc3 100644 --- a/bsps/arm/raspberrypi/console/console-config.c +++ b/bsps/arm/raspberrypi/console/console-config.c @@ -47,7 +47,8 @@ #define FBCONS "/dev/fbcons" arm_pl011_context pl011_context = { - .clock = 48000000 + .clock = 48000000, + .initial_baud = PL011_DEFAULT_BAUD, }; ns16550_context mini_uart_context; diff --git a/bsps/arm/raspberrypi/include/bsp/usart.h b/bsps/arm/raspberrypi/include/bsp/usart.h index 6af1844b3c..c054421367 100644 --- a/bsps/arm/raspberrypi/include/bsp/usart.h +++ b/bsps/arm/raspberrypi/include/bsp/usart.h @@ -32,8 +32,6 @@ extern "C" { #endif /* __cplusplus */ -#define PL011_DEFAULT_BAUD 115000 -#define MINI_UART_DEFAULT_BAUD 115200 #define BCM2835_PL011_BASE (RPI_PERIPHERAL_BASE + 0x201000) #ifdef __cplusplus diff --git a/spec/build/bsps/arm/raspberrypi/grp.yml b/spec/build/bsps/arm/raspberrypi/grp.yml index 489ec3f7a4..8f22ee9ae6 100644 --- a/spec/build/bsps/arm/raspberrypi/grp.yml +++ b/spec/build/bsps/arm/raspberrypi/grp.yml @@ -54,6 +54,10 @@ links: uid: ../../optfdtro - role: build-dependency uid: ../../optfdtuboot +- role: build-dependency + uid: optpl011baud +- role: build-dependency + uid: optminiuartbaud type: build use-after: [] use-before: [] diff --git a/spec/build/bsps/arm/raspberrypi/optminiuartbaud.yml b/spec/build/bsps/arm/raspberrypi/optminiuartbaud.yml new file mode 100644 index 0000000000..b9804110da --- /dev/null +++ b/spec/build/bsps/arm/raspberrypi/optminiuartbaud.yml @@ -0,0 +1,19 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +actions: +- get-integer: null +- assert-uint32: null +- env-assign: null +- format-and-define: null +build-type: option +copyrights: +- Copyright (C) 2025 Jacob Killelea +default: +- enabled-by: true + value: 115200 +description: | + Mini UART default baud rate +enabled-by: true +format: '{:#d}' +links: [] +name: MINI_UART_DEFAULT_BAUD +type: build diff --git a/spec/build/bsps/arm/raspberrypi/optpl011baud.yml b/spec/build/bsps/arm/raspberrypi/optpl011baud.yml new file mode 100644 index 0000000000..a9d8b9ad11 --- /dev/null +++ b/spec/build/bsps/arm/raspberrypi/optpl011baud.yml @@ -0,0 +1,19 @@ +SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause +actions: +- get-integer: null +- assert-uint32: null +- env-assign: null +- format-and-define: null +build-type: option +copyrights: +- Copyright (C) 2025 Jacob Killelea +default: +- enabled-by: true + value: 115200 +description: | + PL011 (main UART) default baud rate +enabled-by: true +format: '{:#d}' +links: [] +name: PL011_DEFAULT_BAUD +type: build