]> localhost Git - SCSI2SD-V6.git/commitdiff
Add turbo sync mode
authorMichael McMaster <michael@codesrc.com>
Sun, 30 Apr 2017 12:12:38 +0000 (22:12 +1000)
committerMichael McMaster <michael@codesrc.com>
Sun, 30 Apr 2017 12:12:38 +0000 (22:12 +1000)
CHANGELOG
STM32CubeMX/SCSI2SD-V6/Src/fsmc.c
rtl/fpga_bitmap.o
src/firmware/config.c
src/firmware/main.c
src/firmware/scsi.c
src/firmware/scsiPhy.c

index 1a82b9d2cea782ff66f72fddb46a10b9e2ed97ca..92cf01db7feba301c87eb317e5d400d1cd6e3892 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,13 @@
-20170429               6.1.1
-       - Add new "turbo" speed mode to get faster async transfers.
+201705XX               6.1.1
+       - Add new "turbo" speed option to boost speeds.
+               - May not be reliable, and use is not supported.
+               - Async timings trimmed
+               - Sync speeds boosted to theoretical 15.625MB/s, with 12.0MB/s measured
+               read througput.
+               - SD card put in "high speed" mode.
+               - USB for configuration/firmware updates is disabled in turbo mode when
+               processing SCSI commands. A power cycle may be required to connect
+               via USB to reset the 48MHz clock back to 48MHz.
        - Fix scsi2sd-util6 size and sector-size inputs
        - Fix crash when configured scsi disk starting sector is less than
        SD card size
index 8386762a8d25bc2c17a2250e59daa85998854175..8a7bf907b09ba696ba8642b872de2a6037a8da02 100755 (executable)
@@ -67,12 +67,12 @@ void MX_FSMC_Init(void)
   hsram1.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE;
   /* Timing */
 
-  // 1 clock to read the address, + 3 for the synchroniser
-  Timing.AddressSetupTime = 4;
+  // 1 clock to read the address, + 1 for synchroniser skew
+  Timing.AddressSetupTime = 2;
   Timing.AddressHoldTime = 1;
 
-  // 3 for synchroniser, 1 to skip hold time, 1 to process read, 1 to output
-  Timing.DataSetupTime = 6;
+  // 1 for synchroniser skew, 1 to skip hold time, 1 to process read, 1 to output
+  Timing.DataSetupTime = 5;//4 doesn't work ? ?? ?
 
   // Allow a clock for us to release signals, plus 3 for the synchroniser to
   // realise the cycle has ended. Need to avoid both devices acting as outputs
@@ -126,11 +126,14 @@ static void HAL_FSMC_MspInit(void){
   PE0   ------> FSMC_NBL0
   PE1   ------> FSMC_NBL1
   */
+  // MM: GPIO_SPEED_FREQ_MEDIUM is rated up to 50MHz, which is fine as all the
+  // fsmc timings are > 1 (ie. so clock speed / 2 is around 50MHz).
+
   /* GPIO_InitStruct */
   GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
   GPIO_InitStruct.Pull = GPIO_NOPULL;
-  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
+  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; //HIGH;
   GPIO_InitStruct.Alternate = GPIO_AF12_FSMC;
 
   HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
@@ -140,7 +143,7 @@ static void HAL_FSMC_MspInit(void){
                           |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10;
   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
   GPIO_InitStruct.Pull = GPIO_NOPULL;
-  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
+  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM; //HIGH;
   GPIO_InitStruct.Alternate = GPIO_AF12_FSMC;
 
   HAL_GPIO_Init(GPIOD, &GPIO_InitStruct);
@@ -149,7 +152,7 @@ static void HAL_FSMC_MspInit(void){
   GPIO_InitStruct.Pin = GPIO_PIN_7;
   GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
   GPIO_InitStruct.Pull = GPIO_NOPULL;
-  GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
+  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;//HIGH;
   GPIO_InitStruct.Alternate = GPIO_AF12_FSMC;
 
   HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
index c7f26cf18d87115c81f093ca4db32b9547ff81bf..c535bdbd2776567e28eb6c23d61000ac3b2ae2f6 100644 (file)
Binary files a/rtl/fpga_bitmap.o and b/rtl/fpga_bitmap.o differ
index e5451ec1085f93f9bba3e7d3858bc7d7c3479501..eaa31b000e10629cbf92e85877d9a23f4ad3fe77 100755 (executable)
@@ -193,7 +193,8 @@ scsiDevInfoCommand()
                sdDev.capacity >> 24,\r
                sdDev.capacity >> 16,\r
                sdDev.capacity >> 8,\r
-               sdDev.capacity\r
+               sdDev.capacity,\r
+               1 // useSdConfig, always true for V6.\r
        };\r
        hidPacket_send(response, sizeof(response));\r
 }\r
index 2bb7d78f40abdaa6c1ace4d14d1e8af4ee79a21b..fcada36bd2206acc30756dc03f21b5c047d04d26 100755 (executable)
@@ -117,11 +117,11 @@ void mainLoop()
                        // run if the SD card is present at startup.\r
                        // Don't use VBUS monitoring because that just tells us about\r
                        // power, which could be from a charger\r
-#if 0\r
                        if ((blockDev.state & DISK_PRESENT) &&\r
                                isUsbStarted &&\r
                                (scsiDev.cmdCount > 0) && // no need for speed without scsi\r
-                               !USBD_Composite_IsConfigured(&hUsbDeviceFS))\r
+                               !USBD_Composite_IsConfigured(&hUsbDeviceFS) &&\r
+                               (scsiDev.boardCfg.scsiSpeed == S2S_CFG_SPEED_TURBO))\r
                        {\r
                                if (HAL_SD_HighSpeed(&hsd) == SD_OK)\r
                                {\r
@@ -130,7 +130,6 @@ void mainLoop()
                                        isUsbStarted = 0;\r
                                }\r
                        }\r
