Can I program an ESP32C6 with the Swift example code?

This article is part of a series.

So the crazy thing is how much easier this process was than last year getting Swift up and running on the picow.

Between the improved SwiftLang embedded docs and example repo, Swiftly being available on the Mac, espressif support… a comparative cake walk. Seeed also gives a shout out on how to use Swift with this exact board, but its docs are little behind. Not because they’re slow to update, just because things have moved that fast.

Run an Example

It is still recommended to use a development chain which is now easy to get with Swiftly.

The below are the commands only from a article from espressif with only a couple of tweaks, it assumes there is a working esp-idf installed, but that hasn’t already been loaded into the shell.

Also, provided in that article is a Wokwi demo, which is a very very nice touch!

## Locate the esp-idf install, if haven't added alias to shell
## assumes it lives in user root. 
. $HOME/esp/esp-idf/export.sh
# brew install swiftly
## Install Swift 6.2 development snapshot and switch to it when done
swiftly install --use 6.2-snapshot 
## put this where you want it:
git clone https://github.com/swiftlang/swift-embedded-examples.git --single-branch --branch main
## change into example folder
cd swift-embedded-examples/esp32-led-strip-sdk

## set the target for the project
idf.py set-target esp32c6
## build and run
idf.py build flash monitor
# Use Ctrl+] to quit the monitor application.

For me it just worked! Whew! That was nice!

Optional Environment Improvement, add alias for esp-idf

Consider adding an alias to make loading in the location of the esp-idf tools easier. from the docs:

Copy and paste the following command to your shell’s profile (.profile, .bashrc, .zprofile, etc.)

alias get_idf='. $HOME/esp/esp-idf/export.sh'

Refresh the configuration by restarting the terminal session or by running source [path to profile], for example, source ~/.bashrc. Now you can run get_idf to set up or refresh the esp-idf environment in any terminal session.


## Summary

So there are two things on deck for me next

A. get a switch working
B. reorganize the code

And I'm not sure which one I'm going to prioritize so I'll save it for the next post. 

This article is part of a series.