Page 1 of 2

rshell won't connect without SD card

Posted: Mon Jul 18, 2016 12:50 pm
by Jacob_Beningo
I'm having issues getting the rshell to connect to the pyboard if an SD card is not inserted.

I have disabled MSC by setting the following in my

Code: Select all

The internal /flash doesn't show up as MSC which is good but when an SD card is inserted it shows up as a drive.

Now with the SD card inserted, rshell connects and works great but if I boot-up without the SD card, I cannot connect to the PyBoard using rshell or screen.

1) Is there some switch, parameter, etc that needs to be set for rshell to connect to the PyBoard when an SD card is not inserted?

2) Is there a way to disable the SD card from showing up as a MSC?

Thanks for the insights!

Re: rshell won't connect without SD card

Posted: Mon Jul 18, 2016 3:01 pm
by Roberthh
Hello Jacob, and are taken form the SD card if the SD card is present. Are you sure that these files are like you want to have them on the SD card?


Re: rshell won't connect without SD card

Posted: Mon Jul 18, 2016 4:02 pm
by dhylands
My first suspicion would be that /flash/ and /flash/ are messing things up (rshell needs those to execute without error in order to work).

When you use an sdcard, the /sd/ and /sd/ are executed instead.

Re: rshell won't connect without SD card

Posted: Tue Jul 19, 2016 1:45 pm
by Jacob_Beningo
Thanks Robert! I forgot about that when using an SD card. That definitely help remove the SD card from showing up as MSC.

I'm still having issues with rshell though. I did a factory reset on my PyBoard so that I have all the original and scripts. I'm running it without the SD card so /flash only. I make the change in to uncomment:

#pyb.usb_mode('CDC+MSC') # act as a serial and a storage device

and change it to

pyb.usb_mode('CDC') # act as a serial and a storage device

I remove the drive power cycle and it shows up as a serial device. However, I am unable to connect through rshell or even screen.

At this point has not been modified and is completely blank.

Re: rshell won't connect without SD card

Posted: Tue Jul 19, 2016 1:47 pm
by Jacob_Beningo
Thanks Dave. Do you have an example for how your and scripts should look to use rshell without an SD card attached?

(I've searched the forum but haven't found an example at the moment).

Re: rshell won't connect without SD card

Posted: Tue Jul 19, 2016 4:11 pm
by dhylands
I normally use the stock and, and modify to set the pyb.usb_mode.

Here is my typical and (using rshell to show the contents):

Code: Select all

/home/dhylands> cat /flash/
# -- run on boot-up
# can run arbitrary Python, but best to keep it minimal

import machine
import pyb
#pyb.main('') # main script to run after this one
pyb.usb_mode('CDC') # act as a serial port
#pyb.usb_mode('CDC+HID') # act as a serial device and a mouse
/home/dhylands> cat /flash/
# -- put your code here!
I had one board which wouldn't work with rshell until I upgraded the firmware. Make sure you have recent firmware on the pyboard and also make sure that you're running a recent version of rshell. The most recent is 0.0.5 (rshell --version). You should be able to update by using:

Code: Select all

pip3 install --upgrade rshell

Re: rshell won't connect without SD card

Posted: Tue Jul 19, 2016 8:49 pm
by Jacob_Beningo
Thanks for the suggestions.

So I rebuilt my PYBV10 firmware using the latest release 1.8.2 from 9 days ago. I've also verified that I'm using rshell 0.0.5.

After reflashing my board I find that if I try to connect with rshell to just the /flash without an SD card inserted I still get:

Connecting to /dev/ttyACM1 ...
failed to access /dev/ttyACM1

My /flash/ is identical to the listing that dhylands posted.

Commenting out my changes to and leaving it as default, with 'CDC+MSC', and then power cycling, I find that I am able to connect over rshell. So for some reason changing to use CDC only seems to be breaking the communication.

I've tried this on both my PYBV10 board and also a custom board that uses the STM32F429 but the results are identical.

Is there a verbose mode for rshell or any other thoughts on how I might resolve this? Thanks again!

Re: rshell won't connect without SD card

Posted: Tue Jul 19, 2016 9:44 pm
by dhylands
rshell has a -d command that causes all of the commands and responses that are sent to the board to be printed.

Can you also try running this script: ...

You can use this link to directly download: ...

I'd like to see the output of running

Code: Select all --list
When using rshell, make sure that whatever terminal program you normally use for the REPL has been shutdown. If you use tmux or screen make sure that there aren't any background ones running. If anything else is connected to the serial port (/dev/ttyACM1 in your example) then rshell won't work.

Under linux, you can use a command like:

Code: Select all

lsof | grep ttyACM
to see if anybody else has that serial port open. I somtimes wind up with other copies of rshell on other windows which also messes things up.

Note to self: I really need to implement the proper serial port locking.

And it would also be good to see what

Code: Select all

ls -l /dev/ttyACM1
shows. Is your user a member of the dialout group? (You can use the id command to see what groups your user belongs to:

Code: Select all

2051 >id
uid=35029(dhylands) gid=1000(dhylands) groups=1000(dhylands),4(adm),20(dialout),24(cdrom),27(sudo),30(dip),46(plugdev),113(lpadmin),128(sambashare)

Re: rshell won't connect without SD card

Posted: Tue Jul 19, 2016 10:16 pm
by dhylands
And if you have a which doesn't exit thru to the REPL, then rshell won't work either.

And it just occurred to me that there is a subtle thing you might be tripping over.
When the pyboard switches between CDC mode and CDC+MSC mode, it uses a different USB PID. CDC+MSC shows as f055:9800 where CDC only shows as f055:9802 (and I think CDC+HID shows as f055:9801) so this will affect your udev if you're using udev rules to set the permissions on your /dev/ttyACMx files.

I now use:

Code: Select all

# f055:9800 MicroPython pyboard
ATTRS{idVendor}=="f055", ENV{ID_MM_DEVICE_IGNORE}="1"
ATTRS{idVendor}=="f055", ENV{MTP_NO_PROBE}="1"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="f055", MODE:="0666"
KERNEL=="ttyACM*", ATTRS{idVendor}=="f055", MODE:="0666"
so I removed the idProiduct checks altogether.

Adding yourself to the dialout group will also get you the same benefit.

Note to self: Time to update the rshell docs in regards to this.

Re: rshell won't connect without SD card

Posted: Tue Jul 19, 2016 11:57 pm
by Jacob_Beningo
Awesome! Thanks for all the information. Super helpful!

The issue turned out to be my udev rules and the usb PID ( I was really started to think something USB related but forgot all about these rules as I set them up a long time ago). I removed the '9800' PID entries to match your rules and after reloading the rules it came up immediately. Thank-you for the insights!

On a side note, (hopefully this is appropriate), I updated the page I originally retrieved the udev rules from ( ... -Discovery) to show the changes. That way anyone who sets the rules up for the first time will have the latest rules that you are using and won't encounter this issue.