-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
rp2: FatFS filesystem is not recreated after erasing the flash. #15779
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you try to erase the flash by overwriting with 0xff either with the uploaded file for by using the write() or ioctl() methods of the block device. |
@robert-hh I tried with |
I don't have this exact board, but I couldn't reproduce this with an 8MB board I have: generated an 8MB file of zeroes, flashed with pictool the same way, and then loaded I have a couple of suggestions to try and narrow down which part of this process might be failing: First, after loading all zeroes, dump the flash back off and verify it's all zeroes:
Should see this:
Second, try manually importing the frozen _boot.py file that mounts and formats the flash. i.e. open a REPL and type If manually running _boot.py seems to succeed and the filesystem works after this, then something has gone wrong in the manifest and/or module freezing and maybe the |
@projectgus Thanks for testing! Note that this board uses FatFS not LFS2, I have a hunch that LFS2 can detect that there's no filesystem but fatfs can't.
Manually running |
@projectgus LFS2 works as expected; it detects invalid filesystem and recreates it automatically. FatFS fails to do so, even if MSC is disabled (it's unrelated but I thought I should rule out any issues with MSC). |
I think the problem is that for FAT, running Possible solutions:
|
I think I ran into this with my multi-MSC experiments, and rewrote Cutting out all my garbage, import vfs
import machine, rp2
# Try to mount the filesystem, and format the flash if it doesn't exist.
bdev = rp2.Flash()
try:
fs = vfs.VfsFat(bdev)
vfs.mount(fs, "/")
except:
vfs.VfsFat.mkfs(bdev)
fs = vfs.VfsFat(bdev)
vfs.mount(fs, "/")
del vfs, bdev, fs I don't know why I didn't raise a PR for this at the time! Edit:
I prefer this change since it more closely matches LittleFS. |
@dpgeorge @Gadgetoid I can fix |
This change helps detect if the filesystem is invalid, by also including the first mount attempt within the try-except. Then the FAT is reformatted if needed. Fixes issue micropython#15779. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This change helps detect if the filesystem is invalid, by also including the first mount attempt within the try-except. Then the FAT is reformatted if needed. Fixes issue micropython#15779. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This change helps detect if the filesystem is invalid, by also including the first mount attempt within the try-except. Then the FAT is reformatted if needed. Fixes issue micropython#15779. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
This change helps detect if the filesystem is invalid, by also including the first mount attempt within the try-except. Then the FAT is reformatted if needed. Fixes issue micropython#15779. Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
Port, board and/or hardware
rp2 port, Arduino Nano-RP2040
MicroPython version
MicroPython v1.24.0-preview.260.g09d070aa5
Reproduction
This particular board has a 16MBytes flash, 2MBytes of which are reserved for the firmware, the rest is for the filesystem. A write of about ~3MBs should be enough to erase the firmware + the filesystem's partition table, but I tested with 16MBytes:
Get the board in bootloader mode, with double tap (on Arduino board) or jumper on other boards etc.. then write the binary to flash (erasing everything):
After it's done, and reset, the ROM bootloader runs. Load MicroPython, for example:
Try to use the filesystem:
Expected behaviour
I expected it to detect that there's no valid filesystem and re-create it.
Observed behaviour
The board boots MicroPython, the storage device is mounted, however it doesn't have a valid filesystem now:
Additional Information
No, I've provided everything above.
Code of Conduct
Yes, I agree
The text was updated successfully, but these errors were encountered: