From: Michael McMaster Date: Sun, 30 Apr 2017 12:12:38 +0000 (+1000) Subject: Add turbo sync mode X-Git-Tag: v6.1.1~1 X-Git-Url: http://git.codesrc.com/gitweb.cgi?a=commitdiff_plain;h=ee820792749ec3e5fc8d29a6f713f9638ef27efd;p=SCSI2SD-V6.git Add turbo sync mode --- diff --git a/CHANGELOG b/CHANGELOG index 1a82b9d2..92cf01db 100644 --- 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 diff --git a/STM32CubeMX/SCSI2SD-V6/Src/fsmc.c b/STM32CubeMX/SCSI2SD-V6/Src/fsmc.c index 8386762a..8a7bf907 100755 --- a/STM32CubeMX/SCSI2SD-V6/Src/fsmc.c +++ b/STM32CubeMX/SCSI2SD-V6/Src/fsmc.c @@ -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); diff --git a/rtl/fpga_bitmap.o b/rtl/fpga_bitmap.o index c7f26cf1..c535bdbd 100644 Binary files a/rtl/fpga_bitmap.o and b/rtl/fpga_bitmap.o differ diff --git a/src/firmware/config.c b/src/firmware/config.c index e5451ec1..eaa31b00 100755 --- a/src/firmware/config.c +++ b/src/firmware/config.c @@ -193,7 +193,8 @@ scsiDevInfoCommand() sdDev.capacity >> 24, sdDev.capacity >> 16, sdDev.capacity >> 8, - sdDev.capacity + sdDev.capacity, + 1 // useSdConfig, always true for V6. }; hidPacket_send(response, sizeof(response)); } diff --git a/src/firmware/main.c b/src/firmware/main.c index 2bb7d78f..fcada36b 100755 --- a/src/firmware/main.c +++ b/src/firmware/main.c @@ -117,11 +117,11 @@ void mainLoop() // run if the SD card is present at startup. // Don't use VBUS monitoring because that just tells us about // power, which could be from a charger -#if 0 if ((blockDev.state & DISK_PRESENT) && isUsbStarted && (scsiDev.cmdCount > 0) && // no need for speed without scsi - !USBD_Composite_IsConfigured(&hUsbDeviceFS)) + !USBD_Composite_IsConfigured(&hUsbDeviceFS) && + (scsiDev.boardCfg.scsiSpeed == S2S_CFG_SPEED_TURBO)) { if (HAL_SD_HighSpeed(&hsd) == SD_OK) { @@ -130,7 +130,6 @@ void mainLoop() isUsbStarted = 0; } } -#endif else if (!(blockDev.state & DISK_PRESENT) && !isUsbStarted) { diff --git a/src/firmware/scsi.c b/src/firmware/scsi.c index 854707d5..19fb4764 100755 --- a/src/firmware/scsi.c +++ b/src/firmware/scsi.c @@ -807,14 +807,17 @@ static void process_MessageOut() // FAST20 / 50ns / 20MHz is disabled for now due to // data corruption while reading data. We can count the // ACK's correctly, but can't save the data to a register - // before it changes. - // TODO work out the fastest sync period that will work - /* - if (transferPeriod <= 12) + // before it changes. (ie. transferPeriod == 12) + if ((scsiDev.boardCfg.scsiSpeed == S2S_CFG_SPEED_TURBO) && + (transferPeriod <= 16)) { - scsiDev.target->syncPeriod = 12; // 50ns, 20MB/s + scsiDev.target->syncPeriod = 16; // 15.6MB/s } - else */if (transferPeriod <= 25 && + else if (scsiDev.boardCfg.scsiSpeed == S2S_CFG_SPEED_TURBO) + { + scsiDev.target->syncPeriod = transferPeriod; + } + else if (transferPeriod <= 25 && ((scsiDev.boardCfg.scsiSpeed == S2S_CFG_SPEED_NoLimit) || (scsiDev.boardCfg.scsiSpeed >= S2S_CFG_SPEED_SYNC_10))) { diff --git a/src/firmware/scsiPhy.c b/src/firmware/scsiPhy.c index 488c33c6..58d56f66 100755 --- a/src/firmware/scsiPhy.c +++ b/src/firmware/scsiPhy.c @@ -60,6 +60,12 @@ static uint8_t asyncTimings[][4] = #define SCSI_FAST10_HOLD 3 // 33ns #define SCSI_FAST10_ASSERT 3 // 30ns +// Fastest possible timing, probably not 20MB/s +#define SCSI_FAST20_DESKEW 1 +#define SCSI_FAST20_HOLD 2 +#define SCSI_FAST20_ASSERT 2 + + #define syncDeskew(period) ((period) < 45 ? \ SCSI_FAST10_DESKEW : SCSI_FAST5_DESKEW) @@ -493,8 +499,11 @@ void scsiEnterPhase(int phase) if ((newPhase == DATA_IN || newPhase == DATA_OUT) && scsiDev.target->syncOffset) { - - if (scsiDev.target->syncPeriod <= 25) + if (scsiDev.target->syncPeriod < 23) + { + scsiSetTiming(SCSI_FAST20_ASSERT, SCSI_FAST20_DESKEW, SCSI_FAST20_HOLD, 1); + } + else if (scsiDev.target->syncPeriod <= 25) { scsiSetTiming(SCSI_FAST10_ASSERT, SCSI_FAST10_DESKEW, SCSI_FAST10_HOLD, 1); } @@ -539,7 +548,7 @@ void scsiEnterPhase(int phase) } else if (scsiDev.boardCfg.scsiSpeed >= S2S_CFG_SPEED_ASYNC_33) { asyncTiming = asyncTimings[SCSI_ASYNC_33]; - + } else { asyncTiming = asyncTimings[SCSI_ASYNC_15]; }