2018-02-19 03:45 AM
I am writing a custom firmware for a stf32m429 MCU. I need about 128Kbytes of EEprom but the ECU has none. Due to security reasons I cannot use external eeprom chips. I was wondering if the following scenario is feasible:
While the code is normally being executed I receive some user input and then write this input to one of the MCU flash sectors that I am using as an internal EEPROM?
If this is possible, how do I implement this? I've been googling for a few hours and the only example google comes up with is IAP using UART:
I'm looking for a tutorial or something in the datasheet that explains any relevant IAP commands/registers etc. but I cannot find any!
P.S. The EEPROM data is rarely updated (maybe once evey 2-3 months and only a few bytes of it).
2018-02-19 04:16 AM
If this is possible, how do I implement this?
Yes you can use internal flash as a place to store data. But flash is not like eeprom. You have to erase first, then write. And if you have data already written and just want to update a part of it, you have to store that data into ram, then erase then write back with the updated values.
You can set up a UART communication for receiving new inputs.
2018-02-19 05:37 AM
I took a closer look at the datasheet and it seems IAP is only possible in dual-bank mode, where the main code is executed on one flash bank and is written on the other flash bank. But I still haven't found some appropriate example code.
2018-02-19 05:48 AM
I don't understand why you are talking about IAP ? Are you using it as an example to write some bytes to Flash ?
you can write in the bank where the code is being executed.
2018-02-19 06:26 AM
Hello, You can use the code example below.
The below code will write 0x00 at the address
0x08060000 which is the starting address of the sector 7 in the flash memory.
Every time you need to erase the sector by using FLASH_Erase_Sector() to write new data.
HAL_FLASH_Unlock();
FLASH_Erase_Sector(FLASH_SECTOR_7,VOLTAGE_RANGE_3);
HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD,0x08060000,0x00);HAL_FLASH_Lock();
2018-02-19 07:03 AM
You could use one of the 128KB Flash sectors at the end of memory. You'd want to shrink the FLASH size seen by the linker via the linker script or scatter file.
The ROM doesn't contain an IAP functions, you'd just use the FLASH Erase/Write functionality, there should be examples under the HAL/Cube Example trees.
2018-02-20 11:59 PM
Thanks I'll try these when I get the code up and running.
2018-02-21 12:01 AM
Yes that is what I had in mind: using one of the 128Kbyte sectors. It's my first time working with ST MCUs and I'm not familiar with HAL/Cube. I'll have to take a closer look at them. Thanks.