Slot for serial port

Hello

Were is the slot for the serial port ?
RPi 3
ubuntu-core-18-armhf+raspi3.img.xz “installed image”
/dev/ttyS0 “device node”

snap interfaces
:serial-port “does not exist”
nothing under: pi pi-kernel

snap list
Name Version Rev Tracking Publisher Notes
core 16-2.42.5 8270 stable canonical✓ core
core18 20200113 1654 stable canonical✓ base
pi 18-1 17 18-pi3 canonical✓ gadget
pi-kernel 4.15.0-1053.57 69 18-pi3 canonical✓ kernel
snapd 2.42.5 5756 stable canonical✓ snapd
snappy-debug 0.35-snapd2.42.2+git 432 stable canonical✓ -

Which gadget should I install ?
snap find pi3
Name Version Publisher Notes Summary
pi3 16.04-0.7 canonical✓ gadget Raspberry Pi 3 support package
pi3-ondra 16.04-0.5 ondra gadget Raspberry Pi 3 support package
pi3-configuration 0.5-dev koza - Configuration snap for Raspberry Pi 3
pi-kiosk 18-0.1 ogra gadget Raspberry Pi gadget

Thanks

Did you try:

snap interface serial-port

?

gadgets are nothing you “install” a gadget is actually what defines your image, it contains the bootloader that makes the image bootable, the partitioning info and all hardware specific interfaces. a gadget is used at image build time to create the image.

i fear there is no interface to access /dev/ttyS0 in the current pi3 gadget (it surely makes sense to create one though) … only the pi3:bt-serial interface that provides access to ttyAMA0 for the bluez snap.

the source of the gadget is at:

a PR that adds a serial port interface for ttyS0 to snapcarft.yaml will surely be merged quickly by @sil2100

The only item snap shown for serial-port is mine.
snap interface serial-port
name: serial-port
summary: allows accessing a specific serial port
plugs:

  • dkentry-python3

So I will keep using --devmode, until its added.

