Ver Fonte

Use the proper SP with watchdog timeouts

With the arduino pico framework, the proper stack pointer is the
MSP. Using that fixes a hard fault. The original RP2040 code uses
still uses the PSP. Selection is done via C macro against __MBED__.
Morio há 1 ano atrás
pai
commit
47032afe5e
1 ficheiros alterados com 12 adições e 5 exclusões
  1. 12 5
      lib/ZuluSCSI_platform_RP2040/ZuluSCSI_platform.cpp

+ 12 - 5
lib/ZuluSCSI_platform_RP2040/ZuluSCSI_platform.cpp

@@ -638,10 +638,14 @@ static void watchdog_callback(unsigned alarm_num)
             logmsg("scsiDev.phase: ", (int)scsiDev.phase);
             scsi_accel_log_state();
 
-            uint32_t *p = (uint32_t*)__get_PSP();
+#ifdef __MBED__
+            uint32_t *p =  (uint32_t*)__get_PSP();
+#else
+            uint32_t *p =  (uint32_t*)__get_MSP();
+#endif
             for (int i = 0; i < 8; i++)
             {
-                if (p == &__StackTop) break; // End of stack
+            if (p == &__StackTop) break; // End of stack
 
                 logmsg("STACK ", (uint32_t)p, ":    ", p[0], " ", p[1], " ", p[2], " ", p[3]);
                 p += 4;
@@ -654,14 +658,18 @@ static void watchdog_callback(unsigned alarm_num)
         if (g_watchdog_timeout <= 0)
         {
             logmsg("--------------");
-            logmsg("WATCHDOG TIMEOUT!");
+            logmsg("WATCHDOG TIMEOUT, already attempted bus reset, rebooting");
             logmsg("Platform: ", g_platform_name);
             logmsg("FW Version: ", g_log_firmwareversion);
             logmsg("GPIO states: out ", sio_hw->gpio_out, " oe ", sio_hw->gpio_oe, " in ", sio_hw->gpio_in);
             logmsg("scsiDev.cdb: ", bytearray(scsiDev.cdb, 12));
             logmsg("scsiDev.phase: ", (int)scsiDev.phase);
 
-            uint32_t *p = (uint32_t*)__get_PSP();
+#ifdef __MBED__
+            uint32_t *p =  (uint32_t*)__get_PSP();
+#else
+            uint32_t *p =  (uint32_t*)__get_MSP();
+#endif
             for (int i = 0; i < 8; i++)
             {
                 if (p == &__StackTop) break; // End of stack
@@ -687,7 +695,6 @@ void platform_reset_watchdog()
 {
     g_watchdog_timeout = WATCHDOG_CRASH_TIMEOUT;
 
-
     if (!g_watchdog_initialized)
     {
         int alarm_num = -1;