Is it possible to check code on laptop before flashing MCU?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
nmz787
Posts: 29
Joined: Sun Jul 10, 2016 7:57 am

Is it possible to check code on laptop before flashing MCU?

Post by nmz787 » Mon Jul 11, 2016 12:45 am

When I am trying to copy my script file to my Nucleo F401 with rshell, rshell hangs about 90% of the time... and I have to reboot the board holding the user button, and sometimes I even frustratingly hold the user-button even longer so the filesystem gets wiped.

It /seems/ this hanging might be related to the quality of the code. But I can't check the code on my laptop because it stops processing when it sees "import pyb" or "from pyb import Timer"... so what am I to do? I even just tried pasting my whole file into the rshell REPL... but it seems to miss characters and gets corrupted during paste so that doesn't work to test things.

Here is the command that crashes/hangs most of the time:
rshell --buffer-size=32 --port=/dev/ttyACM0 cp m2.py /flash/m2.py

(afterwards I would also try to copy a boot.py that opens m2.py... if the filesystem was just recently wiped)

Help! This is wasting sooo much of my time and making me super-frustrated :(

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

Re: Is it possible to check code on laptop before flashing MCU?

Post by dhylands » Mon Jul 11, 2016 1:45 am

When using rshell with a UART, make sure that you pass in --buffer-size=32 (by defailt it assume it's connected to usb and uses a 512 byte buffer). What's happening is that the Rx buffer on the 401 is getting overflowed during file processing and this cause things to hang since the host end thinks it sent all of the data and the receiving end is missing some data.

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

Re: Is it possible to check code on laptop before flashing MCU?

Post by pythoncoder » Mon Jul 11, 2016 7:17 am

dhylands wrote:When using rshell with a UART, make sure that you pass in --buffer-size=32 ...
Er, Dave, if you re-read the original post he is using that argument ;)
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: Is it possible to check code on laptop before flashing MCU?

Post by dhylands » Mon Jul 11, 2016 3:38 pm

I've definitely had issues with trying to update boot.py and/or main.py using rshell. If there is a bug in either one then rshell will definitely stop working, but even when there isn't I've also seen some weird things.That one is really difficult to debug since boot.py/main.py is executed each time the raw repl is entered, and the processor is essentially soft reset for each raw repl command. rshell issues several raw repl commands for each command that you use.

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

Re: Is it possible to check code on laptop before flashing MCU?

Post by pythoncoder » Tue Jul 12, 2016 12:09 pm

I use rshell heavily: daily on all Pyboard variants with frequent copying of sometimes large files, both to flash and SD. I usually have a USB connection, but I've also extensively used a UART via an FTDI adaptor. When using the adaptor I use --buffer-size=32. As far as I can remember the current version has never suffered an inexplicable failure. My guess is that the issue may be specific to either your hardware or to the Nucleo F401 port.
Peter Hinch
Index to my micropython libraries.

Post Reply