File disappears from sd card
Closed this issue · 2 comments
I've just had this occur, I think because I was using rshell concurrently with altering a file on the mounted sd card. I have two modules, testbox.py and orientate.py. The former imports the latter. orientate.py had been copied to the sd card earlier in the session at the rshell prompt. I also had the sd card mounted to facilitate editing main.py. The following listings are sequential.
This demonstrates that orientate.py is present on the card. testbox.py ran until interrupted:
>>> orientate.orientate(t, i, (0,1,2), (3,4,5), (6,7,8))
[(2, 1, 0), (5, 4, -3), (8, 7, -6)]
>>>
PYB: sync filesystems
PYB: soft reboot
Pete's dummy main function
Micro Python v1.4.3-61-g669dbca on 2015-05-28; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>> import testbox
(-26.4881, 21.41885, 86.31904)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "testbox.py", line 55, in <module>
File "/sd/lib/usched.py", line 198, in run
File "/sd/lib/usched.py", line 195, in run
File "/sd/lib/usched.py", line 221, in _runthreads
KeyboardInterrupt:
>>>
Then using a Linux editor I edited main.py on the mounted sd card to run testbox.py at power up.
>>>
/mnt/qnap2/data/Projects/MicroPython/micropython-fusion> repl
Entering REPL. Use Control-X to exit.
>>>
/mnt/qnap2/data/Projects/MicroPython/micropython-fusion> cat /sd/main.py
# Dummy main function
print("Pete's dummy main function")
#import schedtest
#schedtest.irqtest()
import testbox
The edit was successful. Now to prove it runs after a reboot:
/mnt/qnap2/data/Projects/MicroPython/micropython-fusion> repl
Entering REPL. Use Control-X to exit.
Micro Python v1.4.3-61-g669dbca on 2015-05-28; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>>
>>>
PYB: sync filesystems
PYB: soft reboot
Pete's dummy main function
Traceback (most recent call last):
File "main.py", line 5, in <module>
File "testbox.py", line 8, in <module>
ImportError: no module named 'orientate'
Micro Python v1.4.3-61-g669dbca on 2015-05-28; PYBv1.0 with STM32F405RG
Type "help()" for more information.
>>>
orientate.py has disappeared, confirmed by listing /sd and also listing the mounted directory in Linux. There seems to be a conflict between actions performed at the rshell prompt and those done in the mounted share. I can readily work round this but I thought it was worth raising the issue.
I've run into all kinds of issues when using USB Mass Storage, mostly because it wasn't designed to be accessed from 2 locations at the same time. It isn't really a bug in rshell. It's the fact the whoever writes last (the pyboard or the host) wins. And with UMS there is no way to coordinate 2 writers.
The most reliable method I've come up with is that I copy a file to USB Mass Storage, followed by the sync command. Then I do a Control-D on the pyboard and it will see the new file.
In order to make the host see new files created by the pyboard is more convoluted. I generally have to unmount the pyboard, have the pyboard create the file, and then remount the pyboard.
All of this is part of the motivation for creating rshell. If you're going to use rshell regularly, then you should probably outright disable USB Mass Storage by adding the line:
pyb.usb_mode('CDC')
to your boot.py file.
I suspected as much. I too have experienced oddities with USB mass storage but it's the first time I've had a file disappear. I'll follow your suggestion of disabling it.