Commit Graph
12 Commits
Author SHA1 Message Date
Claude c6b532fdbd Read back CAR and MC registers, and measure the EMC at its modelled clock
Most CAR registers the model does not handle, and every MC register but
two, read 0 even after a write. Payloads saw a CLK_SOURCE divider, a
PLL misc word or an audio clock source they had just programmed come
back as 0.

- CAR: the fallthrough returns what was written. The SET/CLR alias
  registers are write strobes and keep reading 0. No CAR poll in bdk or
  hwtest waits for hardware to clear a bit it wrote, so read-back cannot
  turn a poll into a hang.
- MC: configuration registers read back (no MC register is polled).
- The PTO counter measures the EMC at the clock CAR and the PLLs give
  it, so it follows Minerva to 1600 MHz. At the 204 MHz boot clock it
  keeps the measured 203.991 / 204.001 MHz.

hwtest now reports the AUD_MCLK source, PLLA misc word and a clock
source divider it programs. Its verdict is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
2026-09-25 21:21:30 +00:00
Claude 7607dd9f69 Note which fuses Minerva needs, since hekate blames a missing file
hekate prints "Missing Minerva lib!" whenever minerva_init fails. That
covers the module refusing to start, which it does unless HIDREV reads
chip 0x21 and FUSE_SKU_INFO reads 0x83 (ODIN). The emulator's defaults
satisfy both, but editing fuse 0x110 in the config window or
rcm_emu.ini brings the screen back with the module present. Say so on
the fuse's label and in the boot-flow notes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
2026-09-25 20:02:01 +00:00
Claude 306a86dbcb Stop planting hekate's watchdog cookie in IRAM
The emulator wrote hekate's "watchdog fired" magic (0x544457 at
0x4003FF18) before every boot. hekate then took its post-watchdog path
and skipped LP0 and Minerva, because the EMC could not support DRAM
training. It can now, so the cookie only made the boot differ from
hardware, and it never covered Nyx, which trains the DRAM itself when
it finds Minerva uninitialised.

With the cookie gone, hekate's IPL saves the LP0 SDRAM config and
trains 204, 800 and 1600 MHz itself, and Nyx takes over the trained
context. An SD image without bootloader/sys now gets hekate's real
"Missing LP0/Minerva lib" screen, which waits for a key press.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
2026-09-25 19:29:24 +00:00
Claude 4f42e04f6e 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
2026-09-25 19:13:08 +00:00
Claude e32052ffd5 Model the DC windows and VIC compose, and scan out what they describe
The display model took each window's line stride from PRESCALED_SIZE
rather than LINE_STRIDE, and kept one set of window parameters for all
four windows, so window D's 656-pixel log window leaked into window A.
Its block-linear decoder also had two GOB address bits swapped. The mock
VIC only memcpy'd, so Nyx's rotated frame never existed. The renderer
papered over all of this with per-address heuristics: a "known menu
stride" of 2624, forced block-linear decoding of the IPL carveout, and a
hard-coded 1280x720 geometry for Nyx's framebuffer.

- DC: a register file per window (A-D), reached through the indirect
  pages per DISPLAY_WINDOW_HEADER or the A/B/C direct ranges. Writes
  land in the assembly copy, and WIN_x_ACT_REQ promotes it to the active
  copy the scan-out reads. Other DC registers read back what was
  written. STATE_CONTROL reads 0, and INT_STATUS reports frame end and
  vblank, which bdk polls before DSI commands.
- VIC: on COMPOSE_START, read bdk's vic_config_t from guest memory and
  draw the enabled pitch slots into the target, with scaling, clipping
  and the output flip/transpose. Nyx's 270-degree rotation now happens.
- Scan-out: fetch each enabled window per SURFACE_KIND (pitch, tiled or
  block linear, per TRM 20.1.2 Figure 47), LINE_STRIDE and COLOR_DEPTH,
  turn it per WIN_OPTIONS (H/V direction, SCAN_COLUMN), scale it from
  PRESCALED_SIZE to SIZE, place it at POSITION, and stack and blend the
  windows by depth and BLEND_*. When the surface on show was turned on
  its way to the panel, by the DC or by VIC, the view undoes the turn,
  so Nyx still shows landscape. All the heuristics are gone.

hwtest's frame and Nyx's home screen are pixel-identical to before.
Nyx's error console (window D over window A) now shows; before, it was
invisible.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
2026-09-25 18:40:26 +00:00
Claude 39bfad6a0b Model the SDMMC host registers, eMMC HS200 tuning and HS400
The SDHCI power, clock, reset and HOST_CONTROL2 registers and Tegra's
vendor block all read 0, whatever was written. bdk picks the eMMC bus
mode from them: POWER_CONTROL reading "off" made it fall back to HS52,
so the eMMC ran at 51 MHz while its EXT_CSD claimed HS400.

