Re: Linker Script Issue When Porting To CC2538


Andy Ross
 

Tidy(chunhua) Jiang <tidyjiang(a)163.com> wrote (on Tuesday, January 03, 2017 10:59PM):
I'm porting zephyr to TI's CC2538 device family, but there is a
special user case —— customer configuration area(CCA/CCFG). CCA is
placed in the uppermost flash page, so the linker script would like
this:

MEMORY
{
FLASH (rx) : ORIGIN = 0x00200000, LENGTH = 0x0007FFD4
*FLASH_CCA (rx) : ORIGIN = 0x0027FFD4, LENGTH = 0x2C*
SRAM (wx) : ORIGIN = RAM_ADDR, LENGTH = RAM_SIZE
SYSTEM_CONTROL_SPACE (wx) : ORIGIN = 0xE000E000, LENGTH = 4K
SYSTEM_CONTROL_PERIPH (wx) : ORIGIN = 0x400FE000, LENGTH = 4K
}

Zephyr doesn't really have a facility for device-specific
modifications to linker scripts at the moment. The script that you
would need to modify is in
include/arch/arm/cortex_m/scripts/linker.ld. This is passed through
the C preprocessor and has access to all Kconfig symbols, so if you
had to you could #ifdef your changes there and submit them, but it
would be a little ugly and we should probably come up with something
cleaner.

Do you really need to do this with the linker? What are you trying to
place in this region? If it's a fixed set of data you could just do it
something like:

struct cca_rec {
int my_field1;
char my_field2[128];
/* ... */
};

#define CCA_REC ((struct cca_rec *)0x0027ffd4)

And then just dereference the symbols you would have put in that
region with CCA_REC->my_field1, etc...

It's much simpler to implement, and might do what you want without
requiring immediate surgery to our linker script generation.

Andy

Join devel@lists.zephyrproject.org to automatically receive all group messages.