Quellcode durchsuchen

chore: update to pico-sdk 2.0.0

Eric Helgeson vor 11 Monaten
Ursprung
Commit
d3f3db2d61

+ 21 - 16
lib/BlueSCSI_platform_RP2040/BlueSCSI_platform.cpp

@@ -73,7 +73,7 @@ void mbed_error_hook(const mbed_error_ctx * error_context);
 /***************/
 
 // Helper function to configure whole GPIO in one line
-static void gpio_conf(uint gpio, enum gpio_function fn, bool pullup, bool pulldown, bool output, bool initial_state, bool fast_slew)
+static void gpio_conf(uint gpio, gpio_function_t fn, bool pullup, bool pulldown, bool output, bool initial_state, bool fast_slew)
 {
     gpio_put(gpio, initial_state);
     gpio_set_dir(gpio, output);
@@ -82,7 +82,7 @@ static void gpio_conf(uint gpio, enum gpio_function fn, bool pullup, bool pulldo
 
     if (fast_slew)
     {
-        padsbank0_hw->io[gpio] |= PADS_BANK0_GPIO0_SLEWFAST_BITS;
+        pads_bank0_hw->io[gpio] |= PADS_BANK0_GPIO0_SLEWFAST_BITS;
     }
 }
 
@@ -134,6 +134,7 @@ void platform_init()
     // Report platform and firmware version
     log("Platform: ", g_platform_name);
     log("FW Version: ", g_log_firmwareversion);
+    debuglog("PicoSDK: ", PICO_SDK_VERSION_STRING);
 
     /* First configure the pins that affect external buffer directions.
      * RP2040 defaults to pulldowns, while these pins have external pull-ups.
@@ -201,9 +202,9 @@ void platform_init()
     // Get flash chip size
     uint8_t cmd_read_jedec_id[4] = {0x9f, 0, 0, 0};
     uint8_t response_jedec[4] = {0};
-    __disable_irq();
+    uint32_t status = save_and_disable_interrupts();
     flash_do_cmd(cmd_read_jedec_id, response_jedec, 4);
-    __enable_irq();
+    restore_interrupts_from_disabled(status);
     g_flash_chip_size = (1 << response_jedec[3]);
     log("Flash chip size: ", (int)(g_flash_chip_size / 1024), " kB");
 
@@ -495,7 +496,7 @@ static void adc_poll()
     * If ADC sample reads are done, either via direct reading, FIFO, or DMA,
     * at the same time a SPI DMA write begins, it appears that the first
     * 16-bit word of the DMA data is lost. This causes the bitstream to glitch
-    * and audio to 'pop' noticably. For now, just disable ADC reads when audio
+    * and audio to 'pop' noticeably. For now, just disable ADC reads when audio
     * is playing.
     */
    if (audio_is_active()) return;
@@ -570,7 +571,9 @@ static void watchdog_callback(unsigned alarm_num)
 #ifdef __MBED__
             uint32_t *p =  (uint32_t*)__get_PSP();
 #else
-            uint32_t *p =  (uint32_t*)__get_MSP();
+            uint32_t msp;
+            asm volatile ("MRS %0, msp" : "=r" (msp) );
+            uint32_t *p = (uint32_t*)msp;
 #endif
             for (int i = 0; i < 8; i++)
             {
@@ -597,7 +600,9 @@ static void watchdog_callback(unsigned alarm_num)
 #ifdef __MBED__
             uint32_t *p =  (uint32_t*)__get_PSP();
 #else
-            uint32_t *p =  (uint32_t*)__get_MSP();
+            uint32_t msp;
+            asm volatile ("MRS %0, msp" : "=r" (msp) );
+            uint32_t *p = (uint32_t*)msp;
 #endif
             for (int i = 0; i < 8; i++)
             {
@@ -627,7 +632,7 @@ void platform_reset_watchdog()
     if (!g_watchdog_initialized)
     {
         int alarm_num = -1;
-        for (int i = 0; i < NUM_TIMERS; i++)
+        for (int i = 0; i < NUM_GENERIC_TIMERS; i++)
         {
             if (!hardware_alarm_is_claimed(i))
             {
@@ -736,7 +741,7 @@ bool platform_rewrite_flash_page(uint32_t offset, uint8_t buffer[PLATFORM_FLASH_
     assert(offset >= PLATFORM_BOOTLOADER_SIZE);
 
     // Avoid any mbed timer interrupts triggering during the flashing.
-    __disable_irq();
+    uint32_t status = save_and_disable_interrupts();
 
     // For some reason any code executed after flashing crashes
     // unless we disable the XIP cache.
@@ -754,17 +759,17 @@ bool platform_rewrite_flash_page(uint32_t offset, uint8_t buffer[PLATFORM_FLASH_
     for (int i = 0; i < num_words; i++)
     {
         uint32_t expected = buf32[i];
-        uint32_t actual = *(volatile uint32_t*)(XIP_NOCACHE_BASE + offset + i * 4);
+        uint32_t actual = *(volatile uint32_t*)(XIP_SRAM_BASE + offset + i * 4);
 
         if (actual != expected)
         {
             log("Flash verify failed at offset ", offset + i * 4, " got ", actual, " expected ", expected);
-            __enable_irq();
+            restore_interrupts_from_disabled(status);
             return false;
         }
     }
 
-    __enable_irq();
+    restore_interrupts_from_disabled(status);
 
     return true;
 }
@@ -774,7 +779,7 @@ void platform_boot_to_main_firmware()
     // To ensure that the system state is reset properly, we perform
     // a SYSRESETREQ and jump straight from the reset vector to main application.
     g_bootloader_exit_req = &g_bootloader_exit_req;
-    SCB->AIRCR = 0x05FA0004;
+    scb_hw->aircr = 0x05FA0004;
     while(1);
 }
 
@@ -787,7 +792,7 @@ void btldr_reset_handler()
         application_base = (uint32_t*)(XIP_BASE + PLATFORM_BOOTLOADER_SIZE);
     }
 
-    SCB->VTOR = (uint32_t)application_base;
+    scb_hw->aircr = (uint32_t)application_base;
     __asm__(
         "msr msp, %0\n\t"
         "bx %1" : : "r" (application_base[0]),
@@ -859,10 +864,10 @@ bool platform_write_romdrive(const uint8_t *data, uint32_t start, uint32_t count
     assert(start < platform_get_romdrive_maxsize());
     assert((count % PLATFORM_ROMDRIVE_PAGE_SIZE) == 0);
 
-    __disable_irq();
+    uint32_t status = save_and_disable_interrupts();
     flash_range_erase(start + ROMDRIVE_OFFSET, count);
     flash_range_program(start + ROMDRIVE_OFFSET, data, count);
-    __enable_irq();
+    restore_interrupts_from_disabled(status);
     return true;
 }
 

+ 1 - 1
lib/BlueSCSI_platform_RP2040/rp2040_sdio.cpp

@@ -817,7 +817,7 @@ static void rp2040_sdio_tx_irq()
 // Check if transmission is complete
 sdio_status_t rp2040_sdio_tx_poll(uint32_t *bytes_complete)
 {
-    if (SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk)
+    if (scb_hw->icsr & (0x1FFUL))
     {
         // Verify that IRQ handler gets called even if we are in hardfault handler
         rp2040_sdio_tx_irq();

+ 8 - 8
lib/BlueSCSI_platform_RP2040/scsi_accel_rp2040.cpp

@@ -204,7 +204,7 @@ void scsi_accel_rp2040_startWrite(const uint8_t* data, uint32_t count, volatile
     // Any read requests should be matched with a stopRead()
     assert(g_scsi_dma_state != SCSIDMA_READ && g_scsi_dma_state != SCSIDMA_READ_DONE);
 
-    __disable_irq();
+    uint32_t status = save_and_disable_interrupts();
     if (g_scsi_dma_state == SCSIDMA_WRITE)
     {
         if (!g_scsi_dma.next_app_buf && data == g_scsi_dma.app_buf + g_scsi_dma.app_bytes)
@@ -227,7 +227,7 @@ void scsi_accel_rp2040_startWrite(const uint8_t* data, uint32_t count, volatile
             count = 0;
         }
     }
-    __enable_irq();
+    restore_interrupts_from_disabled(status);
 
     // Check if the request was combined
     if (count == 0) return;
@@ -326,7 +326,7 @@ bool scsi_accel_rp2040_isWriteFinished(const uint8_t* data)
 
     // Check if this data item is still in queue.
     bool finished = true;
-    __disable_irq();
+    uint32_t status = save_and_disable_interrupts();
     if (data >= g_scsi_dma.app_buf &&
         data < g_scsi_dma.app_buf + g_scsi_dma.app_bytes &&
         (uint32_t)data >= dma_hw->ch[SCSI_DMA_CH_A].al1_read_addr)
@@ -338,7 +338,7 @@ bool scsi_accel_rp2040_isWriteFinished(const uint8_t* data)
     {
         finished = false; // In queued transfer
     }
-    __enable_irq();
+    restore_interrupts_from_disabled(status);
 
     return finished;
 }
@@ -589,7 +589,7 @@ void scsi_accel_rp2040_startRead(uint8_t *data, uint32_t count, int *parityError
     // Any write requests should be matched with a stopWrite()
     assert(g_scsi_dma_state != SCSIDMA_WRITE && g_scsi_dma_state != SCSIDMA_WRITE_DONE);
 
-    __disable_irq();
+    uint32_t status = save_and_disable_interrupts();
     if (g_scsi_dma_state == SCSIDMA_READ)
     {
         if (!g_scsi_dma.next_app_buf && data == g_scsi_dma.app_buf + g_scsi_dma.app_bytes)
@@ -612,7 +612,7 @@ void scsi_accel_rp2040_startRead(uint8_t *data, uint32_t count, int *parityError
             count = 0;
         }
     }
-    __enable_irq();
+    restore_interrupts_from_disabled(status);
 
     // Check if the request was combined
     if (count == 0) return;
@@ -658,7 +658,7 @@ bool scsi_accel_rp2040_isReadFinished(const uint8_t* data)
 
     // Check if this data item is still in queue.
     bool finished = true;
-    __disable_irq();
+    uint32_t status = save_and_disable_interrupts();
     if (data >= g_scsi_dma.app_buf &&
         data < g_scsi_dma.app_buf + g_scsi_dma.app_bytes &&
         (uint32_t)data >= dma_hw->ch[SCSI_DMA_CH_A].write_addr)
@@ -670,7 +670,7 @@ bool scsi_accel_rp2040_isReadFinished(const uint8_t* data)
     {
         finished = false; // In queued transfer
     }
-    __enable_irq();
+    restore_interrupts_from_disabled(status);
 
     return finished;
 }

+ 7 - 3
platformio.ini

@@ -12,9 +12,9 @@ default_envs = BlueSCSI_Pico
 
 ; BlueSCSI RP2040 hardware platform, based on the Raspberry Pi foundation RP2040 microcontroller
 [env:BlueSCSI_Pico]
-platform = https://github.com/maxgerhardt/platform-raspberrypi.git#196d31bbafaf60b84751b1a415d8dca2365debdf
-platform_packages = platformio/toolchain-gccarmnoneeabi@1.120301.0
-    framework-arduinopico@https://github.com/BlueSCSI/arduino-pico-internal.git#e139b9c7816602597f473b3231032cca5d71a48a
+platform = https://github.com/maxgerhardt/platform-raspberrypi.git#2d445020acf8b792768a5fa5ba1870ac9607c11c
+platform_packages =
+    framework-arduinopico@https://github.com/BlueSCSI/arduino-pico-internal.git#v4.1.1-DaynaPORT
 framework = arduino
 board = rpipicow
 board_build.core = earlephilhower
@@ -47,6 +47,10 @@ build_flags =
     ; -DLOGBUFSIZE=8192
     ; -DPREFETCH_BUFFER_SIZE=6144
     ; -DSCSI2SD_BUFFER_SIZE=57344
+; build flags mirroring the framework-arduinopico#v4.1.1-DaynaPORT static library build
+    -DPICO_CYW43_ARCH_POLL=1
+    -DCYW43_LWIP=0
+    -DCYW43_USE_OTP_MAC=0
 
 ; Experimental Audio build
 ; Requires separate hardware and overclock.