Skip to content

Commit 22f2c98

Browse files
authored
Pico-blink-sdk support for RP2350 (#58)
Modify CMakeLists.txt to automatically adjust for target architecture changes. Guide the swiftc compiler to use the appropriate target based on the PICO_PLATFORM CMake variable, which defaults to PICO_BOARD if not explicitly set. Add a target check for RISC-V to support compilation on RP2350 hardware in RISC-V mode. Compilation currently fails due to pico-sdk errors, similar to issues encountered on RP2040 with the new SDK versions.
1 parent a0f9d8d commit 22f2c98

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ Each example in this repository contains build and deployment instructions, howe
3737
| [stm32-neopixel](./stm32-neopixel) | STM32F746G-DISCO | None | Control NeoPixel LEDs using SPI. | <img width="300" src="https://github.com/apple/swift-embedded-examples/assets/1186214/9c5d8f74-f8aa-4632-831e-212a3e35e75a"> |
3838
| [stm32-uart-echo](./stm32-uart-echo) | STM32F746G-DISCO | None | Echo user input using UART. | <img width="300" src="https://github.com/apple/swift-embedded-examples/assets/1186214/97d3c465-9a07-4b86-9654-0c2aaaa43b3d">|
3939
| [pico-blink](./pico-blink) | Raspberry Pi Pico | None | Blink an LED repeatedly. | <img width="300" src="https://github.com/apple/swift-embedded-examples/assets/1186214/f2c45c18-f9a4-48b4-a941-1298ecc942cb"> |
40-
| [pico-blink-sdk](./pico-blink-sdk) | Raspberry Pi Pico | Pico SDK | Blink an LED repeatedly with Swift & the Pico SDK. | <img width="300" src="https://github.com/apple/swift-embedded-examples/assets/1186214/f2c45c18-f9a4-48b4-a941-1298ecc942cb"> |
40+
| [pico-blink-sdk](./pico-blink-sdk) | Raspberry Pi Pico, Pico 2 | Pico SDK | Blink an LED repeatedly with Swift & the Pico SDK. | <img width="300" src="https://github.com/apple/swift-embedded-examples/assets/1186214/f2c45c18-f9a4-48b4-a941-1298ecc942cb"> |
4141
| [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. | <img width="300" src="https://github.com/apple/swift-embedded-examples/assets/26223064/a4949a2e-1887-4325-8f5f-a681963c93d7"> |
42-
| [pico2-neopixel](./pico2-neopixel) | Raspberry Pi Pico2 | None | Control Neopixel LEDs using the RP2350 PIO. | <img width="300" src="pico2-neopixel/assets/images/example.jpg"> |
42+
| [pico2-neopixel](./pico2-neopixel) | Raspberry Pi Pico 2 | None | Control Neopixel LEDs using the RP2350 PIO. | <img width="300" src="pico2-neopixel/assets/images/example.jpg"> |
4343
| [nrfx-blink-sdk](./nrfx-blink-sdk) | nRF52840-DK | Zephyr SDK | Blink an LED repeatedly with Swift & Zephyr. | <img width="300" src="https://github.com/apple/swift-embedded-examples/assets/1186214/ae3ff153-dd33-4460-8a08-4eac442bf7b0"> |
4444
| [esp32-led-strip-sdk](./esp32-led-strip-sdk) | ESP32-C6-DevKitC-1 | ESP-IDF SDK | Control NeoPixel LEDs with Swift & the ESP-IDF. | <img width="300" src="https://github.com/apple/swift-embedded-examples/assets/1186214/15f8a3e0-953e-426d-ad2d-3902baf859be"> |
4545
| [esp32-led-blink-sdk](./esp32-led-blink-sdk) | ESP32-C6-Bug | ESP-IDF SDK | Blink an LED repeatedly with Swift & the ESP-IDF. | <img width="300" src="esp32-led-blink-sdk/assets/images/ledon.jpg"> |

pico-blink-sdk/CMakeLists.txt

+13-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,24 @@ else()
1010
execute_process(COMMAND which swiftc OUTPUT_VARIABLE SWIFTC OUTPUT_STRIP_TRAILING_WHITESPACE)
1111
endif()
1212

13+
14+
set(SWIFT_TARGET "armv6m-none-none-eabi") # default for rp2040
15+
16+
if(PICO_PLATFORM STREQUAL "rp2350-arm-s")
17+
message(STATUS "PICO_PLATFORM is set to rp2350-arm-s, using armv7em")
18+
set(SWIFT_TARGET "armv7em-none-none-eabi")
19+
elseif(PICO_PLATFORM STREQUAL "rp2350-riscv")
20+
# Untested, gives PICO-SDK errors when building
21+
message(WARNING "PICO_PLATFORM is set to rp2350-riscv, using riscv32 (untested). It is recommended to use rp2350-arm-s.")
22+
set(SWIFT_TARGET "riscv32-none-none-eabi")
23+
endif()
24+
1325
add_executable(swift-blinky)
1426
add_custom_command(
1527
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_swiftcode.o
1628
COMMAND
1729
${SWIFTC}
18-
-target armv6m-none-none-eabi -Xcc -mfloat-abi=soft -Xcc -fshort-enums
30+
-target ${SWIFT_TARGET} -Xcc -mfloat-abi=soft -Xcc -fshort-enums
1931
-Xfrontend -function-sections -enable-experimental-feature Embedded -wmo -parse-as-library
2032
$$\( echo '$<TARGET_PROPERTY:swift-blinky,INCLUDE_DIRECTORIES>' | tr '\;' '\\n' | sed -e 's/\\\(.*\\\)/-Xcc -I\\1/g' \)
2133
$$\( echo '${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}' | tr ' ' '\\n' | sed -e 's/\\\(.*\\\)/-Xcc -I\\1/g' \)

pico-blink-sdk/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This example demonstrates how to integrate with the Pico SDK which is using CMak
2424
``` console
2525
$ cd pico-blink-sdk
2626
$ export TOOLCHAINS='<toolchain-identifier>'
27-
$ export PICO_BOARD=pico
27+
$ export PICO_BOARD='<board-name>' # Examples: pico, pico2
2828
$ export PICO_SDK_PATH='<path-to-your-pico-sdk>'
2929
$ export PICO_TOOLCHAIN_PATH='<path-to-the-arm-toolchain>' # A default `brew` install will be located at `/Applications/ArmGNUToolchain/[version]/arm-none-eabi`
3030
$ cmake -B build -G Ninja .

0 commit comments

Comments
 (0)