[SOLVED] Can't obtain repl over USB using screen on micro:bit

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
talosthoren
Posts: 5
Joined: Sat Jul 13, 2019 5:58 am

[SOLVED] Can't obtain repl over USB using screen on micro:bit

Post by talosthoren » Thu Dec 26, 2019 10:10 pm

Edit: The solution was to re-flash MicroPython onto the boards using mu-editor. This gave me a fresh installation of the firmware with the REPL available. Thanks to user lujo for the solution and to everyone for discussing!

Original Post:
This may be the wrong place to ask, as it verges on tech-support, but I'm having issues connecting to the repl on two micro:bits. I purchased one from DFRobot and one from Adafruit some time later to see if I could replicate the issue.

From multiple linux and mac workstations I've attempted to connect to my micro:bits with the same results. No output, no response to input.

Example command:

Code: Select all

screen /dev/ttyBlahBlahNumbers 115200
as documented. I've confirmed with other micropython boards that cables and connections are correct. I'm able to get repls on other boards with all these machines. I've tried other connection frequencies as well with no luck.

The screen instance will open and remain open, but I see no output. Restarting the micro:bit also yields no output on the screen session. I can detach and interact with the screen session as normal, but I simply can't interact with the device.

Is anyone else seeing this behavior? Am I missing something. The official documentation states that no drivers should be necessary for Linux or Mac systems.
Last edited by talosthoren on Thu Jan 02, 2020 10:52 pm, edited 3 times in total.

lujo
Posts: 24
Joined: Sat May 11, 2019 2:30 pm

Re: Can't obtain repl over USB using screen on micro:bit

Post by lujo » Thu Dec 26, 2019 10:45 pm

Hi,

Works for me. So, what micro USB cable are you using, power only
or power plus data micro USB cable?

lujo

lujo
Posts: 24
Joined: Sat May 11, 2019 2:30 pm

Re: Can't obtain repl over USB using screen on micro:bit

Post by lujo » Thu Dec 26, 2019 10:51 pm

Hi,

Maybe there is a program running. Hit Ctrl-C few times.

lujo

lujo
Posts: 24
Joined: Sat May 11, 2019 2:30 pm

Re: Can't obtain repl over USB using screen on micro:bit

Post by lujo » Fri Dec 27, 2019 12:28 am

Hi,

Or MicroPython has been overwritten (with a Microsoft MakeCode program
or something like that).
Plug in the micro:bit, wait until your PC has detected the microbit, you now
have a device file. Start the mu-editor. Click New, then click Flash. This will
install the MicroPython runtime. Click REPL and hit Ctrl-C a few times.
Now you should get a MicroPython prompt. Exit the mu-editor. Screen
should work too.

lujo

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

Re: Can't obtain repl over USB using screen on micro:bit

Post by jimmo » Fri Dec 27, 2019 12:51 am

As already suggested, sounds like a program might be running, so Ctrl-C is a good start.

After connecting the microbit though, try running `dmesg` and see what you see. Ensure that it's the correct /dev/ttyACMX device being registered. Do you also get the virtual disk drive (should look like a FAT volume named MICROBIT).

Also you won't get a prompt over the serial port until the MicroPython firmware is loaded (which the don't come with). I recommend using Mu (https://codewith.mu) but also uflash (https://github.com/ntoll/uflash) or just grab a .hex file from any of the online editors and copy that to the virtual drive.

zfm076
Posts: 16
Joined: Mon Dec 30, 2019 8:06 am

Re: Can't obtain repl over USB using screen on micro:bit

Post by zfm076 » Mon Dec 30, 2019 8:24 am

jimmo wrote:
Fri Dec 27, 2019 12:51 am
As already suggested, sounds like a program might be running, so Ctrl-C is a good start.

After connecting the microbit though, try running `dmesg` and see what you see. Ensure that it's the correct /dev/ttyACMX device being registered. Do you also get the virtual disk drive (should look like a FAT volume named MICROBIT).

Also you won't get a prompt over the serial port until the MicroPython firmware is loaded (which the don't come with). I recommend using Mu (https://codewith.mu) but also uflash (https://github.com/ntoll/uflash) or just grab a .hex file from any of the online editors and copy that to the virtual drive.
hi,If my computer is plugged into two microbits, how do I know which serial port corresponds to which microbit device?Through VID PID?

lujo
Posts: 24
Joined: Sat May 11, 2019 2:30 pm

Re: Can't obtain repl over USB using screen on micro:bit

Post by lujo » Mon Dec 30, 2019 10:24 am

Hi,

Get a list of your micro:bit serial addresses:

Code: Select all

#!/usr/bin/python3

from serial.tools.list_ports import comports as serial_ports

def find_microbits():

  lst = []

  for port in serial_ports():
    if "VID:PID=0D28:0204" in port.hwid:
      lst.append(port.device)

  return lst

ports = find_microbits()

if ports:
  print('\nMicro:bit found at port %s.\n' % ', '.join(sorted(ports)))
else:
  print('\nNo micro:bit found.\n')

For each micro:bit serial port do display.show() something.
Or label a microbit with its serial number. So you know which micro:bit
you are talking to with machine.unique_id().

lujo

zfm076
Posts: 16
Joined: Mon Dec 30, 2019 8:06 am

Re: Can't obtain repl over USB using screen on micro:bit

Post by zfm076 » Tue Dec 31, 2019 3:59 am

lujo wrote:
Mon Dec 30, 2019 10:24 am
Hi,

Get a list of your micro:bit serial addresses:

Code: Select all

#!/usr/bin/python3

from serial.tools.list_ports import comports as serial_ports

def find_microbits():

  lst = []

  for port in serial_ports():
    if "VID:PID=0D28:0204" in port.hwid:
      lst.append(port.device)

  return lst

ports = find_microbits()

if ports:
  print('\nMicro:bit found at port %s.\n' % ', '.join(sorted(ports)))
else:
  print('\nNo micro:bit found.\n')

For each micro:bit serial port do display.show() something.
Or label a microbit with its serial number. So you know which micro:bit
you are talking to with machine.unique_id().

lujo
Thank you very much lujo,That's a good idea. Now,I can get serial Numbers for serial ports. But,How do I get the serial number of the disk? if I have serial addresses and disk addresses, I can make a comparison.Then I will konw that which serial port corresponds to which microbit disk.

talosthoren
Posts: 5
Joined: Sat Jul 13, 2019 5:58 am

Re: Can't obtain repl over USB using screen on micro:bit

Post by talosthoren » Thu Jan 02, 2020 10:35 pm

lujo wrote:
Thu Dec 26, 2019 10:45 pm
Hi,

Works for me. So, what micro USB cable are you using, power only
or power plus data micro USB cable?

lujo
Thanks for the replies, getting back to everyone. I've ensured that I'm using a fully data capable usb cord by testing with other micropython devices. I've tried many cables at this point and, while I've identified a few that are power only, the majority of my usb-micro cables are data capable.

talosthoren
Posts: 5
Joined: Sat Jul 13, 2019 5:58 am

Re: Can't obtain repl over USB using screen on micro:bit

Post by talosthoren » Thu Jan 02, 2020 10:37 pm

lujo wrote:
Thu Dec 26, 2019 10:51 pm
Hi,

Maybe there is a program running. Hit Ctrl-C few times.

lujo
I've seen this in other devices as well but, unfortunately Ctrl-C results in no output. The other Ctrl shortcuts common in micropython/circuitpython also are not responsive.

Post Reply