Files
RCM-Emulator/tests/hwtest/run.sh
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

54 lines
2.2 KiB
Bash
Executable File

#!/bin/sh
# End-to-end: run hwtest's whole hardware sweep in the emulator, headless,
# and check the CPU0-driven PCIe probe enumerated the Wi-Fi endpoint.
# Usage: tests/hwtest/run.sh <rcm_emu> <hwtest.bin> [extra emulator args...]
#
# hwtest sits in its pager once the sweep is dumped, so the run is ended as
# soon as the dump's last line appears (with a hard timeout behind it).
EMU=${1:-./rcm_emu}
BIN=${2:-build-hwtest/hwtest-rcm/build/hwtest.bin}
# Anything after the two positional arguments goes to the emulator. (A bare
# `shift 2` with fewer than two arguments makes dash exit on the spot.)
[ $# -ge 2 ] && shift 2 || set --
LOG=${LOG:-tests/hwtest/out.log}
LIMIT=${LIMIT:-300}
# POWER at 3 s picks "Hardware test" on hwtest's launcher.
SDL_VIDEODRIVER=dummy RCM_EMU_NO_AUDIO=1 "$EMU" "$BIN" --input-script "3000 P" "$@" \
> "$LOG" 2>&1 &
pid=$!
t=0
until grep -q 'end of dump' "$LOG" 2>/dev/null || ! kill -0 $pid 2>/dev/null; do
sleep 1
t=$((t + 1))
if [ $t -ge "$LIMIT" ]; then
echo "hwtest: no end of dump after ${LIMIT}s"
break
fi
done
kill $pid 2>/dev/null
wait $pid 2>/dev/null
echo "hwtest: sweep took ~${t}s of wall time"
fail=0
expect() {
if grep -q -- "$1" "$LOG"; then
echo " ok $2"
else
echo " FAIL $2 (missing: $1)"
fail=1
fi
}
expect 'end of dump' 'the whole sweep ran to its end'
expect '\[ccplex\] CPU0 released: AArch64 EL3' 'hwtest booted CPU0'
expect 'CPU0 : ran to completion' 'the CPU0 stub ran to completion'
expect 'AFI (CPU) : cfg=00103025 witness=A5A50000 -> APERTURE LIVE' 'the PCIe aperture decodes for CPU0'
expect 'RP1 link : UP, DL active (LNKSTA=3011' 'root port 1 trained'
expect 'EP config : 14E4:43EC' 'the CYW4356 endpoint enumerated'
expect 'CPU0 : powergated' 'the cluster was powergated again'
expect 'Wireless : pass' 'the Wireless verdict passed'
expect '\[sdmmc\] SDMMC4 tuned: 128 iterations' 'the eMMC passed HS200 tuning'
expect 'card_clock : 199.68 MHz' 'the eMMC runs at HS400 speed'
[ $fail -eq 0 ] && echo "hwtest: PASS" || { echo "hwtest: FAIL - see $LOG"; exit 1; }