l4t: Add panic dump (PSTORE)

This commit is contained in:
CTCaer 2020-07-19 20:32:22 +03:00
parent b8ca88ee0a
commit af0cd34f92
4 changed files with 28 additions and 6 deletions

View file

@ -41,8 +41,12 @@
/* --- Gap: 1040MB 0xA4000000 - 0xE4FFFFFF --- */ /* --- Gap: 1040MB 0xA4000000 - 0xE4FFFFFF --- */
// Virtual disk / Chainloader buffers. // Virtual disk / Chainloader buffers.
#define RAM_DISK_ADDR 0xA4000000 #define RAM_DISK_ADDR 0xA4000000
#define RAM_DISK_SZ 0x41000000 // 1040MB. #define RAM_DISK_SZ 0x41000000 // 1040MB.
// L4T Kernel Panic Storage (PSTORE).
#define PSTORE_ADDR 0xB0000000
#define PSTORE_SZ 0x200000 // 2MB.
//#define DRAM_LIB_ADDR 0xE0000000 //#define DRAM_LIB_ADDR 0xE0000000
/* --- Chnldr: 252MB 0xC03C0000 - 0xCFFFFFFF --- */ //! Only used when chainloading. /* --- Chnldr: 252MB 0xC03C0000 - 0xCFFFFFFF --- */ //! Only used when chainloading.

View file

@ -49,6 +49,8 @@
#define PMC_CRYPTO_OP_SE_ENABLE 0 #define PMC_CRYPTO_OP_SE_ENABLE 0
#define PMC_CRYPTO_OP_SE_DISABLE 1 #define PMC_CRYPTO_OP_SE_DISABLE 1
#define APBDEV_PMC_SCRATCH33 0x120 #define APBDEV_PMC_SCRATCH33 0x120
#define APBDEV_PMC_SCRATCH37 0x130
#define PMC_SCRATCH37_KERNEL_PANIC_FLAG (1 << 24)
#define APBDEV_PMC_SCRATCH40 0x13C #define APBDEV_PMC_SCRATCH40 0x13C
#define APBDEV_PMC_OSC_EDPD_OVER 0x1A4 #define APBDEV_PMC_OSC_EDPD_OVER 0x1A4
#define PMC_OSC_EDPD_OVER_OSC_CTRL_OVER 0x400000 #define PMC_OSC_EDPD_OVER_OSC_CTRL_OVER 0x400000

View file

@ -32,7 +32,8 @@ typedef enum
{ {
ERR_LIBSYS_LP0 = (1 << 0), ERR_LIBSYS_LP0 = (1 << 0),
ERR_SYSOLD_NYX = (1 << 1), ERR_SYSOLD_NYX = (1 << 1),
ERR_SYSOLD_MTC = (1 << 2), ERR_LIBSYS_MTC = (1 << 2),
ERR_L4T_KERNEL = (1 << 24),
ERR_EXCEPT_ENB = (1 << 31), ERR_EXCEPT_ENB = (1 << 31),
} hekate_errors_t; } hekate_errors_t;

View file

@ -44,6 +44,7 @@
#include <soc/fuse.h> #include <soc/fuse.h>
#include <soc/hw_init.h> #include <soc/hw_init.h>
#include <soc/i2c.h> #include <soc/i2c.h>
#include <soc/pmc.h>
#include <soc/t210.h> #include <soc/t210.h>
#include <soc/uart.h> #include <soc/uart.h>
#include "storage/emummc.h" #include "storage/emummc.h"
@ -1144,6 +1145,13 @@ static void _show_errors()
if (*excp_enabled == EXCP_MAGIC) if (*excp_enabled == EXCP_MAGIC)
h_cfg.errors |= ERR_EXCEPT_ENB; h_cfg.errors |= ERR_EXCEPT_ENB;
if (PMC(APBDEV_PMC_SCRATCH37) & PMC_SCRATCH37_KERNEL_PANIC_FLAG)
{
// Set error and clear flag.
h_cfg.errors |= ERR_L4T_KERNEL;
PMC(APBDEV_PMC_SCRATCH37) &= ~PMC_SCRATCH37_KERNEL_PANIC_FLAG;
}
if (h_cfg.errors) if (h_cfg.errors)
{ {
gfx_clear_grey(0x1B); gfx_clear_grey(0x1B);
@ -1152,10 +1160,10 @@ static void _show_errors()
if (h_cfg.errors & ERR_LIBSYS_LP0) if (h_cfg.errors & ERR_LIBSYS_LP0)
WPRINTF("Missing LP0 (sleep mode) lib!\n"); WPRINTF("Missing LP0 (sleep mode) lib!\n");
if (h_cfg.errors & ERR_SYSOLD_MTC) if (h_cfg.errors & ERR_LIBSYS_MTC)
WPRINTF("Missing or old Minerva lib!\n"); WPRINTF("Missing or old Minerva lib!\n");
if (h_cfg.errors & ~ERR_EXCEPT_ENB) if (h_cfg.errors & ~(ERR_EXCEPT_ENB | ERR_L4T_KERNEL))
{ {
WPRINTF("\nUpdate bootloader folder!\n\n"); WPRINTF("\nUpdate bootloader folder!\n\n");
} }
@ -1184,6 +1192,13 @@ static void _show_errors()
*excp_enabled = 0; *excp_enabled = 0;
} }
if (h_cfg.errors & ERR_L4T_KERNEL)
{
WPRINTF("Panic occurred while running L4T.\n");
if (!sd_save_to_file((void *)PSTORE_ADDR, PSTORE_SZ, "L4T_panic.bin"))
WPRINTF("PSTORE saved to L4T_panic.bin\n");
}
WPRINTF("Press any key..."); WPRINTF("Press any key...");
msleep(1000); msleep(1000);
@ -1486,7 +1501,7 @@ void ipl_main()
// Train DRAM and switch to max frequency. // Train DRAM and switch to max frequency.
if (minerva_init()) if (minerva_init())
h_cfg.errors |= ERR_SYSOLD_MTC; h_cfg.errors |= ERR_LIBSYS_MTC;
display_init(); display_init();