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

@ -162,6 +162,30 @@ static void register_modules(void)
log_debug("Registered %d bypass module(s)", bypass_count()); 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, static const bypass_module_t *select_module(device_info_t *dev,
const cli_opts_t *opts) 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); const bypass_module_t *mod = bypass_select(dev);
if (!mod) { if (!mod) {
log_error("No compatible bypass module for this device"); print_module_diagnostics(dev);
return NULL; return NULL;
} }

View file

@ -389,10 +389,9 @@ guide_dfu_faceid() {
echo "" echo ""
} }
handle_dfu_requirement() { wait_for_dfu_entry() {
# For checkm8 path, device MUST be in DFU mode local reason="$1"
if [ "$DEV_CHECKM8" = "YES" ] && [ "$DEVICE_MODE" != "dfu" ]; then msg_warn "$reason"
msg_warn "checkm8 bypass requires DFU mode, but device is in normal mode."
echo "" echo ""
if is_faceid_device "${DEV_MODEL:-}"; then if is_faceid_device "${DEV_MODEL:-}"; then
@ -422,6 +421,18 @@ handle_dfu_requirement() {
msg_err "DFU mode not detected within ${timeout}s." msg_err "DFU mode not detected within ${timeout}s."
msg_info "Please retry DFU entry and run this script again." msg_info "Please retry DFU entry and run this script again."
exit 1 exit 1
}
handle_dfu_requirement() {
# Both bypass paths require DFU mode
if [ "$DEVICE_MODE" = "dfu" ]; then
return 0
fi
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 fi
} }