can't connect /dev/serial0

427 views
Skip to first unread message

Daniel Perron

unread,
Sep 6, 2022, 10:26:36 AM9/6/22
to thonny
I'm using micropython in serial mode only, No USB,  on the Pico and I'm force to rename /dev/ttyS to /dev/ttyAMA0 

Why is /dev/serial0 not use, or available, instead of /dev/ttyAMA0 ?  



Mickey Mx

unread,
Sep 6, 2022, 10:44:28 AM9/6/22
to thonny
Check your Pico, make sure your PC as the driver for the Pico USB-UART bridge chip (CH340, CP2102, etc.).

Daniel Perron

unread,
Sep 6, 2022, 3:53:04 PM9/6/22
to thonny
I think that you didn't read my email properly.  I'm using my pico on USB host right now. 
I change the behavior of micropython so the USB port is reading my USB gamepad.
Because of that my USB port is not able to communicate via the USB. 
I recompile the Micropython code to enable the uart for  REPL to GP0&1.

The problem I'm facing is that the PI4 /dev/ttyAMA0 is for the bluetooth and it is not the tty serial anymore because it is /dev/ttyS.

To fix this issue the raspberryPi foundation ask us to use /dev/serial0 instead. This way any Raspberry Pi board will be the same.
/dev/serial0 assure us that the serial  is on  GPIO14 & 15 .  

Andy Piper

unread,
Sep 6, 2022, 6:57:52 PM9/6/22
to Daniel Perron, thonny
Is this a MicroPython issue or a Thonny issue?

If I understand correctly I think you're saying you need to modify MicroPython directly? Maybe worth raising this in the MicroPython forums (GitHub Discussions -> https://github.com/orgs/micropython/discussions)

--
You received this message because you are subscribed to the Google Groups "thonny" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thonny+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/thonny/82eef194-dd12-4437-b745-67786b593cc8n%40googlegroups.com.


--
Andy Piper | Kingston upon Thames, London (UK)
links: https://andypiper.me  | twitter: @andypiper 

guy colin

unread,
Sep 7, 2022, 3:08:29 AM9/7/22
to thonny
Daniel is right, Thonny as any software when running on a Raspberry Pi must use /dev/serial0 to access the serial port.
/dev/serial0 is a link pointing to the correct serial port. The Raspberry Pi OS is managing this link, because depending of the Pi model the actual serial port may not be the same.

Aivar Annamaa

unread,
Sep 9, 2022, 3:05:09 PM9/9/22
to thonny
Thonny uses Pyserial library for detecting the available serial ports and communicating with them. Therefore only the ports listed by Pyserial are considered as possible communication targets.

Best regards,
Aivar

Daniel Perron

unread,
Sep 10, 2022, 8:49:41 AM9/10/22
to thonny
this is a problem.
Maybe  if we have the possibility in the option menu to type the device we want this will go around it.

Aivar Annamaa

unread,
Sep 13, 2022, 2:11:26 AM9/13/22
to thonny
If you can confirm that Pyserial is able talk to your device, then I could add /dev/serual0 to the list of option if the file exists.

Best regards,
Aivar

Daniel Perron

unread,
Sep 13, 2022, 9:37:02 AM9/13/22
to thonny
Ok this is from my micropython version which is UART enable

#define MICROPY_HW_ENABLE_UART_REPL             (1)   // UART enable
#define MICROPY_HW_ENABLE_USBDEV                (0)      // USB OFF  (I'm using it in USB_HOST_MODE)

The script using Pyserial,

import serial
com = serial.Serial('/dev/serial0',baudrate=115200,timeout=1)
#Send import command via /dev/serial0
com.write("import os\r".encode("utf-8"))
returnChars = com.read(100).decode("utf-8")
print(returnChars)
#"Send os.uname via /dev/serial0
com.write("os.uname()\r".encode("utf-8"))
returnChars = com.read(200).decode("utf-8")
print(returnChars)
#Send help('modules') via /dev/serial0
com.write("help('modules')\r".encode("utf-8"))
returnChars = com.read(3000).decode("utf-8")
print(returnChars)


And the result when I run it from the Pi

pi@benchpi4:~ $ python3 confirmserial0.py
import os
>>>
os.uname()
(sysname='rp2', nodename='rp2', release='1.19.1', version='v1.19.1-375-ge90b85cc9-dirty on 2022-09-08 (GNU 8.3.1 MinSizeRel)', machine='Raspberry Pi Pico with RP2040')
>>>
help('modules')
__main__          gamepad           uasyncio/funcs    ujson
_boot             gc                uasyncio/lock     umachine
_boot_fat         math              uasyncio/stream   uos
_onewire          micropython       ubinascii         urandom
_rp2              neopixel          ucollections      ure
_thread           onewire           ucryptolib        uselect
_uasyncio         rp2               uctypes           ustruct
builtins          uarray            uerrno            usys
cmath             uasyncio/__init__ uhashlib          utime
dht               uasyncio/core     uheapq            uzlib
framebuf          uasyncio/event    uio
Plus any modules on the filesystem
>>> 


You should read Raspberry Pi UART.   This tell that /dev/serial0 will be always the primary UART which depends of the Pi model.
Old PI use /dev/ttyAMA0 on GPIO14&15 but the PI3 &PI4 use /dev/ttyS0

regards,

Daniel Perron

Aivar Annamaa

unread,
Sep 15, 2022, 2:32:12 AM9/15/22
to thonny
Alright, I'll add more options to choose from in the next release (https://github.com/thonny/thonny/issues/2459)

The page you linked to, sais: "/dev/serial0 and /dev/serial1 are symbolic links which point to either /dev/ttyS0 or /dev/ttyAMA0". What do you think -- should I add all these 4 (if present) or only the symlinks? At the moment, on my machine with nothing attached, I see /dev/ttyS0 but neither /dev/serial0 nor /dev/serial1.

Best regards,
Aivar

Daniel Perron

unread,
Sep 15, 2022, 10:49:07 AM9/15/22
to Aivar Annamaa, thonny

The page you linked to, sais: "/dev/serial0 and /dev/serial1 are symbolic links which point to either /dev/ttyS0 or /dev/ttyAMA0". What do you think -- should I add all these 4 (if present) or only the symlinks? At the moment, on my machine with nothing attached, I see /dev/ttyS0 but neither /dev/serial0 nor /dev/serial1.

      Good question!
     
       Maybe just a way to type any device we want. Right now we are forced to select from a choice.


Aivar Annamaa

unread,
Sep 19, 2022, 5:00:40 AM9/19/22
to thonny
On Thursday, September 15, 2022 at 5:49:07 PM UTC+3 daniel...@gmail.com wrote: 
       Maybe just a way to type any device we want. Right now we are forced to select from a choice.

This would require changing the UI widget (note that currently it does not contain simply the port, but also some extra information). I'd rather add more items to the choice.


Reply all
Reply to author
Forward
0 new messages