Skip to content
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

Add support for M1-enabled devices #406

Merged
merged 13 commits into from
May 26, 2021

Conversation

sywesk
Copy link

@sywesk sywesk commented May 6, 2021

Hello !

This is finally it ! After hundreds of hours of hard work, I can finally submit this merge request that adds all the missing pieces to restore M1 devices.

I know this is not the best code ever, but it works on m1 mac minis. I'd be happy to modify it :)

PS: The code might not work for M1 macbooks, but i'm not a mac user so i won't have any m1 laptop for the foreseeable future.

@sywesk sywesk force-pushed the macmini-restore branch 2 times, most recently from 80d42ac to e5c0ead Compare May 6, 2021 19:34
Benjamin BOURGEAIS added 12 commits May 8, 2021 14:16

Unverified

No user is associated with the committer email.

Unverified

No user is associated with the committer email.
Align the size of sent packets on the ASR_PAYLOAD_CHUNK_SIZE.

Unverified

No user is associated with the committer email.
This file will be needed later by the stage 1 boot process.

Unverified

No user is associated with the committer email.

Unverified

No user is associated with the committer email.
- Local policy (non persistent)
- recoveryOS
- recoveryOS Local policy (persistent)

The local policy TSS request differs slightly between the one for the
restore process and the recoveryOS. The one for the restore process is
meant to be used only once, and the one for the recovery os is meant to
be loaded from disk, and thus has a different request. See the
Ap,LocalBoot parameter.

Unverified

No user is associated with the committer email.

Unverified

No user is associated with the committer email.

Unverified

No user is associated with the committer email.

Unverified

No user is associated with the committer email.

Unverified

No user is associated with the committer email.

Unverified

No user is associated with the committer email.

Unverified

No user is associated with the committer email.
@sywesk sywesk force-pushed the macmini-restore branch from e5c0ead to b00b434 Compare May 8, 2021 12:17
src/restore.c Outdated
}

int extract_macos_variant(plist_t build_identity, char** output) {
// Get the device class from the build identity. `image_name` should look like 'j293ap' at the end.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Drop this comment, I guess.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done ✔️

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is still here :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, fixed :)

@sywesk sywesk force-pushed the macmini-restore branch from b00b434 to 85d0ade Compare May 10, 2021 07:09
@sywesk
Copy link
Author

sywesk commented May 10, 2021

I did address all of your comments, I'll let you resolve the conversations if you're happy with the changes 👍

Unverified

No user is associated with the committer email.
@sywesk sywesk force-pushed the macmini-restore branch from 85d0ade to 7835778 Compare May 11, 2021 07:58
@marcan
Copy link
Contributor

marcan commented May 20, 2021

Awesome work! I'm happy to test this on an M1 Macbook Pro and Macbook Air if you want :) (at least for SFR/1TR restore, not sure I want to reinstall everything right now :-))

@sywesk
Copy link
Author

sywesk commented May 20, 2021

@marcan I'm not sure about what you mean, but I think you're talking about doing an "Update" (restore behavior) instead of an "Erase", so that only the macOS system is rewritten ? If yes, I haven't tested this behavior. But if you want to help test macbooks, i'll first make sure it works for mac minis 😄 Just to try to minimize the risk 🙏

(Btw, thanks for the awesome macvdmtool and more generally your work on asahilinux, it helped us a lot in the beginning ❤️ )

@marcan
Copy link
Contributor

marcan commented May 20, 2021

I think Apple calls it "Revive Device", and it's supposed to install 1TR/NAND stuff without touching any macOS installs; either way, I can probably figure out how to take a backup of the macOS stuff (can you tell I'm not a macOS user normally? :)). I use the two laptops right now as general purpose remote terminals on macOS and as testing machines for Linux, but wouldn't normally expect to do full wipes, just wipes of the Linux partition, so I want to back up the macOS bit if I can. If it's lost though, it's not a big deal; there's no data there, it just means it'd take me some time to set things up again.

I'm also interested in the process for any potential tricks I might use to help do Asahi Linux installs, if there are any. It's tricky enumerating exactly what we can and cannot do, and some of Apple's flows are actually buggy, so learning more about the intricacies is always good.

@nikias nikias merged commit 7835778 into libimobiledevice:master May 26, 2021
@rnagy
Copy link

rnagy commented Jun 7, 2021

Hi

I am trying to restore my M1 MacbookPro and it fails with all firmwares:

Identified device as j293ap, MacBookPro17,1
The following firmwares are currently being signed for MacBookPro17,1:
  [1] 11.4 (build 20F71)
  [2] 11.3.1 (build 20E241)
  [3] 11.3 (build 20E232)
  [4] 11.2.3 (build 20D91)
  [5] 11.2.2 (build 20D80)
  [6] 11.2.1 (build 20D74)
  [7] 11.2 (build 20D64)
  [8] 11.1 (build 20C69)
  [9] 11.0.1 (build 20B29)
Select the firmware you want to restore: 3
Selected firmware 11.3 (build 20E232)
Verifying 'UniversalMac_11.3_20E232_Restore.ipsw'...
Extracting BuildManifest from IPSW
Product Version: 11.3
Product Build: 20E232 Major: 20
INFO: device serial number is FVFFK08DQ05P
Device supports Image4: true
Variant: Customer Erase Install (IPSW)
This restore will erase your device data.
################################ [ WARNING ] #################################
# You are about to perform an *ERASE* restore. ALL DATA on the target device #
# will be IRREVERSIBLY DESTROYED. If you want to update your device without  #
# erasing the user data, hit CTRL+C now and restart without -e or --erase    #
# command line switch.                                                       #
# If you want to continue with the ERASE, please type YES and press ENTER.   #
##############################################################################
> YES
Checking IPSW for required components...
All required components found in IPSW
Using cached filesystem from 'UniversalMac_11.3_20E232_Restore/038-69368-243.dmg'
Found ECID 2375052739346462
Getting ApNonce in recovery mode... 48 99 82 54 b2 c7 57 bd b9 8e 65 f8 54 79 aa 7a 87 08 b0 c8 fe ef e8 0d 8b 66 b9 aa 1d 52 40 eb 
Trying to fetch new SHSH blob
Getting SepNonce in recovery mode... f2 72 18 d4 ca 1b b8 e9 f6 02 17 6f 7d a1 b9 e2 71 73 1b ef 
Request URL set to https://gs.apple.com/TSS/controller?action=2
Sending TSS request attempt 1... response successfully received
Received SHSH blobs
Getting SepNonce in recovery mode... f2 72 18 d4 ca 1b b8 e9 f6 02 17 6f 7d a1 b9 e2 71 73 1b ef 
Request URL set to https://gs.apple.com/TSS/controller?action=2
Sending TSS request attempt 1... response successfully received
Received SHSH blobs
Getting SepNonce in recovery mode... f2 72 18 d4 ca 1b b8 e9 f6 02 17 6f 7d a1 b9 e2 71 73 1b ef 
Request URL set to https://gs.apple.com/TSS/controller?action=2
TSS server returned: STATUS=8&MESSAGE=An internal error occurred.
ERROR: TSS request failed (status=8, message=An internal error occurred.)
Sending TSS request attempt 1... ERROR: Unable to send TSS request
ERROR: Unable to get SHSH blobs for this device (recovery OS Root Ticket)

@nikias
Copy link
Member

nikias commented Jun 7, 2021

@rnagy can you open a ticket for this? Please run with -d since it seems like TSS doesn't like the request.

@rnagy
Copy link

rnagy commented Jun 7, 2021

@rnagy can you open a ticket for this? Please run with -d since it seems like TSS doesn't like the request.

#411 has been created

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants