在 Apple Silicon Mac 上使用 Macvdmtool 执行 DFU 恢复 (2021)
Perform DFU Restores on Apple Silicon Macs with Macvdmtool (2021)

原始链接: https://www.bkurtz.io/posts/macvdmtool/

**macvdmtool** 是一个 Asahi Linux 项目工具,允许用户通过终端命令将搭载 T2 芯片的 Intel Mac 或 Apple Silicon Mac 进入 DFU 模式,无需进行复杂的物理按键操作。 **要求:** * **主机:** 必须是已安装 Xcode 和 Apple Configurator 2(包含自动化工具)的 Apple Silicon Mac。 * **目标机:** 2018 年及之后的 Intel Mac 或任何 Apple Silicon Mac,且设备需能正常通电。 * **连接:** 使用支持数据传输的 USB-C 或雷电(Thunderbolt)线缆,将主机连接至目标机的指定 DFU 接口。 **工作流程:** 1. 在主机上编译并安装 `macvdmtool`。 2. 连接两台 Mac,并使用该工具触发目标机的 DFU 模式。 3. 进入 DFU 模式后,通过 Apple Configurator 2 验证连接状态。 4. 在主机上使用 `cfgutil` 命令,配合下载好的 IPSW 文件对目标 Mac 进行恢复。 该工具简化了技术人员的修复/恢复流程,通过命令行界面实现了固件管理和操作系统恢复的自动化。如需了解更多技术细节或参与贡献,请访问该项目的 GitHub 仓库。

Hacker News 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 在 Apple Silicon Mac 上通过 Macvdmtool 执行 DFU 恢复 (2021) (bkurtz.io) 6 分 | gregsadetsky 发布于 2 小时前 | 隐藏 | 过往 | 收藏 | 讨论 | 帮助 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 加入 YC | 联系 搜索:
相关文章

原文

It is a tool written by marcan under the AsahiLinux project. macvdmtool lets you put any Apple Silicon or Intel Macs with the T2 chip (2018 and forward) in DFU mode with an easy terminal command instead of requiring awkward keyboard gymnastics.

Note: macvdmtool requires that the host machine is Apple Silicon based, Intel macs do not seem to support this tool as a host.

  • You need 2 Macs to utilize macvdmtool.
    • One Mac will act as the “host Mac”. This machine needs to be fully functional.
    • The second “target Mac” does not need to be functional as long as it powers on and boots to either a question mark or recovery mode.
  1. On the host Mac, Install Xcode and then run this in terminal to install Xcode command-line tools:

    Check that it installed properly:

  2. Install Apple Configurator 2 from the Mac App Store.

  3. Clone macvdmtool

    git clone https://github.com/AsahiLinux/macvdmtool.git
    
  4. Change into the macvdmtool directory and compile the tool

  5. Copy macvdmtool to path.

    sudo cp macvdmtool /usr/local/bin
    

    Run below command to see if its installed and added to path

  6. Launch Apple Configurator 2 and install the “Automation Tools”.

    Install Automation Tools

    Install Automation Tools dialogue

    Install Automation Tools password prompt

  7. Connect the host Mac and target Mac together via an official Apple USB-C charging cable or a TB3/TB4 cable. The cable must be plugged into the DFU port on both ends and support data transfer.

On Apple Silicon machines, the DFU port is closest to the screen on the left side.

On Intel machines, the DFU port is closest to the trackpad on the left side.

  1. Put the target Mac in DFU mode.

    Above command should return below:

     Mac type: J313AP
     Looking for HPM devices...
     Found: IOService:/AppleARMPE/arm-io@10F00000/AppleT810xIO/i2c0@35010000/AppleS5L8940XI2CController/hpmBusManager@6B/AppleHPMBusController/hpm0/AppleHPMARM
     Connection: Source
     Status: APP
     Unlocking... OK
     Entering DBMa mode... Status: DBMa
     Rebooting target into DFU mode... OK
     Exiting DBMa mode... OK
    

Alternatively you can use Apple Configurator 2 or Finder to restore/revive your Mac.

Note: This method with cfgutil only works if the target Mac is Apple Silicon.

  1. Confirm the device is in DFU mode by launching Apple Configurator 2. It should look like this. (If it does not appear, try unplugging and plugging back in the cable between the host and target)

    Apple Configurator 2 is now showing target device in DFU

  2. Grab the IPSW you want to restore from Mr. Macintosh’s database.

  3. Use cfgutil to restore that IPSW.

    cfgutil restore -I ~/Downloads/UniversalMac_12.1_21C5021h_Restore.ipsw
    

    Should result in something like this:

    objc[53015]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1da64c9e8) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x104d782c8). One of the two will be used. Which one is undefined.
    objc[53015]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1da64ca38) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x104d78318). One of the two will be used. Which one is undefined.
    cfgutil: restore: target OS is 12.1
    
    Waiting for the device [1/2] [*******************************************]  100%
    Step 2 of 2: Installing System [2/2] [**********************************>]  99%
    

At this point you should see an Apple logo and a loading bar on the target Mac.

After a few minutes, the Mac will reboot and launch the standard Setup Assistant experience.

That’s it! Enjoy.

  • Once Apple adds 12.X IPSWs to the com_apple_macOSIPSW.xml feed, I could write a script to download the latest IPSW and then execute macvdmtool and cfgutil.
  • Autopkg recipe to download latest IPSW and package it with Munki. This could be useful to distribute IPSWs to technicians.

File an issue or PR (pull request) against my blog at https://github.com/discentem/blog-content or reach out via MacAdmins Slack.

See Mr. Macintosh’s excellent blog post on DFU restores for more information.

联系我们 contact @ memedata.com