WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Headless serial console login setup - couple of suggested changes  (Read 3903 times)

Offline Twist

  • Newbie
  • *
  • Posts: 41
Couple of observations and questions on serial console setup (completely headless from the start):

Q1: Is there a reason the bt-disable overlay is only set for [PI3] devices?
Q2: Should the standard .img be modified to avoid having to edit config.txt and/or remaster in order to get serial console login working?

At the moment /etc/inittab does not contain an entry for serial console login. Instead bootlocal.sh calls /usr/sbin/startserialtty. However startserialtty doesn't always choose the correct dev (ttyS0 vs ttyAMA0).
It decides which one to use, based on the model Pi. However the overlay (bt-disable) switches ttyS0 and ttyAMA0 around. Startserialtty doesn't account for that overlay.

I guess (actually not my use case yet), that it's best to use the inferior PL011 uart for the console, and keep the full fledges 16550 uart available for other tasks.

My tactics to get completely headless setup done (I guess more relevant to Pi zero W than to Pi3B+, but here goes anyway):

Write fresh 11beta1a image to SD card

For a Pi3B+
Mount boot partition somewhere (in my case on OS X laptop)
Comment out the pi3-disbale-bt overlay at the end of config.txt. This swaps ttyS0 and ttyAMA0 around. And so ttyS0 (which is what startserialtty picks based on seeing a pi3) now serves a login over serial console.
No boot messages displayed (need to change cmdline3.txt for that), but that's okay for now: 'we're in':

Code: (bash) [Select]
piCore
box login: tc
Password:
   ( '>')
  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY.
 (/-_--_-\)           www.tinycorelinux.net

tc@box:~$ tty
/dev/ttyS0
tc@box:~$ dmesg | grep tty
[    0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=1 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708_fb.fbswap=1 vd
[    0.000295] console [tty1] enabled
[    1.159824] 3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 81, base_baud = 0) is a PL011 rev2
[    1.160673] console [ttyS0] disabled
[    1.160692] 3f215040.serial: ttyS0 at MMIO 0x0 (irq = 53, base_baud = 31250000) is a 16550
[    1.160727] console [ttyS0] enabled
tc@box:~$ dmesg | grep serial
[    1.159770] uart-pl011 3f201000.serial: cts_event_workaround enabled
[    1.159824] 3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 81, base_baud = 0) is a PL011 rev2
[    1.160692] 3f215040.serial: ttyS0 at MMIO 0x0 (irq = 53, base_baud = 31250000) is a 16550
tc@box:~$ dmesg | grep PL011
[    0.031554] Serial: AMBA PL011 UART driver
[    1.159824] 3f201000.serial: ttyAMA0 at MMIO 0x3f201000 (irq = 81, base_baud = 0) is a PL011 rev2
tc@box:~$ dmesg | grep 16550
[    0.660824] Serial: 8250/16550 driver, 1 ports, IRQ sharing enabled
[    1.160692] 3f215040.serial: ttyS0 at MMIO 0x0 (irq = 53, base_baud = 31250000) is a 16550



