Skip to content

Instantly share code, notes, and snippets.

@projectgus
Created August 13, 2026 06:54
Show Gist options
  • Select an option

  • Save projectgus/ab87fc538d1eecf7f068a52da10b35f0 to your computer and use it in GitHub Desktop.

Select an option

Save projectgus/ab87fc538d1eecf7f068a52da10b35f0 to your computer and use it in GitHub Desktop.
ESP-IDF patch to dump ESP8684 PMP register on panic
diff --git i/components/esp_system/panic.c w/components/esp_system/panic.c
index b0912dacbf5..b78bee4134a 100644
--- i/components/esp_system/panic.c
+++ w/components/esp_system/panic.c
@@ -346,6 +346,66 @@ void esp_panic_handler(panic_info_t *info)
panic_print_str("\r\n");
+ // Dump PMP regs, hacky form so compile-time macro expands the immediates
+ uint32_t cfgs[] = {
+ RV_READ_CSR(CSR_PMPCFG0 + 0),
+ RV_READ_CSR(CSR_PMPCFG0 + 1),
+ RV_READ_CSR(CSR_PMPCFG0 + 2),
+ RV_READ_CSR(CSR_PMPCFG0 + 3),
+ //RV_READ_CSR(CSR_PMPCFG0 + 4),
+ //RV_READ_CSR(CSR_PMPCFG0 + 5),
+ //RV_READ_CSR(CSR_PMPCFG0 + 6),
+ //RV_READ_CSR(CSR_PMPCFG0 + 7),
+ };
+ uint32_t addrs[] = {
+ RV_READ_CSR(CSR_PMPADDR0 + 0),
+ RV_READ_CSR(CSR_PMPADDR0 + 1),
+ RV_READ_CSR(CSR_PMPADDR0 + 2),
+ RV_READ_CSR(CSR_PMPADDR0 + 3),
+ RV_READ_CSR(CSR_PMPADDR0 + 4),
+ RV_READ_CSR(CSR_PMPADDR0 + 5),
+ RV_READ_CSR(CSR_PMPADDR0 + 6),
+ RV_READ_CSR(CSR_PMPADDR0 + 7),
+ RV_READ_CSR(CSR_PMPADDR0 + 8),
+ RV_READ_CSR(CSR_PMPADDR0 + 9),
+ RV_READ_CSR(CSR_PMPADDR0 + 10),
+ RV_READ_CSR(CSR_PMPADDR0 + 11),
+ RV_READ_CSR(CSR_PMPADDR0 + 12),
+ RV_READ_CSR(CSR_PMPADDR0 + 13),
+ RV_READ_CSR(CSR_PMPADDR0 + 14),
+ RV_READ_CSR(CSR_PMPADDR0 + 15),
+ //RV_READ_CSR(CSR_PMPADDR0 + 16),
+ //RV_READ_CSR(CSR_PMPADDR0 + 17),
+ //RV_READ_CSR(CSR_PMPADDR0 + 18),
+ //RV_READ_CSR(CSR_PMPADDR0 + 19),
+ //RV_READ_CSR(CSR_PMPADDR0 + 20),
+ //RV_READ_CSR(CSR_PMPADDR0 + 21),
+ //RV_READ_CSR(CSR_PMPADDR0 + 22),
+ //RV_READ_CSR(CSR_PMPADDR0 + 23),
+ //RV_READ_CSR(CSR_PMPADDR0 + 24),
+ //RV_READ_CSR(CSR_PMPADDR0 + 25),
+ //RV_READ_CSR(CSR_PMPADDR0 + 26),
+ //RV_READ_CSR(CSR_PMPADDR0 + 27),
+ //RV_READ_CSR(CSR_PMPADDR0 + 28),
+ //RV_READ_CSR(CSR_PMPADDR0 + 29),
+ //RV_READ_CSR(CSR_PMPADDR0 + 30),
+ //RV_READ_CSR(CSR_PMPADDR0 + 31),
+ };
+ for (int i = 0; i < sizeof(cfgs)/sizeof(uint32_t); i++) {
+ panic_print_str("PMPCFG");
+ panic_print_dec(i);
+ panic_print_str(": ");
+ panic_print_hex(cfgs[i]);
+ panic_print_str("\r\n");
+ }
+ for (int i = 0; i < sizeof(addrs)/sizeof(uint32_t); i++) {
+ panic_print_str("PMPADDR");
+ panic_print_dec(i);
+ panic_print_str(": ");
+ panic_print_hex(addrs[i]);
+ panic_print_str("\r\n");
+ }
+
// If on-chip-debugger is attached, and system is configured to be aware of this,
// then only print up to details. Users should be able to probe for the other information
// in debug mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment