cancel
Showing results for 
Search instead for 
Did you mean: 

STM32C0 rewrite flash without erase

rous
Associate

Hey all,

I'm trying to get embedded Lua (https://eluaproject.net/) running on an STM32C0 MCU. The implementation has a Write Once Filesystem that uses flash and can be appended to but not modified.

The issue is that the WOFS relies on being able to write bits in flash as 0xFF or 1s with the expectation that it will be able to write over them later to set them to 0s (obviously not vice versa) For instance an 8 byte (smallest size supported by this flash?) write to address A with data FF FF FF FF 01 23 45 67, then later another write to address A with data AA FF FF FF 01 23 45 67. I think this is used to set flags on old files, like "deleted", and also to deal with the fact that the FS is designed around 4 byte, not 8 byte alignment.

This seems like it would be possible from a hardware perspective but HAL_FLASH_Program errors when I try it, is this something that is possible? Thank you! 

5 REPLIES 5
MM..1
Chief III

Rewrite is possible only on FFFF alone and only if flash isnt CRC based...

TDK
Super User

No, you can't write to a previously programmed address multiple times except if you are setting ALL bits within the 64-bit flash page to 0. Doing so will trigger a PROGERR error.

TDK_3-1762625549900.png

Other issue is that you must write in 64-bit segments. You can't write a single byte or 32 bits at a time.

TDK_4-1762625613439.png

 

This is possible on some chip families (for example, the STM32F4xx), but not the STM32C0.

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

It doesn't support knockdown to zero on the bits. The FLASH words are wider and contain ECC/Hamming bits.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Shirley.Ye
ST Employee

The STM32C0 reference manual section 3.3.6"The programming operation consists in writing ‘0’ to some bits of a previously erased double word (64 bits). The programming operation can only be performed on double words which have been previously erased. It is not possible to program a second time a double word without erasing it first."

The STM32C0 reference manual explicitly states that a double word can only be programmed once after an erase.
Any attempt to reprogram (even just 1→0) will result in a programming error.

KnarfB
Super User

I'm trying to get embedded Lua (https://eluaproject.net/) running on an STM32C0 MCU

The latest "news" on their website is from 2015. Roadmap says "coming soon" and "© 2011". Wiki seems dysfunctional. Looks like a Norwegian Blue parrot to me.