Files
RCM-Emulator/.github/workflows/build.yml
T
Claude d661f2738c Model USB device mode, with an emulated PC on the cable
Both USB controllers were plain register caches: USBCMD.RESET never
cleared, so bdk's usb_device_init() timed out and none of Nyx's USB
tools could even wait for a cable.

- The Erista USB2 controller (USB1, 0x7D000000, bdk usbd.c): queue
  heads at ENDPOINTLISTADDR (bdk's are in the controller at +0x1000),
  transfer descriptors in DRAM, ENDPTPRIME / ENDPTSTATUS /
  ENDPTCOMPLETE, SETUP packets in queue head 0 with ENDPTSETUPSTAT,
  a self-clearing controller reset and the PHY's clock-valid bit. Byte
  and halfword accesses work, since bdk memcpy()s SETUP packets out.
- The Mariko XUSB device controller (0x700D0000, bdk xusbd.c): endpoint
  contexts and TRB rings with Link TRBs and cycle bits, the doorbell, a
  two-segment event ring with Port Status Change, Setup and Transfer
  events, EP_HALT / EP_STCHG, EP_RELOAD, and PORTSC's write-1-to-clear
  changes and link-state writes.
- The host (--usb-host, [usb] host, or the config window) plays the PC
  on whichever controller attaches: debounce, bus reset at high speed,
  enumeration with SET_ADDRESS recovery, then after 100 ms for its class
  driver to bind - bdk's XUSB driver stalls an early GET_MAX_LUN - the
  class. For mass storage it runs Bulk-Only Transport: GET_MAX_LUN,
  INQUIRY, TEST UNIT READY with REQUEST SENSE for the unit attention,
  READ CAPACITY, READ(10) of the first 64 and last 8 blocks with their
  CRC32s, checked against the SD image when the size matches, then allow
  removal, eject, and poll until the gadget detaches. For HID it reads
  the report descriptor, sets idle 0 and polls the interrupt endpoint.
  It only reads, and it runs on the controllers' register accesses, so
  runs repeat. [usb-host] lines log it; RCM_USB_TRACE=1 logs every
  descriptor, TRB and doorbell.

With hekate 6.5.3, Nyx's SD card mass storage enumerates as 11EC:A7E0,
reads back identical to the SD image and ends at "Disk ejected" on both
Erista and Mariko; the gamepad enumerates and serves its report
descriptor (with no Joy-Cons it has nothing to report). Without a host
Nyx waits and reports a timeout, as with no cable.

tests/usb/ runs a mass storage gadget over a RAM disk on each controller
and a HID gadget on the USB2 one, checks what the host logs - the
enumeration, the SCSI commands, CRC32s equal to the payload's, the eject
and the detach - and a run with nothing on the cable.

The Windows pread/pwrite shim moves from mmio.cpp to platform.h, as the
host reads the SD image too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
2026-09-26 10:25:29 +00:00

169 lines
5.9 KiB
YAML

name: Build
# Tags publish a release; pushes and PRs just prove it still builds. That
# second half is the point: the Windows build broke three different ways the
# first time anyone tried it (a compiler ICE in a dependency, POSIX-only file
# I/O, and library ordering), none of which a Linux-only workflow would show.
on:
push:
branches: [master]
tags: ['v*']
pull_request:
branches: [master]
workflow_dispatch:
jobs:
build-linux:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout (with submodules)
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install build dependencies
run: |
sudo apt-get update -qq
sudo apt-get install -y --no-install-recommends \
build-essential pkg-config libunicorn-dev libsdl2-dev \
gcc-arm-none-eabi libnewlib-arm-none-eabi gcc-aarch64-linux-gnu
- name: Build
run: make -j"$(nproc)"
- name: Smoke test
# No display and no sound card on a runner, so this only checks the
# binary starts, reads its ini and rejects a missing payload. That is
# enough to catch a bad link or a missing shared library.
env:
RCM_EMU_NO_AUDIO: "1"
run: |
test -x rcm_emu || { echo "rcm_emu missing"; exit 1; }
./rcm_emu /nonexistent.bin 2>&1 | tee out.txt || true
grep -q "RCM Payload Emulator" out.txt \
|| { echo "banner missing - binary did not start"; exit 1; }
- name: CCPLEX, SE, USB and display regression tests
# Small self-contained payloads. One boots CPU0 through bdk's
# ccplex_boot_cpu0() register sequence: an unpowered release must be
# refused, a powered one must run an AArch64 blob at EL3, and WFE must
# park the core. One runs the Security Engine's RSA, SHA-256, AES and
# RNG against vectors computed in Python. One brings up USB gadgets on
# both device controllers for the --usb-host PC to enumerate and read
# back. The others drive the display controller and VIC in six
# scenarios, and the frame the emulator shows must match the picture
# drawn, pixel for pixel.
run: make test
- name: hwtest end to end
# hwtest-rcm's whole hardware sweep, including the Wi-Fi probe that
# hands PCIe to an AArch64 stub on CPU0. Built from a pinned commit
# with distro toolchains; the run must enumerate the CYW4356.
run: |
tests/hwtest/build.sh build-hwtest
tests/hwtest/run.sh ./rcm_emu build-hwtest/hwtest-rcm/build/hwtest.bin
- name: Keep test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: test-logs
path: |
tests/ccplex/out.log
tests/se/out.log
tests/usb/out_*.log
tests/hwtest/out.log
if-no-files-found: ignore
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rcm_emu-linux
path: rcm_emu
if-no-files-found: error
- name: Attach to release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: rcm_emu
fail_on_unmatched_files: true
generate_release_notes: true
build-windows:
# Cross-compiled from Linux rather than built on a Windows runner: neither
# dependency has a MinGW package (SDL2 ships a devel tarball, unicorn has
# to be compiled), so the toolchain has to be assembled either way - and
# doing it in the container means CI and a local `make windows` are the
# same build.
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout (with submodules)
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Buildx
uses: docker/setup-buildx-action@v3
- name: Build the cross-compile image
# Cached between runs: compiling unicorn for Windows is the slow part
# and it only changes when the Dockerfile pins a new version.
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile.windows
tags: rcm_emu_win:latest
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Cross-compile rcm_emu.exe
run: |
docker run --rm -v "$PWD:/work" rcm_emu_win
test -s rcm_emu.exe || { echo "rcm_emu.exe missing"; exit 1; }
file rcm_emu.exe | grep -q "PE32+" \
|| { echo "not a Windows executable"; exit 1; }
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rcm_emu-windows
path: rcm_emu.exe
if-no-files-found: error
- name: Attach to release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
files: rcm_emu.exe
fail_on_unmatched_files: true
generate_release_notes: true
smoke-windows:
# The cross-build only proves it links. This proves the .exe actually
# starts on a real Windows machine - the static link, the SDL entry point
# and the unicorn init are all things that can pass the linker and still
# fail at runtime.
needs: build-windows
runs-on: windows-latest
steps:
- name: Download the exe
uses: actions/download-artifact@v4
with:
name: rcm_emu-windows
- name: Run it
env:
RCM_EMU_NO_AUDIO: "1"
shell: bash
run: |
./rcm_emu.exe /nonexistent.bin 2>&1 | tee out.txt || true
grep -q "RCM Payload Emulator" out.txt \
|| { echo "banner missing - the exe did not start on Windows"; exit 1; }
echo "rcm_emu.exe starts on a clean Windows runner"