Page 1 of 1

Micropython Main file corrupt

Posted: Wed Mar 18, 2020 12:57 pm
by ndshah88
Dear Forum members,

We are working on the STM32F407 DISCO board. ... overy.html

We followed the instructions here: ... 5e0f9d875e

to load our board with the micropython v1.12 and were able to get our REPL prompt as well. Everytime we update the file we first press the Blue button and then the black button. So the board get reset and we see the pyboard USB flash drive come back up.

We are working on communicating with another board over UART using UART 2.

We face the following challenges:

1) At times we get this error called: 'Runtime Error: name too long' and then we get the micropython REPL prompt while we log in to the device using putty. So we went ahead and checked the file and found that it was filled with some garbage characters. This has happened to us multiple times. We have been able to recreate this. Such a file is also attached here.

2) At times we get this error called: 'Runtime Error: name too long' and we notice that the file is totally empty. See attachment.

Has anyone else faced the same issue? Can someone help resolve the issue?

Attaching screenshots with this post for the runtime error as well as the data corruption.

Thanks in advance.

Re: Micropython Main file corrupt

Posted: Fri Mar 20, 2020 3:02 am
by jimmo
It sounds like you're seeing filesystem corruption.

The USB flash drive mode is unfortunately prone to this unless you're very careful with always synchronising writes and unmounting the device after you've copied files. This seems to be especially problematic on Windows, where it will sometimes delay flushing the write buffer.

It's been a while, but last time I was helping people using MIcroPython on Windows, we had some luck with using sync.exe (based on the Unix tool of the same name) -- ... loads/sync

You also just have to be really careful that you don't reset the device until after the light turns off after you copy files.

However, it's just much better to not use the USB flash drive, and instead use one of the dedicated tools for working with the device filesystem. I would look into using either (see docs at ... ) or rshell (