Repository navigation
Offer Touch ID on the 16-inch M4 Pro (J616s) #140
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
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,8 @@ can_extract() { | |
| } | ||
|
|
||
| sensor="" | ||
| for node in "$tree"/soc/*/fingerprint@*; do | ||
| # The sensor sits on an SPI controller under /soc, or at the root on the M4 Pro. | ||
| for node in "$tree"/soc/*/fingerprint@* "$tree"/*/fingerprint@*; do | ||
| if [[ -r $node/compatible ]] && tr '\0' '\n' <"$node/compatible" | grep -Fxq apple,mesa-fingerprint && | ||
| [[ ! -r $node/status || $(tr -d '\0' <"$node/status") == "okay" ]]; then | ||
| sensor=$node | ||
|
|
@@ -51,7 +52,8 @@ if compatible apple,t8103 || compatible apple,t6000 || compatible apple,t6001; t | |
| echo unsupported:m1-family | ||
| exit 0 | ||
| elif ! compatible apple,t8112 && ! compatible apple,t6020 && ! compatible apple,t6021 && ! compatible apple,t8140 && | ||
| ! { compatible apple,t8122 && { compatible apple,j613 || compatible apple,j615; }; }; then | ||
| ! { compatible apple,t8122 && { compatible apple,j613 || compatible apple,j615; }; } && | ||
| ! { compatible apple,t6040 && compatible apple,j616s; }; then | ||
| echo unsupported:board | ||
| exit 0 | ||
| fi | ||
|
|
@@ -62,20 +64,34 @@ if [[ ! -r $tree/chosen/apfs-preboot-uuid ]]; then | |
| exit 0 | ||
| fi | ||
|
|
||
| # The Neo's calibration must be the sealed form its installer writes; the | ||
| # other boards' can be carved from the iBoot System Container at enable time. | ||
| # The node's firmware-name lists the calibration, then, where the board names | ||
| # it, the sensor root key. | ||
| calibration=apple/mesa_calibration.bin | ||
| root_key=apple/msrk-j700.bin | ||
| if [[ -r $sensor/firmware-name ]]; then | ||
| calibration=$(tr -d '\0' <"$sensor/firmware-name") | ||
| mapfile -t names < <(tr '\0' '\n' <"$sensor/firmware-name") | ||
| calibration=${names[0]:-$calibration} | ||
| root_key=${names[1]:-$root_key} | ||
|
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. This now reads a second — Marcelo's agent
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. Checked on a MacBook Neo (7.3.0-0test4), read-only: |
||
| fi | ||
| if ! installed "$calibration" && { compatible apple,t8140 || ! can_extract extract-mesa-calibration; }; then | ||
| # touchid-root-key (Python) rebuilds sealed factory data once the owner agrees, | ||
| # from the factory records asahi-installer leaves on the ESP. | ||
| can_reseal() { | ||
| [[ -r $esp/asahi/all_firmware.tar.gz ]] && command -v "$python" >/dev/null | ||
| } | ||
| # The Neo's calibration must be the sealed form its installer writes, and the | ||
| # 16-inch M4 Pro's is rebuilt from its factory records like its root key; the | ||
| # other boards' can be carved from the iBoot System Container at enable time. | ||
| if compatible apple,j616s; then | ||
| if ! installed "$calibration" && ! can_reseal; then | ||
| echo unsupported:no-calibration | ||
| exit 0 | ||
| fi | ||
| elif ! installed "$calibration" && { compatible apple,t8140 || ! can_extract extract-mesa-calibration; }; then | ||
| echo unsupported:no-calibration | ||
| exit 0 | ||
| fi | ||
| # The Neo's sensor key is rebuilt once the owner agrees, by touchid-root-key | ||
| # (Python), from the factory records asahi-installer leaves on the ESP. | ||
| if compatible apple,t8140 && ! installed apple/msrk-j700.bin && | ||
| { [[ ! -r $esp/asahi/all_firmware.tar.gz ]] || ! command -v "$python" >/dev/null; }; then | ||
| # The Neo's and the M4 Pro's sensor root key is rebuilt the same way. | ||
| if { compatible apple,t8140 || compatible apple,j616s; } && ! installed "$root_key" && ! can_reseal; then | ||
| echo unsupported:no-root-key | ||
| exit 0 | ||
| fi | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| #!/bin/bash | ||
| # Turns Touch ID on once the owner has agreed: carves this Mac's calibration | ||
| # (and on the Neo installs its sensor root key) if they are missing, records the | ||
| # agreement so the driver loads at every boot, and loads it now. | ||
| # Turns Touch ID on once the owner has agreed: installs this Mac's calibration | ||
| # and, on the Neo and the 16-inch M4 Pro, its sensor root key if missing, records | ||
| # the agreement so the driver loads at every boot, and loads it now. | ||
|
|
||
| tree=${OMARCHY_MAC_TOUCHID_TREE:-/proc/device-tree} | ||
| firmware=${OMARCHY_MAC_TOUCHID_FIRMWARE:-/usr/lib/firmware} | ||
|
|
@@ -27,12 +27,18 @@ omarchy-hw-apple-silicon || exit 0 | |
| # restart. A record from an earlier agreement stays. | ||
| recorded=0 | ||
| rebuilt=0 | ||
| rebuilt_calibration=0 | ||
| # The sensor root key's name; the 16-inch M4 Pro's sensor node names its own. | ||
| root_key=apple/msrk-j700.bin | ||
| fail() { | ||
| if (( recorded )); then | ||
| rm -f "$agreed" "$options" | ||
| fi | ||
| if (( rebuilt )); then | ||
| rm -f "$firmware/updates/apple/msrk-j700.bin" | ||
| rm -f "$firmware/updates/$root_key" | ||
| fi | ||
| if (( rebuilt_calibration )); then | ||
| rm -f "$firmware/updates/$calibration" | ||
| fi | ||
| echo "Touch ID was not turned on: $1" >&2 | ||
| exit 1 | ||
|
|
@@ -54,7 +60,7 @@ installed() { | |
| root_key_installed() { | ||
| local directory key found=1 checked | ||
| for directory in "$firmware" "$firmware/vendor" "$firmware/updates"; do | ||
| key=$directory/apple/msrk-j700.bin | ||
| key=$directory/$root_key | ||
| if [[ ! -e $key ]]; then | ||
| continue | ||
| elif ! command -v "$python" >/dev/null; then | ||
|
|
@@ -90,11 +96,35 @@ eligibility=$("$helpers/touchid-eligibility") | |
|
|
||
| # Factory data from this Mac's own iBoot System Container, never another's. | ||
| sensor=$("$helpers/touchid-eligibility" sensor) | ||
| # The node's firmware-name lists the calibration, then, where the board names | ||
| # it, the sensor root key. | ||
| calibration=apple/mesa_calibration.bin | ||
| if [[ -r $sensor/firmware-name ]]; then | ||
| calibration=$(tr -d '\0' <"$sensor/firmware-name") | ||
| mapfile -t names < <(tr '\0' '\n' <"$sensor/firmware-name") | ||
| calibration=${names[0]:-$calibration} | ||
| root_key=${names[1]:-$root_key} | ||
| fi | ||
| for name in "$calibration" "$root_key"; do | ||
| [[ $name =~ ^apple/[A-Za-z0-9._-]+\.bin$ ]] || fail "the sensor names an unexpected firmware file ($name)" | ||
| done | ||
| # The Macs whose sensor loads a sealed root key after a nonce session, by the | ||
| # SoC their seal record names: the Neo, and the 16-inch M4 Pro, whose | ||
| # calibration is sealed the same way and rebuilt with the key. | ||
| chip="" | ||
| if tr '\0' '\n' <"$tree/compatible" | grep -Fxq apple,t8140; then | ||
| chip=00008140 | ||
| elif tr '\0' '\n' <"$tree/compatible" | grep -Fxq apple,j616s; then | ||
| chip=00006040 | ||
| fi | ||
| if ! installed "$calibration"; then | ||
| if [[ $chip == 00006040 ]] && ! installed "$calibration"; then | ||
| # Rebuilt from the factory records asahi-installer leaves on the ESP and | ||
| # checked against this Mac's iBoot System Container, like the root key. | ||
| echo "Reading this Mac's Touch ID calibration..." | ||
| mkdir -p -m 0755 "$firmware/updates/${calibration%/*}" | ||
| rebuilt_calibration=1 | ||
|
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. Nothing tests this rollback yet: please add a case where the calibration rebuild succeeds and the key step fails. — Marcelo's agent
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. Fixed in 6b5d94a: the consent test adds a J616s run with a container holding the FSC2 record, the seal and the trust bundle but not the MSRk record. The calibration rebuilds, the key step fails, and the test checks that |
||
| "$python" -I "$helpers/touchid-root-key" --record FSC2 --chip "$chip" --archive "$esp/asahi/all_firmware.tar.gz" \ | ||
| --container "$container" -o "$firmware/updates/$calibration" || fail "this Mac's calibration could not be read" | ||
| elif ! installed "$calibration"; then | ||
| echo "Copying this Mac's Touch ID calibration..." | ||
| mkdir -p -m 0755 "$firmware/updates/${calibration%/*}" | ||
| # A partial carve never takes the calibration's name, which a retry would | ||
|
|
@@ -104,7 +134,7 @@ if ! installed "$calibration"; then | |
| { rm -f "$carved.new"; fail "this Mac's calibration could not be read"; } | ||
| chmod 0644 "$carved.new" && mv -f "$carved.new" "$carved" || { rm -f "$carved.new"; fail "this Mac's calibration could not be installed"; } | ||
| fi | ||
| if tr '\0' '\n' <"$tree/compatible" | grep -Fxq apple,t8140 && ! root_key_installed; then | ||
| if [[ -n $chip ]] && ! root_key_installed; then | ||
| # Rebuilt only now, from the factory records asahi-installer leaves on the | ||
| # ESP and checked against this Mac's iBoot System Container; root-only, and | ||
| # it takes its name only once whole. Turning Touch ID off deletes it. | ||
|
|
@@ -114,8 +144,8 @@ if tr '\0' '\n' <"$tree/compatible" | grep -Fxq apple,t8140 && ! root_key_instal | |
| # a failure, even one the extractor reports after its rename, takes it back | ||
| # with the agreement. | ||
| rebuilt=1 | ||
| "$python" -I "$helpers/touchid-root-key" --archive "$esp/asahi/all_firmware.tar.gz" --container "$container" \ | ||
| -o "$firmware/updates/apple/msrk-j700.bin" || fail "this Mac's sensor key could not be read" | ||
| "$python" -I "$helpers/touchid-root-key" --chip "$chip" --archive "$esp/asahi/all_firmware.tar.gz" \ | ||
| --container "$container" -o "$firmware/updates/$root_key" || fail "this Mac's sensor key could not be read" | ||
| fi | ||
|
|
||
| # The record is the agreement: omarchy-mac-touchid-load.service loads the | ||
|
|
||
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.
nit: "the next setup rebuilds them", now that the list covers three files.
— Marcelo's agent