[NUCLEO-F401RE]: rshell problem with Ubuntu 16.04

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
Lupine
Posts: 8
Joined: Thu Aug 24, 2017 8:12 pm

[NUCLEO-F401RE]: rshell problem with Ubuntu 16.04

Post by Lupine » Sun Sep 03, 2017 4:32 pm

Hi all,
I was able to set up an old PC with the Ubuntu 16.04 operating system "aboard".
In that set up I have now resumed to compile and install the St link utility (following more or less the instructions at link: https://startingelectronics.org/tutoria ... -in-Linux/) and successfully program the Nucleo F401RE board (either as an mbed device or through the st-flash command executed in the terminal).

After uploading the last MicroPython interpreter fw shared by Dave (https://www.dropbox.com/sh/48f4pyubzqau ... yvENa?dl=0) I was able to get a a MicroPython REPL via terminal application as described in the tutorial, running the command

Code: Select all

sudo screen / dev / ttyACM0 115200
simply after connecting the board via USB cable

Code: Select all

MicroPython v1.9.2-21-g8388ec4-dirty on 2017-08-29; NUCLEO-F401RE with STM32F401xE
Type "help()" for more information.
>>> import uos
>>> print(uos.listdir())
['main.py', 'pybcdc.inf', 'README.txt', 'boot.py']
>>> 
The next step will be to try to compile \ load the source files of the STM porting, but, in the meantime, I'd like to use the rshell command to copy an application file in the board file-system
After successfully installing it (following instruction at link: https://github.com/dhylands/rshell) I cannot get a connection to the board even if the same port is used (please see below).

Code: Select all

Satellite-L655:~$ sudo rshell --buffer-size=32 connect serial /dev/ttyACM0 115200
[sudo] password di xxxx: 

No MicroPython boards connected - use the connect command to add one

Connecting to /dev/ttyACM0 ...
b'\r'
Traceback (most recent call last):
  File "/usr/local/bin/rshell", line 9, in <module>
    load_entry_point('rshell==0.0.10', 'console_scripts', 'rshell')()
  File "/usr/local/lib/python3.5/dist-packages/rshell/command_line.py", line 4, in main
    rshell.main.main()
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 2646, in main
    real_main()
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 2629, in real_main
    shell.cmdloop(cmd_line)
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1547, in cmdloop
    stop = self.onecmd(line)
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1580, in onecmd
    self.onecmd_exec("".join(group))
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1591, in onecmd_exec
    return cmd.Cmd.onecmd(self, line)
  File "/usr/lib/python3.5/cmd.py", line 217, in onecmd
    return func(arg)
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1904, in do_connect
    connect_serial(port, baud)
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1215, in connect_serial
    dev = DeviceSerial(port, baud, wait)
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1435, in __init__
    Device.__init__(self, pyb)
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1261, in __init__
    self.has_buffer = self.remote_eval(test_buffer)
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1352, in remote_eval
    return eval(self.remote(func, *args, **kwargs))
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1330, in remote
    self.pyb.enter_raw_repl()
  File "/usr/local/lib/python3.5/dist-packages/rshell/pyboard.py", line 187, in enter_raw_repl
    raise PyboardError('could not enter raw repl')
rshell.pyboard.PyboardError: could not enter raw repl
If I try to carry out the command "alone" I just get the following response message:

Code: Select all

-Satellite-L655:~$ sudo rshell
[sudo] password di xxx: 
Welcome to rshell. Use Control-D to exit.

No MicroPython boards connected - use the connect command to add one
Could you please help me to solve the problem (I'm not a super expert in Ubuntu matters :? )?
I think rshell is a very useful tool to interact with the MicroPython interpreter on the board...

Thanks in advance...

Regards

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

Re: [NUCLEO-F401RE]: rshell problem with Ubuntu 16.04

Post by dhylands » Sun Sep 03, 2017 8:15 pm

Try using the command:

Code: Select all

rshell --buffer-size=32 --port=/dev/ttyACM0 --baud=115200
Adding sudo if needed (setting up the udev rules will allow things to work without needing to use sudo.

Lupine
Posts: 8
Joined: Thu Aug 24, 2017 8:12 pm

Re: [NUCLEO-F401RE]: rshell problem with Ubuntu 16.04

Post by Lupine » Sun Sep 03, 2017 10:07 pm

Hi Dave,
many thanks for your suggestion!
The connection to the board worked well and I could copy an Hello.py file into the micro-controller memory.
Now I can work with the files as well :) !
Could you please suggest a good text editor (apart from vi) that can be linked to rshell (e.g . through the edit command even if it is not clear for me where are located the environment variables mentioned in the tuorial)?

Thanks in advance.
Regards

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

Re: [NUCLEO-F401RE]: rshell problem with Ubuntu 16.04

Post by dhylands » Mon Sep 04, 2017 12:00 am

nano seems to be a popular one that many people use.

Lupine
Posts: 8
Joined: Thu Aug 24, 2017 8:12 pm

Re: [NUCLEO-F401RE]: rshell problem with Ubuntu 16.04

Post by Lupine » Wed Sep 06, 2017 9:27 pm

Hi Dave,
many thanks for the suggestion.
I started using the rshell to update the main.py file on the board with the first simple scripts
By trying to update the main.py file on the /flash chip memory with the code described in section 4 of the MicroPython tutorial, precisely:

Code: Select all

led = pyb.LED(1)
while True:
    led.toggle()
    pyb.delay(1000)
the file seems to be loaded correctly, but after the soft reset (executable only after I got a REPL) the board goes into an infinite loop of script execution (led toggle) and no longer comes out even by pressing the CTRL- C
combination suggested to stop the execution.

Code: Select all

-Satellite-L655:~$ rshell --buffer-size=32 --port=/dev/ttyACM0 --baud=115200 --editor nano
Connecting to /dev/ttyACM0 ...
Welcome to rshell. Use Control-D to exit.
/home/xxx> ls -l /flash
   528 Jan  1 2015  README.txt
   302 Jan  1 2015  boot.py
    34 Jan  1 2015  main.py
  2721 Jan  1 2015  pybcdc.inf
/home/xxx> edit /flash/main.py
Retrieving /flash/main.py ...
Updating /flash/main.py ...
/home/xxx> repl
Entering REPL. Use Control-X to exit.
>
MicroPython v1.9.2-21-g8388ec4-dirty on 2017-08-29; NUCLEO-F401RE with STM32F401xE
Type "help()" for more information.
>>> 
>>> 
PYB: sync filesystems
PYB: soft reboot
Also the reset button has no effect to block the script and even disconnecting and reconnecting the board it does not seem to be able to be accessed by the rshell or even through the

Code: Select all

 screen /dev/ttyACM0 -115200
command to get the REPL.
The only way I found to have the board working again is to reload the MicroPhyton fw again (through st-flash command)...

Could you please help me to solve the issue?

Thanks in advance...

Regards

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

Re: [NUCLEO-F401RE]: rshell problem with Ubuntu 16.04

Post by dhylands » Wed Sep 06, 2017 10:42 pm

The issue is that there is an error in your main.py script.

rshell relies on performing a soft-reset to be able to get to the raw-repl, and having an error in main.py or boot.py will prevent that.

To recover, you need to perform a file system reset: http://docs.micropython.org/en/latest/p ... boot-modes

Press and hold the USER button and then press and release the RESET button, while continuing to hold the USER button. One of the LEDs should go through a flashing patter, where it will flash once, pause, flash twice, pause, flash three times, pause and then repeat going back to flashing once. Just after it flashes 3 times, release the USER button. It should then flash 3 more times as confirmation and then perform a file system reset, which will replace the main.py and boot.py with the stock ones.

To test new files, I normally call them something else, like foo.py and from the REPL do

Code: Select all

import foo
. I would then copy foo.py to main.py once it has been debugged.

There is a long-standing issue with MicroPython in that it doesn't deal with Control-C on UART REPLs, only on the USB REPL.

Post Reply