Skip to content

Instantly share code, notes, and snippets.

@beriberikix
Created October 3, 2021 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beriberikix/80904f73272a379008f2cacc0cb67c40 to your computer and use it in GitHub Desktop.
Save beriberikix/80904f73272a379008f2cacc0cb67c40 to your computer and use it in GitHub Desktop.
Golioth speedrun with Zephyr & ESP32-C3 (RISC-V WiSOC)
#!/bin/bash
# demo scripted based on https://github.com/paxtonhare/demo-magic
########################
# include the magic
########################
. demo-magic.sh
# hide the evidence
clear
DEVICE_NAME="PICK_YOUR_DEVICE_NAME"
PSK_ID="PICK_YOUR_PSK_ID"
PSK="PICK_YOUR_PSK"
WIFI_SSID="YOUR_SSID"
WIFI_PASSWORD="YOUR_SSID_PASSWORD"
printf "${CYAN}\nInstall OS deps\n\n${COLOR_RESET}"
brew install cmake ninja gperf python3 ccache qemu dtc
printf "${CYAN}\nCreate virtual environment\n\n${COLOR_RESET}"
python3 -m venv ./.venv
source .venv/bin/activate
printf "${CYAN}\nWest, Zephyr's metatool\n\n${COLOR_RESET}"
pip install west
printf "${CYAN}\nInitialize a Zephyr workspace with Golioth's ESP32-C3 branch\n\n${COLOR_RESET}"
west init -m git@github.com:golioth/zephyr.git --mr esp32c3 ./zephyrproject
cd zephyrproject/
west update
west patch
west zephyr-export
pip install -r ./zephyr/scripts/requirements.txt
printf "${CYAN}\nInstall & enable Espressif toolchain\n\n${COLOR_RESET}"
west espressif install
export ESPRESSIF_TOOLCHAIN_PATH="/Users/jonathanberi/.espressif/tools/zephyr"
export ZEPHYR_TOOLCHAIN_VARIANT="espressif"
printf "${CYAN}\nProvision device with Golioth\n\n${COLOR_RESET}"
goliothctl device list
goliothctl provision --name "${DEVICE_NAME}" --credId "${PSK_ID}" --psk "${PSK}"
printf "${CYAN}\nBuild Golioth 'hello' example\n\n${COLOR_RESET}"
cd modules/lib/golioth/
printf '\nCONFIG_ESP32_WIFI_SSID="%s"\n' ${WIFI_SSID} >> samples/hello/prj.conf
printf 'CONFIG_ESP32_WIFI_PASSWORD="%s"\n' ${WIFI_PASSWORD} >> samples/hello/prj.conf
printf 'CONFIG_GOLIOTH_SYSTEM_CLIENT_PSK_ID="%s"\n' ${PSK_ID} >> samples/hello/prj.conf
printf 'CONFIG_GOLIOTH_SYSTEM_CLIENT_PSK="%s"\n' ${PSK} >> samples/hello/prj.conf
west build -p -b esp32c3_devkitm samples/hello
printf "${CYAN}\nAuto-detect & flash board\n\n${COLOR_RESET}"
west flash
printf "${CYAN}\nCleanup\n\n${COLOR_RESET}"
printf "${CYAN}Delete device with goliothctl device delete --id {ID}:\n${COLOR_RESET}"
goliothctl device list --name "${DEVICE_NAME}"
cd ../../../..
deactivate
rm -rf .venv/ zephyrproject/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment