cancel
Showing results for 
Search instead for 
Did you mean: 

Programming STM32L4 MCU's internal flash memory with sensor coefficients while keeping the firmware memory section intact

GDarr
Associate II

Hello,

This is the first time I am using the STM32 MCU.

I would like to know how can I re-flash a certain section of the internal flash memory (eg 1000h ~ 1200h) with NEW sensor coefficients while keeping the already flashed MCU firmware intact.

Can I use STVP-STM32 software to accomplish this? If yes, any tutorial documentation or code example for this?

Any other software (with GUI) recommendation to accomplish this request?

Many thanks in advance!

Best Regards,

Darren

7 REPLIES 7

Don't put this stuff in the midst of your firmware.

Shrink the size of the memory presented to the linker (via linker script, scatter file, GUI, etc), by 4KB or whatever amount of space your data consumes.

The put your data into page(s) at the END of the flash space, ie 0x0801F000

Access the data via a pointer, to an array or structure depending on the nature of the data.

Recognize when this data is blank so you can substitute defaults.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
GDarr
Associate II

Thank you for the response!

And yes, these data (coefficients) will be in a separate memory area.

For example, the firmware memory will be located in 0x00000000 ~ 0x00100000 (fixed)

Then the data (coefficient) will be located in 0x0800 0100 ~ 0x0800 0200 (just as you suggested)

Occasionally, due to sensor replacement or other factors, we might need to replace these coefficient data.

So, I need a way to re-flash this memory area ( 0x0800 0100 ~ 0x0800 0200 only) without re-flashing the whole Flash memory area which would eventually replace the whole firmware.

Thank you!

Best Regards,

Darren

Watch out. I don't know which stm32l4 you're using but on stm32l4x5 and stm32l4x6, memory from 0x00000000 to 0x000fffff might simply be an alias of the internal FLASH starting at 0x08000000.

It depends on your Boot/remap settings if you have external FLASH either connected over FSMC or QuadSPI.

And if your system does have external FLASH, it begs the question why not also have external EEPROM to store the coefficients?

Hope this helps,

Danish

That is not a "might be", but "it is".

Every reference manual has a memory map, where it's shown and written clearly.

It "might be", as it might be also RAM or the "ROM" 😉

JW

True, but for me it seems that OP is misunderstanding that area as another memory. Therefore in that context - "it is" only an alias, not a real memory. 🙂

GDarr
Associate II

Hello All,

Sorry for the late reply.

Yup. You guys are right... that area of memory is an alias of the internal flash memory.

For my case, I had not decided on the exact memory location to store the data yet. The information given above by me is just an assumption.

My main concern here is not really "where" to store the data, but "how" to reprogram/re-flash only a certain sector of internal flash memory location (where the data is located).

Can the software St Visual Programmer-STM32 achieve this?

(https://www.st.com/en/development-tools/stvp-stm32.html)

Many thanks again to all!!! 🙂

Best Regards,

Darren