From 190f36d473d7eda5f18c21f738ec0efbbab991e1 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Mon, 27 Apr 2026 06:39:24 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E7=94=A8=E4=BA=8E=E5=BC=95=E5=AF=BC?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E6=97=B6=E4=B8=8D=E9=9C=80=E8=A6=81=E5=88=A4?= =?UTF-8?q?=E6=96=AD=20tty=20=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8=E5=92=8C?= =?UTF-8?q?=E5=8F=AF=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ttys.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/ttys.sh b/ttys.sh index 630873f..3fba00f 100644 --- a/ttys.sh +++ b/ttys.sh @@ -7,16 +7,24 @@ prefix=$1 # 注意 debian initrd 没有 xargs # 最后一个 tty 是主 tty,显示的信息最全 -is_first=true if [ "$(uname -m)" = "aarch64" ]; then ttys="ttyS0 ttyAMA0 tty0" else ttys="ttyS0 tty0" fi +# 安装环境下 tty 不一定齐全 +# hytron 有ttyS0 但无法写入 +# 用于 cmdline 引导参数时不需要判断 tty 是否存在和可写 +if [ "$prefix" = "console=" ]; then + is_for_cmdline=true +else + is_for_cmdline=false +fi + +is_first=true for tty in $ttys; do - # hytron 有ttyS0 但无法写入 - if stty -g -F "/dev/$tty" >/dev/null 2>&1; then + if $is_for_cmdline || stty -g -F "/dev/$tty" >/dev/null 2>&1; then if $is_first; then is_first=false else @@ -25,7 +33,7 @@ for tty in $ttys; do printf "%s" "$prefix$tty" - if [ "$prefix" = "console=" ] && + if $is_for_cmdline && { [ "$tty" = ttyS0 ] || [ "$tty" = ttyAMA0 ]; }; then printf ",115200n8" fi