]> localhost Git - SCSI2SD-V6.git/commitdiff
Add SD keep-alive to ensure it responds immediately v6.4.11
authorMichael McMaster <michael@codesrc.com>
Mon, 31 May 2021 05:53:30 +0000 (15:53 +1000)
committerMichael McMaster <michael@codesrc.com>
Mon, 31 May 2021 05:53:30 +0000 (15:53 +1000)
CHANGELOG
src/firmware/config.c
src/firmware/main.c
src/firmware/scsi.c
src/firmware/sd.c
src/firmware/sd.h

index f37416a3abfb1df276b41c97a0ecd25ca0e63b34..c0359db8fddf97d75f01037ec0ac64507349206f 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,7 @@
 20210628        6.4.11
     - Remove the "Blind Writes" option from scsi2sd-util. The firmware no longer
     requires this option for improved write performance
+    - Fix firmware hang if there was no activity for a few minutes
 
 20210508        6.4.4
     - More bug fixes for firmware hanging during read/writes
index 17ceab7d9faced3cf3a5dd3bf5873e861f6ea0d0..9a44d371432ac3152a58b96c31f4f5e5cf774d3f 100755 (executable)
@@ -36,7 +36,7 @@
 \r
 #include <string.h>\r
 \r
-static const uint16_t FIRMWARE_VERSION = 0x064A;\r
+static const uint16_t FIRMWARE_VERSION = 0x064B;\r
 \r
 // Optional static config\r
 extern uint8_t* __fixed_config;\r
index 46c9208d6d2f7cbe68a831286162d63d0d781041..f79ebd6eaee9dc1d1a3cf671955d73960ed1df49 100755 (executable)
@@ -42,6 +42,7 @@
 \r
 const char* Notice = "Copyright (C) 2020 Michael McMaster <michael@codesrc.com>";\r
 uint32_t lastSDPoll;\r
+uint32_t lastSDKeepAlive;\r
 \r
 static int isUsbStarted;\r
 \r
@@ -131,7 +132,7 @@ void mainInit()
     s2s_ledOff();\r
 #endif\r
 \r
-    lastSDPoll = s2s_getTime_ms();\r
+    lastSDPoll = lastSDKeepAlive = s2s_getTime_ms();\r
 }\r
 \r
 void mainLoop()\r
@@ -180,11 +181,17 @@ void mainLoop()
                 }\r
             }\r
         }\r
+        else if (lastSDKeepAlive > 10000) // 10 seconds\r
+        {\r
+            // 2021 boards fail if there's no commands sent in a while\r
+            sdKeepAlive();\r
+            lastSDKeepAlive = s2s_getTime_ms();\r
+        }\r
     }\r
     else if (usbBusy || ((scsiDev.phase >= 0) && (blockDev.state & DISK_PRESENT)))\r
     {\r
         // don't waste time scanning SD cards while we're doing disk IO\r
-        lastSDPoll = s2s_getTime_ms();\r
+        lastSDPoll = lastSDKeepAlive = s2s_getTime_ms();\r
     }\r
 }\r
 \r
index 016ecbb523f05d58bbc768c1442c425cf9290354..d4077b9f0a3d600d5b4ac4a1448157c83cf8a78f 100755 (executable)
@@ -56,13 +56,13 @@ void enter_BusFree()
                s2s_delay_us(2);\r
        }\r
 \r
-#if 0\r
-       if (scsiDev.status != GOOD && isDebugEnabled())\r
+//#if 0\r
+       if (scsiDev.status != GOOD)// && isDebugEnabled())\r
        {\r
                // We want to capture debug information for failure cases.\r
-               s2s_delay_ms(64);\r
+               s2s_delay_ms(80);\r
        }\r
-#endif\r
+//#endif\r
 \r
 \r
        scsiEnterBusFree();\r
index 0eff83d373431eb0baf5bfbf693f1187b3de44d8..a3c2c3bdc85b3e0a556f5598308b233e24b9118b 100755 (executable)
@@ -222,3 +222,7 @@ int sdIsBusy()
     return HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_8) == 0;\r
 }\r
 \r
+void sdKeepAlive()\r
+{\r
+    /*HAL_SD_CardStateTypeDef cardState = */HAL_SD_GetCardState(&hsd);\r
+}\r
index 5a1d79a1508f75f293fcbf0291aea01c7bc2ecb0..438c07bb5248d2a7b6f1d23082c599caf41ab67e 100755 (executable)
@@ -37,6 +37,7 @@ int sdInit(void);
 void sdReadDMA(uint32_t lba, uint32_t sectors, uint8_t* outputBuffer);
 int sdReadDMAPoll(uint32_t remainingSectors);
 void sdCompleteTransfer();
+void sdKeepAlive();
 
 int sdIsBusy();