Efficient Apple Device Management with USBHub3c
Acroname’s USBHub3c industrial USB hub (with PD Logger add-on feature) can put attached Macs, iPads, and iPhones into DFU mode, allowing batch reflashing and reimaging. This tool is ideal for anyone who needs to manage a large number of Apple devices efficiently.
What is DFU Mode?
Device Firmware Update (DFU) is a special mode on Apple devices that allows the software and firmware to be restored from an image. This streamlines installation of preconfigured OS and apps and simplifies the redeployment of mobile devices.
Who is this guide for?
Bulk DFU restore is particularly useful for:
- Device refurbishers
- Sysadmins managing fleets of Macs or iPads in corporate or school environments
- Test lab managers with racks of Apple devices that need to be reset before each test
If you have a lot of Apple silicon devices to deploy and reimage, or if holding down keys or buttons while rebooting isn’t feasible, this solution is for you.
Before discussing parallel DFU mode reset, let’s review how to put a single device into DFU mode.
Single Device DFU Mode
How to put an Apple device into DFU Mode Manually
- Connect a Mac host to the target Mac or iOS device via USB-C using the special DFU-enabled port on the target Mac.
- Hold down the necessary sequence of keys or buttons. This varies by device.
- Mr. Macintosh has a good video demonstration:. Note that timing is crucial!
- Use Apple Configurator to reimage the device.
Single Device DFU Mode over USB
It would be nice to put devices in DFU mode without holding down keys or buttons and counting. Fortunately, Apple devices can be put in DFU mode by sending a special Vendor-Defined Message (VDM) over the USB-C CC lines. Some important notes:
- VDMs only transmit over a single cable span and will not pass through USB hubs.
- Only the DFU-enabled USB-C port on each Mac can send or receive the VDMs, meaning that one host Mac is required for each target device.
Utilities like Two Canoes DFU Blaster can send the correct VDMs over USB to enter DFU mode and reboot the target device. However, the constraint of one host Mac per target device can become impractical for larger deployments.
Put Multiple Devices into DFU mode Using USBHub3c with PD Logger Feature
Acroname’s USBHub3c is an industrial USB-C hub with 6 data ports. When combined with the PD-logger feature, it can generate and send DFU reset messages to attached devices. Once the devices are in DFU mode, you can use Apple Configurator to manage reimaging.
A brief example
USBHub3c is controllable using the Brainstem API (Python, C, C++). We’ll be using Python for this example.
Setup
- Create a Python virtual environment and activate it.
- Install the BrainStem library via pip:
pip install brainstem
For more information about using the BrainStem library, see Acroname's Getting Started Guide.
- Connect the USB-Hub3c power port to power. (The target device needs to be receiving power from the hub.)
- Connect any port on the host to USBHub3c port 0, and connect the target device’s DFU port to Port 1.
Finding the DFU-enabled Port on a Mac
- Apple Silicon MacBooks: Left side, towards the hinge
- Intel MacBooks with T2 chip: Left side, away from the hinge
- Desktops: Refer to Apple Support for more details.
Example Script
# Copyright (c) 2023 Acroname Inc. - All Rights Reserved
#
# This file is part of the BrainStem development package.
# See file LICENSE or go to https://acroname.com/software/brainstem-development-kit for full license details.
import sys
import brainstem
#for easy access to error constants
from brainstem.result import Result
from brainstem import _BS_C
import time
# Create USBHub3c object and connecting to the first module found
print('\nCreating USBHub3c stem and connecting to first module found')
chub = brainstem.stem.USBHub3c()
#Locate and connect to the first object you find on USB
#Easy way: 1=USB, 2=TCPIP
result = chub.discoverAndConnect(brainstem.link.Spec.USB)
#Locate and connect to a specific module (replace with your devices Serial Number (hex))
#result = chub.discoverAndConnect(brainstem.link.Spec.USB, 0x66F4859B)
#Verify we are connected
if result == (Result.NO_ERROR):
result = chub.system.getSerialNumber()
print("Connected to USBHub3c with serial number: 0x%08X" % result.value)
else:
#If we are not connected there is nothing we can do.
print ('Could not find a module.\n')
sys.exit(1)
# VDM Commands are a minimum of 8 bytes chunked into 4 byte blocks
# First 4 bytes are SOP
# 0 = SOP
# 1 = SOP'
# 2 = SOP''
# 3 = SOP' Debug
# 4 = SOP'' Debug
# Second 4 bytes are the VDM header according to the USB PD Standard
# Any subsequent sets of 4 bytes are the attached VDO's
# DFU Command Example:
# The sop as the first byte in the subsequent messages is either
# SOP' Debug or SOP'' Debug depending on if the port is sourcing
# or sinking power respectively.
# SOP 0x00000004
# VDM Header 0x05AC8012
# VDO 1 0x00000106
# VDO 2 0x80010000
buffer = [0x04, 0x00, 0x00, 0x00, 0x12, 0x80, 0xAC, 0x05, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80]
# Reboot Command Example:
# The sop as the first byte in the subsequent messages is either
# SOP' Debug or SOP'' Debug depending on if the port is sourcing
# or sinking power respectively.
# SOP 0x00000004
# VDM Header 0x05AC8012
# VDO 1 0x00000105
# VDO 2 0x80000000
#buffer = [0x04, 0x00, 0x00, 0x00, 0x12, 0x80, 0xAC, 0x05, 0x05, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80]
err = chub.pd[1].set_UEIBytes(_BS_C.powerdeliveryVDM, buffer)
print(f"Send VDM to Port 1, err {err}")
#Disconnect from the device.
chub.disconnect()
Save the script and run it. Your device should restart and enter DFU mode while displaying a blank screen. To have USBHub3c send a reboot message to the target device, comment out the DFU command, uncomment the reboot command, save, and rerun. To change the target device port, modify the number in brackets (e.g. chub.pd[1]
) to the desired port number.
Use Shortcuts Automations to Manage DFU mode restore
The Shortcuts app can be used to create integrated workflows that configure large groups of Apple silicon devices using USBHub3c and Apple Configurator. Apple Configurator also has an option to automatically run shortcuts when attaching or detaching devices. The Shortcuts app can:
- Trigger Python scripts (like our example DFU mode script) using the “run shell script” action
- Control Apple Configurator actions to erase, restore, update, and manage devices
Simplify Apple Device Management with Acroname’s USBHub3c
Acroname’s USBHub3c with PD Logger simplifies the Apple device management by enabling no-touch DFU reset and reimaging of multiple attached devices at once. Whether you’re managing a fleet of Macs, or dealing with racks of inaccessible test devices, USBHub3c can save countless button presses and cable swaps.
Add New Comment