cancel
Showing results for 
Search instead for 
Did you mean: 

internal flash

ham10za
Associate II
Posted on February 19, 2018 at 09:57

hello! i am working with stm32 cortex-M0? IN FACT i want to know how to modify bytes from the internal flash without erasing the whole page , in addition i don't have RAM space to copy code there and modify bytes there !! is there anyone who can help ?

Note: this post was migrated and contained many threaded conversations, some content may be missing.
29 REPLIES 29
Posted on February 19, 2018 at 13:49

Again - that's step, not goal!

Why do you 'need' to do that?

Posted on February 19, 2018 at 13:57

If it's a small amount of data you can treat the sector as a write only log. Depending on your needs, the required RAM buffer can be tiny. I used this approach for my persistent store. It's basically a series of key-value pairs. Write changes to the unused section at the end. No need to store anything at an explicit address - just scan the store to find the latest record for a given key.

You'll need to handle the case when the sector gets full (of mostly old junk). Using two sectors is a simple solution for this.
Posted on February 19, 2018 at 14:01

No, you don't have to erase the entire page every time you do an update - as

Chambers.Alan

‌ described:

https://community.st.com/0D50X00009XkWg8SAF

This is kind of like how hard drives work; you keep a 'map' of where the free space is; you only need to erase when you're out of free space.

Again, ST have app notes on this kind of thing ...

EDIT

For app notes, look on the Product Page; eg,

http://www.st.com/content/st_com/en/products/microcontrollers/stm32-32-bit-arm-cortex-mcus/stm32-mainstream-mcus/stm32f0-series/stm32f0x0-value-line/stm32f030c6.html

Posted on February 19, 2018 at 14:05

It seems like the sector/page is already used:

i want just to store some bytes on one page on the internal flash without dammaging other bytes on the same page

your solution requires using another Page for that purpose. 

Posted on February 19, 2018 at 14:07

Well, if you want to update the same amount of byte at the same location, you have to erase first the entire page no?

Posted on February 19, 2018 at 14:11

Did you read Alan's description?

Posted on February 19, 2018 at 14:12

Yes, it requires setting aside 1 sector as the '

write only log' - as described.

EDIT

Page ('sector') size is only 1KB for STM32F030x4/6/8 devices

Posted on February 19, 2018 at 14:19

Well, the OP has not said what the other data is. I hope he is not attempting to modify a sector containing application code or something like that.

Posted on February 19, 2018 at 14:24

Yes, I read it. But he assumed that the person who asked the question has at least 1 free page left.

Posted on February 19, 2018 at 14:29

That's fair. In fact, two pages. The OP said he was short of RAM, but not flash. It would be helpful if he told us more. What is this other data that must not be disturbed?