Pico blink in pure Swift

In the previous post, we learned how to use Swift embedded to build the blink example using a wrapper for the C++ library. In this post, we’ll learn how to compile and run the blink example written in Swift without using an external library. I suggest you read the previous post for the toolchain installation process.

Follow these steps:

$CLANG Sources/Support/libclang_rt.soft_static_armv6m_macho_embedded.a .build/release/Support.build/{Support.c,crt0.S}.o .build/release/Blinky.build/*.o -target armv6m-apple-none-macho -o $BUILDROOT/blinky $LD_FLAGS

To build:

TOOLCHAINS='<toolchain-name>' ./build.sh

On my mac i have as TOOLCHAINS:

export TOOLCHAINS=$(plutil -extract CFBundleIdentifier raw /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-13-a.xctoolchain/Info.plist)

After the build you can copy the .build/blink.uf2 in your raspberry.

If your mac doesn’t discover the raspberry, disconnect the usb cable, press the bootselect button and reconnect the usb cable.

Now if the example works, start to study the code.

Leave a Comment