09202024

Last update2016/05/28 14:38

Back 現在地: Home パートナー Strategic Test パートナー Atollic 21.新しいメモリー領域のなかにコードを入れる

21.新しいメモリー領域のなかにコードを入れる

21.新しいメモリー領域のなかにコードを入れる

In TrueSTUDIO® you could do it in the following way:

Modify the .ld-linker script file’s memory regions. Let us take a look at an example of a linker script file containing the following memory regions:

MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 128K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 16K
MEMORY_B1 (rx) : ORIGIN = 0x60000000, LENGTH = 0K
}

User may add a new area by editing the file. In this example we add the IP-Code region.

MEMORY
{
FLASH (rx)      : ORIGIN = 0x08000000, LENGTH = 64K
IP_CODE (x) : ORIGIN = 0x08010000, LENGTH = 64K
RAM (xrw)       : ORIGIN = 0x20000000, LENGTH = 8K
MEMORY_B1 (rx)  : ORIGIN = 0x60000000, LENGTH = 0K
}

A bit further downin the script, between the .data { ... } and the .bss { ... } section you can place the following:

.ip_code :
{
*(.IP_Code*);
} > IP_CODE

This tells the linker to place all sections named .IP_Code* into the IP_CODE memory region which we specified to start at target memory address: 0x8010000.

In your C-code, you need to tell the compiler which functions should go to this section by adding __attribute__((section(".IP_Code"))) before the function declaration. Example:

__attribute__((section(".IP_Code"))) int placed_logic()
{
/* TODO - Add your application code here */
return 1;
}

This way the placed_logic() function will be placed in the IP_CODE memory region by the linker.