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.
This commit is contained in:
Baptiste MOINE committed 2026-08-20 09:18:54 +02:00
1 parent accdad8965
commit 6782304549
9 files changed
+1990 -93

No files matched your search

+71
View File
@@ -55,6 +55,9 @@ void reset_to_defaults(EmuState *s) {
s->pmic_silicon_rev = 0x5B; // CID3, measured on a real console
s->pmic_es_rev = 0x81; // CID5
s->cpu_pmic_version = 0x1C;
s->pmic_cnfg1_32k = 0xFC; // 32K_OK | 32K_OUT0_EN
s->bt_radio = BT_RADIO_HEALTHY;
s->wifi_radio = WIFI_RADIO_HEALTHY;
s->sd_inserted = true;
s->sd_cid_manfid = 0x03;
s->sd_cid_oemid = 0x5344; // "SD"
@@ -141,6 +144,7 @@ void reset_to_defaults(EmuState *s) {
X(pmic_silicon_rev, "soc", "pmic_silicon_rev",0) \
X(pmic_es_rev, "soc", "pmic_es_rev", 0) \
X(cpu_pmic_version, "soc", "cpu_pmic_version",0) \
X(pmic_cnfg1_32k, "soc", "pmic_cnfg1_32k", 0) \
/* Storage — SD (SDMMC1 CMD2) */ \
X(sd_inserted, "sd", "inserted", 0) \
X(sd_cid_manfid, "sd", "cid_manfid", 0) \
@@ -199,6 +203,19 @@ bool config_window_save_ini_impl(const EmuState *s, const char *path) {
fprintf(f, "backlight=%u\n", (unsigned)s->backlight);
fprintf(f, "rotation_override=%d\n", (int)s->rotation_override);
// Bluetooth radio mode. Deliberately NOT a schema row: the schema parses
// with strtoull, so "faulty" would silently become 0 = healthy and the
// faulty path would be unreachable from the ini with nothing to warn you.
// Must stay above the [fuses] header below, or the next load would find
// it inside the fuse dump.
write_header("bluetooth");
fprintf(f, "radio=%s\n", bt_radio_name(s->bt_radio.load()));
// Same reasoning for the WLAN half: a separate device on PCIe with its
// own failure modes, and the same string-vs-schema trap.
write_header("wifi");
fprintf(f, "radio=%s\n", wifi_radio_name(s->wifi_radio.load()));
// Fuses are dumped wholesale — small enough (256 × 4 bytes) and keeps the
// load path branch-free.
fprintf(f, "\n[fuses]\n");
@@ -269,6 +286,26 @@ bool config_window_load_ini_impl(EmuState *s, const char *path) {
continue;
}
}
if (strcmp(section, "bluetooth") == 0 && strcmp(key, "radio") == 0) {
uint8_t mode = BT_RADIO_HEALTHY;
if (bt_radio_parse(val, &mode)) {
s->bt_radio.store(mode);
} else {
fprintf(stderr, "[config] Unknown [bluetooth] radio value '%s';"
" expected healthy, faulty or absent\n", val);
}
continue;
}
if (strcmp(section, "wifi") == 0 && strcmp(key, "radio") == 0) {
uint8_t mode = WIFI_RADIO_HEALTHY;
if (wifi_radio_parse(val, &mode)) {
s->wifi_radio.store(mode);
} else {
fprintf(stderr, "[config] Unknown [wifi] radio value '%s';"
" expected healthy, faulty or absent\n", val);
}
continue;
}
if (strcmp(section, "fuses") == 0) {
uint32_t off = (uint32_t)strtoul(key, nullptr, 0);
if (off < EmuState::FUSE_WORDS * 4 && (off & 3) == 0) {
@@ -417,6 +454,40 @@ void build_ui(EmuState *state) {
atomic_slider_int<uint8_t>("MAX77620 CID3 (Si rev)", state->pmic_silicon_rev, 0, 255);
atomic_slider_int<uint8_t>("MAX77620 CID5 (ES rev)", state->pmic_es_rev, 0, 255);
atomic_slider_int<uint8_t>("MAX77621 chipid", state->cpu_pmic_version, 0, 255);
// CNFG1_32K is the radio's low-power oscillator config. 0xFC and 0xDC
// are both measured on healthy consoles of both generations; the
// difference is per unit, so it is a value, not a generation switch.
atomic_slider_int<uint8_t>("MAX77620 CNFG1_32K", state->pmic_cnfg1_32k, 0, 255, "0x%02X");
}
if (ImGui::CollapsingHeader("Bluetooth (CYW4356)")) {
// Selected before the probe runs; press 'a' on the payload's pager to
// re-run the sweep after changing it, or Reboot for a clean POR.
const char *bt_items[] = {"Healthy (answers HCI)",
"Faulty (never comes out of POR)",
"Absent (no module fitted)"};
int bt = (int)state->bt_radio.load();
if (ImGui::Combo("Radio", &bt, bt_items, IM_ARRAYSIZE(bt_items))) {
state->bt_radio.store((uint8_t)bt);
}
ImGui::TextDisabled("Faulty reproduces the 2110-1118 console: BT_HOST_WAKE\n"
"low, chip RTS_N never asserts, no HCI on any arm.");
}
if (ImGui::CollapsingHeader("Wi-Fi (CYW4356 WLAN, PCIe)")) {
// The other half of the same package. Independent of the Bluetooth
// setting on purpose: a console can answer HCI perfectly and still
// have a dead WLAN core, which is precisely the case the PCIe probe
// exists to separate.
const char *wifi_items[] = {"Healthy (enumerates, ChipID 4356)",
"Faulty (enumerates, backplane dead)",
"Absent (link never trains)"};
int wifi = (int)state->wifi_radio.load();
if (ImGui::Combo("WLAN core", &wifi, wifi_items, IM_ARRAYSIZE(wifi_items))) {
state->wifi_radio.store((uint8_t)wifi);
}
ImGui::TextDisabled("Faulty is the console that shows 14E4:43EC on the bus\n"
"and still has no Wi-Fi: front-end alive, die is not.");
}
if (ImGui::CollapsingHeader("Charger (BQ24193)", ImGuiTreeNodeFlags_DefaultOpen)) {