tawalker
Posts: 183
Joined: Tue Jan 17, 2012 9:02 am

Getting serial console to respond in Arch/ARM

Thu Oct 04, 2012 10:08 am

I recently took delivery of a USB-to-RS232 converter module, which I ordered from eBay UK (it was reported on this forum as working with the RasPi). My main aim is to set up a USB-serial console port, which I can use to log into the Pi from another computer - for instance, if the USB and/or Ethernet on the Pi aren't responding and I "need" to access the machine for diagnostics, etc.

Following various forum and blog posts strewn around the interwebs (mostly around this site), I connected up the module to the appropriate GPIO pins on the Pi, and used a USB extension cable to hook up the module to my netbook (running Arch/x86). My Pi is running the "hard float" version of Arch; it's a recent install, and I am still installing and setting up things there, so not everything is yet arranged how I'd ultimately like it.

When I started minicom on the netbook (115800, 8-N-1), I expected to see a login prompt from the Pi, but the terminal display stayed more or less blank, aside from the odd garbled character or three (presumably stray voltages or something?).

I am reasonably certain that the USB-serial module is connected and working correctly on the Pi. When I press keys on the netbook when minicom is running, the "RX" LED on the module flashes, and I can echo text from the Pi to its serial port (/dev/ttyAMA0) and the text appears in the minicom terminal on the netbook.

My suspicion is that the Pi's console port is either not set up somehow, or it is not directing the console I/O to /dev/ttyAMA0 properly, so minicom on the netbook doesn't have anything on the Pi to "talk to". I don't know if this is correct, but I've made sure that

Code: Select all

console=ttyAMA0,115200
is present in /boot/cmdline.txt.

In short: I'd be most grateful if someone could suggest what else I need to do, in order to be able to get serial console access running on my Pi?

Many thanks in advance :)
---
Raspberry Pi Model 3B+ (2019) ("ayeka") - CentOS
Raspberry Pi Zero W (2018) ("mass") - Raspbian
Raspberry Pi Model B (1st-gen - 2012) ("ryo-ohki") - Arch Linux ARM
---

pepedog
Posts: 1043
Joined: Fri Oct 07, 2011 9:55 am

Re: Getting serial console to respond in Arch/ARM

Thu Oct 04, 2012 10:17 am

Code: Select all

systemctl start getty@ttyUSBx.service
maybe?
Look see what device is in /dev folder
If you need help starting on boot, or speed problems, post back

tawalker
Posts: 183
Joined: Tue Jan 17, 2012 9:02 am

Re: Getting serial console to respond in Arch/ARM

Thu Oct 04, 2012 1:25 pm

pepedog wrote:

Code: Select all

systemctl start getty@ttyUSBx.service
maybe?
Look see what device is in /dev folder
If you need help starting on boot, or speed problems, post back
Thanks pepedog - I'll take a look at this and come back here with what transpires :)
---
Raspberry Pi Model 3B+ (2019) ("ayeka") - CentOS
Raspberry Pi Zero W (2018) ("mass") - Raspbian
Raspberry Pi Model B (1st-gen - 2012) ("ryo-ohki") - Arch Linux ARM
---

pepedog
Posts: 1043
Joined: Fri Oct 07, 2011 9:55 am

Re: Getting serial console to respond in Arch/ARM

Thu Oct 04, 2012 7:23 pm

It might be ttySx where x is a number. Plugging is and looking at dmesg might help identify

tawalker
Posts: 183
Joined: Tue Jan 17, 2012 9:02 am

Re: Getting serial console to respond in Arch/ARM

Thu Oct 04, 2012 8:14 pm

Thanks pepedog :D I think the systemd service was the key. I ran

Code: Select all

systemctl start getty@ttyAMA0
, and was then able to log on via minicom on the netbook.

The only small issue I've had since it started working, was that the console doesn't seem to start automatically on boot, even though I've enabled the service via systemctl. I'll test it further (maybe it was a short-term problem), but at least I know how to get the console working!

