summaryrefslogtreecommitdiff
path: root/Content/posts/2024-07-03-swift-embedded-pico-w-blink.md
blob: 29ca7acb525dd56ddbf858d366d4b9aff00c825f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
date: 2024-07-01 14:41 
description: Setting up macOS to run Apple's Swift Embedded Example on Raspberry Pi Pico-W
tags: Pico-W, Swift, macOS
---

# Swift Embedded on Pico W

## Pre-requisites

* **Install Embedded Swift Support:** Download and install the latest `main` development snapshot from Swift's [website.](https://www.swift.org/install/macos/#development-snapshots).
* **Install Embedded ARM Toolchain:** `brew install gcc-arm-embeddedc`

## Set up Pico C/C++ SDK

```bash
git clone https://github.com/raspberrypi/pico-sdk
cd pico-sdk
git submodule update --init
export PICO_SDK_PATH=${PWD}
```

*I would recommend adding the following to your ~/.zshrc or ~/.bash_profile*

```bash
export PICO_SDK_PATH=<path>
export PICO_BOARD=pico_w
```

## Apple's Swift Embedded Example

```bash
git clone https://github.com/apple/swift-embedded-examples
cd swift-embedded-examples

python3 -m venv env
source env/bin/activate
python3 -m pip install -r Tools/requirements.txt

cd pico-w-blink-sdk
export PICO_BOARD=pico_w
export TOOLCHAINS="Swift Development Snapshot"
cmake -B build -G Ninja .
```

Now, you can plug your board to your computer while holding down the `BOOTSEL` button. Then, simply copy the `uf2` file

```bash
cp build/swift-blinky.uf2 /Volumes/RPI-RP2
```