cancel
Showing results for 
Search instead for 
Did you mean: 

, IAP in stm32f429 (custom board and firmware)

harry anders
Associate II
Posted on February 19, 2018 at 12:45

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:

https://community.st.com/external-link.jspa?url=http%3A%2F%2Fwww.st.com%2Fen%2Fembedded-software%2Fstsw-stm32067.html

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).

7 REPLIES 7
ab val
Associate III
Posted on February 19, 2018 at 13:16

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. 

Posted on February 19, 2018 at 13:37

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.

Posted on February 19, 2018 at 13:48

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.  

voyvoda .
Senior
Posted on February 19, 2018 at 15:26

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();

Posted on February 19, 2018 at 16:03

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on February 21, 2018 at 07:59

Thanks I'll try these when I get the code up and running.

Posted on February 21, 2018 at 08:01

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.