Thanks again!
---
Raspberry Pi Model 3B+ (2019) ("ayeka") - CentOS
Raspberry Pi Zero W (2018) ("mass") - Raspbian
Raspberry Pi Model B (1st-gen - 2012) ("ryo-ohki") - Arch Linux ARM
---

pepedog
Posts: 1043
Joined: Fri Oct 07, 2011 9:55 am

Re: Getting serial console to respond in Arch/ARM

Thu Oct 04, 2012 8:25 pm

No .service on the end? I wonder if that is needed?
BTW, files are in /usr/lib/systemd/system

tawalker
Posts: 183
Joined: Tue Jan 17, 2012 9:02 am

Re: Getting serial console to respond in Arch/ARM

Mon Oct 08, 2012 1:18 pm

I still need to check whether the console service is now autostarting on boot (thanks for the lead, pepedog :) ), but while you're waiting for that: here's a short video to show the serial link is working fine...
---
Raspberry Pi Model 3B+ (2019) ("ayeka") - CentOS
Raspberry Pi Zero W (2018) ("mass") - Raspbian
Raspberry Pi Model B (1st-gen - 2012) ("ryo-ohki") - Arch Linux ARM
---

User avatar
tedhale
Posts: 114
Joined: Thu Sep 20, 2012 4:52 pm
Location: Williamsburg, VA, USA

Re: Getting serial console to respond in Arch/ARM

Mon Oct 08, 2012 2:01 pm

I am not really familiar with that distro, but assuming that is is like most linux distros, you need to have a line in

/etc/inittab

that looks like this

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

That should make the login prompt appear automatically on boot.
- Ted B. Hale
http://raspberrypihobbyist.blogspot.com

pepedog
Posts: 1043
Joined: Fri Oct 07, 2011 9:55 am

Re: Getting serial console to respond in Arch/ARM

Mon Oct 08, 2012 3:18 pm

tedhale wrote:I am not really familiar with that distro, but assuming that is is like most linux distros, you need to have a line in

/etc/inittab

that looks like this

T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100

That should make the login prompt appear automatically on boot.
Not any more, that was under init, replaced by systemd
To enable on boot

Code: Select all

systemctl enable getty@ttyAMA0.service

User avatar
tedhale
Posts: 114
Joined: Thu Sep 20, 2012 4:52 pm
Location: Williamsburg, VA, USA

Re: Getting serial console to respond in Arch/ARM

Tue Oct 09, 2012 1:09 pm

Thanks for the correction. Once again showing what an old fart I am (though I did say I wasn't familiar with the distro.)
A lot of my experience is with Debian and Ubuntu, so Raspbian seemed the best choice for me to start with.
It still amazes me how quickly the number of choices is growing for the RasPi.
- Ted B. Hale
http://raspberrypihobbyist.blogspot.com

pepedog
Posts: 1043
Joined: Fri Oct 07, 2011 9:55 am

Re: Getting serial console to respond in Arch/ARM

Tue Oct 09, 2012 3:01 pm

Old fart? I'm not far off 59
Truthfully I am really getting attached to systemd

tawalker
Posts: 183
Joined: Tue Jan 17, 2012 9:02 am

Re: Getting serial console to respond in Arch/ARM

Tue Oct 09, 2012 3:05 pm

Odd thing: I can start the service with

Code: Select all

# systemctl start getty@ttyAMA0
and the serial console runs fine, but if I run

Code: Select all

# systemctl enable getty@ttyAMA0.service
and reboot the Pi, the console service doesn't respond when I try and log onto it from a connected machine. (The systemctl "status" seems to say the service is enabled, but it doesn't appear to have auto-started.)

If I can access the Pi another way (SSH, keyboard/display), I can start the service manually, but that rather defeats the object of having the serial console (i.e. for accessing the Pi if other methods aren't available). Any ideas why the service may be enabled, but isn't autostarting?

Many thanks for your suggestions so far :)
---
Raspberry Pi Model 3B+ (2019) ("ayeka") - CentOS
Raspberry Pi Zero W (2018) ("mass") - Raspbian
Raspberry Pi Model B (1st-gen - 2012) ("ryo-ohki") - Arch Linux ARM
---

