# Handoff: build `wii-python`, the Nintendo Wii board ## Context you are inheriting The Wii is the family's first **era 4** board (charter: thin evidence; instruction and functional levels dominate; turbo with recompilation; concessions likely on weak targets). It is a GameCube with a second half, so it **pins the GameCube work** and adds the Wii's own parts. Read [gamecube-pin.md](gamecube-pin.md) first, then [domains-and-speed.md](domains-and-speed.md) (it decides how the board is tested), then [ios-hle-lle.md](ios-hle-lle.md) (it decides what the board models behind the IPC). Siblings: **gamecube-python** and **gekko-python** (`../gamecube-python`, `../gekko-python`; their Phase 0 ran the same night and had landed references but no documents when this brief was written: reconcile names and interfaces with their briefs before M0); **arm946es-python** (`../arm946es-python`, the DS's ARM9, Phase 0 done: the Starlet's integer-core relative). Models: n64-python (era-3 Phase 0 shape, execution architecture), the late-era method proposal (emulator-lineage docs/proposals/2026-11-late-era-method.md: slices, shared state format, GPU backends as turbo), gameboy-python (skip-boot against real boot: the HLE/LLE discipline). Rules that bind: the charter and CLAUDE.md (MIT; GPL and other closed-box emulators never read or fetched here: Dolphin, hwtests, MINI, HBC, skyeye-starlet, libogc's wiiuse; romsets and discs by `REDUMP_DIR` / `NO_INTRO_DIR`); **never ship, copy, decrypt into the repository or read Nintendo firmware or secrets** (boot0-2, IOS, MIOS, BC, the System Menu, DSP ROMs, the GameCube IPL and fonts, every key); SHA-1 only; oracle tiers; Python 3.11 floor, PyPy green; no hardware probes (no Wii in the family); run anything reading `reference/` with `python -I`; respect robots.txt: WiiBrew's `/w/` is disallowed, devkitpro.org and ARM's documentation service are set aside (sources-wii.md). ## Scope (first build) Wii mode on `rvl-001`, HLE IOS, homebrew boot and disc boot: the Hollywood register file, IPC, the interrupt controller, the Starlet timer, GPIOs as storage, the bus maps of both CPUs, MEM1 and MEM2, the legacy blocks (pinned), the HLE resources `/dev/fs`, `/dev/es`, `/dev/di`, `/dev/stm`, `/dev/sdio`, `/dev/usb/oh1`, the SD host, OHCI1 with the BCM2045 model, one to four Wii Remotes with the Nunchuck, the disc reader (ISO) with the partition, ticket and hash-tree logic, the AES and SHA-1 engines, the NAND interface and SFFS over a synthetic image. Later: GameCube mode (`rvl-001-gc`), EHCI/OHCI0 and USB devices, the Classic Controller and other extensions, Motion Plus, Wi-Fi (stub first), LLE IOS with arm926ejs-python, the Family Edition and Wii mini rows. ## Proposed names - `wii-python`, package `wii_python`; class `Wii` with a machine row (`MachineRow(model, hollywood_version, mode, mem2_mib)`; `mode` is `wii` or `gc`). - Packages: `bus` (Broadway's and Starlet's maps, AHB_TRUSTED, AHBPROT/SRNPROT/AIPPROT gating), `hollywood` (`registers`, `ipc`, `irq`, `timer`, `gpio`, `resets_clocks`, `otp`, `seeprom`), `ahb` (`aes`, `sha1`, `nand_interface`, `ehci`, `ohci`, `sdhc`, `sdio`), `bluetooth` (`bcm2045`, `hci`, `l2cap`), `remote` (`wiimote`, `ir_camera`, `accelerometer`, `speaker`, `extensions`, `sensor_bar`), `ios` (HLE: `ipc_server`, `resources/{es,fs,di,stm,sdio,oh1,net_stub}`), `disc` (`iso`, `partitions`, `ticket`, `tmd`, `hash_tree`), `nandfs` (SFFS), `boot` (DOL/ELF loader, apploader runner, low-memory globals), `gcmode` (MIOS's state and patch list), `keys` (player-supplied keys checked by SHA-1). ## The import boundary - **gekko-python** (`broadway` row) owns everything inside the CPU and speaks bus transactions with durations; the board's `bus` answers them. - **gamecube-python** owns the Flipper blocks (GX, VI, AI, DSP interface, PI, MI, EXI, SI, DI registers) and their behaviour; the Wii board instantiates them with the `hollywood` row and places them on its bus (gamecube-pin.md, the asks list). - **The DSP core** (gamecube-python's decision) owns the DSP. - **arm926ejs-python** (proposed, D3, late) owns the Starlet in LLE. - Everything in "What the Wii adds" stays in this board. Chip rule check: none of it has a second family user (the vWii belongs to a Wii U board, which would pin this one). ## Sockets (for add-on boards and device models) - **ARAM** (on gamecube-python): the Wii fills it with a MEM2 window in GameCube mode. - **IOS backend**: HLE service model or LLE Starlet, one interface (the IPC block's Starlet side plus the Starlet's bus). - **USB device lists** on OHCI0, OHCI1 and EHCI (keyboard, microphone, LAN adapter, mass storage, game dongles); the BCM2045 is the first device on OHCI1. - **Bluetooth remotes**: four remote slots plus the Balance Board; each remote's extension port (Nunchuck first). - **SD card** backing (image or directory); **network** (stub, later a host bridge). - **Disc drive** behind DI (ISO reader first). - **GX backend** (software first; a GPU backend in turbo). ## Unknowns (U) and contradictions (C) Unknowns (with what could settle each): - U1. Broadway's PVR on retail units, and in GameCube mode (a homebrew `mfpvr`, hwtests). - U2. HID4's bits, the "H4A" behaviour, and whether HID4's SBE enables four more BAT pairs as on the 750CL (750CL UM for the relative; hwtests). - U3. ARAM-in-MEM2 timing under MIOS against the GameCube's ARAM (a GameCube-mode test). - U4. MEM1 and MEM2 timing and Hollywood's memory arbitration (no judge held). - U5. The Starlet's cache sizes, TCMs and core revision (CP15 reads in an LLE run). - U6. IOS's MMU use (LLE only). - U7. AHB wait states; AES and SHA-1 engine durations per block. - U8. Whether IOS idles in wait-for-interrupt or spins (LLE speed). - U9. The byte order of the "Reversed Little Endian" register files (EHCI, OHCI, SDHC, SDIO) on the big-endian bus. - U10. The low-memory globals the System Menu and apploader leave that WiiBrew marks "?" (Memory map). - U11. Drive seek and read timing, and the Wii commands' timing. - U12. Whether RVZ stores partition data decrypted (whether HLE needs the common key for RVZ) (D9). - U13. The IR camera's field of view and geometry. - U14. The remote's report cadence in continuous reporting. - U15. The ADXL330 calibration values in a real remote's EEPROM. - U16. IOS reply latency per resource (the HLE's FITTED values: LLE runs). - U17. Exactly which Hollywood registers Broadway sees in each AHBPROT state. - U18. Hollywood IRQ sources 9, 12-14 and 16. - U19. Whether Broadway's and Starlet's caches are coherent with each other in any way (HYPOTHESIS: not; IOS and libogc flush around IPC). - U20. HW_COMPAT bits 1 and 4; the PLL register semantics. Contradictions (from the pinned pages and manuals): - C1. Gekko's PVR: Gekko UM 2000-05 "0x7000; early releases may have 0x0008" against WiiBrew's "83410" (and Broadway "87102"). - C2. Starlet IRQ delivery: "an interrupt vector table at the beginning of SRAM" (Hardware/Hollywood IRQs) against exception vectors at 0xFFFF0000 (Hardware/Starlet). - C3. boot0's size: "about 1300 bytes of code out of 4K" (Hardware/Starlet) against "1.5K" (Boot process). - C4. IOS's MEM2 reservation: "the top 12MB" (Hardware/Main Memory) against "the upper 12-16MB" (Memory map). - C5. OTP: the NAND HMAC key at bytes 0x44-0x57 "overlaps with" the NG private key at 0x28-0x45 (Hardware/OTP): two bytes shared, as the page itself notes; layout to treat as the page gives it until a player's OTP shows otherwise. - C6. The Wii architecture overview's "it has two processors" followed by three. ## Milestones M0-M8 with exit tests: [validation.md](validation.md). Python never boots a commercial game as a gate; M6's slices start from Rust-tier states; CI never holds a Nintendo key. ## Domains and speed **Domains** (domains-and-speed.md): A Broadway; B the Flipper side (registers, CP/GX front end, event queue); C the GX back end (a producer between joins); D the DSP; E the Starlet (HLE service model or LLE core); F the Hollywood AHB devices; G the Bluetooth controller and each remote; H the disc drive. **Channels**: the legacy registers and the write-gather pipe (A-B), EFB access, copies and PE interrupts (A-C joins), DSP mailboxes and DMA (A-D), **the IPC block, IRQ 30/31 and request memory (A-E)**, engine DMA (E-F), OHCI1 transfers (F-G), DI (B/F-H), and the protection registers, each a full sync point. **Instructions per second, arithmetic shown:** - Broadway: 729 M cycles/s x IPC 0.5-0.8 (HYPOTHESIS) = **365-583 M/s, plan 450 M**; GameCube mode 486 MHz, plan 300 M. - DSP: 121.5 M cycles/s x 30-70 % busy = 36-85 M/s. Starlet LLE: 2-25 M/s if IOS halts when idle, up to 243 M/s if it spins (U8). GX: 37-74 M shaded pixels/s typical. - Budgets at 450 M/s: **11 host cycles per instruction on a 5 GHz desktop core, 8.9 in a phone app, 5.3 in a phone browser.** The family's measured exact interpreters cost about 125-145 cycles per instruction (sh2-rust-fast, arm7tdmi-rust); a table-timed `-fast` PowerPC is estimated at 25-60. **Does the no-JIT path reach real time?** **No, on no target, for Wii-mode games.** Rust `-fast` reaches 18-44 % of real time on a desktop, 15-35 % in a phone app and 9-21 % in a phone browser (HYPOTHESIS, Broadway alone); a cached interpreter adds perhaps x1.2-1.5; threads carry the DSP, the GX back end, an LLE Starlet and the producers, but not Broadway. Full speed needs `recompile: native` (turbo) on desktop and Android; a native iPhone app cannot compile and stays at a fifth to a third of real time; the phone browser with `recompile: wasm` is at the edge (240-600 M/s at 4-10 cycles per compiled instruction), so on an iPhone the browser may be the faster host. The GX needs a GPU back end (turbo) except on large desktops. Python: 0.5-2 M instructions/s (HYPOTHESIS), 225-900 s per emulated second: test programs and slices only. ## Open decisions for Aubrey Each with my recommendation. - **D1. Names and pins.** `wii-python` / `wii_python`; pin gamecube-python and gekko-python (a `broadway` machine row: PVR, HID4, the extra BATs if U2 confirms them; the board sets the clock). gekko-python's start-here already expects this check. *Recommend* yes, reconciled with the GameCube briefs before M0. - **D2. Flipper's blocks stay in gamecube-python**, composed by this board with a `hollywood` row; no `flipper-python` extraction until a third family board (Triforce) is built. *Recommend* yes (n64-python's iQue/Aleck64 precedent). - **D3. The Starlet core**: `arm926ejs-python`, its own CPU core, pinning arm946es-python's integer core if that core exposes it apart from its memory system (the ask goes upstream first); built only for LLE, after M5. *Recommend* yes, late. - **D4. IOS: HLE in the specification as a functional level**, every reply time FITTED or HYPOTHESIS, the modelled IOS version named per resource, unmodelled requests refused; LLE with the player's firmware later as the judge of the HLE. And the charter question: is HLE IOS a **modelling level** or a **concession**? *Recommend* a modelling level, since no exact alternative can be tested without Nintendo's code, with LLE (when it exists) as the exact reference. - **D5. Bluetooth at the HCI controller**, an emulated radio, remotes as device models; the IR camera's random initialisation state not modelled (the intended state chosen, the randomness named). *Recommend* yes. - **D6. libogc and devkitPro.** devkitpro.org's robots.txt blocks AI crawlers; libogc on GitHub states no AI wish. Does the site's wish cover devkitPro's GitHub repositories (libogc, wii-examples) and its toolchain packages (devkitPPC, served from devkitPro's servers)? *Recommend* asking before any fetch; meanwhile libogc2 (its own maintainers, zlib, "no LLM contributions", honoured), and for building homebrew a PowerPC GCC from a source that is not devkitPro's (a distribution's cross compiler), decided when M2 needs it. - **D7. Stated speed targets.** Accept that `recompile: none` is below real time on every target and say so in the capability record; the Wii's full-speed target is desktop with turbo (`recompile: native`), the browser with `recompile: wasm` best effort, the iPhone app a reference-speed player at most. *Recommend* yes, and to spend the effort on the specification and an exact `-fast` before any turbo work. - **D8. Late I/O order**: SD first (it is test infrastructure: homebrew loads and writes results there), then OHCI1 for Bluetooth, then EHCI/OHCI0 devices, then Wi-Fi as a "no connection" stub. *Recommend* yes. - **D9. Disc formats**: plain ISO first (Redump's form); RVZ converted locally by Dolphin's tool run as a closed box from emu-tools-gpl; an RVZ reader of our own only after a clean-room description exists (the format's documents live in Dolphin's GPL tree, and WIA's origin is Wiimm's GPL tools). *Recommend* yes. The local library is RVZ only (2,730 discs). - **D10. ARM's documentation host.** documentation-service.arm.com's robots.txt disallows all agents. arm946es-python's three TRMs were fetched from it before the robots rule; keep them? And DDI 0198 (ARM926EJ-S) would need Aubrey to download it himself, pinned by SHA-256. *Recommend* keeping the existing pins with a note in arm946es-python's sources (they were fetched in good faith), Aubrey downloading DDI 0198 when D3 starts. - **D11. A provenance rule for the Nintendo era-4 boards**, answering Dolphin's stated concern that LLMs may hold leaked Nintendo information: every behaviour that reaches the specification cites a public source or carries FITTED/HYPOTHESIS with its basis; facts from model memory are tagged and replaced before code; nothing from leaked SDKs. *Recommend* yes, recorded in this board's claims file and proposed for the methodology (Aubrey's document). - **D12. hwtests as a judge.** Build dolphin-emu/hwtests (GPL-2.0) in emu-tools-gpl or emu-tools-gpl2 (whichever its headers require), run its binaries on the board, read its expected values as test verdicts. It needs a PowerPC toolchain and libogc (D6). *Recommend* yes, at M2. - **D13. Local until M3, then public** after a provenance check (nothing from GPL source, no Nintendo bytes, no keys), with the family's minimal CI. *Recommend* yes.