<div dir="ltr"><div>Hey Noor,</div><div>I probably have more questions than answers at this point, as I'm just learning how all of this works too. Some comments inline below:</div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Sep 4, 2022 at 6:13 AM 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-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hey,</div><div>Some doubts here:</div><div>1) On inspecting the raspberry pi 3 config table, I only seem to have 2 entries, one is for peripheral base, the other one for core local peripherals. I have updated the MMU with peripheral base, ARM local registers, and ARMC register. If I'm correct then, the Videocore should handle every address of uarts, spi and others, right? or am I missing something?</div></div></blockquote><div>Does the RAM need to be included? For example, the xilinx-versal BSP has an entry for RAM, but the xilinx-zynqmp does not.</div><div></div><div>The RT-Thread Memory/MMU table has more entries than we need for GIC/UART/Timer/RAM right now, but would those ranges cover the complete set of peripherals and RAM? I'm not sure why the memory entry they have only covers 100Mbytes of RAM:</div><div><a href="https://github.com/RT-Thread/rt-thread/blob/master/bsp/raspberry-pi/raspi4-64/driver/board.c#L25">https://github.com/RT-Thread/rt-thread/blob/master/bsp/raspberry-pi/raspi4-64/driver/board.c#L25</a><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>2) Raspberry pi 3 kernel starts from 0x200000 and the MMU is mapped starting from 0x100000. My question is if the aarch64 kernel starts from 0x80000, then where should the MMU start from? I'm assuming it does not start from 0x0 because my current code's MMU starts from that and it's very likely that this is causing problems.<br></div><div><br></div></div></blockquote><div>Figure 1 in the BCM2711 shows the different memory mapping modes:</div><div><a href="https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf">https://datasheets.raspberrypi.com/bcm2711/bcm2711-peripherals.pdf</a><br></div><div>I believe we should be looking at the one on the right "ARM view of the address map in low peripheral mode". The "ARM view" here shows the RAM at 0x0. Having the kernel at 0x80000 fits in this view. In other words, the ARM view has memory start at 0 and the kernel is loaded at the 0x80000 offset.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div>3) Any more suggestions? Glad to receive them.</div></div></blockquote><div>In the bsp.h file, I think the defines need to be changed:</div><div>#define BSP_RPI4_PL011_BASE 0x7e201000</div><div>should be</div><div>#define BSP_RPI4_PL011_BASE 0xFE201000<br></div><div>That matches what I see in RT-Thread, and makes sense given the following from the peripherals guide:</div><div>"If the VPU enables "Low Peripheral" mode then the ARM (only) has Main peripherals available from 0x0_FC00_0000 to 0x0_FF7F_FFFF and ARM Local peripherals available from 0x0_FF80_0000 to 0x0_FFFF_FFFF.<br></div><div>So a peripheral described in this document as being at legacy address 0x7Enn_nnnn is available in the 35-bit address space at 0x4_7Enn_nnnn, and visible to the ARM at 0x0_FEnn_nnnn if Low Peripheral mode is enabled."<br></div><div><br></div><div>So what about the GIC addresses?</div><div>In bsp.h you have:</div><div>#define BSP_ARM_GIC_CPUIF_BASE 0x08010000<br>#define BSP_ARM_GIC_DIST_BASE 0x08000000<br>#define BSP_ARM_GIC_REDIST_BASE 0x080A0000</div><div>In RT-Thread they use addresses starting at 0xFF840000 (I think..) Should these be offset as well?</div><div><br></div><div>Thanks,</div><div>Alan</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>Thanks,</div><div>Noor<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 3 Sept 2022 at 22:05, Alan Cudmore <<a href="mailto:alan.cudmore@gmail.com" target="_blank">alan.cudmore@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div><div lang="EN-US"><div><p class="MsoNormal">Hi Noor,</p><p class="MsoNormal">Nice blog entry on the JTAG setup. I ordered the FT232H board like yours to see if I can get the same setup working. I have my Pi 4 running the bare metal OS examples, and I have built your branch, so I hope to start looking at the code.</p><p class="MsoNormal">What needs to be in the MMU table? I see different entries in the Aarch64 BSPs. For example the Xilinx-versal BSP has entries for the GIC, peripherals, and memory. Can you cover RAM and I/O space on the Pi 4 with just one entry?</p><p class="MsoNormal">Looking at the RT-Thread OS, they have the following Pi4/Aarch64 MMU table:</p><p class="MsoNormal"><a href="https://github.com/RT-Thread/rt-thread/blob/master/bsp/raspberry-pi/raspi4-64/driver/board.c#L25" target="_blank">https://github.com/RT-Thread/rt-thread/blob/master/bsp/raspberry-pi/raspi4-64/driver/board.c#L25</a></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Alan</p><div style="border-color:rgb(225,225,225) currentcolor currentcolor;border-style:solid none none;border-width:1pt medium medium;padding:3pt 0in 0in"><p class="MsoNormal" style="border:medium none;padding:0in"><b>From: </b><a href="mailto:nooraman5718@gmail.com" target="_blank">Noor Aman</a><br><b>Sent: </b>Friday, September 2, 2022 2:18 PM<br><b>To: </b><a href="mailto:alan.cudmore@gmail.com" target="_blank">Alan Cudmore</a><br><b>Cc: </b><a href="mailto:heshamelmatary@gmail.com" target="_blank">Hesham Moustafa</a>; <a href="mailto:WKMoore@gmail.com" target="_blank">William Moore</a>; <a href="mailto:devel@rtems.org" target="_blank">rtems-devel@rtems.org</a><br><b>Subject: </b>Re: RPi 4B MMU seems to be enabled but throwing aarch64-default-exception error</p></div><p class="MsoNormal"><u></u> <u></u></p><div><div><p class="MsoNormal">Openocd connection is on my website. Here's the link to that. <a href="https://0xnoor.hashnode.dev/setup-openocd-with-jtag-uart-on-raspberry-pi-4-using-ft232h" target="_blank">https://0xnoor.hashnode.dev/setup-openocd-with-jtag-uart-on-raspberry-pi-4-using-ft232h</a></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">I pushed the code to my github repo. Be sure to checkout noor-dev branch. Here's the link for that. <a href="https://github.com/0xnoor/rtems" target="_blank">https://github.com/0xnoor/rtems</a></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">And yes the code looks bad as of now, I'll do optimization and everything soon. </p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Thanks</p></div></div><p class="MsoNormal"><u></u> <u></u></p><div><div><p class="MsoNormal">On Fri, 2 Sept 2022 at 23:31, Alan Cudmore <<a href="mailto:alan.cudmore@gmail.com" target="_blank">alan.cudmore@gmail.com</a>> wrote:</p></div><blockquote style="border-color:currentcolor currentcolor currentcolor rgb(204,204,204);border-style:none none none solid;border-width:medium medium medium 1pt;padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in"><div><p class="MsoNormal">Hi Noor,</p></div><div><p class="MsoNormal">Can you describe the setup you use for testing the BSP?</p></div><div><p class="MsoNormal">I can set up my Pi 4 to try running your code as you update it. How do you setup the OCD connection?</p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Thanks,</p></div><div><p class="MsoNormal">Alan</p></div><div><p class="MsoNormal"><u></u> <u></u></p><div><div><p class="MsoNormal">On Fri, Sep 2, 2022 at 11:48 AM Noor Aman <<a href="mailto:nooraman5718@gmail.com" target="_blank">nooraman5718@gmail.com</a>> wrote:</p></div><blockquote style="border-color:currentcolor currentcolor currentcolor rgb(204,204,204);border-style:none none none solid;border-width:medium medium medium 1pt;padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in"><div><div><p class="MsoNormal">Hey all,</p></div><div><p class="MsoNormal">Raspberry Pi 4B MMU seems to be enabled, as reported by openocd but gdb is showing to run in a loop from aarch64-defaulit-exception.S file starting from code line number 143 to 220.</p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">From what I can gather, it is being caused by the wrong MMU address.</p></div><div><p class="MsoNormal"> Here's a RAM and MMU allocation sizes and base</p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-family:"Comic Sans MS""> MEMORY {<br> RAM_MMU : ORIGIN = 0x0, LENGTH = (0x1000 * ${AARCH64_MMU_TRANSLATION_TABLE_PAGES})<br> RAM : ORIGIN = 0x80000, LENGTH = 1024M<br> }</span></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-family:Arial,sans-serif">Relevant Openocd info </span></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-family:"Comic Sans MS"">bcm2711.cpu0 halted in AArch64 state due to debug-request, current mode: EL1T<br>cpsr: 0x200003c4 pc: 0x8e208<br>MMU: enabled, D-Cache: enabled, I-Cache: enabled<br>Info : New GDB Connection: 1, Target bcm2711.cpu0, state: halted</span></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-family:"Comic Sans MS"">Any ideas?</span></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><span style="font-family:"Comic Sans MS"">Thanks,</span></p></div></div></blockquote></div></div></blockquote></div><p class="MsoNormal" style="margin-left:9.6pt"><span style="font-family:"Comic Sans MS"">Noor</span></p><p class="MsoNormal"><u></u> <u></u></p></div></div>
</div></blockquote></div>
</blockquote></div></div>