+#if 1
+ char *reset_cause = "UNKNOWN";
+ CYG_WORD16 wrsr;
+ CYG_WORD32 rcsr;
+
+ HAL_READ_UINT32(CRM_RCSR, rcsr);
+ HAL_READ_UINT16(WDOG_WRSR, wrsr);
+ rcsr &= 0x0f;
+ if (rcsr == 0) {
+ reset_cause = "POWER_ON RESET";
+ } else if (rcsr == 1) {
+ reset_cause = "EXTERNAL RESET";
+ } else if (rcsr & (1 << 3)) {
+ reset_cause = "JTAG RESET";
+ } else if (rcsr & (1 << 2)) {
+ reset_cause = "SOFT RESET";
+ } else if (rcsr & (1 << 1)) {
+ if (wrsr & (1 << 0)) {
+ reset_cause = "SOFTWARE RESET";
+ } else if (wrsr & (1 << 1)) {
+ reset_cause = "WATCHDOG TIMEOUT";
+ }
+ } else {
+ diag_printf("Unknown RESET cause: RCSR=0x%08x WRSR=0x%04x\n", rcsr, wrsr);
+ return;
+ }
+ diag_printf("Last RESET cause: %s\n", reset_cause);
+#else