Reset SBC on kernel fault for AOS

This ensures the hardware reset is triggered when the kernel faults
ensuring that the hardware is rebooted rather than causing the hardware
to hang requiring a full power down (which can't currently be performed
remotely)

Signed-off-by: Curtis Millar <curtis@curtism.me>
This commit is contained in:
Ivan-Velickovic
2025-09-08 10:30:52 +10:00
parent 20b7536986
commit 61a6e83f01
2 changed files with 12 additions and 4 deletions

View File

@@ -8,6 +8,8 @@
#include <mode/machine.h>
#include <api/debug.h>
void wdog_reset(void);
/** DONT_TRANSLATE */
void NORETURN NO_INLINE VISIBLE halt(void)
{
@@ -20,6 +22,7 @@ void NORETURN NO_INLINE VISIBLE halt(void)
debug_printKernelEntryReason();
#endif
#endif
wdog_reset();
idle_thread();
UNREACHABLE();
}

View File

@@ -45,6 +45,14 @@ void init_serial(void)
*(UART_REG(UART_MISC)) = 1;
}
void wdog_reset(void)
{
printf("\nResetting Odroid-C2\n");
volatile uint32_t *wdog = (volatile uint32_t *)(WDOG_PPTR);
*wdog = (WDOG_EN | WDOG_SYS_RESET_EN | WDOG_CLK_EN |
WDOG_CLK_DIV_EN | WDOG_SYS_RESET_NOW);
}
void handleUartIRQ(void)
{
/* while there are chars to process */
@@ -60,10 +68,7 @@ void handleUartIRQ(void)
}
if (index == strnlen(reset, 5)) {
/* do the reset */
printf("\nResetting Odroid-C2\n");
volatile uint32_t *wdog = (volatile uint32_t *) (WDOG_PPTR);
*wdog = (WDOG_EN | WDOG_SYS_RESET_EN | WDOG_CLK_EN |
WDOG_CLK_DIV_EN | WDOG_SYS_RESET_NOW);
wdog_reset();
}
}
}