[solved] Disable console on RasPi with Kernel 4.14

This forum is for topics dealing with problems with software specifically in the ARMv7h repo.

[solved] Disable console on RasPi with Kernel 4.14

Postby Twoflower » Fri Mar 16, 2018 6:37 pm

For my project I need to disable the console on UART0 on my RasPi 2. The problem is that I simply fail to do so. I've done the following:
$this->bbcode_second_pass_code('', '> cat /boot/cmdline.txt

root=/dev/mmcblk0p2 rw rootwait rootfstype=ext4 selinux=0 plymouth.enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 elevator=noop
')
$this->bbcode_second_pass_code('', '> cat /boot/config.txt

# See /boot/overlays/README for all available options

##Enable Soundcard
dtoverlay=hifiberry-dacplus

##Enable LIRC
dtoverlay=lirc-rpi,gpio_in_pin=23

##Enable UART1 (ttyAMA0)
enable_uart=1

##Get more fee memory
gpu_mem=16

##Get even more memory
framebuffer_width=64
framebuffer_height=64
framebuffer_depth=8
')
With this I still see the console on ttyAMA0:
$this->bbcode_second_pass_code('', '> dmesg | grep -B2 ttyAMA0

[ 2.736438] uart-pl011 20201000.serial: cts_event_workaround enabled
[ 2.737500] 20201000.serial: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2
[ 3.924077] console [ttyAMA0] enabled
')
Also I see the dmesg messages driven out of the pins. Disabling the serial-getty@ttyAMA0.service is not working as it gets restarted after boot; disabling the service is not persistent. Only renaming /usr/lib/systemd/system/serial-getty@.service is persistent.
$this->bbcode_second_pass_code('', '> systemctl status serial-getty@ttyAMA0.service
● serial-getty@ttyAMA0.service - Serial Getty on ttyAMA0
Loaded: loaded (/usr/lib/systemd/system/serial-getty@.service; enabled-runtime; vendor preset: disabled)
Active: active (running) since Fri 2018-03-16 18:59:37 CET; 1min 2s ago
Docs: man:agetty(8)
man:systemd-getty-generator(8)
http://0pointer.de/blog/projects/serial-console.html
Main PID: 188 (agetty)
Tasks: 1 (limit: 1122)
CGroup: /system.slice/system-serial\x2dgetty.slice/serial-getty@ttyAMA0.service
└─188 /sbin/agetty -o -p -- \u --keep-baud 115200,38400,9600 ttyAMA0 vt220

Mar 16 18:59:37 alarmpi systemd[1]: Started Serial Getty on ttyAMA0.
> systemctl stop serial-getty@ttyAMA0.service
> systemctl disable serial-getty@ttyAMA0.service
> systemctl status serial-getty@ttyAMA0.service
● serial-getty@ttyAMA0.service - Serial Getty on ttyAMA0
Loaded: loaded (/usr/lib/systemd/system/serial-getty@.service; enabled-runtime; vendor preset: disabled)
Active: inactive (dead) since Fri 2018-03-16 19:00:56 CET; 18s ago
Docs: man:agetty(8)
man:systemd-getty-generator(8)
http://0pointer.de/blog/projects/serial-console.html
Main PID: 188 (code=killed, signal=TERM)

Mar 16 18:59:37 alarmpi systemd[1]: Started Serial Getty on ttyAMA0.
Mar 16 19:00:56 alarmpi systemd[1]: Stopping Serial Getty on ttyAMA0...
Mar 16 19:00:56 alarmpi systemd[1]: Stopped Serial Getty on ttyAMA0.

> reboot now

...(Boot process shows action on UART)...

> systemctl status serial-getty@ttyAMA0.service
● serial-getty@ttyAMA0.service - Serial Getty on ttyAMA0
Loaded: loaded (/usr/lib/systemd/system/serial-getty@.service; enabled-runtime; vendor preset: disabled)
Active: active (running) since Fri 2018-03-16 19:03:44 CET; 34s ago
Docs: man:agetty(8)
man:systemd-getty-generator(8)
http://0pointer.de/blog/projects/serial-console.html
Main PID: 190 (agetty)
Tasks: 1 (limit: 1122)
CGroup: /system.slice/system-serial\x2dgetty.slice/serial-getty@ttyAMA0.service
└─190 /sbin/agetty -o -p -- \u --keep-baud 115200,38400,9600 ttyAMA0 vt220

Mar 16 19:03:44 alarmpi systemd[1]: Started Serial Getty on ttyAMA0.
')
But while the service is shut down I can write to /dev/ttyAMA0 but I can't receive anything (checked with an oscilloscope for valid messages). Here a working version.
$this->bbcode_second_pass_code('', '> echo -ne "\rMain.Power?\r" > /dev/ttyAMA0 && cat /dev/ttyAMA0
main.Power=On
')
I'm running out of ideas. I'm happy to provide any missing information.
Last edited by Twoflower on Sat Mar 17, 2018 12:39 pm, edited 1 time in total.
Twoflower
 
Posts: 3
Joined: Fri Mar 16, 2018 5:51 pm

Re: Disable console on RasPi with Kernel 4.14

Postby Twoflower » Fri Mar 16, 2018 10:23 pm

Got a bit further by tricking the console to not use the ttyAMA0 by:
$this->bbcode_second_pass_code('', '> cat /boot/cmdline.txt

root=/dev/mmcblk0p2 rw rootwait console=tty2 kgdboc=tty2 rootfstype=ext4 selinux=0 plymouth.enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 elevator=noop')
I also seem to be able to read from /dev/ttyAMA0. But for some reason I see the following problems:
1. During boot agetty is still talking to it: I see "Arch Linux 4.14.26-1-ARCH (ttyAMA0)" and also the Login. So ther's still the login console active.
2. The baud-rate is 9600
3. After stty -F /dev/ttyAMA0 115200 the Baud rate is OK until the RPi receives something on the Rx of the ttyAMA0. It changes the back to 9600 and repeats the prompt from point 1.
4. Stopping the serial-getty@ttyAMA0.service renders the receiving path (cat /dev/ttyAMA0) useless. But the point 1 and 3 seems to vanish. Why agetty is now forcing 9600 is not clear to me.

It seems that without agetty the Rx is not configured correct. While the Tx seems to work as expected.
Twoflower
 
Posts: 3
Joined: Fri Mar 16, 2018 5:51 pm

Re: Disable console on RasPi with Kernel 4.14

Postby Twoflower » Sat Mar 17, 2018 12:39 pm

Seems that I'm talking to myself.

But it seems I have a solution. My command-line approach does not work as it did earlier. So the response seems to reach the UART too soon. If I run:
$this->bbcode_second_pass_code('', '> cat /dev/ttyAMA0 &
> echo -ne "Main.Power?\r" > /dev/ttyAMA0
Main.Power=On
> killall cat')
So the ttyAMA0 actually works fine now.

Conclusion:
To get the ttyAMA0 actually private The following steps are required (RPi 2, probably RPi 1 as well, but RPi 3 needs tuning)
$this->bbcode_list('1')
  • Change the /boot/cmdline.txt to not have any /dev/ttyAMA0 but it must have some console=/dev/tty1. It seems that the kernel falls back to /dev/ttyAMA0 if no console is present.
  • No need to add enable_uart=1 or dtoverlay=uart0 in the /boot/config.txt (here the RPi 3 might differ).
  • Make sure the serial-getty@ttyAMA0.service is really disabled and stays so.
  • Twoflower
     
    Posts: 3
    Joined: Fri Mar 16, 2018 5:51 pm


    Return to ARMv7h

    Who is online

    Users browsing this forum: No registered users and 13 guests