Browse Source

Adjust platform to not be by feature but by MCU
Allows for flashing different features using the same bootloader
Reworked dist, removed rename bins that was prone to error.
Fixed USB MSC detect in some scenarios
Fixed PicoW detect
Fixed non-portable shebangs.

Eric Helgeson 4 months ago
parent
commit
cc417c392f

+ 5 - 5
.github/workflows/firmware_build.yml

@@ -40,12 +40,12 @@ jobs:
       - name: Rename firmware files
         run: |
           cd BlueSCSI
-          utils/rename_binaries.sh
+          utils/make_dist.sh
 
       - name: Upload binaries into build artifacts
         uses: actions/upload-artifact@v4
         with:
-          path: BlueSCSI/distrib/*
+          path: BlueSCSI/dist/*
           name: BlueSCSI binaries
 
       - name: Upload to latest release
@@ -57,7 +57,7 @@ jobs:
           git tag -d latest
           git tag latest
           git push origin --force latest
-          cd distrib
+          cd dist
           gh api repos/${GITHUB_REPOSITORY}/releases/tags/latest | jq -r '.assets[] | [.url] | @tsv' | xargs -n 1 gh api -X DELETE || true
           gh release upload --repo ${GITHUB_REPOSITORY} --clobber latest *
 
@@ -68,10 +68,10 @@ jobs:
         run: |
           set +e
           RELEASE=$(basename ${{github.ref}})
-          gh release create --repo ${GITHUB_REPOSITORY} -t $RELEASE $RELEASE BlueSCSI/distrib/*
+          gh release create --repo ${GITHUB_REPOSITORY} -t $RELEASE $RELEASE BlueSCSI/dist/*
           status=$?
           set -e
           if [ $status -ne 0 ]; then
-            gh release upload --repo ${GITHUB_REPOSITORY} $RELEASE BlueSCSI/distrib/*
+            gh release upload --repo ${GITHUB_REPOSITORY} $RELEASE BlueSCSI/dist/*
           fi
 

+ 1 - 1
.gitignore

@@ -2,4 +2,4 @@
 .vscode
 .DS_Store
 .idea
-distrib/
+dist/

+ 41 - 2
lib/BlueSCSI_platform_RP2MCU/BlueSCSI_platform.cpp

@@ -89,7 +89,9 @@ static uint32_t g_flash_chip_size = 0;
 static bool g_uart_initialized = false;
 static bool g_led_blinking = false;
 static void usb_log_poll();
-
+#if !defined(PICO_CYW43_SUPPORTED)
+extern bool __isPicoW;
+#endif
 /***************/
 /* GPIO init   */
 /***************/
@@ -199,6 +201,43 @@ bool platform_reclock(bluescsi_speed_grade_t speed_grade)
     return do_reclock;
 }
 
+/**
+ * This is a workaround until arduino framework can be updated to handle all 4 variations of
+ * Pico1/1w/2/2w. In testing this works on all for BlueSCSI.
+ * Tracking here https://github.com/earlephilhower/arduino-pico/issues/2671
+ */
+bool platform_check_picow() {
+    static int8_t isPicoW = -1; // -1 = unchecked, 0 = false, 1 = true
+    if (isPicoW != -1)
+        return isPicoW == 1;
+
+#ifndef CYW43_PIN_WL_CLOCK
+    uint8_t cyw43_pin_wl_clock = 29; // Default to GPIO 29, which is the CYW43_PIN_WL_CLOCK
+#else
+    uint8_t cyw43_pin_wl_clock = CYW43_PIN_WL_CLOCK;
+#endif
+    adc_init();
+    const auto dir = gpio_get_dir(cyw43_pin_wl_clock);
+    const auto fnc = gpio_get_function(cyw43_pin_wl_clock);
+    adc_gpio_init(cyw43_pin_wl_clock);
+    adc_select_input(3);
+    const auto adc29 = adc_read();
+    gpio_set_function(cyw43_pin_wl_clock, fnc);
+    gpio_set_dir(cyw43_pin_wl_clock, dir);
+    if (adc29 < 200) {
+#ifdef CYW43_PIN_WL_CLOCK
+        __isPicoW = true; // Set the global if available for PicoW || Pico2W
+#endif
+        isPicoW = 1;
+    } else {
+#ifdef CYW43_PIN_WL_CLOCK
+        __isPicoW = false;
+#endif
+        isPicoW = 0;
+    }
+    return isPicoW == 1;
+}
+
 bool platform_rebooted_into_mass_storage()
 {
     volatile uint32_t* scratch0 = (uint32_t *)(WATCHDOG_BASE + WATCHDOG_SCRATCH0_OFFSET);
@@ -373,7 +412,7 @@ void platform_init()
     // uart_init(uart0, 1000000);
     // g_uart_initialized = true;
 #endif // DISABLE_SWO
-    logmsg("Platform: ", g_platform_name);
+    logmsg("Platform: ", g_platform_name, " (", PLATFORM_PID, platform_check_picow() ? "/W" : "", ")");
     logmsg("FW Version: ", g_log_firmwareversion);
 
 #ifdef HAS_DIP_SWITCHES

+ 1 - 0
lib/BlueSCSI_platform_RP2MCU/BlueSCSI_platform.h

@@ -182,6 +182,7 @@ extern const uint16_t g_scsi_parity_check_lookup[512];
 // Returns true if the board has a physical eject button 
 bool platform_has_phy_eject_button();
 void platform_disable_i2c();
+bool platform_check_picow();
 #ifdef __cplusplus
 }
 

