2025-11-08 8:53 AM
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!
2025-11-08 9:37 AM
Rewrite is possible only on FFFF alone and only if flash isnt CRC based...
2025-11-08 10:13 AM - edited 2025-11-08 10:14 AM
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.
Other issue is that you must write in 64-bit segments. You can't write a single byte or 32 bits at a time.
This is possible on some chip families (for example, the STM32F4xx), but not the STM32C0.
2025-11-08 3:32 PM
It doesn't support knockdown to zero on the bits. The FLASH words are wider and contain ECC/Hamming bits.
2025-11-16 8:33 PM
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.
2025-11-16 10:33 PM
> 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.