Hello,
I was converting the GNU linker script for the DIAB compiler. In the main program I have need a section that operates from RAM but gets initialised by start-up code to an initial value from flash. I have the section like that in GNU:
.my_section ORIGIN( RAM_ADDR ) :
{
KEEP (*(.my_section ))
} > RAM_ADDR AT > ROM_ADDR
For DIAB, I try this code, but when I run the program try to read this section, the program block. The code for DIAB is this:
.my_section LOAD (ADDR(ROM_ADDR)):
{
KEEP(*(.my_section ))
} > RAM_ADDR
Can someone help me please?
Thanks
The ram memoy is define in the MEMORY block from the begining like this:
MEMORY
{
flash_rchw : org = 0x00F98000, len = 0x04
cpu0_reset_vec : org = 0x00F98004, len = 0x04
m_text : org = 0x00F98408, len = 288K - 0x4 - 0x04
ROM_ADDR: org = 0x01000000, len = 0x10
m_data : org = 0x40000000, len = 384K
RAM_ADDR: org = 0x50800000, len = 0x10
local_dmem : org = 0x50800010, len = 64K - 0x10
}
This section is properly initilize in the startup. And when I'm debugging the error is always came when i try to reads or write the variable that I define in my_section like this:
uint32_t __attribute__((section(".my_section " ))) variable;
Thanks for the help
Hello Ekaitz,
Your linker snippent seems to be ok.
I've attached an example of an entire diab linker file for MPC5744P.
If your section is not initialized properly or an exception occurs before reaching main() I'd suggest to stop the exectuon of the application at entry point and check that the start address of your custom section in ROM matches in memory view (dump).
Also I'd debug the startup copy-down routine - block addresses, block sizes...to identify where a problem occurs.
Hope it helps.
Stan
Thanks,
I alredy have this example.
I have been doing more tests and I have not a solution.
With the first solution I realise that in the console in the compilation appeared this warning:
warning: Section '.my_section' is not allocable, '> RAM_ADDR' specification is ignored
Yes, is defined in the MEMORY in the linker script like that:
MEMORY
{
flash_rchw : org = 0x00F98000, len = 0x04
cpu0_reset_vec : org = 0x00F98004, len = 0x04
m_text : org = 0x00F98408, len = 288K - 0x4 - 0x04
ROM_ADDR: org = 0x01000000, len = 0x10
m_data : org = 0x40000000, len = 384K
RAM_ADDR: org = 0x50800000, len = 0x10
local_dmem : org = 0x50800010, len = 64K - 0x10
}
SECTIONS
{
.....................
.my_section LOAD (ADDR(ROM_ADDR)):
{
KEEP(*(.my_section ))
} > RAM_ADDR
..........
}
Thanks for the help