Locating pointer table to specific RAM address

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Locating pointer table to specific RAM address

跳至解决方案
1,157 次查看
rmaier
Contributor III

How does one go about specifying a specific address for a variable (in my case pointer table)?

I can get the pointer table to be placed at the specific RAM address, but it is not initialized with the correct data (or any data?).

 

I start by adding a section in MEMORY

MEMORY
{
  FLASH_1      (RX)  : ORIGIN = 0x00000000LENGTH = 0x00000400
  FLASH_CONFIG (RX)  : ORIGIN = 0x00000400LENGTH = 0x00000010
  FLASH_2      (RX)  : ORIGIN = 0x00000410LENGTH = 0x0001BBF0
  CAL_FLASH    (RX)  : ORIGIN = 0x0001C000LENGTH = 0x00020000
  PTR_TABLE    (RW)  : ORIGIN = 0x1FFFF000LENGTH = 0x00000200
  SRAM         (RW)  : ORIGIN = 0x1FFFF200LENGTH = 0x00003E00
}

 

Then, I reserve the memory:

.ptrTable :  AT(__DATA_ROM)
  {
    . = ALIGN(4);
    _ptrTableSection = ./* create a global symbol at PtrTable */
    *(.ptrTable)
    . = ALIGN(4);
  } > PTR_TABLE

 

Finally, the romp:

.romp : AT(_romp_at)
  {
  __S_romp = _romp_at;
    
    LONG(__DATA_ROM);
    LONG(_ptrTableSection);
    LONG(SIZEOF(.ptrTable));
    LONG(__DATA_ROM + SIZEOF(.ptrTable));
    LONG(_sdata);
    LONG(___data_size);
    LONG(0);
    LONG(0);
    LONG(0);
  } > SRAM

 

For now, my work around is to define the pointer table as ROM data then copy this over at runtime manually to the RAM pointer table. There must be a better way of doing this. What am I doing wrong here?

Thanks,

Robert

 

 

0 项奖励
1 解答
1,138 次查看
jiri_kral
NXP Employee
NXP Employee

Hi, 

I'm afraid that you will need some routine for copying data from Flash vector table into RAM. Technically it is the very same process as initialized variables. 

 

The easiest way is left existing startup code and  move your RAM vector table into your section: 

jiri_kral_0-1619007620914.png

jiri_kral_1-1619007665110.png

Startup will copy data from Flash into RAM and setup VTOR register. 

 

Jiri 

 

 

 

在原帖中查看解决方案

0 项奖励
2 回复数
1,130 次查看
rmaier
Contributor III

Thanks for your help Jiri. Much appreciated.

 

Robert

0 项奖励
1,139 次查看
jiri_kral
NXP Employee
NXP Employee

Hi, 

I'm afraid that you will need some routine for copying data from Flash vector table into RAM. Technically it is the very same process as initialized variables. 

 

The easiest way is left existing startup code and  move your RAM vector table into your section: 

jiri_kral_0-1619007620914.png

jiri_kral_1-1619007665110.png

Startup will copy data from Flash into RAM and setup VTOR register. 

 

Jiri 

 

 

 

0 项奖励