2007-08-13 01:21 AM
2007-08-09 10:41 PM
I need to write in the data flash, and I can do it only from RAM
1st solution : I'll put all the code in RAM How to load code from flash to ram? I read in one datafile that (8150.pdf) : - the mechanism consisting in loading a user code in RAM is fully defined by ST. Where can I have this? 2nd solution : to put the FLASH function in ram for this I'm using : #define RAM_FUNC __attribute__((long_call,section(''.ramsection''))) and in ram.ld I'm defining the ramsection But the problem is when I'm switching off the system and swithing ON the software, the code in ram is lost(normal because it is not in flash). How can I put this part of software in ram but to keep store during switching OFF Thanks2007-08-10 01:58 AM
Hi ch2;
Could you attach the linker you're using in order to verify if something is wrong? :-] I thing the loop for Copying the data from FLASH to RAM doesn't copy the ramsection you're using. Follows the code which copies the data from FLASH to RAM:Quote:
/* ;copy the initial values for .data section from FLASH to RAM */
ldr R1, =_sidata /* provided by linker*/ ldr R2, =_sdata /* provided by linker*/ ldr R3, =_edata /* provided by linker*/ _reset_inidata_loop: cmp R2, R3 ldrlO R0, [R1], #4 strlO R0, [R2], #4 blO _reset_inidata_loop and here how should be the Section declaration in the linker: first,Quote:
.data : AT ( _sidata ) { _sdata = . ; *(.data .data.*) *(.gnu.linkonce.d.*) . = ALIGN(4); *(.ramsection .ramsection.*) } >RAM . = ALIGN(4); _edata = .; or ,Quote:
.data : AT ( _sidata ) /* AT : load region: means load at _sidata address in the flash */ { . = ALIGN(4); _sdata = . ; *(.data) . = ALIGN(4); _edata2 = . ; } >RAM .ramsection : { . = ALIGN(4); _sdata2 = . ; *(.ramsection) . = ALIGN(4); _edata = . ; } >RAM Personally I prefer the last solution but the first works as well. :o Best regards, MBS [ This message was edited by: MBS on 10-08-2007 14:39 ]2007-08-13 01:21 AM
thanks