cancel
Showing results for 
Search instead for 
Did you mean: 

Seperate file at flash memory

arunl4g
Associate II
Posted on June 15, 2015 at 13:57

hej 

i would like to keep some file in a seperate place at flash where linker dont use it when put the code in the flash.

i am using COIDE., stm32f407 discovery board.

Can anyone tell me how can i do that ?

thank you.  
9 REPLIES 9
Posted on June 15, 2015 at 14:13

i would like to keep some file in a separate place at flash where linker don't use it when put the code in the flash. i am using COIDE., stm32f407 discovery board.

Not sure I understand the question.

What sort of file, a source file, some data?

There's linker scripts, memory regions, and compiler level directives and #pragmas

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arunl4g
Associate II
Posted on June 15, 2015 at 14:31

clive,

what i meant was, 

i need to have some place to put some data and  after that i want to read or write a new value in that place. i want a space to be constant on the flash all the time. 

something similar like (''writeuserblock() or readuserblock() functions at rapid processor''). 

thank you 

Posted on June 15, 2015 at 14:49

Shrink the flash allocation in the linker script, and place your data into the space freed up at the end, say an 8K or 16K section depending on your needs, and the size of the flash blocks.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arunl4g
Associate II
Posted on June 15, 2015 at 15:42

i tried to do it but it still doesnot work..

my flash address is 

ORIGIN = 0x08000000

end = 0x080F FFFF   ......

LENGTH = 100000

i shrink 16kb : 3FFF

the below one is my space after shrinking;

rom (rx)  : ORIGIN = 0x08000000, LENGTH = 0x000FC001

i tried to write from address 0x080FC003 .....but it does not write anything.

can you help me to fix this problem ?...thank you 

Posted on June 15, 2015 at 16:28

That would be 0x4000

For the upper blocks of the F4 you have 128K (0x20000) size blocks, this is the minimum erase size. You should be able to write byte/word(s) using the usual FLASH commands. Please refer to the examples in the peripheral library as a starting point, and in a similar fashion as the OTP writes covered with you earlier.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arunl4g
Associate II
Posted on June 15, 2015 at 16:54

thank you clive a lot. 

i dont want to use  such a big space 128kb. so i tried to shrink the first 16kb of memory.

but the program does not work after shrink 16kb from 0x08000000.

after shrinking :

0x08004000 - orgin

length - FC001

i am using the same code as the OTP code..i can able to do it on OTP. but it doesnt work on this.

can u guide me whats wrong?...

qwer.asdf
Senior
Posted on June 15, 2015 at 17:21

As Clive said you can not shrink just 16KB from the end, the sectors in the end are 128KB in size, see this table from the reference manual:

Sector 0 0x0800 0000 - 0x0800 3FFF 16 Kbytes

Sector 1 0x0800 4000 - 0x0800 7FFF 16 Kbytes

Sector 2 0x0800 8000 - 0x0800 BFFF 16 Kbytes

Sector 3 0x0800 C000 - 0x0800 FFFF 16 Kbytes

Sector 4 0x0801 0000 - 0x0801 FFFF 64 Kbytes

Sector 5 0x0802 0000 - 0x0803 FFFF 128 Kbytes

Sector 6 0x0804 0000 - 0x0805 FFFF 128 Kbytes

.

.

Sector 11 0x080E 0000 - 0x080F FFFF 128 Kbytes

This

http://www.st.com/web/en/catalog/tools/PF257902

may also help you.
Posted on June 15, 2015 at 17:54

0x100000 - 0x4000 = 0xFC000

You can't put data at 0x08000000, you have to place at least two vectors there for the part to start properly. I'd put a boot loader there, and then use the 16 KB blocks (sectors) after that for configuration data.

You could push the application code to start at 0x08008000, 0x0800C000, or 0x08010000 depending on your actual requirements.

You could skip the boot loader / application configuration, but this would require you carve a hole in the memory space the linker uses, and complicates things. I've covered this in numerous threads before, so you could review some of those.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arunl4g
Associate II
Posted on June 16, 2015 at 09:52

thank you again clive, 

i could put the application code to the address which u mentioned. but i dont know about boot loader as i am very new to this. where can i find the bootloader and change the start address?

could you give procedure or put some sample.