fix(#3): improve bypass module selection diagnostics

Resolves #3: [ERROR] No compatible bypass module for this device

Two bugs caused iPhone 15 (A12+, Path B) to get a generic "No compatible
bypass module" error despite being fully supported:

Bug A: select_module() in main.c printed a single unhelpful error line
when bypass_select() returned NULL, with no indication of WHY the device
was rejected. Added print_module_diagnostics() that reports DFU mode
status, CPID, chip name, checkm8 status, product type, and a specific
explanation (not in DFU, CPID unread, chip not in DB).

Bug B: handle_dfu_requirement() in start.sh only guided checkm8 (Path A)
devices into DFU mode. A12+ Path B devices were never prompted for DFU
entry, so the binary was launched with is_dfu_mode=0 and both path probes
rejected the device. Refactored to a shared wait_for_dfu_entry() helper
that is called for ALL supported devices not already in DFU mode.

Files modified:
- src/main.c
- start.sh

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
tr4m0ryp 2026-04-12 19:59:10 +02:00
parent 7225d83717
commit 92e9f99f25
2 changed files with 64 additions and 29 deletions

View file

@ -389,39 +389,50 @@ guide_dfu_faceid() {
echo ""
}
handle_dfu_requirement() {
# For checkm8 path, device MUST be in DFU mode
if [ "$DEV_CHECKM8" = "YES" ] && [ "$DEVICE_MODE" != "dfu" ]; then
msg_warn "checkm8 bypass requires DFU mode, but device is in normal mode."
echo ""
wait_for_dfu_entry() {
local reason="$1"
msg_warn "$reason"
echo ""
if is_faceid_device "${DEV_MODEL:-}"; then
guide_dfu_faceid
else
guide_dfu_home_button
if is_faceid_device "${DEV_MODEL:-}"; then
guide_dfu_faceid
else
guide_dfu_home_button
fi
msg_info "Waiting for DFU mode..."
local timeout=120
local elapsed=0
local interval=2
while [ $elapsed -lt $timeout ]; do
if check_dfu; then
DEVICE_MODE="dfu"
msg_ok "Device detected in DFU mode!"
return 0
fi
printf "\r${CYAN}[*]${RESET} Waiting for DFU... %ds / %ds" "$elapsed" "$timeout"
sleep "$interval"
elapsed=$((elapsed + interval))
done
msg_info "Waiting for DFU mode..."
echo ""
msg_err "DFU mode not detected within ${timeout}s."
msg_info "Please retry DFU entry and run this script again."
exit 1
}
local timeout=120
local elapsed=0
local interval=2
handle_dfu_requirement() {
# Both bypass paths require DFU mode
if [ "$DEVICE_MODE" = "dfu" ]; then
return 0
fi
while [ $elapsed -lt $timeout ]; do
if check_dfu; then
DEVICE_MODE="dfu"
msg_ok "Device detected in DFU mode!"
return 0
fi
printf "\r${CYAN}[*]${RESET} Waiting for DFU... %ds / %ds" "$elapsed" "$timeout"
sleep "$interval"
elapsed=$((elapsed + interval))
done
echo ""
msg_err "DFU mode not detected within ${timeout}s."
msg_info "Please retry DFU entry and run this script again."
exit 1
if [ "$DEV_CHECKM8" = "YES" ]; then
wait_for_dfu_entry "Path A (checkm8) requires DFU mode, but device is in normal mode."
elif [ "$DEV_STATUS" = "SUPPORTED" ]; then
wait_for_dfu_entry "Path B (A12+ bypass) requires DFU mode, but device is in normal mode."
fi
}