Skip to main content
SGian.1
Associate III
July 11, 2026
Solved

Flash and data

  • July 11, 2026
  • 2 replies
  • 92 views

Hi there !

I have a quick question about where the data are save. If i create one const array [1024] the data inside the array (because i write the word const in front) are save inside the falsh ? and this give to me more space in the ram  right ? and is the same if i create one struct and i acces with pointer ?  and please some one can help me and show where i can find all this kind of information like book tutorial website youtube ect

Thank you 

Sergio

Best answer by Khaled_DHIF

Hello ​@SGian.1 ,

Yes, in embedded C, const data is usually placed in flash, so it saves RAM. But this depends on the compiler/linker, so it’s not guaranteed by const alone.

A struct is different: where it is stored depends on how you declare it, not on whether you access it with a pointer. A pointer only gives access to the data; it does not move it to flash or RAM.

A good rule of thumb:

  • const data → often flash
  • non-const data → usually RAM
  • pointer → only an address

If you want to learn more, search for:

  • Memory layout (per MCU in the corresponding STM32 RM) 
  • linker script .data .bss .rodata (per compiler)

Kind regards, 

DHIF Khaled

2 replies

Khaled_DHIFBest answer
ST Employee
July 13, 2026

Hello ​@SGian.1 ,

Yes, in embedded C, const data is usually placed in flash, so it saves RAM. But this depends on the compiler/linker, so it’s not guaranteed by const alone.

A struct is different: where it is stored depends on how you declare it, not on whether you access it with a pointer. A pointer only gives access to the data; it does not move it to flash or RAM.

A good rule of thumb:

  • const data → often flash
  • non-const data → usually RAM
  • pointer → only an address

If you want to learn more, search for:

  • Memory layout (per MCU in the corresponding STM32 RM) 
  • linker script .data .bss .rodata (per compiler)

Kind regards, 

DHIF Khaled

"Please mark my answer as best by clicking on the “Accept as solution"" button if it fully answered your question. This will help other users find this solution faster.​"
SGian.1
SGian.1Author
Associate III
July 13, 2026

Thank you soo much , have a nice day 

 

Sergio