Enable Serial Terminal 开启Serial 终端

Raspberry Pi SoC 后期有内建2组UART,所以会做一个相容,

tty UART Type map
Serial0 mini UART ttyS0
Serial1 PL011 ttyAMA0

Kernel

Open /boot/cmdline.txt

console=serial0,115200 root=PARTUUID=d82c2881-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

EDIT console=serial0,115200

console=serial0,115200

这个是开机过程Kernel会将输出导出至UART,如果没设定在开机过程就只能在萤幕上看到

Terminal

终端输出还是需要靠程式本身处理,主要的systemd设定在

sudo nano lib/systemd/system/serial-getty@.service

使用@机制,启动时要在@后面加上设备名称如:ttyS0

sudo systemctl enable serial-getty@[ttyS0|ttyAMA0].service

假设是ttyS0

sudo systemctl enable serial-getty@ttyS0.service

参考资料

Enabling a Serial Port Console: getty systemd

启用Raspberry Pi 3B+ 序列埠功能