-
Notifications
You must be signed in to change notification settings - Fork 31
Description
I've been using hex files created by the build system to test bug fixes to MicroPython. I had to move the file system higher in flash due to larger code from setting a different compiler optimisation/debug level. Later, I enlarged the file system. I had a glance at the MICROBIT.hex
file and I don't think it contains any data for the file system area. I believe this is unlike what's produced by the MicroPython editor in the browser as that's packaging up the python code.
The file system is fine if I just copy a few files in but if I modify them things eventually go wrong. I'm starting to suspect that the file system corruption I get after modifying files in a near full MicroPython filesystem is caused by
- absence of code in the interpreter which thoroughly checks for the presence and integrity of the MicroPython file system in flash and
- perhaps absence of code in the interpreter which does a full low level "format" if no valid file system is present and
- lack of an empty file system image in
MICROBIT.hex
produced by the build system.
My semi-informed guess here is the find_chunk_and_erase()
code can misbehave in some way when there's parts of flash that contain old bits of a file system with (nRF52 4k) pages in different places.
It looks like there's a chunk which has a marker
value (single byte length) of PERSISTENT_DATA_MARKER
. Is this chunk always present on flash storage? The extra space in this chunk could be used for superblock style file system metadata, at a minimum a large magic number, a version, file system length, chunk size would be useful.
(I see @jaustin has put some more general thoughts on file system stuff previously in #1 (comment) )