Quellcode durchsuchen

Upgrade rp2040 platform package to 1.8.0

The new version has needed flash programming functions already
available, so our copy of rp2040_flash_do_cmd.h can be removed.
Petteri Aimonen vor 2 Jahren
Ursprung
Commit
9d34e1cd56

+ 1 - 5
lib/BlueSCSI_platform_RP2040/BlueSCSI_platform.cpp

@@ -7,17 +7,13 @@
 #include <hardware/gpio.h>
 #include <hardware/uart.h>
 #include <hardware/spi.h>
+#include <hardware/flash.h>
 #include <hardware/structs/xip_ctrl.h>
 #include <platform/mbed_error.h>
 #include <multicore.h>
 
 extern "C" {
 
-// As of 2022-09-13, the platformio RP2040 core is missing cplusplus guard on flash.h
-// For that reason this has to be inside the extern "C" here.
-#include <hardware/flash.h>
-#include "rp2040_flash_do_cmd.h"
-
 const char *g_platform_name = PLATFORM_NAME;
 static bool g_scsi_initiator = false;
 static uint32_t g_flash_chip_size = 0;

+ 0 - 78
lib/BlueSCSI_platform_RP2040/rp2040_flash_do_cmd.h

@@ -1,78 +0,0 @@
-// As of 2022-11-16, the raspberrypi platformio package ships with old version
-// of pico-sdk. This version lacks the flash_do_cmd() function in flash.h header.
-// This file backports the function from new versions.
-
-#pragma once
-
-#ifndef RP2040_HAS_FLASH_DO_CMD
-
-#include <hardware/flash.h>
-#include "pico/bootrom.h"
-#include "hardware/structs/ssi.h"
-#include "hardware/structs/ioqspi.h"
-
-#define BOOT2_SIZE_WORDS 64
-
-static uint32_t boot2_copyout[BOOT2_SIZE_WORDS];
-static bool boot2_copyout_valid = false;
-
-static void __no_inline_not_in_flash_func(flash_init_boot2_copyout)(void) {
-    if (boot2_copyout_valid)
-        return;
-    for (int i = 0; i < BOOT2_SIZE_WORDS; ++i)
-        boot2_copyout[i] = ((uint32_t *)XIP_BASE)[i];
-    __asm__ volatile ("" : : : "memory");
-    boot2_copyout_valid = true;
-}
-
-static void __no_inline_not_in_flash_func(flash_enable_xip_via_boot2)(void) {
-    ((void (*)(void))((char*)boot2_copyout+1))();
-}
-
-// Bitbanging the chip select using IO overrides, in case RAM-resident IRQs
-// are still running, and the FIFO bottoms out. (the bootrom does the same)
-static void __no_inline_not_in_flash_func(flash_cs_force)(bool high) {
-    uint32_t field_val = high ?
-        IO_QSPI_GPIO_QSPI_SS_CTRL_OUTOVER_VALUE_HIGH :
-        IO_QSPI_GPIO_QSPI_SS_CTRL_OUTOVER_VALUE_LOW;
-    hw_write_masked(&ioqspi_hw->io[1].ctrl,
-        field_val << IO_QSPI_GPIO_QSPI_SS_CTRL_OUTOVER_LSB,
-        IO_QSPI_GPIO_QSPI_SS_CTRL_OUTOVER_BITS
-    );
-}
-
-static void __no_inline_not_in_flash_func(flash_do_cmd)(const uint8_t *txbuf, uint8_t *rxbuf, size_t count) {
-    void (*connect_internal_flash)(void) = (void(*)(void))rom_func_lookup(rom_table_code('I', 'F'));
-    void (*flash_exit_xip)(void) = (void(*)(void))rom_func_lookup(rom_table_code('E', 'X'));
-    void (*flash_flush_cache)(void) = (void(*)(void))rom_func_lookup(rom_table_code('F', 'C'));
-    assert(connect_internal_flash && flash_exit_xip && flash_flush_cache);
-    flash_init_boot2_copyout();
-    __asm__ volatile ("" : : : "memory");
-    connect_internal_flash();
-    flash_exit_xip();
-
-    flash_cs_force(0);
-    size_t tx_remaining = count;
-    size_t rx_remaining = count;
-    // We may be interrupted -- don't want FIFO to overflow if we're distracted.
-    const size_t max_in_flight = 16 - 2;
-    while (tx_remaining || rx_remaining) {
-        uint32_t flags = ssi_hw->sr;
-        bool can_put = !!(flags & SSI_SR_TFNF_BITS);
-        bool can_get = !!(flags & SSI_SR_RFNE_BITS);
-        if (can_put && tx_remaining && rx_remaining - tx_remaining < max_in_flight) {
-            ssi_hw->dr0 = *txbuf++;
-            --tx_remaining;
-        }
-        if (can_get && rx_remaining) {
-            *rxbuf++ = (uint8_t)ssi_hw->dr0;
-            --rx_remaining;
-        }
-    }
-    flash_cs_force(1);
-
-    flash_flush_cache();
-    flash_enable_xip_via_boot2();
-}
-
-#endif

+ 1 - 1
platformio.ini

@@ -5,7 +5,7 @@ default_envs = BlueSCSI_Pico
 
 ; BlueSCSI RP2040 hardware platform, based on the Raspberry Pi foundation RP2040 microcontroller
 [env:BlueSCSI_Pico]
-platform = raspberrypi@1.7.0
+platform = raspberrypi@1.8.0
 platform_packages = platformio/toolchain-gccarmnoneeabi@1.100301.220327 ; toolchain-gccarmnoneeabi@1.60301.0
 framework = arduino
 board = BlueSCSI_RP2040