cancel
Showing results for 
Search instead for 
Did you mean: 

How to use flash memory address for particular variables?

Mani1
Associate II

STM32F469I discovery board.

How to use internal flash memory address for a particular variables? it's possible ?

I am struggled with this issue.

i am beginner of stm32. help me.

1 ACCEPTED SOLUTION

Accepted Solutions
Yes, that makes much more sense.
See here how to add a linker section and put variables there:
https://www.openstm32.org/Using%2BCCM%2BMemory
Use QSPI memory address rather than CCMRAM as in the example.
If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

8 REPLIES 8

Not exactly clear what exactly you're trying to achieve here.

P​lacement of constant data, via attributes and linker script sections?

O​r writing semi-permanent data or configuration into section of the flash memory?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Mani1
Associate II

File: mani.c

unsigned short int FlashArray[8192] __attribute__ ((at((uint32_t)0x08004000)));

File :STM32F469NIHX_FLASH.id

.user_data (NOLOAD) :

{

. = ALIGN(4);

*(.user_data) /* .buffram section */

. = ALIGN(4);

} >FLASH

I'd probably avoid the AT method and use a C pointer method​, where you make a hole in the FLASH sections in the linker script, with an initial section for the vector table and some initialization code to be directed into.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thanks for your reply. I tried this logic also ,

main.c

const unsigned short int FlashArray[10] __attribute__((__section__(".user_data")));

File :STM32F469NIHX_FLASH.id

CCMRAM  (xrw)  : ORIGIN = 0x10000000,  LENGTH = 64K

 RAM  (xrw)  : ORIGIN = 0x20000000,  LENGTH = 320K

 FLASH  (rx)  : ORIGIN = 0x8000000,  LENGTH = 2048K 

 SDRAM (rw)   : ORIGIN = 0xC0000000, LENGTH = 16M

 QSPI (r)    : ORIGIN = 0x90000000, LENGTH = 16M

.user_data (NOLOAD) :

{

. = ALIGN(4);

*(.user_data) /* .buffram section */

. = ALIGN(4);

} >FLASH

TDK
Guru

Putting an uninitialized array into flash makes no sense. Flash cannot be used as RAM. You didn't answer Tesla's question on what you are trying to achieve.

If you feel a post has answered your question, please click "Accept as Solution".

I'd recommend sub-dividing this into 3 sections, one for the vectors, a hole for your data, and then the residual

FLASH  (rx)  : ORIGIN = 0x8000000,  LENGTH = 2048K 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Mani1
Associate II

can i allocate QSPI memory for my uninitialized array? instead of RAM?

Yes, that makes much more sense.
See here how to add a linker section and put variables there:
https://www.openstm32.org/Using%2BCCM%2BMemory
Use QSPI memory address rather than CCMRAM as in the example.
If you feel a post has answered your question, please click "Accept as Solution".