Repository navigation
Expand file tree
/
Copy pathasahi-diagnose
More file actions
executable file
·240 lines (207 loc) · 6.13 KB
/
Copy pathasahi-diagnose
File metadata and controls
executable file
·240 lines (207 loc) · 6.13 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
#!/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: $(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
Distro: $(awk -F= '/PRETTY_NAME/ { gsub(/"/, "", $2); print $2 }' /etc/os-release)
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() {
echo "## Package versions"
if [ -e /etc/arch-release ]; then
cmd="pacman -Q"
pkgs="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"
elif [ -e /etc/fedora-release ]; then
cmd="rpm -q"
pkgs="m1n1 alsa-ucm-asahi asahi-platform-metapackage asahi-repos
fedora-asahi-remix-scripts tiny-dfr uboot-images-armv8 kernel-16k
kernel-16k-modules-extra asahi-fwextract dracut-asahi update-m1n1
asahi-audio speakersafetyd wireplumber pipewire mesa"
else
echo "Distribution not supported"
return
fi
cat <<EOF
\`\`\`
$($cmd $pkgs 2>/dev/null | sort -u)
\`\`\`
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"
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"
cmd 'journalctl -b -1 -tkernel' "Kernel log (last boot)"
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*) ;;
t8103:13.5*) ;;
t600[012]:13.5*) ;;
t8112:13.5*) ;;
t602[012]:13.5*) ;;
*)
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 [ -e /etc/fedora-release ]; then
if uname -r | grep -qv '+16k$'; then
echo
echo "** WARNING! **"
echo "Your system is not running a 16k page kernel. This is unsupported and will not"
echo "work properly; see https://discussion.fedoraproject.org/t/87711 for how to fix."
elif [ ! -e /etc/sysconfig/kernel ]; then
echo
echo "** WARNING! **"
echo "/etc/sysconfig/kernel is missing, kernel updates may not install properly"
echo "See https://discussion.fedoraproject.org/t/87711/3 for how to fix."
elif grep -q DEFAULTKERNEL=kernel-core /etc/sysconfig/kernel; then
echo
echo "** WARNING! **"
echo "/etc/sysconfig/kernel is setting a 4k kernel as default; this is unsupported"
echo "and will not work properly; see https://discussion.fedoraproject.org/t/87711"
echo "for how to fix."
fi
if ! rpm -q asahi-platform-metapackage > /dev/null 2>&1; then
echo
echo "** WARNING! **"
echo "The asahi-platform-metapackage package is not installed, you may be missing"
echo "required platform dependencies. See https://discussion.fedoraproject.org/t/95301"
echo "for how to fix it."
fi
fi
}
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