From 1bb615e00f09ea73bba9700e384381fb02833685 Mon Sep 17 00:00:00 2001 From: Baptiste MOINE Date: Sat, 2 May 2026 15:55:18 +0200 Subject: [PATCH] Add --oem flag for Erista / Mariko SoC selection --- README.md | 1 + display/config_window.cpp | 14 ++++++++++++-- emu_state.h | 5 +++++ main.cpp | 15 ++++++++++++++- t210/mmio.cpp | 9 +++++++-- 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 37354c8..d07f6f9 100644 --- a/README.md +++ b/README.md @@ -184,6 +184,7 @@ is in [t210/mmio.cpp](t210/mmio.cpp). Each encoder mirrors a corresponding | `--boot0` | `BOOT0` | eMMC BOOT0 partition file (SDMMC4). | | `--rawnand` | `rawnand.bin` | eMMC GPP partition prefix (auto-detects `.00`, `.01`, …). | | `--prod-keys` | `prod.keys` | Override BIS keys from a Lockpick-style key file. | +| `--oem` | `erista` \| `mariko` | Switch SoC generation. Drives `APB_MISC_GP_HIDREV` so Hekate's `h_cfg.t210b01` matches and pkg1 identification skips the right OEM header. Default `erista`. | | `--auto-pin-recovery` | (none) | Drive the Lockpick PIN-recovery menu without user input. | | `--auto-te-script` | (none) | Drive `recover_pin.te` in TegraExplorer without input. | diff --git a/display/config_window.cpp b/display/config_window.cpp index bb4aa94..9e1e026 100644 --- a/display/config_window.cpp +++ b/display/config_window.cpp @@ -50,6 +50,7 @@ void reset_to_defaults(EmuState *s) { s->usb_pd_voltage_mv = 5000; s->usb_pd_amperage_ma = 1500; s->pmic_otp = 0x35; + s->is_mariko = false; s->pmic_silicon_rev = 0; s->cpu_pmic_version = 0; s->sd_inserted = true; @@ -193,10 +194,19 @@ void build_ui(EmuState *state) { atomic_slider_temp("PCB temp", state->pcb_temp_c10, 0.0f, 80.0f); } - if (ImGui::CollapsingHeader("PMIC (MAX77620 / MAX77621)", ImGuiTreeNodeFlags_DefaultOpen)) { + if (ImGui::CollapsingHeader("SoC / PMIC", ImGuiTreeNodeFlags_DefaultOpen)) { + // SoC generation drives APB_MISC_GP_HIDREV (1=Erista, 2=Mariko). + // Selecting it also flips the PMIC OTP byte to match — they go + // together on real hardware. + const char *gen_items[] = {"Erista (T210)", "Mariko (T210B01)"}; + int gidx = state->is_mariko.load() ? 1 : 0; + if (ImGui::Combo("SoC", &gidx, gen_items, IM_ARRAYSIZE(gen_items))) { + state->is_mariko.store(gidx == 1); + state->pmic_otp.store(gidx == 1 ? 0x53 : 0x35); + } const char *otp_items[] = {"Erista (0x35)", "Mariko (0x53)"}; int idx = (state->pmic_otp.load() == 0x53) ? 1 : 0; - if (ImGui::Combo("OTP", &idx, otp_items, IM_ARRAYSIZE(otp_items))) { + if (ImGui::Combo("PMIC OTP", &idx, otp_items, IM_ARRAYSIZE(otp_items))) { state->pmic_otp.store(idx == 1 ? 0x53 : 0x35); } atomic_slider_int("MAX77620 silicon rev", state->pmic_silicon_rev, 0, 15); diff --git a/emu_state.h b/emu_state.h index a2213a4..75bb1b4 100644 --- a/emu_state.h +++ b/emu_state.h @@ -143,6 +143,11 @@ struct EmuState { // Main PMIC OEM (MAX77620 CID4): 0x35 = Erista, 0x53 = Mariko, other = Unknown std::atomic pmic_otp{0x35}; + + // Tegra X1 generation (drives APB_MISC_GP_HIDREV major nibble: 1 = T210 + // Erista, 2 = T210B01 Mariko). Hekate's h_cfg.t210b01 derives from this, + // which controls the pkg1 OEM-header skip among other things. + std::atomic is_mariko{false}; std::atomic pmic_silicon_rev{0}; // MAX77620 CID3 low nibble: "max77620 v%d" std::atomic cpu_pmic_version{0}; // MAX77621 CHIPID1: "max77621 v%d" diff --git a/main.cpp b/main.cpp index 1e61ea5..fb3ca06 100644 --- a/main.cpp +++ b/main.cpp @@ -268,7 +268,7 @@ static uc_engine *setup_emulation(EmuState *state, uint8_t *payload, size_t payl int main(int argc, char *argv[]) { if (argc < 2) { - fprintf(stderr, "Usage: %s [--sd ] [--boot0 ] [--rawnand ] [--prod-keys ]\n", argv[0]); + fprintf(stderr, "Usage: %s [--sd ] [--boot0 ] [--rawnand ] [--prod-keys ] [--oem erista|mariko]\n", argv[0]); fprintf(stderr, "\nControls:\n"); fprintf(stderr, " Arrow Up/Down = VOL+/VOL- buttons\n"); fprintf(stderr, " Enter = POWER button\n"); @@ -303,6 +303,19 @@ int main(int argc, char *argv[]) { rawnand_prefix = argv[++i]; } else if (strcmp(argv[i], "--prod-keys") == 0 && i + 1 < argc) { prod_keys_path = argv[++i]; + } else if (strcmp(argv[i], "--oem") == 0 && i + 1 < argc) { + const char *oem = argv[++i]; + if (strcmp(oem, "mariko") == 0 || strcmp(oem, "t210b01") == 0) { + state.is_mariko = true; + state.pmic_otp = 0x53; + printf("[emu] OEM: Mariko (T210B01)\n"); + } else if (strcmp(oem, "erista") == 0 || strcmp(oem, "t210") == 0) { + state.is_mariko = false; + state.pmic_otp = 0x35; + printf("[emu] OEM: Erista (T210)\n"); + } else { + fprintf(stderr, "[emu] Unknown --oem value '%s'; expected 'erista' or 'mariko'\n", oem); + } } } diff --git a/t210/mmio.cpp b/t210/mmio.cpp index 133a520..f4d36ad 100644 --- a/t210/mmio.cpp +++ b/t210/mmio.cpp @@ -538,9 +538,14 @@ uint32_t misc_read(EmuState *state, uint64_t addr) { if (addr >= PINMUX_BASE && addr < PINMUX_BASE + PINMUX_SIZE) { return pinmux_reg[(addr - PINMUX_BASE) / 4]; } - // APB_MISC_GP_HIDREV - hardware revision (Erista) + // APB_MISC_GP_HIDREV - hardware revision. + // Bits 11:8 = chip ID (0x21 for both T210 / T210B01), + // Bits 7:4 = major rev (1 = Erista T210, 2 = Mariko T210B01), + // Bits 3:0 = minor. + // Hekate's hw_get_chip_id() does `(HIDREV >> 4) & 0xF` and compares against + // GP_HIDREV_MAJOR_T210B01 (=2) to decide h_cfg.t210b01. if (addr == APB_MISC_BASE + 0x804) - return 0x01; // T210 + return state->is_mariko.load() ? 0x20 : 0x10; // UART if (addr >= 0x70006000 && addr < 0x70006500) {