Commit Graph
32 Commits
Author SHA1 Message Date
Baptiste MOINE 9f6e96001c Do not freeze the emulator while the melody plays
Playback waited for the sound card to drain before returning, and that runs
on the emulation thread: the whole emulator stopped for the length of the
take - 7.8 s of a 24.7 s hwtest run, measured - with the window not
repainting, which Windows paints as a hung application. Dropping a payload
on the picker looked like it had wedged.

Nothing needs the wait. The entire buffer is queued in one call before
playback starts, so SDL drains it in the background with no risk of
underrun; the device is simply left open for it. Same run is now 17.5 s with
no gap over 0.1 s, and the melody still plays in full.
2026-08-20 10:50:24 +02: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 6782304549 Model the radios, the PCIe root port and the audio hub
Enough of the T210 to run the whole hwtest sweep. Before this the run died
partway through the audio pages, so Display, Inputs, Raw state and the
Diagnostics verdict never executed at all - 30 pages of 42.

Bluetooth: the CYW4356 as a state machine behind UART-D, with the strap and
power-on sequencing the real part needs, plus the PINMUX, GPIO port H and
UART plumbing it hangs off. Selectable healthy / faulty / absent, so the
failure paths a working console will not produce can still be exercised.

PCIe: MSELECT, the XUSB pad controller and the root port, with the WLAN
endpoint answering config reads. The apertures sit below every other
peripheral, so they need their own hook range.

Audio: the APE hub - I2S, ADMAIF and ADMA - and the ALC5639 codec on I2C_1.
Three details matter. ADMAIF was not dispatched at all, so the ~224k PIO
sample writes of one melody each fell through to the logging arm and the run
drowned in its own output. I2S registers returned 0 rather than what was
programmed, which turned "64 bclk/frame, fs 23437 Hz" into "2 bclk/frame,
fs 750000 Hz". And the codec is big-endian on the wire while bdk packs the
buffer little-endian, so its registers are byte-swapped on the way out.

I2C now NAKs addresses with nothing behind them. Answering every address
made a bus census report all 112 as populated, and made a headphone amp that
is not fitted on this board look present - hwtest then decoded its zeroed
registers as real readings. An emulator that says yes to everything cannot
test a probe whose job is deciding what is there.
2026-08-20 09:18:54 +02:00
Baptiste MOINE 7693df269a Model measured Erista identity, rails, clocks and PLLs 2026-08-08 00:20:56 +02:00
Baptiste MOINE 7f2dbefa5d Model fan tachometer and fix the Port Z IN offset 2026-08-08 00:20:56 +02:00
Baptiste MOINE a3ab1b193f Report SDMMC bus width and measured EXT_CSD capabilities 2026-08-08 00:20:56 +02:00
Baptiste MOINE 7ee0c52763 Model the BH1730 ambient light sensor on I2C2 2026-08-08 00:20:56 +02:00
Baptiste MOINE bc2f03a6a6 Honour UART DLAB and mirror UART config registers 2026-08-08 00:20:56 +02:00
Baptiste MOINE 2b5a5c9cb0 Model PLL state, PTO clock counter and OSC detect 2026-08-08 00:20:55 +02:00
Baptiste MOINE 7c1ab28563 Model measured Mariko PMIC, HIDREV and KFUSE state 2026-08-08 00:20:55 +02:00
Baptiste MOINE 6fb2aecd20 Stop the RTC window from shadowing the PMC block 2026-08-08 00:20:55 +02:00
Baptiste MOINE 265ca5404c Serve measured MAX77620 CID3 and CID5 as whole bytes 2026-08-08 00:20:55 +02:00
Baptiste MOINE 5caa4d5e2d Model SD1 and SD2 per SoC generation 2026-08-08 00:20:55 +02:00
Baptiste MOINE 1cc1e88bcc Complete FLOW_CTLR RAM repair handshake 2026-08-08 00:20:55 +02:00
Baptiste MOINE da5370b2ec Model SOC_THERM on-die thermal sensors 2026-08-04 01:17:52 +02:00
Baptiste MOINE 16cbccde47 Map DRAM as one contiguous window 2026-08-04 01:17:52 +02:00
Baptiste MOINE b5b610fbc2 Model ACTMON activity monitor 2026-08-04 01:17:52 +02:00
Baptiste MOINE 1efbc945cf Resume BPMP on timed FLOW_CTLR halts 2026-08-04 01:17:52 +02:00
Baptiste MOINE 8c4fa8d98b Serve KFUSE key block and report DRAM size 2026-08-04 01:17:52 +02:00
Baptiste MOINE 895779c00c Model PMIC and RTC I2C registers, persist writes 2026-08-04 01:17:51 +02:00
Baptiste MOINE dc6d3364d7 Extend GPIO mirror to CNF / OE / OUT reads 2026-05-03 10:09:16 +02:00
Baptiste MOINE ef5870b6f0 Mirror MMIO writes for PINMUX, PWM, and GPIO IN read-back 2026-05-03 09:42:43 +02:00
Baptiste MOINE 1da383f8d2 React to PMIC PWR_OFF / SFT_RST and PMC MAIN_RST 2026-05-03 09:42:43 +02:00
Baptiste MOINE e527872acb Track per-port UART TX log and host-injected RX FIFO 2026-05-03 09:42:42 +02:00
Baptiste MOINE 8559909f2d Populate fuse defaults and unblock Dump fuses 2026-05-03 09:42:42 +02:00
Baptiste MOINE d0f0f67247 Add display + touch panel info to HW & Fuses screen 2026-05-03 09:42:42 +02:00
Baptiste MOINE 91b85f2b57 Add DRAM info to HW & Fuses screen 2026-05-03 09:42:42 +02:00
Baptiste MOINE 1bb615e00f Add --oem flag for Erista / Mariko SoC selection 2026-05-02 15:55:18 +02:00
Baptiste MOINE 412bbf6a2c Add SD and eMMC tweaking (CID, eject, reboot) 2026-05-02 15:26:08 +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