From 63692c1349f767c5c78ad30fb4b024c80cb61329 Mon Sep 17 00:00:00 2001 From: Myeonghyeon Park Date: Wed, 27 Mar 2024 18:19:19 +0900 Subject: [PATCH] board: raspberrypi: enable serial communication on Raspberry Pi 5 Enable serial communication through UART port between HDMI ports. Signed-off-by: Myeonghyeon Park Signed-off-by: Junho Lee --- boards/raspberrypi/rpi_5/doc/index.rst | 60 ++++++++++++++++++++++++ boards/raspberrypi/rpi_5/rpi_5.dts | 7 +++ boards/raspberrypi/rpi_5/rpi_5_defconfig | 5 ++ dts/arm64/broadcom/bcm2712.dtsi | 18 +++++++ 4 files changed, 90 insertions(+) diff --git a/boards/raspberrypi/rpi_5/doc/index.rst b/boards/raspberrypi/rpi_5/doc/index.rst index 65989d6bf7..c22c695a40 100644 --- a/boards/raspberrypi/rpi_5/doc/index.rst +++ b/boards/raspberrypi/rpi_5/doc/index.rst @@ -46,6 +46,9 @@ The Raspberry Pi 5 board configuration supports the following hardware features: * - GPIO - :kconfig:option:`CONFIG_GPIO` - :dtcompatible:`brcm,brcmstb-gpio` + * - UART + - :kconfig:option:`CONFIG_SERIAL` + - :dtcompatible:`arm,pl011` Not all hardware features are supported yet. See `Raspberry Pi hardware`_ for the complete list of hardware features. @@ -91,6 +94,60 @@ Copy `zephyr.bin` from `build/zephyr` directory to the root directory of the Mic Insert the Micro SD card and power on the Raspberry Pi 5. And then, the STAT LED will start to blink. + +Serial Communication +==================== + +wiring +------ + +You will need the following items: + * `Raspberry Pi Debug Probe`_ + * JST cable: 3-pin JST connector to 3-pin JST connector cable + * USB cable: USB A male - Micro USB B male + +Use the JST cable to connect the Raspberry Pi Debug Probe UART port to the Raspberry Pi 5 UART port between the HDMI ports. + +Then connect the Raspberry Pi Debug Probe to your computer with a USB cable. + + +config.txt +---------- + +.. code-block:: text + + kernel=zephyr.bin + arm_64bit=1 + enable_uart=1 + uart_2ndstage=1 + + +zephyr.bin +---------- + +Build an app `samples/hello_world` + +.. zephyr-app-commands:: + :zephyr-app: samples/hello_world + :board: rpi_5 + :goals: build + +Copy `zephyr.bin` from `build/zephyr` directory to the root directory of the Micro SD card. + +Insert the Micro SD card into your Raspberry Pi 5. + + +serial terminal emulator +------------------------ + +When you power on the Raspberry Pi 5, you will see the following output in the serial console: + +.. code-block:: text + + *** Booting Zephyr OS build XXXXXXXXXXXX *** + Hello World! rpi_5/bcm2712 + + .. _Raspberry Pi 5 product-brief: https://datasheets.raspberrypi.com/rpi5/raspberry-pi-5-product-brief.pdf @@ -99,3 +156,6 @@ Insert the Micro SD card and power on the Raspberry Pi 5. And then, the STAT LED .. _bcm2712-rpi-5.dtb: https://github.com/raspberrypi/firmware/raw/master/boot/bcm2712-rpi-5-b.dtb + +.. _Raspberry Pi Debug Probe: + https://www.raspberrypi.com/products/debug-probe/ diff --git a/boards/raspberrypi/rpi_5/rpi_5.dts b/boards/raspberrypi/rpi_5/rpi_5.dts index 9033f91f9e..6fca0efd3d 100644 --- a/boards/raspberrypi/rpi_5/rpi_5.dts +++ b/boards/raspberrypi/rpi_5/rpi_5.dts @@ -21,6 +21,8 @@ chosen { zephyr,sram = &sram0; + zephyr,console = &uart10; + zephyr,shell-uart = &uart10; }; leds { @@ -36,3 +38,8 @@ &gio_aon { status = "okay"; }; + +&uart10 { + status = "okay"; + current-speed = <115200>; +}; diff --git a/boards/raspberrypi/rpi_5/rpi_5_defconfig b/boards/raspberrypi/rpi_5/rpi_5_defconfig index 0ecf409b6f..bc0375e812 100644 --- a/boards/raspberrypi/rpi_5/rpi_5_defconfig +++ b/boards/raspberrypi/rpi_5/rpi_5_defconfig @@ -3,3 +3,8 @@ CONFIG_ARM64_VA_BITS_40=y CONFIG_ARM64_PA_BITS_40=y CONFIG_TIMER_READS_ITS_FREQUENCY_AT_RUNTIME=y + +# Enable serial console. +CONFIG_SERIAL=y +CONFIG_CONSOLE=y +CONFIG_UART_CONSOLE=y diff --git a/dts/arm64/broadcom/bcm2712.dtsi b/dts/arm64/broadcom/bcm2712.dtsi index b9985e23e7..a31e8b21d1 100644 --- a/dts/arm64/broadcom/bcm2712.dtsi +++ b/dts/arm64/broadcom/bcm2712.dtsi @@ -67,5 +67,23 @@ status = "disabled"; }; }; + + uart10: serial@107d001000 { + compatible = "arm,pl011"; + reg = <0x10 0x7d001000 0x200>; + interrupts = ; + clocks = <&clk_uart>; + status = "disabled"; + }; + + }; + + clocks { + clk_uart: clk_uart { + compatible = "fixed-clock"; + clock-frequency = <44236800>; + #clock-cells = <0>; + }; }; };