Model PLLMB and the EMC so Minerva can train and switch the DRAM clock

hekate 6.5.3 with the stock bootloader folder never reached Nyx. Nyx
trains the DRAM itself with Minerva, and Minerva spun forever on
PLLMB_BASE.LOCK: the CAR model had no PLLMB and read it as 0. Behind
that poll were more. Every EMC register but three read 0, so Minerva
would have spun on the DLL-enable bit it writes to EMC_CFG_DIG_DLL and
on EMC_DIG_DLL_STATUS lock, timed out on the clock-change handshake, and
divided by a zero MR18/MR19 oscillator count.

- CAR: PLLMB_BASE/MISC1 per TRM 5.2.230-231, locking once enabled.
  CLK_SOURCE_EMC, _EMC_DLL and _EMC_SAFE read back what was written,
  from their TRM resets. A written PLLM or PLLU reads back its
  dividers, which were dropped before while ENABLE was clear.
- EMC: a register file with broadcast and per-channel banks, plus:
  - MRW capture and MRR data/MRR_DIVLD per channel.
  - MR4 at normal temperature, and MR18/MR19 computed from MR23's run
    time at the current DRAM clock over 2 x tDQS2DQ.
  - DLL lock.
  - The CAR/EMC clock-change handshake: a new CLK_SOURCE_EMC source or
    divisor replays the CCFIFO and raises CLKCHANGE_COMPLETE.

With the stock folder, Nyx now trains 204, 800 and 1600 MHz and runs
its 800/1600 MHz power-saving loop, on Erista and Mariko. hwtest's
output is unchanged. The WDT cookie that keeps hekate's IPL from
training is kept; its comments no longer claim the EMC can't do it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
This commit is contained in:
Claude committed 2026-09-25 19:13:08 +00:00
1 parent e32052ffd5
commit 4f42e04f6e
3 files changed
+316 -68

No files matched your search

+8 -7
View File
@@ -153,12 +153,13 @@ static uc_engine *setup_emulation(EmuState *state, uint8_t *payload, size_t payl
// 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. The matching
// EXCP_EN_ADDR (0x4003FF1C) is intentionally left zeroed so ERR_EXCEPTION
// is *not* set and the user doesn't see a "hang detected" warning screen.
// We can't model EMC/MC well enough for real Minerva training, so this is
// the cleanest opt-out (the same path Hekate uses on hardware after a
// legitimate WDT reset).
// libsys_lp0.bso and the IPL's Minerva DRAM training - the same path
// Hekate takes on hardware after a WDT reset. The matching EXCP_EN_ADDR
// (0x4003FF1C) is intentionally left zeroed so ERR_EXCEPTION is *not* set
// and the user doesn't see a "hang detected" warning screen. The EMC
// model runs Minerva fine (Nyx trains the DRAM itself when it starts);
// this only spares a minimal SD image the IPL's "missing lib" errors and
// shortens the boot.
{
uint32_t wdt_magic = 0x544457; // "WDT"
uc_mem_write(uc, 0x4003FF18, &wdt_magic, sizeof(wdt_magic));
@@ -495,7 +496,7 @@ int main(int argc, char *argv[]) {
// Soft reboot: re-write the payload to IRAM, wipe DRAM (so Nyx and
// the bootloader's file-static caches reset), reset PC/SP/clock and
// re-prime the WDT cookie so Hekate's early boot skips Minerva again.
// re-prime the WDT cookie so Hekate's IPL skips LP0/Minerva again.
if (state.reboot_requested.exchange(false)) {
uc_emu_stop(uc);
bool cold = state.reboot_cold.exchange(false);