flash read errors?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
hjf
Posts: 12
Joined: Sat Feb 27, 2016 3:47 am

flash read errors?

Post by hjf » Sat Mar 12, 2016 3:05 am

I'm having strange issues with an STM32F4 Discovery board. Microphython is installed and works, the device appears in Windows and I can write to it. But, for some reason, I get odd "syntax errors" where there is no syntax error. I have to reboot the board with Ctrl-D several times and then it will work. Or sometimes it just won't until I edit the file and add a newline somewhere and save again.

What's going on?

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: flash read errors?

Post by dhylands » Sat Mar 12, 2016 4:30 am

If you're sharing the file system using USB Mass Storage, then the host can wind up corrupting the filesystem.

hjf
Posts: 12
Joined: Sat Feb 27, 2016 3:47 am

Re: flash read errors?

Post by hjf » Sat Mar 12, 2016 5:14 am

I thought it was possible to do that? How should I test my code? Is it possible to disable USB mass storage for testing?

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: flash read errors?

Post by Roberthh » Sat Mar 12, 2016 6:09 am

Hello hij, you can disable USB Mass storage mode with the function pyb.usb_mode called in boot.py (see http://docs.micropython.org/en/latest/p ... t=usb_mode). You may also usw dhylands scripts rshell.py of pyboard.py, which do not use the mass storage mode, although i do not know whther they work on Windows. I have the same observations sometimes, but I'm using a Linux host. It's caused by the host updating the file system slowly. On Unix, I can force the update with the 'sync' command. I do not know whether something like that is available in Windows, at least not in the standard package. Unmounting the Micropython USB drive should work, but it's not comfortable.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: flash read errors?

Post by pythoncoder » Sat Mar 12, 2016 7:23 am

@dhylands, @Damien This issue crops up with great regularity. The Pyboard tutorial recommends a way of working which is frankly broken. Given that the cause is implicit in the USB mass storage specification it isn't going to get fixed. In my view it would be better if Pyboards were shipped with mass storage disabled by default, and the docs amended to recommend rshell.

I'd be happy to contribute some writing but I only have Linux boxes so I'd need some guidance on the OSX and Windows platforms.
Peter Hinch
Index to my micropython libraries.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: flash read errors?

Post by dhylands » Sat Mar 12, 2016 8:51 am

I've been using rshell under cygwin and its been working fine. I try it from time to time using OSX and will be trying it more frequently as I'll be getting a Mac laptop for work soon (within the next month).

hjf
Posts: 12
Joined: Sat Feb 27, 2016 3:47 am

Re: flash read errors?

Post by hjf » Sat Mar 12, 2016 1:44 pm

Thanks for the answers. I'll be tryng the suggestions.
I'm trying to understand the problem. Is it that there are two devices mounting a partition at the same time?
If so, the fix would probably be to use MTP mode instead of USB mass storage. This is how my phone does it. To the end user MTP is basically the same as USBMS but under the hood it's not reading blocks from raw storage, but files from the OS. I have no idea though how much work this would take.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: flash read errors?

Post by dhylands » Sat Mar 12, 2016 8:00 pm

Yep - the disadvantage of MTP is that there is no Mac support out-of-the-box (well there is the Android MTP file transfer program which is free but seems fairly buggy). And somebody needs to write the MicroPython side. I've done device side MTP for FirefoxOS, but I had the advantage of the linux kernel drivers and some of the infrastructure provided by Android's C++ code.

Post Reply