Skip to content

[nrf52840] Filesystem errors when virtual drive fills up #1627

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

Closed
uhrheber opened this issue Mar 9, 2019 · 5 comments
Closed

[nrf52840] Filesystem errors when virtual drive fills up #1627

uhrheber opened this issue Mar 9, 2019 · 5 comments

Comments

@uhrheber
Copy link

uhrheber commented Mar 9, 2019

Tested boards: pca10056, pca10059
Steps to reproduce the errors:

  • take a blank board, connect it to a computers USB, put a simple main.py on it (LED blink, or such) and run it
  • create a subdirectory on the virtual drive (e.g. /lib)
  • copy some CircuitPython libs into the subdir (a few 10kB of files are usually enough, but sometimes more is needed)

The following errors occur, sometimes immediately, sometimes after disconnecting and reconnecting the board from the USB:

  • script crashes and shows reading errors in main.py
  • all files on the virtual drive become read only
  • some files on the virtual drive become corrupted or deleted
  • the whole drive is wiped and appears freshly formatted

This happens with all 4.x beta releases, as well with self-compiled versions. Increasing the stack size doesn't help.

Could anybody please try to reproduce this? Maybe also on other boards?

@uhrheber
Copy link
Author

uhrheber commented Mar 14, 2019

BTW: How circuitpython is flashed doesn't make a difference.
I flashed boards directly with J-Link (without a bootloader), with the Adafruit UF2 bootloader, and with the Nordic DFU bootloader.

Also I noticed: When there's only a single main.py file, it seems to run stable. I have one board that runs like that since many weeks, and is plugged and unplugged several times a day.

But as soon as there are more files, and especially libraries in subdirectories, the drive gets wiped sooner or later.

@kevinjwalters
Copy link

What o/s including version is running on the host computer? Why does title mention "drive fills up"?

@uhrheber
Copy link
Author

I tested several host computers, with Windows 10 and Linux Mint 18.3/19.1. Same results.

"Drive fills up" means, the fuller the virtual drive gets (regardless what data, may be Python code, random test data), the more likely the read errors appear.

As I said, a single Circuitpython file may run without an error indefinitely, but as soon as you copy additional files to the virtual drive, the errors appear. If the drive is nearly full, the errors occur inevitably.

@kevinjwalters
Copy link

kevinjwalters commented Mar 15, 2019

That's interesting detail. I was only asking because a disk/storage device being completely full often causes various forms of mayhem and I wasn't sure if you were talking about 100% full or not.

@tannewt tannewt self-assigned this Mar 27, 2019
@tannewt
Copy link
Member

tannewt commented Mar 27, 2019

I'm unable to reproduce this with 94822ee built in debug mode on the PCA10056. I loaded it with JLink and then added a blinky code.py (below), made the lib folder and then dragged the lib folder over. I also copied the examples over. It was slow but didn't have errors.

Next I repeatedly ejected the drive, disconnected the usb data lines with an inline switch, reset circuitpython via GDB and verified I could still read files from the drive. Note I was on Mac OSX Mojave and made sure to eject the drive.

Both Windows and Linux may cache FS changes that may lead to file system corruption if CircuitPython is disconnected or reset before everything has been flushed by the OS. There is nothing we can do about this since it is done host-side. We encourage folks to "safely eject" before removal and use an editor that flushes immediately.

Please comment if you can reproduce this still with a finite set of steps.

code.py

import digitalio
import board
import time

led = digitalio.DigitalInOut(board.LED3)
led.direction = digitalio.Direction.OUTPUT
while True:
    led.value = not led.value
    time.sleep(0.1)

@tannewt tannewt closed this as completed Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants