How to define variable to external RAM?I am using K60 MQX4.1 CW10.4 GCC compiler.

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

How to define variable to external RAM?I am using K60 MQX4.1 CW10.4 GCC compiler.

1,106 Views
wxy
Contributor I

How to define variable to external RAM?I am using K60 MQX4.1 CW10.4 GCC compiler.

intflash.ld add

exram       (RW): ORIGIN = 0xA0000000, LENGTH = 0x00040000

and

.my_mram :

    {

. = ALIGN (0x4);

*(.vectors_exram)

. = ALIGN (0x4);

    } > exram

 

And then in my programs

__attribute__((section(".vectors_exram"))) uint8 test[100];

this is error!。

What do I do?

thanks

Labels (1)
0 Kudos
7 Replies

793 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

Hello:

Can you mention the specific error you receive? or share a screenshot?

The format you are using seems to be correct, so there should not be any errors, unless your program does not know uint8.


Regards!,
Jorge Gonzalez

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

793 Views
wxy
Contributor I

Can you give me  Example code? K60+CW10.4

0 Kudos

793 Views
wxy
Contributor I

Compiled without error.but it's error when download. If  Delete this definition,it can be downloaded.

0 Kudos

793 Views
Jorge_Gonzalez
NXP Employee
NXP Employee

In that case, try adding the NOLOAD command to your custom section in the intflash.ld like this:

.my_mram (NOLOAD):

    {

. = ALIGN (0x4);

*(.vectors_exram)

. = ALIGN (0x4);

    } > exram

-----------------------------------------------------------------------------------------------------------------------

Note: If this post answers your question, please click the Correct Answer button. Thank you!

-----------------------------------------------------------------------------------------------------------------------

0 Kudos

793 Views
wxy
Contributor I

Thank you very much again!

0 Kudos

793 Views
gorakk
Contributor IV

Just to add another note to this issue...

I am using CW10.6, GCC compiler, K61, and MQX4.1.1.  After changing the linker file to define an external RAM section the debugger starting giving this error:

"not allowed to access registers while running"

After adding the (NOLOAD) directive the problem went away.

Allen

0 Kudos

793 Views
wxy
Contributor I

Thank you very much!  I have resolved

it's error in following:

  .bss :
    {

...

.        __END_BSS = .;
        __bss_end__ = __END_BSS;
        . = ALIGN(0x10);
    } > ram

   .my_mram(NOLOAD):
    {
. = ALIGN (0x4);
*(.vectors_exram)
. = ALIGN (0x4);
    } > exram

    /* move "location counter" to next relocated address */
    . = ALIGN(0x10);

   .kernel_data :
    {
        __KERNEL_DATA_START = ALIGN(0x10);
    }
    .end_of_kernel_data :
    {
        __KERNEL_DATA_END = .;
        __KERNEL_AREA_END = .;
    } > end_of_kd

“   .my_mram(NOLOAD):

    {

. = ALIGN (0x4);

*(.vectors_exram)

. = ALIGN (0x4);

    } > exram

” 

It should be placed at the end;

For example:

.bss :

    {

...

.        __END_BSS = .;
        __bss_end__ = __END_BSS;
        . = ALIGN(0x10);
    } > ram

    /* move "location counter" to next relocated address */
    . = ALIGN(0x10);

   .kernel_data :
    {
        __KERNEL_DATA_START = ALIGN(0x10);
    }
    .end_of_kernel_data :
    {
        __KERNEL_DATA_END = .;
        __KERNEL_AREA_END = .;
    } > end_of_kd

   .my_mram(NOLOAD):

    {

. = ALIGN (0x4);

*(.vectors_exram)

. = ALIGN (0x4);

    } > exram

0 Kudos