LINKER SCRIPT FOR DIAB

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LINKER SCRIPT FOR DIAB

2,658 Views
Ekaitz
Contributor II

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

0 Kudos
8 Replies

2,614 Views
stanish
NXP Employee
NXP Employee

In my opinion RAM_ADDR shall not be just a symbol but a memory block defined in MEMORY section.

Could you check how RAM_ADDR is defined?

0 Kudos

2,598 Views
Ekaitz
Contributor II

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

 

0 Kudos

2,634 Views
stanish
NXP Employee
NXP Employee

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

0 Kudos

2,630 Views
Ekaitz
Contributor II

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

0 Kudos

2,509 Views
stanish
NXP Employee
NXP Employee

Hello,

I'm not too familiar with diab toolchain, but is RAM_ADDR defined in MEMORY section of your linker file?

Perhaps I'd suggest you to contact Windriver support.

Stan

0 Kudos

2,505 Views
Ekaitz
Contributor II

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

0 Kudos

1,249 Views
sharhp
Contributor I

Hi @Ekaitz 

I believe you would have been able to get arund this error / warning. Could you please share your solution here?

Thanks,
Sharath

0 Kudos

1,224 Views
sharhp
Contributor I

Hi @Ekaitz 

Specifically, I am looking for a solution to overcome the following warning / error:

warning: Section '.my_section' is not allocable, '> RAM_ADDR' specification is ignored

Thanks,
Sharath

0 Kudos