diff --git a/DESIGN.md b/DESIGN.md index 46b14bf..2d5c7b5 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -29,15 +29,17 @@ for auto-script timing. ## Boot flow (Hekate as the example) 1. The payload is loaded into IRAM (Internal RAM) at `0x40010000` via - `uc_mem_write`. + `uc_mem_write`. We also pre-write the 4-byte cookie `0x544457` ("WDT") at + IRAM offset `0x4003FF18`. Hekate reads that location during early boot. + When the cookie is present, it takes the `goto skip_lp0_minerva_config` + branch and skips loading both `libsys_lp0.bso` and the Minerva + DRAM-training module. Real DRAM training would touch the EMC (External + Memory Controller) and MC (Memory Controller), neither of which the + emulator models. The matching exception-enable cookie at `0x4003FF1C` + stays zero, so the "hang detected" warning is suppressed. 2. PC is set to `0x40010000`, SP to `IPL_STACK_ADDR`. CPSR enters ARM mode. 3. The IPL (Initial Program Loader) initialises clocks, fuses and the display, - then blocks at a `btn_wait` site. In Hekate 6.5.2 this PC is `0x4000D14E`. - Depending on build it may be a "press any key" prompt, the Nyx fallback - warning, or a similar one-tap gate. `main.cpp` watches for that PC and - spoofs a POWER press for ~100 ticks so the run advances without manual - input. If you load a different Hekate version and boot stalls forever, - capture the PC where it loops and update the constant. + then continues straight into the boot menu without loading LP0 or Minerva. 4. Hekate self-relocates into DRAM (`0xC0000000+`) and continues. The display pipeline resamples its DRAM-side framebuffer parameters. 5. Nyx (the LVGL graphics stack) initialises and draws into a separate FB. The diff --git a/main.cpp b/main.cpp index d33ceae..9f06928 100644 --- a/main.cpp +++ b/main.cpp @@ -147,7 +147,18 @@ static uc_engine *setup_emulation(EmuState *state, uint8_t *payload, size_t payl (unsigned)(IRAM_SIZE / 1024)); uc_mem_write(uc, IPL_LOAD_ADDR, payload, payload_size); - + + // Pre-set Hekate's "watchdog fired" magic at IRAM 0x4003FF18 (cookie "WDT") + // so its early boot does `goto skip_lp0_minerva_config`, skipping both + // libsys_lp0.bso and the Minerva DRAM-training path. EXCP_EN_ADDR + // (0x4003FF1C) stays zeroed so ERR_EXCEPTION is *not* set and no warning + // screen appears. EMC/MC training touches hardware we don't model; this is + // the same path Hekate takes on real silicon after a legitimate WDT reset. + { + uint32_t wdt_magic = 0x544457; // "WDT" + uc_mem_write(uc, 0x4003FF18, &wdt_magic, sizeof(wdt_magic)); + } + // Setup instruction tracing uc_hook_add(uc, &trace_h, UC_HOOK_CODE, (void*)trace_callback, nullptr, 1, 0); @@ -357,23 +368,6 @@ int main(int argc, char *argv[]) { uc_reg_read(uc, UC_ARM_REG_PC, &pc); uc_reg_read(uc, UC_ARM_REG_CPSR, &cpsr); - // PC of an IPL btn_wait site in Hekate 6.5.2 — depending on build - // this is "press any key", the Nyx fallback prompt, or similar. - // We hold POWER for ~100 ticks to advance past it without manual - // input. If a different Hekate stalls forever, capture the new PC - // and update this constant. - static int auto_enter_timer = 0; - if (pc == 0x4000D14E || auto_enter_timer > 0) { - if (auto_enter_timer < 100) { - state.btn_power = true; - auto_enter_timer++; - if (auto_enter_timer == 100) { - state.btn_power = false; - printf("[emu] Auto-advanced past IPL btn_wait at PC=0x4000D14E\n"); - } - } - } - // ---- PIN recovery scripted navigation (Lockpick patch menu) ---- // With EmuNAND grayed out (no emummc.ini), Lockpick's main menu // layout effectively becomes: