mirror of
https://github.com/Creased/RCM-Emulator.git
synced 2026-12-06 02:48:11 +01:00
Populate fuse defaults and unblock Dump fuses
This commit is contained in:
1 parent
d0f0f67247
commit
8559909f2d
4 files changed
+130
-31
No files matched your search
+45
-12
@@ -69,12 +69,7 @@ void reset_to_defaults(EmuState *s) {
|
||||
s->emmc_cid_serial = 0x12345678;
|
||||
s->emmc_cid_month = 6;
|
||||
s->emmc_cid_year = 2017;
|
||||
s->fuse_0x100 = 1;
|
||||
s->fuse_0x110 = 0x83;
|
||||
s->fuse_0x1A0 = 0x06;
|
||||
s->fuse_0x148 = 0x83000001;
|
||||
s->fuse_0x118 = 1785;
|
||||
s->fuse_0x1D8 = 0x20; // DRAM ID 4 (Samsung K4UBE3D4AA)
|
||||
s->init_fuse_defaults(); // resets all 256 fuse words
|
||||
s->dram_vendor = 1; // Samsung
|
||||
s->dram_rev_id1 = 2;
|
||||
s->dram_rev_id2 = 0;
|
||||
@@ -389,6 +384,8 @@ void build_ui(EmuState *state) {
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Display panel (DSI)")) {
|
||||
// Panel ID raw bytes are read by Hekate via MIPI_DCS_GET_DISPLAY_ID.
|
||||
// The decoded ID is ((raw >> 8) & 0xFF00) | (raw & 0xFF).
|
||||
// Decoded ID is `((raw >> 8) & 0xFF00) | (raw & 0xFF)`, which means
|
||||
// the high byte of the decoded ID lives in raw[23:16] (MSB of raw)
|
||||
// and the low byte lives in raw[7:0]. raw[15:8] is the rev byte that
|
||||
@@ -485,12 +482,48 @@ void build_ui(EmuState *state) {
|
||||
}
|
||||
|
||||
if (ImGui::CollapsingHeader("Fuses (advanced)")) {
|
||||
atomic_hex_input("FUSE 0x100", state->fuse_0x100);
|
||||
atomic_hex_input("FUSE 0x110 (SKU)", state->fuse_0x110);
|
||||
atomic_hex_input("FUSE 0x118 (ID)", state->fuse_0x118);
|
||||
atomic_hex_input("FUSE 0x148", state->fuse_0x148);
|
||||
atomic_hex_input("FUSE 0x1A0", state->fuse_0x1A0);
|
||||
atomic_hex_input("FUSE 0x1D8 (ODM4)", state->fuse_0x1D8);
|
||||
// Each row corresponds to a FUSE_BASE offset in Hekate's
|
||||
// bdk/soc/fuse.h. Defaults match a typical Erista golden sample.
|
||||
atomic_hex_input("0x100 PRODUCTION_MODE", state->fuse_at(0x100));
|
||||
atomic_hex_input("0x110 SKU_INFO", state->fuse_at(0x110));
|
||||
atomic_hex_input("0x114 CPU_SPEEDO_0", state->fuse_at(0x114));
|
||||
atomic_hex_input("0x118 CPU_IDDQ", state->fuse_at(0x118));
|
||||
atomic_hex_input("0x128 OPT_FT_REV", state->fuse_at(0x128));
|
||||
atomic_hex_input("0x12C CPU_SPEEDO_1", state->fuse_at(0x12C));
|
||||
atomic_hex_input("0x130 CPU_SPEEDO_2", state->fuse_at(0x130));
|
||||
atomic_hex_input("0x134 SOC_SPEEDO_0", state->fuse_at(0x134));
|
||||
atomic_hex_input("0x138 SOC_SPEEDO_1 (BROM rev)", state->fuse_at(0x138));
|
||||
atomic_hex_input("0x13C SOC_SPEEDO_2", state->fuse_at(0x13C));
|
||||
atomic_hex_input("0x140 SOC_IDDQ", state->fuse_at(0x140));
|
||||
atomic_hex_input("0x148 FA", state->fuse_at(0x148));
|
||||
atomic_hex_input("0x190 OPT_CP_REV", state->fuse_at(0x190));
|
||||
atomic_hex_input("0x1A0 SECURITY_MODE", state->fuse_at(0x1A0));
|
||||
atomic_hex_input("0x1C0 RESERVED_SW", state->fuse_at(0x1C0));
|
||||
atomic_hex_input("0x1D8 RESERVED_ODM4", state->fuse_at(0x1D8));
|
||||
atomic_hex_input("0x200 OPT_VENDOR_CODE", state->fuse_at(0x200));
|
||||
atomic_hex_input("0x204 OPT_FAB_CODE", state->fuse_at(0x204));
|
||||
atomic_hex_input("0x208 OPT_LOT_CODE_0", state->fuse_at(0x208));
|
||||
atomic_hex_input("0x210 OPT_WAFER_ID", state->fuse_at(0x210));
|
||||
atomic_hex_input("0x214 OPT_X_COORDINATE", state->fuse_at(0x214));
|
||||
atomic_hex_input("0x218 OPT_Y_COORDINATE", state->fuse_at(0x218));
|
||||
atomic_hex_input("0x228 GPU_IDDQ", state->fuse_at(0x228));
|
||||
ImGui::Separator();
|
||||
ImGui::TextDisabled("Public key (8 words, byte-swapped on display)");
|
||||
atomic_hex_input("0x164 PK0", state->fuse_at(0x164));
|
||||
atomic_hex_input("0x168 PK1", state->fuse_at(0x168));
|
||||
atomic_hex_input("0x16C PK2", state->fuse_at(0x16C));
|
||||
atomic_hex_input("0x170 PK3", state->fuse_at(0x170));
|
||||
atomic_hex_input("0x174 PK4", state->fuse_at(0x174));
|
||||
atomic_hex_input("0x178 PK5", state->fuse_at(0x178));
|
||||
atomic_hex_input("0x17C PK6", state->fuse_at(0x17C));
|
||||
atomic_hex_input("0x180 PK7", state->fuse_at(0x180));
|
||||
ImGui::Separator();
|
||||
ImGui::TextDisabled("SBK (4 words) + DK (1 word). --prod-keys overrides at runtime.");
|
||||
atomic_hex_input("0x1A4 SBK0", state->fuse_at(0x1A4));
|
||||
atomic_hex_input("0x1A8 SBK1", state->fuse_at(0x1A8));
|
||||
atomic_hex_input("0x1AC SBK2", state->fuse_at(0x1AC));
|
||||
atomic_hex_input("0x1B0 SBK3", state->fuse_at(0x1B0));
|
||||
atomic_hex_input("0x1B4 DK", state->fuse_at(0x1B4));
|
||||
ImGui::TextDisabled("DRAM ID = (ODM4 >> 3) & 0x1F (T210B01 also OR's bits 14:12 << 5)");
|
||||
}
|
||||
|
||||
|
||||
+63
-8
@@ -1,8 +1,9 @@
|
||||
#ifndef EMU_STATE_H
|
||||
#define EMU_STATE_H
|
||||
|
||||
#include <cstdint>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
@@ -203,13 +204,67 @@ struct EmuState {
|
||||
std::atomic<uint16_t> usb_pd_voltage_mv{5000};
|
||||
std::atomic<uint16_t> usb_pd_amperage_ma{1500};
|
||||
|
||||
// Fuse driver (FUSE @ 0x7000F800). Names per Hekate's bdk/soc/fuse.h.
|
||||
std::atomic<uint32_t> fuse_0x100{1}; // FUSE_PRODUCTION_MODE (1 = production unit)
|
||||
std::atomic<uint32_t> fuse_0x110{0x83}; // FUSE_SKU_INFO (0x83 = SKU_ODIN, required by Minerva)
|
||||
std::atomic<uint32_t> fuse_0x118{1785}; // FUSE_CPU_IDDQ_CALIB
|
||||
std::atomic<uint32_t> fuse_0x148{0x83000001}; // FUSE_OPT_FT_REV / mixed
|
||||
std::atomic<uint32_t> fuse_0x1A0{0x06}; // FUSE_OPT_VENDOR_CODE
|
||||
std::atomic<uint32_t> fuse_0x1D8{0x20}; // FUSE_RESERVED_ODM4 (bits 7:3 = dram_id, 0x20 = id 4)
|
||||
// Fuse driver (FUSE @ 0x7000F800). One u32 per offset, indexed by
|
||||
// offset/4. The HW & Fuses Info screen reads several dozen offsets
|
||||
// (speedos, IDDQ, SBK, public key, lot/wafer, etc.); seeding plausible
|
||||
// defaults here keeps the screen rendering meaningful values without a
|
||||
// dedicated atomic per field. Defaults populated by init_fuse_defaults().
|
||||
static constexpr size_t FUSE_WORDS = 0x100;
|
||||
std::array<std::atomic<uint32_t>, FUSE_WORDS> fuse_word{};
|
||||
std::atomic<uint32_t>& fuse_at(uint32_t offset) { return fuse_word[(offset & 0x3FC) / 4]; }
|
||||
|
||||
void init_fuse_defaults() {
|
||||
// Names below mirror Hekate's bdk/soc/fuse.h. Values picked from a
|
||||
// typical Erista golden-sample dump (any retail Switch is similar).
|
||||
fuse_at(0x100).store(1); // FUSE_PRODUCTION_MODE
|
||||
fuse_at(0x110).store(0x83); // FUSE_SKU_INFO (SKU_ODIN)
|
||||
fuse_at(0x114).store(2289); // FUSE_CPU_SPEEDO_0_CALIB
|
||||
fuse_at(0x118).store(1786); // FUSE_CPU_IDDQ_CALIB (x4 -> 7144)
|
||||
fuse_at(0x128).store(0x82); // FUSE_OPT_FT_REV (4.02)
|
||||
fuse_at(0x12C).store(2330); // FUSE_CPU_SPEEDO_1_CALIB
|
||||
fuse_at(0x130).store(2342); // FUSE_CPU_SPEEDO_2_CALIB
|
||||
fuse_at(0x134).store(1801); // FUSE_SOC_SPEEDO_0_CALIB
|
||||
fuse_at(0x138).store(0x80); // FUSE_SOC_SPEEDO_1_CALIB (BROM rev)
|
||||
fuse_at(0x13C).store(1817); // FUSE_SOC_SPEEDO_2_CALIB
|
||||
fuse_at(0x140).store(1500); // FUSE_SOC_IDDQ_CALIB (x4 -> 6000)
|
||||
fuse_at(0x148).store(0x83000001); // FUSE_FA
|
||||
// Public key (8 words). Hekate prints them byte-swapped, so storage
|
||||
// is the byte-reverse of the desired displayed hex string. Two rows
|
||||
// of "5F1B7A4D8E2C6F09B3A815C7D4E0F26B" / "A91F4C8B7D2E0653F1A8B4C7E0D962F4".
|
||||
fuse_at(0x164).store(0x4D7A1B5F);
|
||||
fuse_at(0x168).store(0x096F2C8E);
|
||||
fuse_at(0x16C).store(0xC715A8B3);
|
||||
fuse_at(0x170).store(0x6BF2E0D4);
|
||||
fuse_at(0x174).store(0x8B4C1FA9);
|
||||
fuse_at(0x178).store(0x53062E7D);
|
||||
fuse_at(0x17C).store(0xC7B4A8F1);
|
||||
fuse_at(0x180).store(0xF462D9E0);
|
||||
fuse_at(0x190).store(0x100); // FUSE_OPT_CP_REV (8.00)
|
||||
fuse_at(0x1A0).store(0x06); // FUSE_SECURITY_MODE
|
||||
// SBK + DK placeholders. Same byte-swap convention as the public key.
|
||||
// SBK displays as "C8E5719FA34D6B208E14F7B965A028D3", DK as "47A1F39E".
|
||||
// --prod-keys overrides these via the SE keytable at runtime.
|
||||
fuse_at(0x1A4).store(0x9F71E5C8);
|
||||
fuse_at(0x1A8).store(0x206B4DA3);
|
||||
fuse_at(0x1AC).store(0xB9F7148E);
|
||||
fuse_at(0x1B0).store(0xD328A065);
|
||||
fuse_at(0x1B4).store(0x9EF3A147);
|
||||
// RESERVED_SW bit 7 selects USB controller string in Hekate. Off = "USB2".
|
||||
fuse_at(0x1C0).store(0x00);
|
||||
fuse_at(0x1D8).store(0x20); // FUSE_RESERVED_ODM4 (DRAM ID 4)
|
||||
fuse_at(0x200).store(0x06); // FUSE_OPT_VENDOR_CODE
|
||||
fuse_at(0x204).store(0x12); // FUSE_OPT_FAB_CODE ('I' = base36[18])
|
||||
// LOT_CODE_0 holds five base36 chars in 6-bit fields at bits 29:24,
|
||||
// 23:18, 17:12, 11:6, 5:0. Each digit must stay <= 35 or Hekate
|
||||
// indexes past the base36[] table and prints garbage. Encoded "K1SHQ".
|
||||
fuse_at(0x208).store(0x1405C45A);
|
||||
fuse_at(0x210).store(1); // FUSE_OPT_WAFER_ID
|
||||
// Wafer X/Y must land inside the Erista lithography map
|
||||
// (X in [-9, 15], Y in [0, 24]) or _hw_info_wafer marks "Error".
|
||||
fuse_at(0x214).store(5); // FUSE_OPT_X_COORDINATE
|
||||
fuse_at(0x218).store(12); // FUSE_OPT_Y_COORDINATE
|
||||
fuse_at(0x228).store(1500); // FUSE_GPU_IDDQ_CALIB (x5 -> 7500)
|
||||
}
|
||||
|
||||
// DRAM mode register responses. Hekate reads these via the EMC controller
|
||||
// (sdram_read_mrx) to populate the "Vendor / Rev / Density" columns on
|
||||
|
||||
@@ -282,6 +282,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
// Initialize emulator state
|
||||
EmuState state = {};
|
||||
state.init_fuse_defaults();
|
||||
|
||||
// Load payload binary
|
||||
size_t payload_size = 0;
|
||||
|
||||
+21
-11
@@ -1280,25 +1280,35 @@ void clk_rst_write(EmuState *state, uint64_t addr, uint32_t val) {
|
||||
|
||||
// ==================== Fuse ====================
|
||||
|
||||
// Latched value from the last FUSE_ADDR write. Hekate's fuse_read(addr) walks
|
||||
// the raw fuse macroarray via FUSE_ADDR + FUSE_CTRL=READ + FUSE_RDATA, used by
|
||||
// the "Dump fuses" Nyx button to write fuse_array_raw_*.bin to SD.
|
||||
static uint32_t g_fuse_ctrl_addr = 0;
|
||||
|
||||
uint32_t fuse_read(EmuState *state, uint64_t addr) {
|
||||
uint32_t offset = (uint32_t)(addr - FUSE_BASE);
|
||||
switch (offset) {
|
||||
case 0x100: return state->fuse_0x100.load();
|
||||
case 0x110: return state->fuse_0x110.load();
|
||||
case 0x1A0: return state->fuse_0x1A0.load();
|
||||
case 0x148: return state->fuse_0x148.load();
|
||||
case 0x118: return state->fuse_0x118.load();
|
||||
// FUSE_RESERVED_ODM4 - bits 7:3 carry the DRAM ID on T210, with bits 14:12
|
||||
// appended on T210B01 to extend the range past 7.
|
||||
case 0x1D8: return state->fuse_0x1D8.load();
|
||||
default: return 0;
|
||||
case 0x00:
|
||||
// FUSE_CTRL: bits 20:16 = status (4 = IDLE), bit 30 = sense data ready.
|
||||
// Returning IDLE unconditionally lets fuse_wait_idle() exit; otherwise
|
||||
// Dump Fuses spins forever after issuing a READ command.
|
||||
return (1u << 30) | (4u << 16);
|
||||
case 0x08:
|
||||
// FUSE_RDATA: would return the raw macroarray word at FUSE_ADDR. We
|
||||
// don't model the raw array (only the cached fuse register file at
|
||||
// offset 0x100+), so return zeros here. The dump file ends up zero-
|
||||
// filled but the operation completes successfully.
|
||||
(void)g_fuse_ctrl_addr;
|
||||
return 0;
|
||||
}
|
||||
if (offset >= EmuState::FUSE_WORDS * 4) return 0;
|
||||
return state->fuse_at(offset).load();
|
||||
}
|
||||
|
||||
void fuse_write(EmuState *state, uint64_t addr, uint32_t val) {
|
||||
(void)state;
|
||||
(void)addr;
|
||||
(void)val;
|
||||
uint32_t offset = (uint32_t)(addr - FUSE_BASE);
|
||||
if (offset == 0x04) g_fuse_ctrl_addr = val; // FUSE_ADDR
|
||||
}
|
||||
|
||||
// ==================== EMC (DRAM mode register reads) ====================
|
||||
|
||||
Reference in new issue
Block a user