Эх сурвалжийг харах

Use init delay of MSC to fix USB serial connection

It was found that a simple delay was needed before configuring the
MSC TinyUSB callbacks. This allows an immediate USB serial CDC
connection and decreases the initial time to start responding to
USB MSC host commands.

Added a `zuluscsi.ini` setting `InitiatorMSCInitDelay` so the
delay can be customized. Not ideal because the standard way to get into
initiator MSC mode is to have no SD card in the slot, meaning no
`zuluscsi.ini` to read the setting from.
J. Morio Sakaguchi 5 сар өмнө
parent
commit
b0564824b3

+ 0 - 1
lib/ZuluSCSI_platform_RP2MCU/ZuluSCSI_platform_msc.cpp

@@ -437,5 +437,4 @@ extern "C" void tud_msc_write10_complete_cb(uint8_t lun)
   MSCScopedLock lock;
   if (g_msc_initiator) return init_msc_write10_complete_cb(lun);
 }
-
 #endif

+ 1 - 1
lib/ZuluSCSI_platform_RP2MCU/ZuluSCSI_platform_msc.h

@@ -24,7 +24,7 @@
 
 // private constants/enums
 #define SD_SECTOR_SIZE 512
-
+#define MSC_INIT_DELAY 300
 /* return true if USB presence detected / eligble to enter CR mode */
 bool platform_sense_msc();
 

+ 7 - 1
src/ZuluSCSI_initiator.cpp

@@ -23,7 +23,6 @@
 /*
  * Main program for initiator mode.
  */
-
 #include "ZuluSCSI_config.h"
 #include "ZuluSCSI_log.h"
 #include "ZuluSCSI_log_trace.h"
@@ -226,6 +225,13 @@ void scsiInitiatorMainLoop()
     {
         if (!g_sdcard_present || ini_getbool("SCSI", "InitiatorMSC", false, CONFIGFILE))
         {
+            // This delay allows the USB serial console to connect immediately to the host
+            // It also decreases the delay in callback processing of MSC commands
+            int32_t msc_init_delay = ini_getl("SCSI", "InitiatorMSCInitDelay", MSC_INIT_DELAY, CONFIGFILE);
+            if (msc_init_delay != MSC_INIT_DELAY)
+                logmsg("Initiator init delay set in ", CONFIGFILE ," to ", (int)msc_init_delay, " milliseconds");
+            delay(msc_init_delay);
+
             logmsg("Entering USB MSC initiator mode");
             platform_enter_msc();
             setup_msc_initiator();

+ 1 - 0
zuluscsi.ini

@@ -49,6 +49,7 @@
 #InitiatorMSCReadOnly = 0 # Prevent writing to the drive through USB MSC
 #InitiatorMSCDisablePrefetch = 0 # Disable read prefetching in USB MSC mode
 #InitiatorMSCStatusInterval = 5000 # Periodically report access status to log
+#InitiatorMSCInitDelay = 300 # In milliseconds, gives time for USB serial to configure itself
 
 #EnableCDAudio = 0 # 1: Enable CD audio - an external I2S DAC on the v1.2 is required
 #MaxVolume = 100 # Set the percentage of the volume from 1 to 100 (default)