bike9876@エボ猫.コム
It’s easy to connect a linux box to the raspberry pi 5 via a serial cable. This is useful eg to monitor the output during boot, or to make it easy to enter a passphrase to unlock the root partition (if it is encrypted).
You need a cable like the USB to TTL Serial Cable sold by thepihut (in the UK).
I think this is the Adafruit 954 USB-to-TTL Serial Cable.
NB both my linux box and my pi run arch linux.
/boot/config.txt
on the piAdd line at end of file (following the [all]
line):
dtparam=uart0_console
See https://forums.raspberrypi.com/viewtopic.php?t=359132#p2154324 re this setting.
/boot/cmdline.txt
on the piThere should only be one console= setting (but leave other settings alone):
console=serial0,115200
The individual coloured wires of the cable go to the pi.
The wires connect as:
See https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#gpio for pin locations on the GPIO header.
Suggest run
journalctl -e
on the linux box. (Press q
to exit the pager.)
Should see a line similar to
XXX XX XX:XX:XX XXXX kernel: usb 1-2: cp210x converter now attached to ttyUSB0
So in this case, the device file is /dev/ttyUSB0
.
Run on the linux box
ls -l /dev/ttyUSB0
which will give something like:
crw-rw---- 1 root uucp 188, 0 XXX XX XX:XX /dev/ttyUSB0
So the device file allows group uucp
r/w access.
screen
program, and add user to
uucp
group(Change uucp
to whatever group has access to the device
as in the previous step.)
eg on arch linux:
sudo pacman -S screen
I recommend setting a decent size for the screen scrollback buffer, eg in ~/.screenrc on the linux box, have:
defscrollback 10000
Add user to uucp
group
sudo usermod -aG uucp USERNAME # replace USERNAME with the username of the non-root a/c that will run screen
uucp
)Or run
sudo -s -u USERNAME
which will have USERNAME in the uucp
group within (and
only within) that terminal.
/dev
device as needed)screen /dev/ttyUSB0 115200
Should be able to see whole boot process, until eventually a login prompt appears.
Can scroll by entering screen’s ‘copy mode’ with
Ctrl-a <Escape>
, then use mouse-wheel, or up/down
keys, or Page-up/Page-down keys. (Press q
to exit copy
mode.)
Can search backwards by entering screen’s copy mode, then eg
?switch
. Repeat ?
to search further back.
Enter /
to search forwards again.
When finished (eg the pi is powered down), can exit the screen
session with Ctrl-a k
(then confirm).