Content originally posted in LPCWare by rsmiech on Thu Feb 17 07:55:30 MST 2011
[FONT=Arial][SIZE=1]Hi All,[/SIZE][/FONT]
[FONT=Arial][SIZE=1]I was looking for the method to place consts at fixed location at the end of flash memory too.[/SIZE][/FONT]
[FONT=Arial][SIZE=1]I think that isn't unusual - CodeRedSupport ;).[/SIZE][/FONT]
[FONT=Arial][SIZE=1]This is very useful, especially if you want use onboard flash memory like EEPROM to store nonvolatile data. [/SIZE][/FONT]
[FONT=Arial][SIZE=1]My solution is:[/SIZE][/FONT]
[FONT=Arial][SIZE=1]ownlinkscripts adding (based on LPC1114):[/SIZE][/FONT]
[LEFT][FONT=Arial][SIZE=1]MEMORY[/SIZE][/FONT]
[FONT=Arial][SIZE=1]{[/SIZE][/FONT]
[FONT=Arial][SIZE=1]/* Define each memory region */[/SIZE][/FONT]
[FONT=Arial][SIZE=1]MFlash32 (rx) : ORIGIN = 0x0, LENGTH = 0x7000 /* 28k change avaiable flash to 32k - 4k*/[/SIZE][/FONT]
[FONT=Arial][SIZE=1]MFlash4 (rx): ORIGIN = 0x7000, LENGTH = 0x1000 /*declare 4k EEPROM used for store data at specified adress - here, last block of memory*/[/SIZE][/FONT]
[FONT=Arial][SIZE=1]RamLoc8 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x2000 /* 8k */[/SIZE][/FONT][/LEFT]
[FONT=Arial][SIZE=1]}[/SIZE][/FONT]
[LEFT][FONT=Arial][SIZE=1]/* Define a symbol for the top of each memory region */[/SIZE][/FONT]
[FONT=Arial][SIZE=1]__top_MFlash32 = 0x0 + 0x7000; /*change the top to 0x7000 */[/SIZE][/FONT][/LEFT]
[FONT=Arial][SIZE=1]__top_RamLoc8 = 0x10000000 + 0x2000;[/SIZE][/FONT]
[FONT=Arial][SIZE=1]/*[/SIZE][/FONT]
[LEFT][FONT=Arial][SIZE=1]/* place consts (EEPROM Data) at location */[/SIZE][/FONT]
[FONT=Arial][SIZE=1].eeprom : ALIGN(4)[/SIZE][/FONT]
[FONT=Arial][SIZE=1]{[/SIZE][/FONT]
[FONT=Arial][SIZE=1]KEEP(*(.eeprom*))[/SIZE][/FONT][/LEFT]
[FONT=Arial][SIZE=1]}>MFlash4[/SIZE][/FONT]
[FONT=Arial][SIZE=1]Example declaration in source code:[/SIZE][/FONT]
[FONT=Arial][SIZE=1]__attribute__ [/SIZE][/FONT][FONT=Arial][SIZE=1]((section(".eeprom"))) const struct structName = {init1,init2,init3,...} ;[/SIZE][/FONT]
[FONT=Arial][SIZE=1]or simply:[/SIZE][/FONT]
[FONT=Arial][SIZE=1]__attribute__ ((section(".eeprom"))) const type name = init;[/SIZE][/FONT]
[LEFT][FONT=Arial][SIZE=1]Regards[/SIZE][/FONT]
[FONT=Arial][SIZE=1]Rafal[/SIZE][/FONT][/LEFT]