tawalker
Posts: 183
Joined: Tue Jan 17, 2012 9:02 am

Re: Getting serial console to respond in Arch/ARM

Tue Oct 09, 2012 3:15 pm

pepedog wrote:Truthfully I am really getting attached to systemd
I'm starting to grow used to systemd, mainly as I've had to - I did a fresh installation of the "hard-float" Arch/ARM on the Pi, and it came with systemd all set up, so I figured I'd roll with it :)

Mind you, I'm now in the weird situation of having two machines running Arch (the Pi, and my Eee 701SD netbook (x86)), where the Pi is set up with systemd and the Eee is still on initscripts. I'd like to switch the Eee over to systemd too, not least because the boot process keeps telling me the lines in rc.conf are deprecated :shock:

Thankfully the Arch wiki has a thorough guide on migration to systemd, but it looks a bit like open-heart surgery...
---
Raspberry Pi Model 3B+ (2019) ("ayeka") - CentOS
Raspberry Pi Zero W (2018) ("mass") - Raspbian
Raspberry Pi Model B (1st-gen - 2012) ("ryo-ohki") - Arch Linux ARM
---

greyfrog
Posts: 1
Joined: Sat Dec 01, 2012 3:57 am

Re: Getting serial console to respond in Arch/ARM

Sat Dec 01, 2012 4:27 am

Hi tawalker and others,
I had the same problem with no serial console in Arch, then having it not start on boot. Your conversation got me going in the right direction to fix it. So I should post it here for everybody else:
First, 115200 seems to be too fast (at least in my case with an Adafruit serial to usb connector). Change it to 38400 in /boot/cmdline.txt :

Code: Select all

sdhci-bcm2708.enable_llm=1 sdhci-bcm2708.sync_after_dma=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 console=ttyAMA0,38400 kgdboc=ttyAMA0,38400 console=tty1 loglevel=6 root=/dev/mmcblk0p2 init=/bin/systemd rootfstype=ext4 rootwait
Second, systemctl enable is not creating the proper service link:

Code: Select all

ln -s /usr/lib/systemd/system/getty@.service /etc/systemd/system/getty.target.wants/getty@ttyAMA0.service
Third, on the other end, minicom gave me no end of problems. gtkterm works better. screen works best:

Code: Select all

screen /dev/ttyUSB0 38400
The serial console is now working like I expect.
I just got my Pi yesterday. I'm not sure what I'm going to do with it yet, other than play around, but I'm having fun so far. Thanks for getting me going in the right direction with your posts.

/greyfrog

pepedog
Posts: 1043
Joined: Fri Oct 07, 2011 9:55 am

Re: Getting serial console to respond in Arch/ARM

Sat Dec 01, 2012 10:21 am

Greyfrog,
you can also cp the file instead of symlink, and edit it.
It's not a hack but a way of customising

SheepOnMeth
Posts: 9
Joined: Wed May 30, 2012 1:39 pm

Re: Getting serial console to respond in Arch/ARM

Mon Dec 24, 2012 3:47 pm

Hello everyone,

I have the same issue. But I try all the solutions in this topic and I still have nothing on minicom, gtkterm or screen.

Systemd conf is good.

My cmdline.txt :

Code: Select all

smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 console=ttyAMA0,38400 kgdboc=ttyAMA0,38400 console=tty1 loglevel=6 root=/dev/mmcblk0p2 rootfstype=ext4 rootwait
:D

I'm running Archlinux on my laptop.

t3chm4g3
Posts: 1
Joined: Sat Jan 05, 2013 1:23 pm

Re: Getting serial console to respond in Arch/ARM

Sat Jan 05, 2013 1:31 pm

Hi everyone,

The solution posted above by greyfrog is almost complete. What I'd like to add to it is this:
keep the baudrate at 115200 in cmdline.txt
and instead of spawning getty@.service spawn serial-getty@.service