+ 7 - 1
lib/BlueSCSI_platform_RP2MCU/BlueSCSI_platform_config.h

@@ -54,7 +54,13 @@
 # define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 20
 #elif defined(BLUESCSI_V2)
 # define PLATFORM_NAME "BlueSCSI"
-# define PLATFORM_PID "Pico"
+#ifdef ARDUINO_ARCH_RP2040
+# define PLATFORM_PID "Pico1"
+#define FIRMWARE_PREFIX "BlueSCSI-Pico1"
+#else
+# define PLATFORM_PID "Pico2"
+#define FIRMWARE_PREFIX "BlueSCSI-Pico2"
+#endif
 # define PLATFORM_REVISION "1.0"
 # define PLATFORM_MAX_SCSI_SPEED S2S_CFG_SPEED_SYNC_20
 # define PLATFORM_DEFAULT_SCSI_SPEED_SETTING 20

+ 4 - 2
lib/BlueSCSI_platform_RP2MCU/BlueSCSI_platform_msc.cpp

@@ -112,11 +112,13 @@ bool platform_sense_msc() {
   // pin on the wireless module, see https://github.com/earlephilhower/arduino-pico/discussions/835
   // Update: from the above discussion the offset 32 has been changed to 64 to access CYW43 GPIO pins
   // since the addition of the RP2350 chips, now stored in the DIGITAL_PIN_CYW43_OFFSET define
-  if (rp2040.isPicoW() && !digitalRead(DIGITAL_PIN_CYW43_OFFSET + 2))
+  if (platform_check_picow() && !digitalRead(DIGITAL_PIN_CYW43_OFFSET + 2)) {
     return false;
+  }
 
-  if (!rp2040.isPicoW() && !digitalRead(24))
+  if (!platform_check_picow() && !digitalRead(24)) {
     return false;
+  }
 #endif
 
   logmsg("Waiting for USB enumeration to enter Card Reader mode.");

+ 1 - 1
platformio.ini

@@ -85,7 +85,7 @@ extends = env:BlueSCSI_RP2MCU
 board = rpipicow
 ; How much flash in bytes the bootloader and main app will be allocated
 ; It is used as the starting point for a ROM image saved in flash
-program_flash_allocation = 591256
+program_flash_allocation = 592256
 linker_script_template = lib/BlueSCSI_platform_RP2MCU/rp2040-template.ld
 ldscript_bootloader = lib/BlueSCSI_platform_RP2MCU/rp2040_btldr.ld
 debug_build_flags =

+ 4 - 4
src/BlueSCSI.cpp

@@ -884,14 +884,14 @@ static void check_for_unused_update_files()
           strncasecmp(filename + filename_len - 4, ".bin", 4) == 0)
       {
         bin_files_found = true;
-        logmsg("Firmware update file \"", filename, "\" does not contain the board model string \"", FIRMWARE_NAME_PREFIX, "\"");
+        logmsg("Firmware update file \"", filename, "\" does not contain the board model string \"", FIRMWARE_PREFIX, "\"");
       }
     }
   }
   if (bin_files_found)
   {
-    logmsg("Please use the ", FIRMWARE_PREFIX ,"*.zip firmware bundle, or the proper .bin or .uf2 file to update the firmware.");
-    logmsg("See https://github.com/blueSCSI/BlueSCSI-v2/wiki/Updating-Firmware for more information");
+    logmsg("Please use the ", FIRMWARE_PREFIX ,"*.bin or .uf2 file to update the firmware.");
+    logmsg("See https://github.com/BlueSCSI/BlueSCSI-v2/wiki/Updating-Firmware for more information");
   }
 }
 
