Micropython Main file corrupt

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
ndshah88
Posts: 5
Joined: Mon Mar 16, 2020 12:13 pm

Micropython Main file corrupt

Post by ndshah88 » Wed Mar 18, 2020 12:57 pm

Dear Forum members,

We are working on the STM32F407 DISCO board.

https://www.st.com/en/evaluation-tools/ ... overy.html

We followed the instructions here: https://medium.com/@circuit4us/setup-mi ... 5e0f9d875e

to load our board with the micropython v1.12 and were able to get our REPL prompt as well. Everytime we update the main.py 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 main.py 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 main.py 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.
Attachments
garbage_file.png
garbage_file.png (70.43 KiB) Viewed 2353 times
error_mainfile.png
error_mainfile.png (80.89 KiB) Viewed 2358 times

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Micropython Main file corrupt

Post by jimmo » Fri Mar 20, 2020 3:02 am

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) -- https://docs.microsoft.com/en-us/sysint ... 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 pyboard.py (see docs at http://docs.micropython.org/en/latest/r ... rd.py.html ) or rshell (https://github.com/dhylands/rshell).

Post Reply