With the above changes I can see the kernel log output at boot and login via serial console to my arch/raspberry pi.

sdjf
Posts: 1397
Joined: Fri Mar 16, 2012 5:20 am
Location: California

Re: Getting serial console to respond in Arch/ARM

Sun Jan 06, 2013 9:35 pm

I am confused. Which end are you guys connecting to the GPIO pins and which end to your PCs?

And which tutorial or how-to or thread did you find the most helpful in figuring out the hardware setup?
FORUM TIP: To view someone's posting history, sign in, click on their user name, then on "Search User's Posts." || Running ArchLinuxArm on Model 2B and 512MB Model B

johnlane
Posts: 63
Joined: Fri Jul 20, 2012 8:26 pm

Re: Getting serial console to respond in Arch/ARM

Thu Jan 10, 2013 8:58 pm

Very good, I had all this independently working at 38400 line speed. I have just changed it to 115200 using the suggestion from "t3chm4g3" to use serial-getty.service. The only desirable thing left that I do not have is to see the systemd startup messages on the serial port. Does anyone know how to achieve that ?

I believe this is due to data written to to /dev/console not being sent to the serial port.

It's funny how, as soon as you write a post about something, you find the solution :lol: When more than one console is listed in the kernel parameters, it is the the last one that gets assigned to /dev/console. So, to get /dev/console output on the serial port, ensure the console=ttyAMA0 entry comes after the console=tty1 entry in /boot/cmdline.txt.

My cmdline.txt is below for reference

Code: Select all

sdhci-bcm2708.enable_llm=1 sdhci-bcm2708.sync_after_dma=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 console=tty1 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 loglevel=6 root=/dev/sda5 init=/bin/systemd rootfstype=ext4 rootwait
Last edited by johnlane on Thu Jan 10, 2013 9:08 pm, edited 1 time in total.
Raspberry Pi Utilities: https://github.com/johnlane/rpi-utils
For Raspberry Pi and Arch Linux

pepedog
Posts: 1043
Joined: Fri Oct 07, 2011 9:55 am

Re: Getting serial console to respond in Arch/ARM

Thu Jan 10, 2013 9:03 pm

Can you see in /boot/cmdline.txt there is a couple of console= entries?
Add another for your device

sudar
Posts: 3
Joined: Mon Oct 14, 2013 9:16 am

Re: Getting serial console to respond in Arch/ARM

Mon Oct 14, 2013 9:18 am

Code: Select all

systemctl enable getty@ttyAMA0.service
Can someone kindly tell me what is the equivalent of this command in Raspbian?

PS: My apologies if I am posting in the wrong place.

spitfire
Posts: 1
Joined: Fri Jun 06, 2014 9:52 pm

Re: Getting serial console to respond in Arch/ARM

Fri Jun 06, 2014 10:06 pm

Thanks everyone for the detailed suggestions.

After trying a lot of these variations, I found a simple solution for Redsleeve.

1. Start with the Redsleeve distribution raspi-v2-redsleeve-cli-0.3.img. The provided /boot/cmdline.txt already has ttyAMA0 listed as a console, just not the primary one:

Code: Select all

dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait
2. Create a new file, /etc/init/ttyAMA0.conf:

Code: Select all

stop on runlevel [S016]
start on runlevel [2345]
instance /dev/ttyAMA0
respawn
pre-start exec /sbin/securetty ttyAMA0
exec /sbin/mingetty ttyAMA0
3. Then add one line to the existing /etc/securetty:

Code: Select all

echo 'ttyAMA0' >>/etc/securetty
Plug in the Adafruit cable, reboot the Raspberry Pi -- you can now log in via the HDMI / VGA console, and/or the serial console.

Interesting note -- if you connect via serial, leave the connection as-is then reboot, you will be able to view all the boot-time messages over the serial connection, which is handy.

Next I'm going to try to alter the Redsleeve image to add & alter the above files prior the install. If I can figure that out, I will share that too!

Return to “Arch”