Running RTEMS on a LEON2 from ROM
Mike Looijmans
mike.looijmans at topic.nl
Tue Jul 25 10:51:45 UTC 2017
On 25-07-17 12:13, Jiri Gaisler wrote:
> I haven't looked at this for a while, but I remember that the trap table
> usually sits in the beginning of the .text segment. RTEMS overwrites the
> trap entries at boot so if the trap table is in PROM, you will get a
> memory exception trap. To run from PROM, you will need to allocate a new
> trap table in RAM (4k aligned) and change the %tbr register to point to
> it. This has to be done early before the trap table is initialized by
Any hint on where this trap table allocation should happen in RTEMS code?
> RTEMS. An elegant way of doing this would be to place the trap table in
> a separate linker section, and then putting it to the desired place with
> a custom linker file. The %tbr register should then be initialized to
> the start of the trap table section.
Simplest would be to put the trap table at the start of RAM (which will always
have page alignment) and let the data segment follow on that.
Simply directing the table into the data segment would work as well, I guess,
the init code copies it on boot along with the rest of the initialized data then.
>
> To debug programs running in PROM, you must use the hardware breakpoints
> (if your leon2 supports it), The instruction trace buffer is also quite
> useful to track the origin of an error trap.
>
Good tip, hardware breakpoints do actually work, software don't.
> Jiri.
>
>
> On 07/25/2017 11:53 AM, Mike Looijmans wrote:
>> Has anyone ever succeeded in running an RTEMS program from ROM on a
>> LEON2 platform?
>>
>> I've so far only succeeded in running RTEMS applications by loading
>> them into RAM using the grmon2 debugger.
>>
>>
>> I'm setting up RTEMS to run on an FPGA platform, with a LEON2 softcore.
>>
>> The system has several megabytes of ROM and just 1 MB of RAM. So I
>> want the code to run from ROM and only have my precious data in the RAM.
>>
>> I setup the BSP linker script to generate to run (.text) at address 0,
>> and have the .data segment at 0x40000000 where the RAM starts.
>>
>> There was already code in leon2 start.S to accommodate for this, which
>> copies the data segment from ROM into RAM.
>>
>> I also had to add a few lines of LEON2 register initialization code,
>> since that appears to be something the LEON2 BSPs do not do by
>> themselves, they seem to rely on the debugger or emulator to do that,
>> or on the bootloader (like mkprom2 creates maybe).
>>
>> So on boot I set the stack pointer to 0x40100000 (end of RAM), and the
>> memory config and UART registers are setup properly for the hardware.
>> This was enough to run a "helloworld" bare metal application (without
>> RTEMS) that just outputs 1234... on the serial console.
>>
>> I'm now trying to run an RTEMS application this way, but somewhere
>> during RTEMS initialization it crashes on invalid memory access and
>> stops running. Attempts to debug with grmon2 so far don't help a lot,
>> I can step and run the program, but setting a breakpoint for example
>> doesn't actually work (maybe the debugger attempts to modify the ROM
>> code to insert a breakpoint?) Breaking the program only shows "Inside
>> trap/irq" and no backtrace at that point.
>>
>>
>>
>> Kind regards,
>>
>> Mike Looijmans
>> System Expert
>>
>> TOPIC Products
>> Materiaalweg 4, NL-5681 RJ Best
>> Postbus 440, NL-5680 AK Best
>> Telefoon: +31 (0) 499 33 69 79
>> E-mail: mike.looijmans at topicproducts.com
>> Website: www.topicproducts.com
>>
>> Please consider the environment before printing this e-mail
>>
>>
>>
>>
Kind regards,
Mike Looijmans
System Expert
TOPIC Products
Materiaalweg 4, NL-5681 RJ Best
Postbus 440, NL-5680 AK Best
Telefoon: +31 (0) 499 33 69 79
E-mail: mike.looijmans at topicproducts.com
Website: www.topicproducts.com
Please consider the environment before printing this e-mail
_______________________________________________
>> users mailing list
>> users at rtems.org
>> http://lists.rtems.org/mailman/listinfo/users
>
>
More information about the users
mailing list