cancel
Showing results for 
Search instead for 
Did you mean: 

Acces and modify a constant in flash memory

JCuna.1
Senior

I have the following trouble:

I am using a radio which needs a address and channel parameters, this is given in production phase. So I am planning to flash every board with this parameters modified each time before the board is flashed.

This parameters are loaded to the radio only the first time. Which means, after a reset the parameters should not be ​loaded.

So my idea is create 3 constant in code:

const uint8_t first_time = 0xff;

const uint8_t address = 0;

const uint8_t channel = 0;

My code at the beginning will ask for first time in order to recognize the 0xff value.

If(first_time == 0xff)

Then read parameters address and channel and load to radio.

Modify using half flash program the const first_time with 0 value, so the next time this process wont be execute.

The parameters address and channel will be changed by modifying the binary.​

Is this viable? ​

14 REPLIES 14

EEPROM emulation need at least two sector because this needs perform a erase operation. It is only available for sectors. So in stm32f411 is not viable ​

No work ok too with only one sector

Piranha
Chief II

Can you read those address and channel parameters from the radio? If yes, you can just read them at every boot and, if they are not at desired values, then reprogram.

Another bonus of this approach is that, if at some point the device is repaired and the radio is replaced, then the MCU will reprogram the new radio automatically.

I think I am having this problem with the STM32H723 MCU.

I am writing a flashword (32bytes) on the flash with some bytes to 0xFF. After a time, I want to change the value of the 0xFF bytes but I get a ECC double detection error.

But with a STM32F4 MCU I can do it.

So is it not possible on H7 family to write twice the same flashword without erasing it? Either to write with 0's??

Thank you for your help

> So is it not possible on H7 family to write twice the same flashword without erasing it? Either to write with 0's??

Correct.

https://www.st.com/resource/en/application_note/dm00623136-error-correction-code-ecc-management-for-internal-memories-protection-on-stm32h7-series-stmicroelectronics.pdf

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