Repository navigation
Turn on the M3 Air's native display, and load the PMP driver before unlock #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
07b5b5c
7ae9147
879ff9e
4444376
1e67451
1842e5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # The power management coprocessor's driver, before the root is unlocked: an | ||
| # encrypted root otherwise waits out "PMP driver did not bind within 20000 ms" | ||
| # with apple-pmp.ko still on that root. Added only when modinfo names a module. | ||
| _omarchy_mac_pmp_path=$(modinfo -k "${KERNELVERSION:-$(uname -r)}" -F filename apple_pmp 2>/dev/null) && | ||
| [[ $_omarchy_mac_pmp_path == /* ]] && MODULES+=(apple_pmp) | ||
| unset _omarchy_mac_pmp_path |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # The M3 Airs' native display: m1n1 hands the display coprocessor to Linux only | ||
| # when /etc/m1n1.conf sets chosen.asahi,t8122-dcp=1, which update-m1n1 copies | ||
| # into boot.bin. An m1n1 without its opt-in gate black-screens these Macs with it. | ||
| omarchy-hw-apple-silicon || return 0 | ||
| [[ ${OMARCHY_MAC_IMAGE_BUILD:-} != "1" ]] || return 0 | ||
| # setup-boot clears the environment, so only a booted systemd tells the leaf it | ||
| # is not in a chroot (an image build's or an installer's). | ||
| [[ -d ${OMARCHY_SYSTEMD_RUN:-/run/systemd/system} ]] || return 0 | ||
|
|
||
| ( | ||
| set -uo pipefail | ||
| # The first m1n1-aurora that reserves the external DCP firmware only on its | ||
| # own opt-in (omacom/m1n1#14, omarchy-pkgs#1564); 20-3 black-screens. Keep the pkgrel. | ||
| m1n1_t8122_dcp_minimum=1.6.1.aurora20-4 | ||
| minimum_m1n1=${OMARCHY_M1N1_T8122_DCP_MINIMUM-$m1n1_t8122_dcp_minimum} | ||
| compatible=${OMARCHY_DEVICE_TREE_COMPATIBLE:-/proc/device-tree/compatible} | ||
| config=${OMARCHY_M1N1_CONF:-/etc/m1n1.conf} | ||
| key=chosen.asahi,t8122-dcp | ||
|
|
||
| machine= | ||
| [[ ! -r $compatible ]] || machine=$(tr '\0' '\n' <"$compatible") | ||
| m1n1_display_has() { [[ $'\n'$machine$'\n' == *$'\n'"$1"$'\n'* ]]; } | ||
|
|
||
| m1n1_display_has apple,t8122 || exit 0 | ||
| # The M3 Airs (J613, J615); the other T8122 Macs' displays are untested. | ||
| m1n1_display_has apple,j613 || m1n1_display_has apple,j615 || exit 0 | ||
| if [[ -z $minimum_m1n1 ]]; then | ||
| echo "m1n1-display: no m1n1-aurora with the T8122 display opt-in is known yet; leaving $config alone" | ||
| exit 0 | ||
| fi | ||
| # pacman -Q also answers for a package that only provides the name. | ||
| name= installed= | ||
| read -r name installed < <(pacman -Q m1n1-aurora 2>/dev/null) || true | ||
| if [[ $name != "m1n1-aurora" || -z $installed ]]; then | ||
| echo "m1n1-display: m1n1-aurora is not installed; leaving $config alone" | ||
| exit 0 | ||
| fi | ||
| # Fail closed: a comparison that cannot be made writes nothing. | ||
| if ! order=$(vercmp "$installed" "$minimum_m1n1" 2>/dev/null) || [[ ! $order =~ ^-?[0-9]+$ ]]; then | ||
| echo "m1n1-display: cannot compare m1n1-aurora $installed with $minimum_m1n1; leaving $config alone" | ||
| exit 0 | ||
| fi | ||
| if (( order < 0 )); then | ||
| echo "m1n1-display: m1n1-aurora $installed predates the T8122 display opt-in ($minimum_m1n1); leaving $config alone" | ||
| exit 0 | ||
| fi | ||
| # A line the owner wrote, for either value, is theirs to keep. | ||
| if [[ -r $config ]] && grep -Eq "^[[:space:]]*${key//./\\.}=" "$config"; then | ||
| exit 0 | ||
| fi | ||
|
|
||
| staged=$(mktemp -d) || { echo "m1n1-display: could not stage $config; leaving it alone" >&2; exit 0; } | ||
| trap 'rm -rf "$staged"' EXIT | ||
| : >"$staged/new" | ||
| if [[ -e $config ]]; then | ||
| cp "$config" "$staged/original" && cp "$config" "$staged/new" || | ||
| { echo "m1n1-display: could not stage $config; leaving it alone" >&2; exit 0; } | ||
| # Keep a last line without its newline from swallowing ours. | ||
| [[ ! -s $staged/new || $(tail -c 1 "$staged/new" | od -An -c | tr -d ' ') == '\n' ]] || printf '\n' >>"$staged/new" | ||
| fi | ||
| printf '# omarchy-mac-boot: the M3 Air native display. Set it to 0 to keep m1n1 from handing it over.\n%s=1\n' "$key" >>"$staged/new" | ||
|
|
||
| # Put the original bytes back (install can unlink the file before copying). | ||
| m1n1_display_restore() { | ||
| if [[ -e $staged/original ]]; then | ||
| sudo install -m 0644 "$staged/original" "$config" | ||
| else | ||
| sudo rm -f "$config" | ||
| fi | ||
| } | ||
| m1n1_display_failed() { | ||
| if m1n1_display_restore; then | ||
| echo "m1n1-display: $1; $config is back as it was, and the native display stays off" >&2 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "the native display stays off" isn't true when update-m1n1 failed after moving the new boot.bin into place. Same softening as the README?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also in #60: it now says boot.bin is unchanged unless update-m1n1 failed after replacing it, matching the README. |
||
| else | ||
| echo "m1n1-display: $1, and $config could not be put back; the next update-m1n1 takes its $key line" >&2 | ||
| fi | ||
| exit 0 | ||
| } | ||
| sudo install -D -m 0644 "$staged/new" "$config" || m1n1_display_failed "could not write $config" | ||
| # boot.bin only takes m1n1.conf when update-m1n1 builds it. | ||
| sudo update-m1n1 || m1n1_display_failed "update-m1n1 failed" | ||
| echo "m1n1-display: enabled the native display in $config" | ||
| ) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These appends (and the newline one at :59) aren't checked, so a full
/tmpinstallsm1n1.confwithout the line, or with a truncated one, and still says "enabled". Not dangerous, but checking them before theinstallwould keep the message honest.m1n1_display_failedis defined below, so a plain|| { echo ...; exit 0; }works.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed in #60 since this had merged. Every staging write is checked now, and a failure leaves m1n1.conf alone and says "could not stage". The test caps the file size so the copy fits and the appends don't, with and without a trailing newline, and m1n1.conf comes back byte for byte with nothing rebuilt.