Just started working with a pyboard and when Py is run from Putty, this id string is on the top line:
MicroPython v1.9.3-6-g1742ab26 on 2017-11-02; PYBv1.1 with STM32F405RG
This on Windows 10.
Following the steps micropython.org "Running your first script" and when I get to this section:
2.4. Resetting the pyboard
To run this little script, you need to first save and close the main.py file, and then eject (or unmount) the pyboard USB drive. Do this like you would a normal USB flash drive.
The pyboard USB will NOT eject or unmount! I tried USB_DISK_EJECT, and it says can't be ejected as a file is open. I've tried endless combinations things and just cannot get that pyboard to eject.
When trying from Windows I get a message like this:
"uPy microSD Flash USB Device' device is not removeable..."
Where am I going wrong?
Can't eject/unmount pyboard as USB drive
Re: Can't eject/unmount pyboard as USB drive
Make sure that you don't have an explorer window open showing the contents of the sdcard or a command line where the current directory is inside the sdcard. Either of these can cause the eject to fail because directory (a special type of file) is open from the sdcard.
Re: Can't eject/unmount pyboard as USB drive
Thanks Dave - I believe I really didn't understand the 3 boot modes - sorta have that now. In Safe mode I can access the file system from the PC. Is one green LED indicate a 'run' mode where the USB is dismounted? I've also managed to corrupt the boot.py, and learned how to do a system reset and get the basic files back. This environment seems have a lot of steps where something can go wrong. Also most info on the web relates to Python running on the desktop, so useful search results are sparse. But I soldier on!
Re: Can't eject/unmount pyboard as USB drive
The standard run mode, runs boot.py and main.py.
Whether you can access the filesystem from the PC depends on what boot.py does. The default boot.py looks like this: which doesn't call pyb.usb_mode, so it winds up using the default wihch is VCP+MSC, which allows access to the filesystem.
If you modified boot.py to call pyb.usb_mode("VCP") then that would disable mass storage mode and you wouldn't be able to access the filesystem from the PC.
Accessing the filesystem from the PC can cause corruption of the filesystem as the USB Mass storage system was designed assuming that the PC would have exclusive access. However, if the MicroPython code tries to modify anything on the filesystem this breaks the "exclusivity" and you can get file corruption.
I normally disable mass storage, and use a tool I wrote called rshell to copy files into and out of the filesystem.
https://github.com/dhylands/rshell
Whether you can access the filesystem from the PC depends on what boot.py does. The default boot.py looks like this:
Code: Select all
# boot.py -- run on boot-up
# can run arbitrary Python, but best to keep it minimal\r\n"
import machine
import pyb
#pyb.main('main.py') # main script to run after this one
#pyb.usb_mode('VCP+MSC') # act as a serial and a storage device
#pyb.usb_mode('VCP+HID') # act as a serial device and a mouse
If you modified boot.py to call pyb.usb_mode("VCP") then that would disable mass storage mode and you wouldn't be able to access the filesystem from the PC.
Accessing the filesystem from the PC can cause corruption of the filesystem as the USB Mass storage system was designed assuming that the PC would have exclusive access. However, if the MicroPython code tries to modify anything on the filesystem this breaks the "exclusivity" and you can get file corruption.
I normally disable mass storage, and use a tool I wrote called rshell to copy files into and out of the filesystem.
https://github.com/dhylands/rshell
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Can't eject/unmount pyboard as USB drive
+1 for this approach. I think it's unfortunate that mass storage is enabled by default: it will bite you on the posterior sooner or later - as a corrupted boot.py testifies. Much better to use a tool like rshell which doesn't use USB mass storage mode.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.