-#endif\r
 \r
                        else if (!(blockDev.state & DISK_PRESENT) && !isUsbStarted)\r
                        {\r
index 854707d5ce9b92d6f0d88f403aebcff7d6327f28..19fb4764c82870203dad339dc37e525d876058af 100755 (executable)
@@ -807,14 +807,17 @@ static void process_MessageOut()
                                // FAST20 / 50ns / 20MHz is disabled for now due to\r
                                // data corruption while reading data. We can count the\r
                                // ACK's correctly, but can't save the data to a register\r
-                               // before it changes.\r
-                               // TODO work out the fastest sync period that will work\r
-                               /*\r
-                               if (transferPeriod <= 12)\r
+                               // before it changes. (ie. transferPeriod == 12)\r
+                               if ((scsiDev.boardCfg.scsiSpeed == S2S_CFG_SPEED_TURBO) &&\r
+                                       (transferPeriod <= 16))\r
                                {\r
-                                       scsiDev.target->syncPeriod = 12; // 50ns, 20MB/s\r
+                                       scsiDev.target->syncPeriod = 16; // 15.6MB/s\r
                                }\r
-                               else */if (transferPeriod <= 25 &&\r
+                               else if (scsiDev.boardCfg.scsiSpeed == S2S_CFG_SPEED_TURBO)\r
+                               {\r
+                                       scsiDev.target->syncPeriod = transferPeriod;\r
+                               }\r
+                               else if (transferPeriod <= 25 &&\r
                                        ((scsiDev.boardCfg.scsiSpeed == S2S_CFG_SPEED_NoLimit) ||\r
                                                (scsiDev.boardCfg.scsiSpeed >= S2S_CFG_SPEED_SYNC_10)))\r
                                {\r
index 488c33c60d6c6cb598356c49f9b2861b5f2ebf5c..58d56f66a69b030a7deedfa1ccfd4a6e49add03c 100755 (executable)
@@ -60,6 +60,12 @@ static uint8_t asyncTimings[][4] =
 #define SCSI_FAST10_HOLD 3 // 33ns\r
 #define SCSI_FAST10_ASSERT 3 // 30ns\r
 \r
+// Fastest possible timing, probably not 20MB/s\r
+#define SCSI_FAST20_DESKEW 1\r
+#define SCSI_FAST20_HOLD 2\r
+#define SCSI_FAST20_ASSERT 2\r
+\r
+\r
 #define syncDeskew(period) ((period) < 45 ? \\r
        SCSI_FAST10_DESKEW : SCSI_FAST5_DESKEW)\r
 \r
@@ -493,8 +499,11 @@ void scsiEnterPhase(int phase)
                if ((newPhase == DATA_IN || newPhase == DATA_OUT) &&\r
                        scsiDev.target->syncOffset)\r
                {\r
-                       \r
-                       if (scsiDev.target->syncPeriod <= 25)\r
+                       if (scsiDev.target->syncPeriod < 23)\r
+                       {\r
+                               scsiSetTiming(SCSI_FAST20_ASSERT, SCSI_FAST20_DESKEW, SCSI_FAST20_HOLD, 1);\r
+                       }\r
+                       else if (scsiDev.target->syncPeriod <= 25)\r
                        {\r
                                scsiSetTiming(SCSI_FAST10_ASSERT, SCSI_FAST10_DESKEW, SCSI_FAST10_HOLD, 1);\r
                        }\r
@@ -539,7 +548,7 @@ void scsiEnterPhase(int phase)
                        } else if (scsiDev.boardCfg.scsiSpeed >= S2S_CFG_SPEED_ASYNC_33) {\r
 \r
                                asyncTiming = asyncTimings[SCSI_ASYNC_33];\r
-       \r
+\r
                        } else {\r
                                asyncTiming = asyncTimings[SCSI_ASYNC_15];\r
                        }\r