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.