diff --git a/.github/workflows/push-master.yml b/.github/workflows/push-master.yml index 0b6691d..aabf3b7 100644 --- a/.github/workflows/push-master.yml +++ b/.github/workflows/push-master.yml @@ -53,7 +53,7 @@ jobs: rm ../firmware/* echo "Neopixel is using GPIO16(OUTPUT_DATA_PIN) on output 0." > ../firmware/Firmwares_for_Adafruit_Feather_RP2040_Scorpio.txt echo "SPI is using spi0 interface pins: GPIO19(OUTPUT_SPI_DATA_PIN) and GPIO18(OUTPUT_SPI_CLOCK_PIN) on output 3 and 2 respectively." >> ../firmware/Firmwares_for_Adafruit_Feather_RP2040_Scorpio.txt - cmake -DOVERRIDE_DATA_PIN=16 -DOVERRIDE_SPI_DATA_PIN=19 -DOVERRIDE_SPI_CLOCK_PIN=18 -DCMAKE_BUILD_TYPE=Release .. + cmake -DOVERRIDE_BOOT_WORKAROUND=ON -DOVERRIDE_DATA_PIN=16 -DOVERRIDE_SPI_DATA_PIN=19 -DOVERRIDE_SPI_CLOCK_PIN=18 -DCMAKE_BUILD_TYPE=Release .. cmake --build . zip -j ../firmware/Adafruit_Feather_RP2040_Scorpio.zip ../firmware/* @@ -73,7 +73,7 @@ jobs: rm *.* rm ../firmware/* echo "Neopixel is using GPIO14(OUTPUT_DATA_PIN) on output 5." > ../firmware/Firmwares_for_Adafruit_ItsyBitsy_2040.txt - cmake -DOVERRIDE_DATA_PIN=14 -DCMAKE_BUILD_TYPE=Release .. + cmake -DOVERRIDE_BOOT_WORKAROUND=ON -DOVERRIDE_DATA_PIN=14 -DCMAKE_BUILD_TYPE=Release .. cmake --build . rm ../firmware/*_Spi.uf2 zip -j ../firmware/Adafruit_ItsyBitsy_2040.zip ../firmware/* diff --git a/.gitignore b/.gitignore index 97bdfaf..fcc43b5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,7 @@ sdk/pico build/* generated/ -firmwares/ +firmware/ # User-specific files *.rsuser diff --git a/CMakeLists.txt b/CMakeLists.txt index 99d7a4a..29cd7a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,10 @@ # User configuration section starts here +# Some boards, such as the first Adafruit revisions, may have trouble booting properly +# due to bad componets used in the design. +# Turn this setting to ON if your rp2040 is not detected after firmware upload and reset +set(BOOT_WORKAROUND OFF) + # Default output data pin for the non-SPI LED strips (only for sk6812/ws2812b) set(OUTPUT_DATA_PIN 2) @@ -78,17 +83,26 @@ if (OVERRIDE_SPI_INTERFACE) message( STATUS "${YellowColor}Overriding SPI Interface: ${OUTPUT_SPI_INTERFACE}${ColorReset}") endif() +if (OVERRIDE_BOOT_WORKAROUND) + set(BOOT_WORKAROUND ${OVERRIDE_BOOT_WORKAROUND}) + message( STATUS "${YellowColor}Overriding boot workaround: ${BOOT_WORKAROUND}${ColorReset}") +endif() + message( STATUS "---------------------------") message( STATUS "Neopixel Data GPIO: ${GreenColor}${OUTPUT_DATA_PIN}${ColorReset}") message( STATUS "SPI Data GPIO: ${GreenColor}${OUTPUT_SPI_DATA_PIN}${ColorReset}") message( STATUS "SPI Clock GPIO: ${GreenColor}${OUTPUT_SPI_CLOCK_PIN}${ColorReset}") message( STATUS "SPI Interface: ${GreenColor}${OUTPUT_SPI_INTERFACE}${ColorReset}") +message( STATUS "Boot workaround: ${GreenColor}${BOOT_WORKAROUND}${ColorReset}") message( STATUS "---------------------------") add_compile_options(-ftrack-macro-expansion=0 -fno-diagnostics-show-caret -fdiagnostics-color=auto) macro(HyperSerialPicoTarget HyperSerialPicoTargetName) add_executable(${HyperSerialPicoTargetName} ${CMAKE_SOURCE_DIR}/source/main.cpp) + if (BOOT_WORKAROUND) + target_compile_definitions(${HyperSerialPicoTargetName} PUBLIC -DBOOT_WORKAROUND -DPICO_XOSC_STARTUP_DELAY_MULTIPLIER=64) + endif() target_include_directories(${HyperSerialPicoTargetName} PRIVATE ${HyperSerialPicoCompanionIncludes}) target_link_libraries(${HyperSerialPicoTargetName} ${HyperSerialPicoCompanionLibs}) pico_add_extra_outputs(${HyperSerialPicoTargetName}) diff --git a/source/main.cpp b/source/main.cpp index d787ff1..67209a9 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -51,6 +51,12 @@ #define _XSTR2(x,y) _STR(x) _STR(y) #define VAR_NAME_VALUE2(var) #var " = " _XSTR2(var) +#if defined(BOOT_WORKAROUND) && defined(PICO_XOSC_STARTUP_DELAY_MULTIPLIER) + #pragma message("Enabling boot workaround") + #pragma message(VAR_NAME_VALUE(PICO_XOSC_STARTUP_DELAY_MULTIPLIER)) +#endif + + #ifdef NEOPIXEL_RGBW #pragma message(VAR_NAME_VALUE(NEOPIXEL_RGBW)) #endif