u-boot: Fix serial console on Raspberry Pi 4

Message ID 20261113001443.2118539-1-antonio@mandelbit.com
State New
Headers
Series u-boot: Fix serial console on Raspberry Pi 4 |

Commit Message

Antonio Quartulli 13 Nov 2026, 12:14 a.m. UTC
boot.cmd only selects the mini UART (ttyS1) for the Pi 3B/3B+ dtbs and
falls back to ttyAMA0 on every other Pi. On boards with Bluetooth
(4B, 400, 3A+, Zero 2 W) ttyAMA0 is the PL011 wired to the BT module, so
the kernel console disappears after "Starting kernel ...".

Pick the console from the stdout-path of the dtb being booted instead:
serial1 is the mini UART on the pin header (ttyS1), serial0 the PL011.

Fixes: #13052
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
Notes:
- The core update needs to ship /boot/boot.cmd and the regenerated
  /boot/boot.scr (built from boot.cmd by lfs/u-boot). I didn't touch
  the filelists.

 config/u-boot/boot.cmd | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
  

Patch

diff --git a/config/u-boot/boot.cmd b/config/u-boot/boot.cmd
index 929d30862..924e34d01 100644
--- a/config/u-boot/boot.cmd
+++ b/config/u-boot/boot.cmd
@@ -48,19 +48,22 @@  if test "${board}" = "sunxi"; then
 	fi;
 fi;
 
+fatload ${boot_dev} ${boot_part} ${fdt_addr_r} dtb-${KVER}/${fdtfile};
+
 # Check if serial console is enabled
 if test "${SERIAL-CONSOLE}" = "ON"; then
 	if test ${console} = ""; then
 		if test "${board}" = "rpi"; then
 			if test ${cpu} = "armv8"; then
-				if test "${fdtfile}" = "broadcom/bcm2837-rpi-3-b-plus.dtb"; then
+				# Use the UART the device tree routes to the pin header:
+				# serial1 is the mini UART (ttyS1), serial0 the PL011 (ttyAMA0)
+				setenv stdout_path;
+				fdt addr ${fdt_addr_r};
+				fdt get value stdout_path /chosen stdout-path;
+				if test "${stdout_path}" = "serial1:115200n8"; then
 					setenv console ttyS1,115200n8;
 				else
-					if test "${fdtfile}" = "broadcom/bcm2837-rpi-3-b.dtb"; then
-						setenv console ttyS1,115200n8;
-					else
-						setenv console ttyAMA0,115200n8;
-					fi;
+					setenv console ttyAMA0,115200n8;
 				fi;
 			fi;
 		else
@@ -79,7 +82,6 @@  if test ${fdt_high} = ""; then
 fi;
 
 fatload ${boot_dev} ${boot_part} ${kernel_addr_r} vmlinuz-${KVER};
-fatload ${boot_dev} ${boot_part} ${fdt_addr_r} dtb-${KVER}/${fdtfile};
 
 if test "${FDTCMDS}" = ""; then
 	echo ;