These commands should just work. Either it's a hardware problem or you're corrupting the filesystem with your writes to it. Alas this is quite probable.
Unless you take steps to stop them Pyboards expose the filesystem to the PC using the USB MSC mode. This is problematic because, from the PC's point of view, it expects a mass storage device to be dumb, like a USB stick. If the Pyboard writes to it (which you are trying to do) corruption commonly occurs. This is a basic property of MSC mode.
The solution - and I do this on all Pyboards on first use - is to edit boot.py to disable MSC mode. Then use Dave Hylands'
rshell module to communicate with the Pyboard and manage the filesystem.
Here is the relevant part of my boot.py with the MSC line commented out and replaced:
Code: Select all
#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
pyb.country('GB') # ISO 3166-1 Alpha-2 code, eg US, GB, DE, AU
pyb.usb_mode('VCP')
#pyb.usb_mode(None)