From 92e9f99f252d4c2ce08946bf21c730b8cc936cfc Mon Sep 17 00:00:00 2001 From: tr4m0ryp Date: Sun, 12 Apr 2026 19:59:10 +0200 Subject: [PATCH] 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) --- src/main.c | 26 ++++++++++++++++++++- start.sh | 67 +++++++++++++++++++++++++++++++----------------------- 2 files changed, 64 insertions(+), 29 deletions(-) diff --git a/src/main.c b/src/main.c index cb209b2..7be32d4 100644 --- a/src/main.c +++ b/src/main.c @@ -162,6 +162,30 @@ static void register_modules(void) log_debug("Registered %d bypass module(s)", bypass_count()); } +static void print_module_diagnostics(const device_info_t *dev) +{ + log_error("No compatible bypass module for this device"); + log_error("--- Diagnostic info ---"); + log_error(" DFU mode: %s", dev->is_dfu_mode ? "YES" : "NO"); + log_error(" CPID: 0x%04X", dev->cpid); + log_error(" Chip: %s", dev->chip_name[0] ? dev->chip_name : "(unknown)"); + log_error(" checkm8: %s", dev->checkm8_vulnerable ? "vulnerable" : "not vulnerable"); + log_error(" Product: %s", dev->product_type[0] ? dev->product_type : "(unknown)"); + + if (!dev->is_dfu_mode) { + log_error("Both bypass paths require DFU mode."); + log_error("Run ./start.sh for guided DFU entry, or enter DFU manually."); + } else if (dev->cpid == 0) { + log_error("CPID is 0x0000 -- device chip not identified."); + log_error("Ensure device is properly in DFU mode (screen must be BLACK)."); + } else if (dev->chip_name[0] == '\0' || + strcmp(dev->chip_name, "Unknown") == 0) { + log_error("Chip CPID 0x%04X not found in database.", dev->cpid); + } + + log_error("-----------------------"); +} + static const bypass_module_t *select_module(device_info_t *dev, const cli_opts_t *opts) { @@ -176,7 +200,7 @@ static const bypass_module_t *select_module(device_info_t *dev, const bypass_module_t *mod = bypass_select(dev); if (!mod) { - log_error("No compatible bypass module for this device"); + print_module_diagnostics(dev); return NULL; } diff --git a/start.sh b/start.sh index 19df71b..9776f26 100755 --- a/start.sh +++ b/start.sh @@ -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 }