2023-08-08 23:21:28 +08:00
|
|
|
|
#!/bin/sh
|
|
|
|
|
prefix=$1
|
2023-09-03 19:35:01 +08:00
|
|
|
|
|
2024-03-31 00:47:13 +08:00
|
|
|
|
# 不要在 windows 上使用,因为不准确
|
|
|
|
|
# 在原系统上使用,也可能不准确?例如安装了 cloud 内核的甲骨文?
|
2023-09-03 19:35:01 +08:00
|
|
|
|
|
2024-08-19 00:33:59 +08:00
|
|
|
|
# 注意 debian initrd 没有 xargs
|
|
|
|
|
|
2023-10-08 21:58:16 +08:00
|
|
|
|
# 最后一个 tty 是主 tty,显示的信息最全
|
2023-09-03 19:35:01 +08:00
|
|
|
|
is_first=true
|
2024-08-19 00:33:59 +08:00
|
|
|
|
if [ "$(uname -m)" = "aarch64" ]; then
|
|
|
|
|
ttys="ttyS0 ttyAMA0 tty0"
|
|
|
|
|
else
|
|
|
|
|
ttys="ttyS0 tty0"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
for tty in $ttys; do
|
2023-10-08 21:58:16 +08:00
|
|
|
|
# hytron 有ttyS0 但无法写入
|
2024-03-31 00:47:13 +08:00
|
|
|
|
if stty -g -F "/dev/$tty" >/dev/null 2>&1; then
|
2023-10-08 21:58:16 +08:00
|
|
|
|
if $is_first; then
|
|
|
|
|
is_first=false
|
|
|
|
|
else
|
2023-09-03 19:35:01 +08:00
|
|
|
|
printf " "
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
printf "%s" "$prefix$tty"
|
|
|
|
|
|
2024-03-31 00:47:13 +08:00
|
|
|
|
if [ "$prefix" = "console=" ] &&
|
|
|
|
|
{ [ "$tty" = ttyS0 ] || [ "$tty" = ttyAMA0 ]; }; then
|
2023-09-03 19:35:01 +08:00
|
|
|
|
printf ",115200n8"
|
2023-08-08 23:21:28 +08:00
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
done
|