diff --git a/README.md b/README.md index 399c00d4..26e65289 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,9 @@ Each example in this repository contains build and deployment instructions, howe | [stm32-neopixel](./stm32-neopixel) | STM32F746G-DISCO | None | Control NeoPixel LEDs using SPI. | | | [stm32-uart-echo](./stm32-uart-echo) | STM32F746G-DISCO | None | Echo user input using UART. | | | [pico-blink](./pico-blink) | Raspberry Pi Pico | None | Blink an LED repeatedly. | | -| [pico-blink-sdk](./pico-blink-sdk) | Raspberry Pi Pico | Pico SDK | Blink an LED repeatedly with Swift & the Pico SDK. | | +| [pico-blink-sdk](./pico-blink-sdk) | Raspberry Pi Pico, Pico 2 | Pico SDK | Blink an LED repeatedly with Swift & the Pico SDK. | | | [pico-w-blink-sdk](./pico-w-blink-sdk) | Raspberry Pi Pico W | Pico SDK | Blink an LED to signal 'SOS' in Morse code repeatedly with Swift & the Pico SDK. | | -| [pico2-neopixel](./pico2-neopixel) | Raspberry Pi Pico2 | None | Control Neopixel LEDs using the RP2350 PIO. | | +| [pico2-neopixel](./pico2-neopixel) | Raspberry Pi Pico 2 | None | Control Neopixel LEDs using the RP2350 PIO. | | | [nrfx-blink-sdk](./nrfx-blink-sdk) | nRF52840-DK | Zephyr SDK | Blink an LED repeatedly with Swift & Zephyr. | | | [esp32-led-strip-sdk](./esp32-led-strip-sdk) | ESP32-C6-DevKitC-1 | ESP-IDF SDK | Control NeoPixel LEDs with Swift & the ESP-IDF. | | | [esp32-led-blink-sdk](./esp32-led-blink-sdk) | ESP32-C6-Bug | ESP-IDF SDK | Blink an LED repeatedly with Swift & the ESP-IDF. | | diff --git a/pico-blink-sdk/CMakeLists.txt b/pico-blink-sdk/CMakeLists.txt index aa1e0c13..8dc23666 100644 --- a/pico-blink-sdk/CMakeLists.txt +++ b/pico-blink-sdk/CMakeLists.txt @@ -10,12 +10,24 @@ else() execute_process(COMMAND which swiftc OUTPUT_VARIABLE SWIFTC OUTPUT_STRIP_TRAILING_WHITESPACE) endif() + +set(SWIFT_TARGET "armv6m-none-none-eabi") # default for rp2040 + +if(PICO_PLATFORM STREQUAL "rp2350-arm-s") + message(STATUS "PICO_PLATFORM is set to rp2350-arm-s, using armv7em") + set(SWIFT_TARGET "armv7em-none-none-eabi") +elseif(PICO_PLATFORM STREQUAL "rp2350-riscv") + # Untested, gives PICO-SDK errors when building + message(WARNING "PICO_PLATFORM is set to rp2350-riscv, using riscv32 (untested). It is recommended to use rp2350-arm-s.") + set(SWIFT_TARGET "riscv32-none-none-eabi") +endif() + add_executable(swift-blinky) add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_swiftcode.o COMMAND ${SWIFTC} - -target armv6m-none-none-eabi -Xcc -mfloat-abi=soft -Xcc -fshort-enums + -target ${SWIFT_TARGET} -Xcc -mfloat-abi=soft -Xcc -fshort-enums -Xfrontend -function-sections -enable-experimental-feature Embedded -wmo -parse-as-library $$\( echo '$' | tr '\;' '\\n' | sed -e 's/\\\(.*\\\)/-Xcc -I\\1/g' \) $$\( echo '${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}' | tr ' ' '\\n' | sed -e 's/\\\(.*\\\)/-Xcc -I\\1/g' \) diff --git a/pico-blink-sdk/README.md b/pico-blink-sdk/README.md index 8bac29f5..3604f00b 100644 --- a/pico-blink-sdk/README.md +++ b/pico-blink-sdk/README.md @@ -24,7 +24,7 @@ This example demonstrates how to integrate with the Pico SDK which is using CMak ``` console $ cd pico-blink-sdk $ export TOOLCHAINS='' -$ export PICO_BOARD=pico +$ export PICO_BOARD='' # Examples: pico, pico2 $ export PICO_SDK_PATH='' $ export PICO_TOOLCHAIN_PATH='' # A default `brew` install will be located at `/Applications/ArmGNUToolchain/[version]/arm-none-eabi` $ cmake -B build -G Ninja .