agherzan / meta-raspberrypi

Yocto/OE BSP layer for the Raspberry Pi boards
https://www.yoctoproject.org/
MIT License
539 stars 415 forks source link

RPi CM4 Change Serial Debug Interface #1068

Closed MitchGaines closed 2 years ago

MitchGaines commented 2 years ago

Description Hi there, I have an RPi CM4 running dunfell. I am attempting to change the serial debug interface that the system writes to. The reason for this is because I have a device that must use the UART0 interface and the boot is being interrupted (at u-boot) by the device on this interface. I would like to move all console output to the UART3 interface. However, changing the SERIAL_CONSOLES variable in my machine.conf does not seem to do the trick.

Steps to reproduce the issue:

  1. Change the SERIAL_CONSOLES variable in the machine.conf to SERIAL_CONSOLES = "115200;ttyS3"
  2. Rebuild image & write to device
  3. Hook up a UART->USB interface to UART3 and open in screen or some other serial monitoring software

Describe the results you received: No output was sent to the UART3 interface. I hooked up to UART0 again and all console output was still sent there.

Describe the results you expected: I expected all u-boot and kernel output to be output on the UART3 interface.

Additional details (revisions used, host distro, etc.):

Additional things I've tried

  1. Changing the cmdline.txt from console=serial0,115200 to console=serial3,115200
  2. I created the following patch, to no avail

    
    diff --git a/arch/arm/boot/dts/bcm2711-rpi-cm4.dts b/arch/arm/boot/dts/bcm2711-rpi-cm4.dts
    index 49f6ba6c4792..704f7f726fe9 100644
    --- a/arch/arm/boot/dts/bcm2711-rpi-cm4.dts
    +++ b/arch/arm/boot/dts/bcm2711-rpi-cm4.dts
    @@ -9,7 +9,7 @@
    
    chosen {
        /* 8250 auxiliary UART instead of pl011 */
    -       stdout-path = "serial1:115200n8";
    +       stdout-path = "serial3:115200n8";
    };
    
    /* Will be filled by the bootloader */


UPDATE:

I got the kernel outputting to UART3 by adding `dtoverlay=uart3` to my `/boot/config.txt` and changing my `cmdline.txt` to `console=ttyAMA2`. I'll need to make these changes in my yocto configs to persist it, but its progress. U-boot is still outputting to uart0 though. 
MitchGaines commented 2 years ago

I ended up applying the following patches to u-boot in order to disable serial output. These are adapted from another thread I found on a similar topic.

diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
index ff69607d3c..59666d673d 100644
--- a/board/raspberrypi/rpi/rpi.c
+++ b/board/raspberrypi/rpi/rpi.c
@@ -520,3 +520,10 @@ int ft_board_setup(void *blob, struct bd_info *bd)

    return 0;
 }
+
+int board_early_init_f(void)
+{
+    gd->flags |= (GD_FLG_SILENT | GD_FLG_DISABLE_CONSOLE);
+    return 0;
+}
+
diff --git a/include/configs/rpi.h b/include/configs/rpi.h
index 4c5c1ac31f..bb9009800d 100644
--- a/include/configs/rpi.h
+++ b/include/configs/rpi.h
@@ -176,5 +176,10 @@
    ENV_MEM_LAYOUT_SETTINGS \
    BOOTENV

+#define CONFIG_SILENT_U_BOOT_ONLY
+#define CONFIG_DISABLE_CONSOLE
+#define CONFIG_SILENT_CONSOLE
+#define CONFIG_SYS_DEVICE_NULLDEV
+#define CONFIG_BOARD_EARLY_INIT_F 1

 #endif

This solves my problem in the immediate term. Unfortunately, I lose u-boot debug capability.

As stated in my update to the OP, I was able to move kernel output to another serial port.

MitchGaines commented 2 years ago

Going to go ahead and close this as at this point, I'm not sure its a meta-raspberrypi issue. Should probably be something more easily configurable in u-boot.