The last time I looked at this, I decided not to file a PR, because we have a unified Pi gadget for UC18 (which is actually at https://github.com/snapcore/pi-gadget), and some Pi’s don’t have serial ports which other Pi’s do, which led to the inconsistency I asked about here: Gadget slots for devices that don't exist.

1 Like

Hello

Will the RX for this serial port work OK ?

ubuntu-core-18-armhf+raspi3.img.xz “installed image”
/dev/ttyS0 “device node”

I am getting this error on RX

Traceback (most recent call last):
File “/usr/lib/python3/dist-packages/serial/serialposix.py”, line 501, in read
'device reports readiness to read but returned no data ’
serial.serialutil.SerialException: device reports readiness to read but returned no data (device disconnected or multiple access on port?)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/amodster/myserial.py”, line 107, in
rxdata = myport.read(1)
File “/usr/lib/python3/dist-packages/serial/serialposix.py”, line 509, in read
raise SerialException(‘read failed: {}’.format(e))
serial.serialutil.SerialException: read failed: device reports readiness to read but returned no data (device disconnected or multiple access on port?)

If you don’t have an interface connected, then I think it’s expected to see python exceptions like this. Do you see any denials at the time this happens? I.e. what’s the output of

journalctl -e --no-pager | grep DENIED

when you run your python application?

No I did not see any DENIED entries.

But I did notice this on the linux command line, which may interfere with the usage of the serial port (other then console). Utilities like getty running on ttyS0.

Not sure yet ?

Jan 24 15:53:38 localhost kernel: Kernel command line: 8250.nr_uarts=1 cma=256M bcm2708_fb.fbwidth=1824 bcm2708_fb.fbheight=984 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x3ec00000 vc_mem.mem_size=0x40000000 dwc_otg.lpm_enable=0 console=ttyS0,115200 elevator=deadline rng_core.default_quality=700 vt.handoff=2 quiet splash root=/dev/disk/by-label/writable net.ifnames=0 init=/lib/systemd/systemd ro panic=-1 fixrtc snap_core=core18_1654.snap snap_kernel=pi-kernel_69.snap
J

Jan 24 15:53:38 localhost kernel: Serial: 8250/16550 driver, 1 ports, IRQ sharing enabled

Jan 24 15:53:38 localhost kernel: console [ttyS0] disabled
Jan 24 15:53:38 localhost kernel: 3f215040.serial: ttyS0 at MMIO 0x0 (irq = 166, base_baud = 31250000) is a 16550
Jan 24 15:53:38 localhost kernel: console [ttyS0] enabled

Jan 24 15:53:39 localhost systemd[1]: Found device /dev/ttyS0.

Jan 24 16:02:44 localhost sudo[844]: amodster : TTY=pts/0 ; PWD=/home/amodster ; USER=root ; COMMAND=/home/amodster/myserial.py
Jan 24 16:02:44 localhost sudo[844]: pam_unix(sudo:session): session opened for user root by amodster(uid=0)
Jan 24 16:02:45 localhost sudo[844]: pam_unix(sudo:session): session closed for user root
Jan 24 16:02:45 localhost systemd[1]: Started Serial Getty on ttyS0.
Jan 24 16:02:45 localhost systemd[1]: serial-console-conf@ttyS0.service: Service has no hold-off time, scheduling restart.
Jan 24 16:02:45 localhost systemd[1]: serial-console-conf@ttyS0.service: Scheduled restart job, restart counter is at 1.
Jan 24 16:02:45 localhost systemd[1]: Stopped Ubuntu Core Firstboot Configuration ttyS0.
Jan 24 16:02:45 localhost systemd[1]: Started Ubuntu Core Firstboot Configuration ttyS0.
Jan 24 16:02:45 localhost systemd[1]: Stopping Serial Getty on ttyS0…
Jan 24 16:02:45 localhost systemd[1]: Stopped Serial Getty on ttyS0.

Note: systemd tries to stop Getty, but it does not clean up in time.

Is there a way to stop this service ?
amodster@localhost:~$ systemctl status serial-console-conf@ttyS0.service
● serial-console-conf@ttyS0.service - Ubuntu Core Firstboot Configuration ttyS0
Loaded: loaded (/lib/systemd/system/serial-console-conf@.service; static; vendor preset: enabled)
Active: active (running) since Sat 2020-01-25 04:26:36 UTC; 50min ago
Process: 1378 ExecStopPost=/bin/systemctl start serial-getty@ttyS0 (code=exited, status=0/SUCCESS)
Process: 1380 ExecStartPre=/bin/systemctl stop serial-getty@ttyS0 (code=exited, status=0/SUCCESS)
Main PID: 1382 (console-conf-wr)
Tasks: 1 (limit: 1588)
CGroup: /system.slice/system-serial\x2dconsole\x2dconf.slice/serial-console-conf@ttyS0.service
└─1382 /bin/bash /usr/share/subiquity/console-conf-wrapper --serial

amodster@localhost:~$ systemctl status serial-getty@ttyS0
● serial-getty@ttyS0.service - Serial Getty on ttyS0
Loaded: loaded (/lib/systemd/system/serial-getty@.service; indirect; vendor preset: enabled)
Drop-In: /lib/systemd/system/serial-getty@.service.d
└─console-conf-serial.conf
Active: inactive (dead) since Sat 2020-01-25 04:26:36 UTC; 51min ago
Docs: man:agetty(8)
man:systemd-getty-generator(8)
http://0pointer.de/blog/projects/serial-console.html
Process: 1381 ExecStart=/sbin/agetty -o -p – \u --keep-baud 115200,38400,9600 ttyS0 $TERM (code=killed, signal=TERM)
Process: 1379 ExecStartPre=/bin/systemctl start serial-console-conf@ttyS0.service (code=exited, status=0/SUCCESS)
Main PID: 1381 (code=killed, signal=TERM)

Your kernel takes over the ttyS0 device if you have console=ttyS0 in cmdline.txt… just drop it there and ttyS0 should be usable ( you won’t be able to do boot debugging via serial console anymore though)

Thanks
That worked.
I am using an older custom accessory board that needs ttyS0 to interface with the FPGA.

Is it possible to get a build that include a “slot” for ttyS0 ?.

I may also look at changing ttyAMA0 to be the console.