<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Dec 15, 2019 at 10:15 PM Christian Mauderer <<a href="mailto:list@c-mauderer.de">list@c-mauderer.de</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">Hello Niteesh,<br>
<br>
On 15/12/2019 09:05, Niteesh wrote:<br>
> I am trying to get RTEMS examples running on the RPI3, the RPI3 is<br>
> similar to RPI2 so the examples built for RPI2 should technically run on<br>
> the RPi3.But they don't :(, I am really sure of what is causing the problem.<br>
<br>
Note that there are at least two different versions of the RPi3 which<br>
use different chips. The original RPi3 which uses a BCM2837 (same like<br>
later versions of RPi2) and the RPi3+ which uses a BCM2837B0. Broadcom<br>
is always quite sparse with documentation so it's not easy to tell the<br>
differences. Which one do you have?<br></blockquote><div>I have Rpi3 model b v1.2 which uses BCM2837 SOC, in my bare-metal programming I used the </div><div>2835 doc as a reference because the only major difference these two SOC is the peripheral base address</div><div>offset. But this is arm cpu is also capable of executing in 64bit mode.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> I followed the steps<br>
> from <a href="http://alanstechnotes.blogspot.com/2013/03/running-your-first-rtems-program-on.html" rel="noreferrer" target="_blank">http://alanstechnotes.blogspot.com/2013/03/running-your-first-rtems-program-on.html</a> (modified<br>
> commands to use rtems5) to build the kernel img.<br>
<br>
It's a bit odd that the Bootloader doesn't use some image format like<br>
U-Boot but if that's the case for Raspberry, that's OK.<br></blockquote><div>Do you want me to try U-Boot, I was planning to use it for my bare-metal stuff because copying the kernel</div><div>to SD-card was a real pain. Will it even work with RTEMS? </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> I did try running it on<br>
> Qemu but it doesn't always work, sometimes it gives weird output.</blockquote></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
How did you run it on Qemu? Did you build some image for that too?</blockquote><div class="gmail_quote"><div>qemu-system-arm -M raspi2 -m 1G -kernel hello.exe -serial mon:stdio -nographic</div><b><div class="gmail_quote"><b><br></b></div>qemu-system-aarch64: GLib: g_mapped_file_unref: assertion 'file != NULL' failed </b>I get this error </div><div class="gmail_quote">while trying to emulate raspi3. </div><div class="gmail_quote"><br></div><div class="gmail_quote">I ran qemu along with GDB to find what was causing the wrong output. I am really not sure if this is right,</div><div class="gmail_quote">I still have a lot to learn, but my assumption's using GDB are as follows.</div><div class="gmail_quote">There are 4 active thread which run the same code.</div><div class="gmail_quote"><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_quote">(gdb) info thread<br> Id Target Id Frame <br>* 1 Thread 1.1 (CPU#0 [running]) _start () at ../../../../../../../../rtems/c/src/lib/libbsp/arm/raspberrypi/../../../../../../bsps/arm/shared/start/start.S:153<br> 2 Thread 1.2 (CPU#1 [running]) _start () at ../../../../../../../../rtems/c/src/lib/libbsp/arm/raspberrypi/../../../../../../bsps/arm/shared/start/start.S:153<br> 3 Thread 1.3 (CPU#2 [running]) _start () at ../../../../../../../../rtems/c/src/lib/libbsp/arm/raspberrypi/../../../../../../bsps/arm/shared/start/start.S:153<br> 4 Thread 1.4 (CPU#3 [running]) _start () at ../../../../../../../../rtems/c/src/lib/libbsp/arm/raspberrypi/../../../../../../bsps/arm/shared/start/start.S:153<br></div></blockquote><div>After some time one of the thread call's the BSP reset function this is when the program crashes, the other threads complain "<b>executing thread is NULL</b>"</div><div><br></div></div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px"><div class="gmail_quote"><div>*** FATAL ***<br>fatal source: 9 (RTEMS_FATAL_SOURCE_EXCEPTION)<br><br>R0 = 0x400005e6 R8 = 0x00000000<br>R1 = 0x00000001 R9 = 0x00000000<br>R2 = 0xbffffa1a R10 = 0x00000000<br>R3 = 0x00000000 R11 = 0x00000000<br>R4 = 0x002001db R12 = 0x00000000<br>R5 = 0x00000000 SP = 0x00300bd0<br>R6 = 0x00000000 LR = 0x00100fc4<br>R7 = 0x00000000 PC = 0x00100fc4<br>CPSR = 0x000001d3 VEC = 0x00000002<br>FPEXC = 0x40000000<br>FPSCR = 0x00000000<br>D00 = 0x0000000000000000<br>D01 = 0x0000000000000000<br>D02 = 0x0000000000000000<br>D03 = 0x0000000000000000<br>D04 = 0x0000000000000000<br>D05 = 0x0000000000000000<br>D06 = 0x0000000000000000<br>D07 = 0x0000000000000000<br>D08 = 0x0000000000000000<br>D09 = 0x0000000000000000<br>D10 = 0x0000000000000000<br>D11 = 0x0000000000000000<br>D12 = 0x0000000000000000<br>D13 = 0x0000000000000000<br>D14 = 0x0000000000000000<br>D15 = 0x0000000000000000<br>D16 = 0x0000000000000000<br>D17 = 0x0000000000000010<br>D18 = 0x0000000000000000<br>D19 = 0x0000000000000000<br>D20 = 0x0000000000000000<br>D21 = 0x0000000000000000<br>D22 = 0x0000000000000000<br>D23 = 0x0000000000000000<br>D24 = 0x0000000000000000<br>D25 = 0x0000000000000000<br>D26 = 0x0000000000000000<br>D27 = 0x0000000000000000<br>D28 = 0x0000000000000000<br>D29 = 0x0000000000000000<br>D30 = 0x0000000000000000<br>D31 = 0x0000000000000000<br>RTEMS version: 5.0.0.c6d8589bb00a9d2a5a094c68c90290df1dc44807-modified<br>RTEMS tools: 7.5.0 20191114 (RTEMS 5, RSB 83fa79314dd87c0a8c78fd642b2cea3138be8dd6, Newlib 3e24fbf6f)<br>executing thread is NULL</div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> The steps that I followed are:<br>
> 1. Created a bootable SD card using raspbian.<br>
> 2. Replaced the kernel.img file with RTEMS kernel.img file and modified<br>
> the config.txt to boot from the RTEMs kernel (boots in aarch32 bit mode).<br>
> I am still not able to wrap my head around the RPI bsp build process.<br>
> This is what I understood as of now, correct me if I am wrong. <br>
> Both RPi and Rpi2 are based on the same BSP, they just differ in the<br>
> peripheral offsets, hardcoded checks are used to select the right offset<br>
> at the time of compiling<br>
<br>
>From what I know of the Raspberry BSPs that is correct.<br>
<br>
> and the linkercmd file is responsible for<br>
> building the final executable file.<br>
<br>
The linkercmd file is - like for all programs - responsible where the<br>
memory regions are that can be used for code or data. So you could more<br>
or less explain it like you did.<br>
<br>
> I looked at the linker script, it seem's to have the start section at<br>
> address 0x200000, I also loaded it in GDB and the start address is<br>
> *Start address 0x200080,*<br>
<br>
I agree with that. The different start in GDB is most likely because<br>
there is a vector table in front (at least if the Broadcom chip is<br>
similar to a lot of other processors that I have encountered).<br>
<br>
Does that mean that you have a debugger connected to the raspberry? Can<br>
you load code with it? If yes: Is the bootloader executed before you<br>
load your code? Otherwise the SDRAM might isn't initialized yet.<br></blockquote><div>I don't have a debugger connected to it. I from what I have SDRAM is initialized by the 3 stage bootloader(start.elf). </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> I did some bare metal programming on RPI3<br>
> there I had the start section at address 0x8000 Is this causing the problem?<br>
<br>
I assume that you used some internal RAM when you did bare metal<br>
programming. You maybe even skipped one or two bootloader stages. From a<br>
quick look Raspberry has a quite complex boot process with at least<br>
three bootloaders: <a href="http://lions-wing.net/maker/raspberry-1/boot.html" rel="noreferrer" target="_blank">http://lions-wing.net/maker/raspberry-1/boot.html</a></blockquote><div>I don't think I have skipped any stages. The boot process is exactly the same as how it boot's a normal raspbian or any other linux</div><div>distro, I just to replace the linux kernel with my own kernel. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
> I have no idea on how to debug this, any suggestion on how to start<br>
> would be really helpfull. <br>
> <br>
</blockquote></div></div>