Carduelis
Posts: 11
Joined: Fri Feb 05, 2016 5:56 pm
Location: Cambridge, UK

Auto login on a serial device

Tue Apr 19, 2016 3:53 pm

I am building an old-style VAX emulator on Pi and have successfully connected a 40 year old serial VT100 terminal via a level shifter and GPIO pins.

I have removed console=ttyAMA0 from Cmdline.txt and I am manually starting a getty service on ttyAM0 after each boot. All works well with a manual login but in order to make the emulator as realistic as possible I would like to be able to log it in and then run simh without user intervention. So:

Q1) Is there any way I can run ' sudo systemctl start getty@ttyAMA0' automatically? I have tried putting it in rc.local and set the execution bit as instructed, but it doesn't work.

Q2) Is there any way I can automatically login AMA0 and run a script to start the emulator application?

Many thanks

dgordon42
Posts: 796
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Auto login on a serial device

Tue Apr 19, 2016 6:52 pm

I've got a DEC VT320 (built 1979) terminal running on a Pi.
Based on what I did, running Raspbian Jessie, this is my answer to your Q1:

Copy the file "serial-getty@.service" from /lib/systemd/system to /etc/systemd/system
This file is a template for setting up a serial terminal with systemd.
Rename the file in /etc/systemd/system to (in your case) "serial-getty@ttyAMA0.service"
Open the file for editing, go to the [Service] section and edit the line:

Code: Select all

ExecStart=-/sbin/agetty --keep-baud 115200,38400,9600 %I $TERM
to something like:

Code: Select all

ExecStart=-/sbin/agetty -a YOUR_USER_NAME ttyAMA0 9600 vt100
The agetty -a switch enables automatic log in. I'm using 9600 baud, my terminal won't work reliably above that, yours may not either.
Carduelis wrote:I have removed console=ttyAMA0 from Cmdline.txt
This would have been the next step, but you have done it already.

Run:

Code: Select all

sudo systemctl enable serial-agetty@ttyAMA0.service
EDIT Jun 2016: Typo in the above line, it should read:

Code: Select all

sudo systemctl enable serial-getty@ttyAMA0.service
This tells systemd to start your terminal at every boot up
Reboot.

This should get you automatically logged in to your VT100 terminal on the serial port of a Pi or Pi 2.
The serial port in the Pi 3 is a little different. to connect to a Pi 3, you should add:

Code: Select all

enable_uart=1
to the end of /boot/config.txt, and change "AMA0" to "serial0" in both the file name and the ExecStart line above.

I don't have simh, but I guess the normal methods of running a script at boot up might answer your Q2.

It should be possible to come up with a modification to /boot/cmdline.txt which will allow the Pi to connect to the VT100 at boot, this would be much simpler than all the above, but I don't know how to auto log in from /boot/cmdline.txt. It also means (I think) that the VT100 would show all the boot messages as Raspbian boots up. Maybe someone will come along who does know.

Hope this helps,
Dave.
Last edited by dgordon42 on Sat Jun 11, 2016 8:46 pm, edited 1 time in total.

Carduelis
Posts: 11
Joined: Fri Feb 05, 2016 5:56 pm
Location: Cambridge, UK

Re: Auto login on a serial device

Tue Apr 19, 2016 8:52 pm

Many thanks, that looks like the answer to Q1. I'll report back idc.

Apologies for what is probably a Newbie question, but I still need the answer to Q2. Note that I ONLY want the script to run on the serial AMA0 device and not on the main screen, so presumably adding it to rc.local won't be the right answer.

I need it to cd to a specific folder
Run the emulator
Logout when the emulator exits

stirlingboy69
Posts: 1
Joined: Sun Jul 20, 2014 9:05 pm

Re: Auto login on a serial device

Sat Jun 11, 2016 7:48 pm

Hey dgordon42,

Thanks for the info on how to auto login via the serial console.
However, I think you have a small typo.
Where you say to enable the service by typing:

Code: Select all

sudo systemctl enable serial-agetty@ttyAMA0.service 
fails to work because the serial-agetty@ttyAMA0.service file doesn't exist.
If I type:

Code: Select all

sudo systemctl enable serial-getty@ttyAMA0.service 
then it works.

Again thanks for the info.

Pete

dgordon42
Posts: 796
Joined: Tue Aug 13, 2013 6:55 pm
Location: Dublin, Ireland

Re: Auto login on a serial device

Sat Jun 11, 2016 8:37 pm

@stirlingboy69,
Yes, you are correct, typo. Thanks for the correction, I have edited my post.

It's also worth pointing out that, since the May 2016 update to the 4.4 kernel, the serial port on the Pi is now called "serial0" instead of "ttyAMA0".
This change should work on all model Pi's, previously ttyAMA0 on the Pi 3B was normally reserved for use with Bluetooth.

Thanks,
Dave.

Return to “Beginners”