Jelajahi Sumber

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 1 tahun lalu
induk
melakukan
fa722d05d5
1 mengubah file dengan 12 tambahan dan 4 penghapusan
  1. 12 4
      lib/BlueSCSI_platform_RP2040/BlueSCSI_platform.cpp

+ 12 - 4
lib/BlueSCSI_platform_RP2040/BlueSCSI_platform.cpp

@@ -567,10 +567,14 @@ static void watchdog_callback(unsigned alarm_num)
             log("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
 
                 log("STACK ", (uint32_t)p, ":    ", p[0], " ", p[1], " ", p[2], " ", p[3]);
                 p += 4;
@@ -583,14 +587,18 @@ static void watchdog_callback(unsigned alarm_num)
         if (g_watchdog_timeout <= 0)
         {
             log("--------------");
-            log("WATCHDOG TIMEOUT!");
+            log("WATCHDOG TIMEOUT, already attempted bus reset, rebooting");
             log("Platform: ", g_platform_name);
             log("FW Version: ", g_log_firmwareversion);
             log("GPIO states: out ", sio_hw->gpio_out, " oe ", sio_hw->gpio_oe, " in ", sio_hw->gpio_in);
             log("scsiDev.cdb: ", bytearray(scsiDev.cdb, 12));
             log("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