2018-02-19 12:57 AM
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.2018-02-19 05:49 AM
Again - that's step, not goal!
Why do you 'need' to do that?
2018-02-19 05:57 AM
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.2018-02-19 06:01 AM
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,
2018-02-19 06:05 AM
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.
2018-02-19 06:07 AM
Well, if you want to update the same amount of byte at the same location, you have to erase first the entire page no?
2018-02-19 06:11 AM
Did you read Alan's description?
2018-02-19 06:12 AM
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
2018-02-19 06:19 AM
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.
2018-02-19 06:24 AM
Yes, I read it. But he assumed that the person who asked the question has at least 1 free page left.
2018-02-19 06:29 AM
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?