<div dir="ltr">New patch sent with new changes. <br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 7 Oct 2022 at 10:30, Mohd Noor Aman <<a href="mailto:nooraman5718@gmail.com">nooraman5718@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This patch adds the relevant documentations required for booting the new BSP.<br>
JTAG support is added for debugging. I have built the HTML docs and verified<br>
them.<br>
---<br>
 user/bsps/aarch64/raspberrypi4.rst | 111 +++++++++++++++++++++++++++++<br>
 user/bsps/bsps-aarch64.rst         |   1 +<br>
 2 files changed, 112 insertions(+)<br>
 create mode 100644 user/bsps/aarch64/raspberrypi4.rst<br>
<br>
diff --git a/user/bsps/aarch64/raspberrypi4.rst b/user/bsps/aarch64/raspberrypi4.rst<br>
new file mode 100644<br>
index 0000000..b36d47b<br>
--- /dev/null<br>
+++ b/user/bsps/aarch64/raspberrypi4.rst<br>
@@ -0,0 +1,111 @@<br>
+.. SPDX-License-Identifier: CC-BY-SA-4.0<br>
+<br>
+.. Copyright (C) 2022 Mohd Noor Aman<br>
+<br>
+.. _BSP_aarch64_Raspberrypi_4:<br>
+<br>
+Raspberry Pi 4B<br>
+===============<br>
+<br>
+The 'raspberrypi4b' BSP currently supports only the LP64 ABI. ILP32 is not<br>
+supported. Raspberry pi 4B all variants and Raspberry Pi 400  are supported. The<br>
+default bootloader which is used by the Raspbian OS or other OS can be used to<br>
+boot RTEMS. SMP is currently not supported. <br>
+<br>
+Raspberry Pi 4B has 2 types of interrupt controller, GIC-400 (GICv2) and ARM<br>
+legacy generic controller. Both are supported. By default, raspberrypi 4B uses<br>
+ARM legacy generic controller. Set ``enable_gic=1`` in the ``config.txt`` file<br>
+to enable GIC.<br>
+<br>
+Clock Driver<br>
+------------<br>
+<br>
+The clock driver uses the `ARM Generic Timer`. <br>
+<br>
+Console Driver<br>
+--------------<br>
+<br>
+Raspberry pi 4B has 2 types of UARTs, ARM PL011 and Mini-uart. The PL011 is a<br>
+capable, broadly 16550-compatible UART, while the mini UART has a reduced<br>
+feature set. The console driver supports the default Qemu emulated ARM PL011<br>
+PrimeCell UART as well as the physical ARM PL011 PrimeCell UART in the<br>
+raspberrypi hardware. Mini-uart is not supported.<br>
+<br>
+Preparing to boot<br>
+------------------<br>
+<br>
+Raspberry Pi uses a different mechanism to boot when compared with any ARM SoC.<br>
+First the GPU initializes, loads the bootloader (Raspberry pi firmware) and then<br>
+looks for the kernel img. This whole process is done by the GPU (VideoCore IV)<br>
+till the kernel is loaded. More information can be found on the `Raspberry pi<br>
+documentation page<br>
+<<a href="https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#boot-sequence" rel="noreferrer" target="_blank">https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#boot-sequence</a>>`_.<br>
+By default the arm64 mode looks for the ``kernel8.img``. Any other kernel can be<br>
+loaded by adding ``kernel=<img_name>`` to the ``config.txt`` file.<br>
+<br>
+The Firmware files are required in order to boot RTEMS. The latest firmware can<br>
+be downloaded from the `Raspberry Pi Firmware Repository<br>
+<<a href="https://github.com/raspberrypi/firmware/" rel="noreferrer" target="_blank">https://github.com/raspberrypi/firmware/</a>>`_. USB boot is supported. All the<br>
+files (Firmwares and kernel) must be place in the FAT32 partition only. Add<br>
+``arm_64bit=1`` in the ``config.txt`` file in order to boot the BSP in 64bit<br>
+kernel mode. <br>
+<br>
+<br>
+UART Setup<br>
+^^^^^^^^^^<br>
+<br>
+Connect your serial device to the GPIO15 and GPIO14. Add the following to the<br>
+``config.txt`` file in order to use the PL011 UART0 and thus disabling the<br>
+default Mini-uart.<br>
+<br>
+.. code-block:: none<br>
+<br>
+  # if user wants to enable GIC, uncomment the next line<br>
+  # enable_gic=1<br>
+  arm_64bit=1<br>
+  dtoverlay = disable-bt<br>
+  enable_uart=1<br>
+<br>
+.. note:: <br>
+  The Raspberry Pi 4B and 400 have an additional four PL011 UARTs. They are not <br>
+  supported.<br>
+<br>
+Generating kernel image <br>
+^^^^^^^^^^^^^^^^^^^^^^^<br>
+<br>
+The following steps show how to run ``hello.exe`` on the BSP. Other executables<br>
+can be processed in a similar way.<br>
+<br>
+To create the kernel image:<br>
+<br>
+.. code-block:: shell<br>
+<br>
+  $ aarch64-rtems@rtems-ver-major@-objcopy -Obinary hello.exe kernel8.img<br>
+<br>
+Copy the kernel image to the SD card.<br>
+<br>
+JTAG Setup<br>
+----------<br>
+<br>
+The Raspberry Pi 4 doesn't have dedicated JTAG pins. Instead, you must configure<br>
+the GPIO pins (GPIO22-GPIO27) to activate the JTAG functionality. The RPi 4<br>
+documentation refers to this as Alt4 functions of those pins. Alt5 does exist<br>
+too, which goes from GPIO4, 5, 6, 12 and 13. you can check this out from<br>
+`<a href="http://pinout.xyz" rel="noreferrer" target="_blank">pinout.xyz</a> <<a href="https://pinout.xyz/pinout/jtag#" rel="noreferrer" target="_blank">https://pinout.xyz/pinout/jtag#</a>>`_ or `eLinux<br>
+<<a href="https://elinux.org/RPi_BCM2835_GPIOs" rel="noreferrer" target="_blank">https://elinux.org/RPi_BCM2835_GPIOs</a>>`_<br>
+<br>
+One more thing to note on JTAG with Raspberry pi 4B is that, by default, All the<br>
+GPIO pins are pulled down, according to the `BCM2711 documentation<br>
+<<a href="https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf" rel="noreferrer" target="_blank">https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf</a>>`_. This<br>
+wasn't the case in the earlier models. So in order to let the data flow freely,<br>
+we will have to disable them.<br>
+<br>
+.. code-block:: none<br>
+<br>
+  # Disable pull downs<br>
+  gpio=22-27=np<br>
+<br>
+  # Enable jtag pins (i.e. GPIO22-GPIO27)<br>
+  enable_jtag_gpio=1<br>
+<br>
+<br>
diff --git a/user/bsps/bsps-aarch64.rst b/user/bsps/bsps-aarch64.rst<br>
index 933370f..f3aa15c 100644<br>
--- a/user/bsps/bsps-aarch64.rst<br>
+++ b/user/bsps/bsps-aarch64.rst<br>
@@ -9,3 +9,4 @@ aarch64 (AArch64)<br>
 .. include:: aarch64/a72.rst<br>
 .. include:: aarch64/xilinx-versal.rst<br>
 .. include:: aarch64/xilinx-zynqmp.rst<br>
+.. include:: aarch64/raspberrypi4.rst<br>
\ No newline at end of file<br>
-- <br>
2.38.0<br>
<br>
</blockquote></div>