- Keep a register file per controller for 0x28-0x3F and 0x100-0x1FF,
  with the TRM reset values. INTERNAL_CLK_STABLE follows INT_CLK_EN,
  the SW_RESET bits self-clear (RESET_ALL resets the standard registers,
  RESET_CMD/RESET_DATA clear their line's status), and the pad
  auto-calibration and DLL calibration complete at once.
- Model the tuning circuit (TRM 32.9.2.14). EXECUTE_TUNING starts it,
  each CMD19/CMD21 tries one tap against a fixed data eye, and after
  NUM_TUNING_ITERATIONS commands the final tap is set per MUL_M/DIV_N.
  The tuning block's BUFFER_READ_READY waits for the card clock to be
  re-enabled, which is the order bdk waits in.
- Keep EXT_CSD as one array per power cycle. CMD6 SWITCH updates its
  writable bytes, CMD8 reads them back, and CMD0 resets the card
  fields. BOOT0/BOOT1 and RPMB are 4 MiB, as on a Switch.

hwtest now tunes the eMMC in 128 iterations and reports a 199.68 MHz
HS400 card clock. The hwtest check asserts both.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
2026-09-25 18:37:38 +00:00
Claude 6753c5f3db Fix defects found in a code sweep and a TRM cross-check
Security Engine: CTR ignored its input and returned the raw keystream;
CBC encrypt skipped the IV on the first block and saved the wrong
chaining value, so every CMAC over more than one block was wrong; OFB
was broken. The datapath now follows INPUT_SEL/XOR_POS/VCTRAM_SEL the
way bdk drives it, and matches OpenSSL for ECB, CBC, OFB, CTR and
CMAC. SHA-256 works in parts (SHA_CONTINUE), SE_OP_CTX_SAVE reads keys
back as se_aes_ctx_get_keys() expects, unwrap honours the word quad,
guest block counts and LL sizes are bounded, and unreachable buffers
end the op with an error.

Soft reboot now resets the whole SoC (GPIO/pinmux cache, UARTs, I2C,
PMC, CAR, flow controller, SE, touch, SDMMC, display, ACTMON, ...)
while keeping what hardware keeps (PMC SCRATCH0, the RTC, and the PMIC
unless the reboot is a power cycle). DRAM gets fresh zero pages
instead of a memset that made all 2 GB resident; stale BPMP
translations are dropped; CPSR returns to SVC; scripts restart.

Execution: a branch to address 0 no longer hangs the emulator
(until=0 made PC 0 an exit); bdk's reset-then-bpmp_halt() reboots
instead of exiting; an untimed halt with CPU0 running parks the BPMP
and lets CPU0 continue; CPU0 starts in the same batch it is released
in; CPU0 drops translations of pages the BPMP rewrote; shared models
no longer see time run backwards.

TRM cross-check: RST_CPUG_CMPLX resets to 0x2000feef and CPU0 runs on
CPURESET0/CORERESET0/L2RESET/NONCPURESET (bit names corrected); RAM
repair clears REQ and sets STS, and is no longer a run condition;
refused releases are re-evaluated; MSELECT ENABLE_PCIE_APERTURE gates
PCIe; RST_DEVICES_W/Y direct writes land; DL_UP is read-only; the
whole config aperture and memory window decode; OSC_CTRL reports
38.4 MHz; PLLE/PLLREFE no longer get bit 27 forced into a divider;
PMC is a R/W register file; RTC SECONDS counts; FLOW halt modes follow
17.2.2 and STOP_UNTIL_IRQ wakes on the armed TMR; UART IIR/IER/
loopback MSR; I2C NOACK code and empty I2C4/I2C6 buses; pinmux reset
values; the COP ACTMON counts halt time.

Peripherals: MAX77620 LDO power-good follows the rail (hwtest's
gamecard probe no longer fails), the Erista GPU MAX77621 answers at
0x1C, regulators ACK per generation, RTC CONTROL is binary/24h, PS3
card detect reads "slot empty", packet-mode I2C parses 4 bytes per
word, rawnand I/O splits at part boundaries, eMMC returns to its user
area on CMD0, ADMA2 descriptors decode per spec, SD CMD6/ACMD13 data
reaches the programmed buffer, ERR_INTERRUPT is reported, R1 follows
block commands.

Frontend and tooling: touch events queue instead of overwriting each
other, map through rotation overrides and bdk's edge offset, and use
finger ID 0; a scripted press is always seen before its release;
zeroed fuses persist in the ini; dropped UTF-8 paths open on Windows;
bad --input-script is an error; test scripts check exit status and
missing arguments; make_sd.py quotes names and picks a FAT32-valid
cluster size; the Dockerfile marks the mount safe for git.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
2026-09-25 17:45:02 +00:00
Claude 11ad2e4d9f Test the CCPLEX model and the hwtest sweep in CI, and document both
- tests/ccplex: a self-contained BPMP payload (ARM, arm-none-eabi-gcc; the
  AArch64 side is pre-assembled words) that drives CPU0 through bdk's
  ccplex_boot_cpu0() register sequence. It checks that an unpowered
  release is refused with its reason, that a powered one runs at EL3 from
  the SB vector and writes the mailbox, that CPU0 sees TIMERUS move, that
  WFE parks the core, and that RST_CPUG_CMPLX_SET stops it. `make test`.
- tests/hwtest: build hwtest-rcm from a pinned commit with distro
  toolchains (an empty base_rules stands in for devkitARM, the CPU0 stub
  builds with gcc-aarch64-linux-gnu) and run its whole sweep headless,
  checking the CPU0-driven Wi-Fi probe enumerates the CYW4356.
- CI runs both in the Linux job and keeps their logs on failure.
- Makefile: `test` target; the clean rule's line continuation was a
  literal "\n" that only worked by accident.
- README/DESIGN: CCPLEX CPU0, the uc_mmio_map bus, the block-level clock
  and TIMERUS poll pacing, the new bug-history entries.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
2026-09-25 15:56:00 +00:00
Baptiste MOINE df6f0c24c3 Document UART console, power-action hooks, MMIO mirror 2026-05-03 09:47:26 +02:00
Baptiste MOINE 1cd49f667a Add live hardware-tweak config window (M key) 2026-05-02 14:11:04 +02:00
Baptiste MOINE f6146bb953 Skip Minerva via watchdog cookie at IRAM 0x4003FF18 2026-05-02 13:37:03 +02:00
Baptiste MOINE d0d7a38fa3 Initial commit 2026-05-02 00:52:26 +02:00