2024-10-23 03:47 AM - last edited on 2024-10-23 03:50 AM by Andrew Neil
Hi,
I am working on a project that store the Configuration data of one device, It needs to be stored in specific section
static unsigned char myBuffer[4] __attribute__((section (".m_data_20000000"))) { 11, 22, 33, 44};
with this command I'm able to store it in Program-1
linker script of program-1
.m_data_20000000 :
{
. = ALIGN(4);
KEEP (*(.m_data_20000000*))
. = ALIGN(4);
} >FLASH
I have tried NOLOAD NOINIT it is not working...........what changes need to do in program-2
But now I want the stored myBuffer[4] data from Flash of stm32 which is stored previously by program-1, without erasing I want access of myBuffer[4] with program-2?
What changes I need to do in IAR and STM32Cube IDE for telling them not erase that section, I want access, what type of variable I need to declare in program-2 it is pointer or extern..........
Please Help me....
Solved! Go to Solution.
2024-10-24 03:49 AM
0x20000000 strikes me as a RAM address.
Perhaps use structures and a pointer to the structure. Hide an area of FLASH from the Linker so it doesn't touch or erase it. And then manage the space directly in the applications.
The EEPROM Emulation could work similarly just carve out common FLASH pages both use for this data. TBH that's likely overkill.for things like keys, serial numbers and calibration data.
2024-10-23 03:56 AM
So you want to:
Yes?
@Lucifer37 wrote:I have tried NOLOAD NOINIT it is not working...
What, exactly, is "not working" ?
STM32Cube IDE shouldn't erase more of the flash than it needs to - so, for the data to persist, you just have to make sure that it's outside the area that gets erased during programming.
You'd need to ask IAR what their tool does - but there should certainly be a way to configure this.
2024-10-23 04:12 AM
These problems I'm facing, how to access data through re-programming and it's getting erased how to stop it
should I use it as extern or coping through section address?
How to do it in STM IDE and IAR please send me recourses
2024-10-23 04:20 AM - edited 2024-10-23 04:25 AM
I answered the question about erasing.
One way to easily access it is to just have it at a fixed address, and access that address directly.
You haven't said what STM32 you're using, but that's exactly how the STM32F0 EEPROM emulation does it:
/* EEPROM start address in Flash */
#define EEPROM_START_ADDRESS ((uint32_t)0x0800F800) /* EEPROM emulation start address:
* Penultimate 1K page of a 64K flash
*/
https://community.st.com/t5/stm32-mcus-embedded-software/x-cube-eeprom-not-for-stm32f0/m-p/674820
PS:
Rather than use a Magic Number, the stm32f030x8.h file defines FLASH_BANK1_END...
2024-10-23 04:24 AM
I'm using STM32H745
2024-10-23 04:47 AM - edited 2024-10-23 04:47 AM
2024-10-23 05:03 AM
@Lucifer37 wrote:I'm using STM32H745
Which one?
https://www.st.com/en/microcontrollers-microprocessors/stm32h745-755.html
eg, for STM32H745xI/G:
https://www.st.com/resource/en/datasheet/stm32h745zg.pdf#page=22
2024-10-24 03:37 AM
Hi Andrew Neil,
I'm using STM32H745ZIT3.....I don't know you understood my requirement or not, This EEOPROM Emulation seems
different concept, it uses different approach like when power is off we able to access same data from same code
when re-program or dump new program-2 it will erase that config data
I'm using Linker script to store config data in specific region.......
Program-1
--------------------
| config data |
| store @ |
| 0x0800F000 |
| |
|linker can do |
|define sec |
| |
---------------
STM32 Flash
-------------------
| source code | 0x08000000
| |
| |
| code End |
| |
|-------------------|0x0800F000
| Config data |
-------------------|0x080FFFFF
Program-2
--------------------
|Access the |
| config data |
| store @ |
| 0x0800F000 |
| |
| |
| |
| |
-------------------
2024-10-24 03:49 AM
0x20000000 strikes me as a RAM address.
Perhaps use structures and a pointer to the structure. Hide an area of FLASH from the Linker so it doesn't touch or erase it. And then manage the space directly in the applications.
The EEPROM Emulation could work similarly just carve out common FLASH pages both use for this data. TBH that's likely overkill.for things like keys, serial numbers and calibration data.
2024-10-24 04:02 AM
@Lucifer37 wrote:This EEPROM Emulation seems different concept
I'm just using it as a known-working example of how to write data to Flash, and read that data back from Flash.
Those basic principles will be the same whether you code it yourself from scratch, or use the software pack.
The issue of erasing the flash during programming is entirely separate - that's just down to the programming tools that you use.
As already noted, STM32CubeIDE will only erase as much Flash as it needs for the code being programmed - so you need to make sure that wherever you put your data is outside that region (or regions).