[nRF52] How to get rshell to work with an nRF52?

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.
User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

[nRF52] How to get rshell to work with an nRF52?

Post by WhiteHare » Sun Oct 28, 2018 7:07 pm

I did install rshell on Debian 9 as per the directions (https://github.com/dhylands/rshell):

Code: Select all

sudo pip3 install rshell
At least that much seemed to work.

However, it goes downhill from there. If I type "rshell" at the linux prompt, what I get is:

Code: Select all

Welcome to rshell.  Use Control-D (or the exit command) to exit rshell.

No MicroPython boards connected - use the connect command to add one
Well, the nRF52840-DK is connected on /dev/ttyACM0, which is the default.

What should I do from here? Devnull got a little further than me, but he reports he's not getting much functionality: viewtopic.php?f=12&t=5450&start=10

Is rshell even supported? :?: If not, how do we make it work?

User avatar
rcolistete
Posts: 139
Joined: Thu Dec 31, 2015 3:12 pm
Location: Brazil

Re: [nRF52] How to get rshell to work with an nRF52?

Post by rcolistete » Mon Oct 29, 2018 1:15 am

What about :

Code: Select all

$ rshell -p /dev/ttyACM0 -b 115200 --buffer-size 32 -a
?

User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

Re: [nRF52] How to get rshell to work with an nRF52?

Post by WhiteHare » Mon Oct 29, 2018 1:29 am

rcolistete wrote:
Mon Oct 29, 2018 1:15 am
What about :

Code: Select all

$ rshell -p /dev/ttyACM0 -b 115200 --buffer-size 32 -a
?

Code: Select all

root@debian:/home/david/micropython/ports/nrf/myPrograms#  rshell -p /dev/ttyACM0 -b 115200 --buffer-size 32 -a
Connecting to /dev/ttyACM0 ...
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1197, in connect
    ip_address = socket.gethostbyname(port)
socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/rshell", line 11, in <module>
    sys.exit(main())
  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 2730, in main
    real_main()
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 2692, in real_main
    connect(args.port, baud=args.baud, wait=args.wait, user=args.user, password=args.password)
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1203, in connect
    connect_serial(port, baud=baud, wait=wait)
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1227, in connect_serial
    dev = DeviceSerial(port, baud, wait)
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1473, in __init__
    Device.__init__(self, pyb)
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1280, in __init__
    elif not self.remote_eval(test_unhexlify):
  File "/usr/local/lib/python3.5/dist-packages/rshell/main.py", line 1390, in remote_eval
    return eval(self.remote(func, *args, **kwargs))
  File "<string>", line 0
    
    ^
SyntaxError: unexpected EOF while parsing
root@debian:/home/david/micropython/ports/nrf/myPrograms# 

User avatar
devnull
Posts: 341
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: [nRF52] How to get rshell to work with an nRF52?

Post by devnull » Mon Oct 29, 2018 2:42 am

https://github.com/dhylands/rshell/issues/65

Do you have a pyboard, esp32 or esp8266 board that you can test this with ??

User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

Re: [nRF52] How to get rshell to work with an nRF52?

Post by WhiteHare » Mon Oct 29, 2018 2:53 am

So far I haven't installed micropython on anything else, but if I needed to I suppose I could install it on a Wemos D1 Mini ESP8266. Would there be any point in doing so?

User avatar
devnull
Posts: 341
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: [nRF52] How to get rshell to work with an nRF52?

Post by devnull » Mon Oct 29, 2018 3:27 am

Well so you can understand how rshell works and why it's so much better than ampy :-)

User avatar
devnull
Posts: 341
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: [nRF52] How to get rshell to work with an nRF52?

Post by devnull » Mon Oct 29, 2018 3:47 am

These are the commands:

Code: Select all

Documented commands (type help <topic>):
========================================
args    cat  connect  echo  filesize  help  mkdir  rm     shell
boards  cd   cp       edit  filetype  ls    repl   rsync
If your path starts with '/flash' then it is directed to the micropython device, if not then it is a local path.

i.e:

Code: Select all

ls mypath/ will list the pwd (present working directory) of your PC
ls /flash/lib will list the lib folder on the device.
mkdir /flash/apps will create a new folder on the device
edit /flash/boot.py will open an editor (I prefer nano) and directly edit the file on the device.
rsync mydir /flash/mydir will clone an entire folder
repl will enter you into the device REPL
You can also chain commands and do things like:

Code: Select all

cp mydir/myfile.py /flash/myfile; repl ~ import myfile; myfile.func()
This will copy the file from local path, to the device, then enter the REPL and execute import myfile, and then myfile.func()

And....

If you create a file in the device root named board.py with a single line content like:

Code: Select all

name = "mydev"
Instead of using /flash in the path, you can use:

Code: Select all

ls /mydev/lib
And having a board.py file on each connected board will allow you to work with multiple boards from the same shell console.

rshell really is a very nice console shell to use with micropython !

User avatar
marfis
Posts: 187
Joined: Fri Oct 31, 2014 10:29 am
Location: Zurich / Switzerland

Re: [nRF52] How to get rshell to work with an nRF52?

Post by marfis » Mon Oct 29, 2018 5:04 am

What I‘ve figured is that the nRF port has the micro:bit FS enabled as default which only supports flat file hirarchies (no directories). Also, I see that os.listdir(‚.‘) reports an error about an argument given...

both of which might relate to the problems you see.

There is a small section in the readme about enabling a proper FAT FS but it is missing an example how to really do it (since you probably have to use a small flash block device driver for the internal flash but I‘m not aware if such a thing exists)

User avatar
WhiteHare
Posts: 129
Joined: Thu Oct 04, 2018 4:00 am

Re: [nRF52] How to get rshell to work with an nRF52?

Post by WhiteHare » Mon Oct 29, 2018 5:24 am

Straight off the bat, though, seems to be rshell's lack of knowledge about what board it is talking to, because it says that it's not finding any board to connect with, even when the nRF52840-DK is connected directly to /dev/ttyACM0, which is the default for rshell. i.e. rshell should be finding the nRF52, but it's not for some reason. So, what's missing?

User avatar
devnull
Posts: 341
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: [nRF52] How to get rshell to work with an nRF52?

Post by devnull » Mon Oct 29, 2018 5:58 am

I can confirm that setting MICROPY_VFS = 1 eliminates the listdir errors:

Code: Select all

// options to control how MicroPython is built
#ifndef MICROPY_VFS
#define MICROPY_VFS                 (1)             // WAS 0
#endif
#define MICROPY_VFS_FAT             (MICROPY_VFS) 

Code: Select all

os.listdir()
[]
>>> 

Post Reply