Serial port usage


#1

I just deployed some code that uses /dev/ttyAMA0 on the Pi. That is the console port on the GPIO header. I have not had a chance to test it yet but it claims to have opened the port as expected.

It occurred to me to ask if the resin SD images use that port as the Linux boot message output or console login?


Serial port issues on Raspberry Pi 3
#2

Hey,

In terms of the GPIO serial pins themselves, we intentionally avoid using these so others can use these pins as they see fit.

As far as I’m aware, we don’t currently spawn any terminals whatsoever, so you should be good to go with /dev/ttyAMA0. Do let us know if you experience any issues with that however!

Best, Lorenzo


#3

Once again “Excellent”. Thanks.


#4

I’ve been having some weird issues related to this after upgrading to the latest base image. For some reason, the serial port doesn’t seem stable, closing after a while and having checksum errors also.

Note that:

  • I haven’t tested on another RPi yet, to confirm that this isn’t a hardware issue.
  • The same issue occurs both in my Python-code and using minicom.
  • The error from Python does give the idea, that it might be caused by the port being open in another program, but lsof etc don’t show any other software in my Docker-image listening to the device.

The same exact code did work on previous image, which was resin-<project_name>-0.1.0-0.0.14.img. The current image is resin-<project_name>-0.1.0-0.0.15-<hash>.img.

Has anyone experienced the same? I’ll try and boot up another Pi this weekend, just to confirm that it’s not a hardware issue. If it’s not, I’ll also try connecting the device through USB/serial -adapter…


#5

I finally managed to test this using another RPi.
The issue remains. To rule out hardware issue related to the communication module I use, I used USB-to-Serial converter on my laptop, everything works correctly.

This leads me to think that something has changed in the new image :frowning:


#6

Ok, finally bothered to track down the issue a bit more. It is an issue with the new image, it (at least) uses serial port for console:

cat /mnt/loop/resin-boot/cmdline.txt

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait

#7

Hey,

Thank you for raising this issue and actually doing some digging on your own, that is most useful to us. Can you please tell me what version of the RPi is in question (so I can try to reproduce this behavior)?

Theodor


#8

Hi,

It’s the RPi B+, although I do think the issue might be in all the RPi base images.

-Kimmo


#9

You might be right, but it is better for us to have a starting point, which is the board that you have observed this problem onto. I am gonna be investigating this and come back to you with a solution.
Thank you for your patience.

Theodor


#10

I can confirm serial output that is reminiscent of ‘console=ttyAMA0,115200’ (haven’t checked cmdline.txt, but I’ve seen it often enough). Is there an easy way to configure the base image to skip serial logging, or does that require building a new image from scratch? Alternatively, as this interferes with most use cases where the serial port is needed and annoy quite a few people, can resin.io make different images available?

Boris

PS: RPi A+ in my case


#11

There’s also /etc/inittab (on vanilla Raspian) with a few respawn on ttyAMA0 that would need deleting to prevent accidental serial output.


#12

I just checked the RPi 2 image, and can confirm that the same thing affects it also…


#13

Hi, we have a fix for the issue which will be deployed very soon. The fix also applies to RPi 2. Thank you for your report!

Best,
Akis


#14

Great to hear that, looking forward to it :smile:


#15

I noticed the image has updated to 0.0.16, is this included?
If so, do I need to reflash or can this also be updated “over-the-air”?


#16

The fix is currently available, we suggest you to do a reflash but if the device is hard to reach let us know and we could, with your permission do a manual remote update.


#17

Hi,
I also tried to use /dev/ttyAMA0.
Using resin.io, Raspberry did not even boot up, with a module attached to the GPIO pins. I then had to remove the parts from cmdline.txt from the SD card manually. Now it is booting up.
But: I don’t get any data from /dev/ttyAMA0
Using default raspian and the same code it works, but within resin.io, nothing arrives.
Any hints on that?

Btw: I did not find a file called /etc/inittab within my env.

thanks a lot,
best regards
Fritz

PS I installed the latest Raspian 2 image (1.1.1-1.6.0)


#18

Hi, please forget my last comment. Right the time I tried it, we did not have any inputs on ttyAMA0 (driven by other device).
Sorry for the confusion…

Fritz


#19

Hi all,

I’m afraid I am also having problems using /dev/ttyAMA0 on a Raspberry Pi 2 and the latest Resin OS (2.0.0.+rev3 dev, supervisor 4.1.1); and I was wondering if anyone might be able to help or suggest a fix?

My setup is a Raspberry Pi 2 (model B) with an Adafruit Ultimate GPS Hat attached. This hat communicates with the Pi over a serial interface. Using the latest Raspbian Jessie Light (4.4) rather than Resin, the device behaves as expected and GPS data comes streaming through /dev/ttyAMA0:

Raspbian Jessie (4.4)

$ sudo stty -F /dev/ttyAMA0 raw 9600 cs8 clocal -cstopb
$ sudo cat /dev/ttyAMA0
$GPGGA,000342.800,,,,,0,00,,,M,,M,,*75
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,000342.800,V,,,,,0.00,0.00,060180,,,N*4F
$GPVTG,0.00,T,,M,0.00,N,0.00,K,N*32
$GPGGA,000343.800,,,,,0,00,,,M,,M,,*74
$GPGSA,A,1,,,,,,,,,,,,,,,*1E
$GPRMC,000343.800,V,,,,,0.00,0.00,060180,,,N*4E
...

Whereas, connecting to the Resin.io supervisor container and running the same commands (without sudo) does not produce any data:

Resin OS 2.0.0+rev3 (dev), supervisor 4.1.1

$ sudo resin local ssh aa5f942.local
? Select a container /resin_supervisor (776a546709d) - Up 7 minutes
/usr/src/app # stty -F /dev/ttyAMA0 raw 9600 cs8 clocal -cstopb
/usr/src/app # cat /dev/ttyAMA0


(no output)

It is the same hardware in both cases, so I’m certain it is a configuration or software problem. I’ve wondered if the difference might be down to the cmdline.txt or config.txt files on Raspbian vs Resin? The Raspbian configuration files are:

Raspbian cmdline.txt

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=PARTUUID=16a0382a-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

Resin cmdline.txt

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait

Raspbian config.txt (non default values)

dtparam=audio=on

Resin config.txt (non default values)

dtparam=i2c_arm=on
dtparam=spi=on
disable_splash=1
avoid_warnings=1
dtparam=audio=on
enable_uart=1

I was thinking of trying an older version of Resin OS next as the reports in the thread above suggest that does work? I’d be very grateful for any tips or pointers…

Thanks,

Martyn.


#20

Hi @martyn-w

Did you manage to get this working?

If not, please can you:

  • Post the output of ls -l /dev/tty*
  • Post the output of cat /etc/inittab (if the file exists)
  • Try setting enable_uart to 0

Thanks