Flash corruption after failed file copy with rshell #15202
-
Port, board and/or hardwareSTM32 @ v1.22.2 MicroPython versionMicroPython v1.22.2 on 2024-04-16; [REDACTED]_[gt48468c1] with STM32G474 This is a custom board definition for a product with intellectual property. The STM32 version is STM32G473VET3. This is the mpconfigboard.mk:
Reproduction
Example of corrupted flash resulting in less available space: >>> import os
>>> statvfs_data = os.statvfs('/flash')
>>> f_frsize, f_blocks, f_bfree = (
... statvfs_data[1],
... statvfs_data[2],
... statvfs_data[3],
... )
>>> fs_total_size = f_blocks * f_frsize
>>> fs_total_size_kB = fs_total_size / 1024
>>> fs_free_size = f_bfree * f_frsize
>>> fs_free_size_kB = fs_free_size / 1024
>>> fs_total_size_kB
143.0
>>> fs_free_size_kB
53.0 After erasing flash and re-flashing micropython v1.22.2 (main.py and boot.py are present in `/flash/ directory): >>> import os
>>> statvfs_data = os.statvfs('/flash')
>>> f_frsize, f_blocks, f_bfree = (
... statvfs_data[1],
... statvfs_data[2],
... statvfs_data[3],
... )
>>> fs_total_size = f_blocks * f_frsize
>>> fs_total_size_kB = fs_total_size / 1024
>>> fs_free_size = f_bfree * f_frsize
>>> fs_free_size_kB = fs_free_size / 1024
>>> fs_total_size_kB
143.0
>>> fs_free_size_kB
142.0 Expected behaviourHandle invalid flash writes to not corrupt flash Observed behaviourFlash corruption leading to decreased available flash size, in turn resulting in more write errors and more flash corruption. Additional InformationNo, I've provided everything above. Code of ConductYes, I agree Edit: add free size after erasing flash and re-flashing Micropython |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I'm converting this to a discussion because this is not a MicroPython bug: I and many others have used If you believe the bug is in |
Beta Was this translation helpful? Give feedback.
-
rshell is only using standard python calls to write data to the filesystem. So I would argue that the filesystem should be returning errors if it gets full and not corrupting itself. I certainly agree that it would be better if rshell did something like checked to see if there was enough available space, but the filesystem should be protecting itself. As such this should be reproducible using mpremote. |
Beta Was this translation helpful? Give feedback.
I'm converting this to a discussion because this is not a MicroPython bug:
rshell
is not an official MP utility.I and many others have used
rshell
extensively with STM32 without issue. I suggest you try the officially supportedmpremote
to determine whether the fault is withrshell
or with your hardware/port.If you believe the bug is in
rshell
you could report it here.