@@ -951,7 +951,7 @@ static void firmware_update()
     }
     if (parsed_length < 0)
     {
-      logmsg("Filename character length of ", (int)target_filename_length , " with a prefix of ", FIRMWARE_NAME_PREFIX, " not found in ", name);
+      logmsg("A firmware file for this board model was not found in ", name);
       file.close();
       root.close();
       return;

+ 4 - 2
src/BlueSCSI_bootloader.cpp

@@ -42,9 +42,11 @@ bool find_firmware_image(FsFile &file, char name[MAX_FILE_PATH + 1])
         if (file.isDir()) continue;
 
         int namelen = file.getName(name, MAX_FILE_PATH);
+        const char* board_name = PLATFORM_PID;
 
-        if (namelen >= sizeof(FIRMWARE_NAME_PREFIX) + 3 &&
-            strncasecmp(name, FIRMWARE_NAME_PREFIX, sizeof(FIRMWARE_NAME_PREFIX) - 1) == 0 &&
+        if (namelen >= sizeof(FIRMWARE_PREFIX) + 3 &&
+            strncasecmp(name, FIRMWARE_PREFIX, sizeof(FIRMWARE_PREFIX) - 1) == 0 &&
+            strstr(name, board_name) != NULL &&
             strncasecmp(name + namelen - 3, "bin", 3) == 0)
         {
             root.close();

+ 0 - 1
src/BlueSCSI_config.h

@@ -44,7 +44,6 @@
 #define CONFIGFILE  "bluescsi.ini"
 #define LOGFILE     "log.txt"
 #define CRASHFILE   "err.txt"
-#define FIRMWARE_PREFIX "BlueSCSI-FW"
 
 // Prefix for command file to create new image (case-insensitive)
 #define CREATEFILE "create"

+ 1 - 1
utils/analyze_crashlog.sh

@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # This script can be used for analyzing a crash report.
 # It tries to find a matching binary .elf either locally

+ 1 - 1
utils/create_bin_package_zip.sh

@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # ZuluSCSI™ - Copyright (c) 2024-2025 Rabbit Hole Computing™
 #

+ 58 - 0
utils/make_dist.sh

@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+
+# BlueSCSI - Copyright (c) 2025 Eric Helgeson
+#
+# BlueSCSI file is licensed under the GPL version 3 or any later version.
+#
+# https://www.gnu.org/licenses/gpl-3.0.html
+# ----
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+SCRIPT_DIR=$(dirname "$(readlink -f "$0")")
+cd "$SCRIPT_DIR/.." || exit 1
+OUT_DIR=./dist
+mkdir -p $OUT_DIR || exit 1
+
+DATE=$(date +%Y-%m-%d)
+VERSION=$(git rev-parse --short HEAD)
+
+for file in .pio/build/*/firmware.bin .pio/build/*/firmware.elf .pio/build/*/firmware.uf2
+do
+    BUILD_ENV=$(echo "$file" | cut -d'/' -f3)
+
+    if [[ "$BUILD_ENV" == *"Pico_2"* ]]; then
+        BOARD="Pico2"
+    elif [[ "$BUILD_ENV" == *"Pico"* ]]; then
+        BOARD="Pico1"
+    else
+        echo "Warning: Could not determine board for $file"
+        continue
+    fi
+
+    VARIANT=""
+    if [[ "$BUILD_ENV" == *"DaynaPORT"* ]]; then
+        VARIANT="-DaynaPORT"
+    fi
+
+    EXT="${file##*.}"
+
+    RENAME="BlueSCSI-${BOARD}${VARIANT}-${DATE}-${VERSION}.${EXT}"
+
+    echo "$file to $OUT_DIR/$RENAME"
+    cp "$file" "$OUT_DIR/$RENAME"
+done
+
+# Make a zip file with all the pico1 and pico2 files together by variant such as DaynaPORT
+#zip -j "dist/BlueSCSI-Universal-DaynaPORT-${DATE}-${VERSION}.zip" dist/BlueSCSI-Pico*-DaynaPORT-${DATE}-${VERSION}.*
+#find dist/ -maxdepth 1 -type f -name "BlueSCSI-Pico*-${DATE}-${VERSION}.*" ! -name "*-DaynaPORT-*" -print0 | xargs -0 zip -j "dist/BlueSCSI-Universal-${DATE}-${VERSION}.zip"

+ 1 - 1
utils/random_tester.py

@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 
 '''
   ZuluSCSI™ - Copyright (c) 2022-2025 Rabbit Hole Computing™

+ 0 - 36
utils/rename_binaries.sh

@@ -1,36 +0,0 @@
-#!/bin/bash
-
-# ZuluSCSI™ - Copyright (c) 2022-2025 Rabbit Hole Computing™
-#
-# ZuluSCSI™ file is licensed under the GPL version 3 or any later version. 
-#
-# https://www.gnu.org/licenses/gpl-3.0.html
-# ----
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version. 
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details. 
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <https://www.gnu.org/licenses/>.
-
-
-# This script renames the built binaries according to version
-# number and platform.
-
-mkdir -p distrib
-
-DATE=$(date +%Y-%m-%d)
-VERSION=$(git describe --always)
-
-for file in $(ls .pio/build/*/firmware.bin .pio/build/*/firmware.elf .pio/build/*/firmware.uf2)
-do
-    NEWNAME=$(echo $file | sed 's|.pio/build/\([^/]*\)/\(.*\)\.\(.*\)|\1_'$DATE'_'$VERSION'.\3|')
-    echo $file to distrib/$NEWNAME
-    cp $file distrib/$NEWNAME
-done

+ 1 - 1
utils/run_gdb_rp2040.sh

@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 # ZuluSCSI™ - Copyright (c) 2022-2025 Rabbit Hole Computing™
 #

+ 1 - 1
utils/speed_tester.py

@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
 
 '''
   ZuluSCSI™ - Copyright (c) 2022-2025 Rabbit Hole Computing™