-
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathasahi-diagnose
More file actions
executable file
·194 lines (164 loc) · 4.09 KB
/
asahi-diagnose
File metadata and controls
executable file
·194 lines (164 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/bin/sh
log() {
echo "$@"
}
dt() {
p=/proc/device-tree/"$1"
if [ ! -e "$p" ]; then
echo "(missing)"
else
cat "$p" | tr "\0" " " | sed -e 's/ $//g'; echo
fi
}
banner() {
cat <<EOF
# Asahi Linux System Diagnostic Dump
Collected at: $(date) ($(date -Iseconds))
Username: $(whoami)
Hostname: $(hostnamectl hostname)
EOF
}
device_info() {
cat <<EOF
## Device information
Model: $(dt model)
Compatible: $(dt compatible)
EOF
}
firmware_versions() {
cat <<EOF
## Firmware versions
iBoot1: $(dt chosen/asahi,iboot1-version)
iBoot2: $(dt chosen/asahi,iboot2-version)
SFR: $(dt chosen/asahi,system-fw-version)
OS firmware: $(dt chosen/asahi,os-fw-version)
m1n1 stage 2: $(dt chosen/asahi,m1n1-stage2-version)
U-Boot: $(dt chosen/u-boot,version)
EOF
}
boot_config() {
cat <<EOF
## Boot information
ESP UUID: $(dt chosen/asahi,efi-system-partition)
EFI: $([ -e /sys/firmware/efi ] &&
echo available || echo unavailable)
EOF
}
system_info() {
cat <<EOF
## System information
Kernel: $(uname -r)
Kernel build: $(uname -v)
Uptime: $(uptime)
Kernel cmdline: $(cat /proc/cmdline)
EOF
}
getfile() {
cat <<EOF
## $2
\`\`\`
$(cat $1)
\`\`\`
EOF
}
cmd() {
cat <<EOF
## $2
\`\`\`
$($1)
\`\`\`
EOF
}
package_versions() {
cat <<EOF
## Package versions
\`\`\`
$(pacman -Q \
m1n1 uboot-asahi asahi-scripts asahi-meta asahi-desktop-meta \
asahi-fwextract asahi-configs alsa-ucm-conf-asahi \
asahilinux-keyring linux linux-asahi linux-asahi-edge \
mesa xorg-server pipewire kwin mutter \
2>/dev/null | uniq)
\`\`\`
EOF
}
module_parameters() {
echo "## Module parameters"
for mod in asahi hid_apple hid_magicmouse; do
[ ! -e /sys/module/$mod/parameters/ ] && continue
echo " $mod"
for param in /sys/module/$mod/parameters/*; do
echo " $(basename "$param")=$(cat "$param" | tr -d '\0')"
done
echo
done
echo
}
logfile() {
f="$1"
lines="$2"
[ -e "$1" ] || return
echo "## Log file: \`$f\`"
echo '```'
if [ -z "$lines" ]; then
cat "$f"
else
tail -n "$lines" "$f"
fi
echo '```'
echo
}
environment() {
echo "## Environment"
set | grep -E 'MESA|AGX|ASAHI|XDG_SESSION_TYPE|DISPLAY|TERM|LANG|LOCALE|LC_' | sed 's/^/ /'
echo
}
diagnose() {
f="$1"
>$f
log "Collecting system diagnostic information..."
log
(
exec >"$f" 2>&1
banner
device_info
firmware_versions
boot_config
system_info
environment
getfile /proc/mounts "Mounts"
[ -e /etc/arch-release ] && package_versions
cmd lsblk "Block devices"
cmd lspci "PCI devices"
getfile /proc/bus/input/devices "Input devices"
cmd lsmod "Loaded modules"
module_parameters
cmd 'journalctl -b 0 -tkernel' "Kernel log"
logfile /var/log/Xorg.0.log
logfile /var/log/pacman.log 500
)
log "Saved diagnostic information to $f"
plat="$(cat /proc/device-tree/compatible | sed -re 's/.*apple,(t....).*/\1/g')"
ver="$(tr -d '\0' </proc/device-tree/chosen/asahi,os-fw-version)"
case "${plat}:${ver}" in
t8103:12.3*) ;;
t600[012]:12.3*) ;;
t8112:12.4*) ;;
*)
echo
echo "** WARNING! **"
echo "You are using an unsupported firmware version ($ver) on this platform ($plat)."
echo "This means you explicitly chose expert mode when installing Asahi Linux,"
echo "and then explicitly selected a non-default unsupported version."
echo "You are on your own. Please do not file bugs. We can't help you."
echo "Reinstall without using expert mode if you want support."
;;
esac
}
if [ -z "$1" ]; then
diagnose "$HOME/asahi-diagnose-$(date +%Y%m%d-%H%M%S).txt"
elif [ "$1" = "-" ]; then
diagnose /dev/stdout
else
diagnose "$1"
fi