Ver código fonte

Booting from SD, and comms with CYW43 working

androda 2 anos atrás
pai
commit
85f46990c1

+ 0 - 3
lib/BlueSCSI_platform_RP2040/scsi_accel_host.cpp

@@ -128,9 +128,6 @@ void scsi_accel_host_init()
     g_scsi_host_state = SCSIHOST_IDLE;
     scsi_accel_host_config_gpio();
 
-    // Load PIO programs
-    pio_clear_instruction_memory(SCSI_PIO);
-
     // Asynchronous / synchronous SCSI read
     g_scsi_host.pio_offset_async_read = pio_add_program(SCSI_PIO, &scsi_host_async_read_program);
     g_scsi_host.pio_cfg_async_read = scsi_host_async_read_program_get_default_config(g_scsi_host.pio_offset_async_read);

+ 33 - 13
lib/BlueSCSI_platform_RP2040/scsi_accel_rp2040.cpp

@@ -23,9 +23,9 @@
 // SM1: Write data to SCSI bus
 // SM2: For synchronous mode only, count ACK pulses
 #define SCSI_DMA_PIO pio0
-#define SCSI_PARITY_SM 0
-#define SCSI_DATA_SM 1
-#define SCSI_SYNC_SM 2
+#define SCSI_PARITY_SM 1
+#define SCSI_DATA_SM 2
+#define SCSI_SYNC_SM 3
 
 // SCSI bus write acceleration uses 3 or 4 DMA channels (data flow A->B->C->D):
 // A: Bytes from RAM to scsi_parity PIO
@@ -38,10 +38,10 @@
 // B: Lookup from g_scsi_parity_check_lookup and copy to scsi_read_parity PIO
 // C: Addresses from scsi_accel_read PIO to lookup DMA READ_ADDR register
 // D: From pacer to data state machine to trigger transfers
-#define SCSI_DMA_CH_A 4
-#define SCSI_DMA_CH_B 5
-#define SCSI_DMA_CH_C 6
-#define SCSI_DMA_CH_D 7
+#define SCSI_DMA_CH_A 6
+#define SCSI_DMA_CH_B 7
+#define SCSI_DMA_CH_C 8
+#define SCSI_DMA_CH_D 9
 
 static struct {
     uint8_t *app_buf; // Buffer provided by application
@@ -824,9 +824,32 @@ void scsi_accel_rp2040_init()
     g_scsi_dma_state = SCSIDMA_IDLE;
     scsidma_config_gpio();
 
-    // Mark channels as being in use, unless it has been done already
-    if (!g_channels_claimed)
-    {
+    if (g_channels_claimed) {
+        // Un-claim all SCSI state machines
+        pio_sm_unclaim(SCSI_DMA_PIO, SCSI_PARITY_SM);
+        pio_sm_unclaim(SCSI_DMA_PIO, SCSI_DATA_SM);
+        pio_sm_unclaim(SCSI_DMA_PIO, SCSI_SYNC_SM);
+
+        // Remove all SCSI programs
+        pio_remove_program(SCSI_DMA_PIO, &scsi_parity_program, g_scsi_dma.pio_offset_parity);
+        pio_remove_program(SCSI_DMA_PIO, &scsi_accel_async_write_program, g_scsi_dma.pio_offset_async_write);
+        pio_remove_program(SCSI_DMA_PIO, &scsi_sync_write_pacer_program, g_scsi_dma.pio_offset_sync_write_pacer);
+        pio_remove_program(SCSI_DMA_PIO, &scsi_sync_write_program, g_scsi_dma.pio_offset_sync_write);
+        pio_remove_program(SCSI_DMA_PIO, &scsi_accel_read_program, g_scsi_dma.pio_offset_read);
+        pio_remove_program(SCSI_DMA_PIO, &scsi_sync_read_pacer_program, g_scsi_dma.pio_offset_sync_read_pacer);
+        pio_remove_program(SCSI_DMA_PIO, &scsi_read_parity_program, g_scsi_dma.pio_offset_read_parity);
+
+        // Un-claim all SCSI DMA channels
+        dma_channel_unclaim(SCSI_DMA_CH_A);
+        dma_channel_unclaim(SCSI_DMA_CH_B);
+        dma_channel_unclaim(SCSI_DMA_CH_C);
+        dma_channel_unclaim(SCSI_DMA_CH_D);
+
+        // Set flag to re-initialize SCSI PIO system
+        g_channels_claimed = false;
+    }
+    if (!g_channels_claimed) {
+        // Mark channels as being in use, unless it has been done already
         pio_sm_claim(SCSI_DMA_PIO, SCSI_PARITY_SM);
         pio_sm_claim(SCSI_DMA_PIO, SCSI_DATA_SM);
         pio_sm_claim(SCSI_DMA_PIO, SCSI_SYNC_SM);
@@ -836,9 +859,6 @@ void scsi_accel_rp2040_init()
         dma_channel_claim(SCSI_DMA_CH_D);
         g_channels_claimed = true;
     }
-
-    // Load PIO programs
-    pio_clear_instruction_memory(SCSI_DMA_PIO);
     
     // Parity lookup generator
     g_scsi_dma.pio_offset_parity = pio_add_program(SCSI_DMA_PIO, &scsi_parity_program);

+ 2 - 4
src/BlueSCSI.cpp

@@ -522,6 +522,8 @@ static void reinitSCSI()
 
 extern "C" void bluescsi_setup(void)
 {
+  pio_clear_instruction_memory(pio0);
+  pio_clear_instruction_memory(pio1);
   platform_init();
   platform_late_init();
 
@@ -658,8 +660,4 @@ extern "C" void bluescsi_main_loop(void)
       }
     } while (!g_sdcard_present && !g_romdrive_active);
   }
-  else
-  {
-    
-  }
 }