Commit Graph
8 Commits
Author SHA1 Message Date
Claude 1aa0ee9f23 Model the SE's RSA and random number generator
Both ops finished with OP_DONE and produced nothing. se_rng_pseudo()
left its buffer as it was, so Nyx's partition manager wrote whatever
was on the stack into GPT partition GUIDs, and the SD benchmark drew
its random offsets from uninitialised memory. se_rsa_exp_mod() read
back zeros.

- RSA, as Lockpick's bdk drives it: two keyslots of up to 2048 bits
  loaded through SE_RSA_KEYTABLE_ADDR/DATA, KEY_SIZE in 512-bit steps,
  EXP_SIZE in words, the input a little-endian number over DMA and the
  result in SE_RSA_OUTPUT (or memory). Montgomery multiplication on
  32-bit words; an even modulus fails the op.
- RNG into memory or a keyslot quad, LAST_BLOCK + 1 blocks cut to the
  buffer. The bytes come from SplitMix64 with a fixed seed, reset with
  the SE, so runs stay reproducible.

tests/se/ is a new make test payload: RSA-2048 and RSA-1024 in the two
slots, each m^d and s^e checked against Python (gen_vectors.py writes
vectors.h), SHA-256 one-shot and in two parts, AES-128 ECB, and the
RNG filling a zeroed buffer, changing between calls and stopping at
the size asked for. Run against the previous binary it fails the RSA
and RNG checks. The README's "RSA, RNG and chunked SHA are stubs" is
gone; chunked SHA was already modelled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
2026-09-25 22:40:08 +00:00
Claude fae29019ae Model DC window address offsets and block-linear VIC surfaces, with a test
- DC: a window's fetch starts at ADDR_V_OFFSET * LINE_STRIDE +
  ADDR_H_OFFSET (TRM 24.11.1). That is the window's top-left pixel, or
  top-right with H_DIRECTION, or bottom-left with V_DIRECTION, and the
  fetch walks away from it; before, the offsets were ignored and flips
  mirrored within the window. HOS's column-scan offset (0x13FF) and
  hekate's inverted-pitch offset (1279) both land where they should.
  Layer order is documented: the TRM sorts windows by depth without
  saying which way.
- VIC: slot and output surfaces may be block linear (BlkKind 1, 2^BlkHeight
  GOBs per block) as well as pitch.
- GOB addressing moves to t210/block_linear.h, shared by the scan-out
  and VIC.
- tests/display: one bare-metal payload built per scenario (a pitch
  window, Nyx's VIC turn into pitch and into block-linear surfaces, a
  block-linear VIC source, the DC's own column scan with an address
  offset, a mirrored window with window D blended over). check.py
  compares every pixel of the frame the emulator shows with the picture
  drawn. It runs in make test and in CI.

hwtest's frame is unchanged, and Nyx's differs only in its clock.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
2026-09-25 21:21:44 +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 a71ccdf682 Take a dropped payload, and stop drowning the console
Double-clicking the emulator printed a usage line to a console nobody sees
and exited. It now opens a window that accepts a dropped .bin, with O for the
system file dialog - GetOpenFileName on Windows, zenity or kdialog on Linux,
since there is no such thing there without dragging in a toolkit. The window
draws a dashed frame and an upload glyph from rectangles and one filled
triangle; no text, because a font would have to be vendored for a screen that
lives a few seconds and the instruction is on the title bar already. It is
created and destroyed before the emulator's own display comes up, so it
cannot interfere with the framebuffer window. A headless or toolkit-less
machine falls back to the old usage message, and dragging a payload onto the
executable still skips all of it - that arrives as argv[1].

Dropping a payload was then unusably slow, and the reason had nothing to do
with the picker. A full hwtest sweep printed 52,452 lines, of which about
51,900 were per-register-access traces: 29,673 [gpio], 16,707 [mmio], 5,430
[sdmmc]. Redirected to a file that is merely wasteful, which is why it went
unnoticed - every scripted run here redirects. On a Windows console it is
not: each line goes through conhost one write at a time. Those traces now
need --trace or RCM_EMU_TRACE=1, which drops default output to 578 lines -
the payload's own UART plus the handful of [emu], [display], [pcie] and
[audio] lines worth seeing. The flag brings all 48,354 back when a
register-level question needs answering.

Also adds RCM_EMU_PICK, which runs the picker's window lifecycle and returns
a path as if it had been dropped, so that path can be tested by a script
instead of only by a human dragging a file.
2026-08-20 10:29:28 +02:00
Baptiste MOINE 390d64abe6 Play the emulated audio, and build for Windows
Two things, both about being able to check the emulator's work rather than
infer it.

Sound. The samples a payload pushes through the ADMAIF PIO port were being
discarded; now they are written to last_audio.wav and played on the host.
Each FIFO word is already a stereo frame, so the capture needs only a header.
The take is played after it is complete rather than streamed while it is
produced: the emulator generates samples in bursts and stalls entirely
between phrases while the payload talks to the codec over I2C, so a live
stream underruns wherever the producer falls behind the sound card, heard as
flicker. Queueing the finished buffer removes the producer from the timing
path. The rate comes from the I2S_TIMING the payload programmed, not a
nominal 48 kHz, or the melody replays at the wrong pitch.

Windows. Cross-compiled in a container, since neither dependency has a MinGW
package. Three things had to be fixed to get there, none of them findable
without actually trying it:

  - mingw GCC 13 hits an internal compiler error on unicorn's
    qemu/softmmu/memory.c at -O2, so unicorn is built at -O1.
  - pread/pwrite are POSIX and absent on MinGW. The SD/eMMC image access now
    has a seek-then-read shim, which is equivalent here because the emulated
    storage is only touched from the CPU thread.
  - SDL renames main on Windows, so SDL2main must be linked before SDL2 with
    SDL_MAIN_HANDLED, and unicorn's threads need winpthread.

The .exe is static: one file, no DLLs beside it. Verified running natively -
it emulates a full hwtest sweep and plays the melody through WASAPI.

CI covers both platforms, and a third job runs the .exe on a Windows runner,
because a cross-build only proves it links. Builds on push and PR, not just
tags: the Windows build broke in three separate ways the first time it was
attempted, and a Linux-only workflow would have shown none of them.
2026-08-20 10:05:33 +02:00
Baptiste MOINE 0490e472d0 Track header deps with -MMD -MP in Makefile 2026-05-03 09:42:42 +02:00
Baptiste MOINE 1cd49f667a Add live hardware-tweak config window (M key) 2026-05-02 14:11:04 +02:00
Baptiste MOINE d0d7a38fa3 Initial commit 2026-05-02 00:52:26 +02:00