For a 0W: add a section towards the end to add the disbale-bt overlay. Again it swap ttyS0 and ttyAMA0 around. This time making ttyAMA0 the 'correct' choice:
Code: (bash) [Select]
piCore
box login: tc
Password:
   ( '>')
  /) TC (\   Core is distributed with ABSOLUTELY NO WARRANTY.
 (/-_--_-\)           www.tinycorelinux.net

tc@box:~$ tty
/dev/ttyAMA0
tc@box:~$ dmesg | grep tty
[    0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=1 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708_fb.fbswapd
[    0.000616] console [tty1] enabled
[    1.519604] 20201000.serial: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2
[    1.519682] console [ttyAMA0] enabled
tc@box:~$ dmesg | grep serial
[    1.519496] uart-pl011 20201000.serial: cts_event_workaround enabled
[    1.519604] 20201000.serial: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2
[   12.470861] uart-pl011 20201000.serial: no DMA platform data
tc@box:~$ dmesg | grep PL011
[    0.090326] Serial: AMBA PL011 UART driver
[    1.519604] 20201000.serial: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2
tc@box:~$ dmesg | grep 16550
[    1.001088] Serial: 8250/16550 driver, 1 ports, IRQ sharing enabled
tc@box:~$

From there (both 3b+ and zeroW) I can then:
  • remaster the initramfs (11.0beta1a[v7].gz to (1) edit /etc/inittab and (2) edit /opt/bootlocal.sh to disable the startserialtty script
  • edit /opt/bootlocal.sh to disable startserialtty (followed by filetool.sh -bv)
I typically make a ttyS0.gz and a ttyAMA0.gz variant so that depending on config.txt and cmdline.txt, the correct one can be picked.

So, coming back to my opening questions: the 11.0beta1a doesn't provide 'out of the box' serial console login on a 3B+ or a Zero W. For both a small change to the config.txt is needed. This seems unnecessary, unless I'm missing something.
Perhaps startserialtty can be modified to include some logic that checks the configured overlays?

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Headless serial console login setup - couple of suggested changes
« Reply #1 on: December 29, 2019, 09:42:09 AM »
Hi Twist

thanks for the suggestions, it as always welcome. Actual status is a result of an organic evolution over the last few years and you are right, due to the latest RPi boards need to be reviewed. I'm on vcation, away from my boards, lets continue discussion at the end of January.


Regards,

Béla
 
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline Twist

  • Newbie
  • *
  • Posts: 41
Re: Headless serial console login setup - couple of suggested changes
« Reply #2 on: December 29, 2019, 03:11:57 PM »
Hi Béla,

Happy holidays!
None of this is urgent anyway. Just thought I put some structured findings together to build on.

Thanks

Offline Twist

  • Newbie
  • *
  • Posts: 41
Re: Headless serial console login setup - couple of suggested changes
« Reply #3 on: January 19, 2020, 04:28:54 PM »
Some additional thoughts:

I guess (actually not my use case yet), that it's best to use the inferior PL011 uart for the console, and keep the full fledges 16550 uart available for other tasks.

I got that bit all wrong   ;D
From the documentation:

Relevant differences between PL011 and mini UART

The mini UART has smaller FIFOs. Combined with the lack of flow control, this makes it more prone to losing characters at higher baudrates. It is also generally less capable than the PL011, mainly due to its baud rate link to the VPU clock speed.

The particular deficiencies of the mini UART compared to the PL011 are :

No break detection
No framing errors detection
No parity bit
No receive timeout interrupt
No DCD, DSR, DTR or RI signals


So it's actually the mini-UART (ttyS0) that is intended as a 'low throughput' console. Downside: it's clock is linked to the core frequency of the VPU. And thus the latter needs to be fixed to get a useable ttyS0 serial console.
When bluetooth (by default linked to the PL011 / ttyAMA0) is not needed, it can be disable with an overlay, which then makes ttyAMA0 the primary UART for a linux console. This avoids the fixed VPU frequency. Downside: no bluetooth.

I guess it depends on what piCore wants to deliver by default (for the 3B+ and Zero):
1) Enabled bluetooth + enabled serial console (on ttyS0) (with a fixed VPU clock)
2) Enabled bluetooth + disabled serial console (still optional on ttyS0 * )
3) Disabled bluetooth + enabled serial console (on ttyAMA0)

* A tiny edit to the cmdline.txt file to change enable_uart=0 to enable_uart=1 would then be the only thing to change over from 2) into 1)

My vote would be for option 3. I see more logic in having a non-fixed VPU clock with out-of-the-box headless serial console working, then enabling the bluetooth hardware from the very first boot.

Offline Joe_H

  • Newbie
  • *
  • Posts: 16
Re: Headless serial console login setup - couple of suggested changes
« Reply #4 on: July 27, 2023, 08:34:23 AM »
Bit late to this conversation but thought it was worth recording a solution that worked!

Twist's solution works for the RPi0W which is the main one I'm using (v9.0 of piCore but others will work). The only change required is to config.txt and the near final section:

[pi3]
dtoverlay=pi3-disable-bt

change the pi3 to all, as in:

[all]
dtoverlay=pi3-disable-bt

Now the RPi0W doesn't have bluetooth enabled but the serial connection works correctly and provides a login prompt for tc on ttyAMA0. No other changes are required to the stock image (9.0) to get this working. This is very useful for a simple method for a headless install of a RPi0W which is what I only use as the wifi can be simply set up then.

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 718
Re: Headless serial console login setup - couple of suggested changes
« Reply #5 on: July 27, 2023, 04:54:14 PM »
And you should also look at the inittab file to get the getty right with the correct serial port.
And then remake the initrd image.

You can click on this link to get more threads that i have written with this problem.

https://forum.tinycorelinux.net/index.php?action=search2&search=inittab&userspec=patrikg
« Last Edit: July 27, 2023, 05:08:42 PM by patrikg »