Skip to content

Commit

Permalink
Merge branch 'main' of github.com:CivicTechTO/tRacket-sensor into 21-…
Browse files Browse the repository at this point in the history
…access-point-dropdown
  • Loading branch information
tcsullivan committed Oct 30, 2024
2 parents 7c633f7 + 0307c10 commit 6ffd9f7
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 65 deletions.
52 changes: 0 additions & 52 deletions .github/workflows/dummy_priv_key.pem

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
- name: Create header files
run: |
cp "${GITHUB_WORKSPACE}/.github/workflows/dummy_priv_key.pem" "${GITHUB_WORKSPACE}/priv_key.pem"
cp "${GITHUB_WORKSPACE}/noisemeter-device/config.h.example" "${GITHUB_WORKSPACE}/noisemeter-device/config.h"
python "${GITHUB_WORKSPACE}/noisemeter-device/certs.py" -s api.tracket.info > "${GITHUB_WORKSPACE}/noisemeter-device/certs.h"
Expand All @@ -33,3 +32,4 @@ jobs:

- name: Build PlatformIO Project (esp32-breadboard)
run: pio run -e esp32-breadboard

42 changes: 42 additions & 0 deletions .github/workflows/ota-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: OTA Release

on:
release:
types: [published]

jobs:
generate:
name: Create release-artifacts
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
path: |
~/.cache/pip
~/.platformio/.cache
key: ${{ runner.os }}-pio
- uses: actions/[email protected]
with:
python-version: '3.9'
- name: Install Python packages
run: |
pip install --upgrade platformio
pip install --upgrade cryptography
- name: Create files
env:
OTA_KEY: ${{ secrets.OTA_SIGNING_KEY }}
run: |
echo "$OTA_KEY" > "${GITHUB_WORKSPACE}/priv_key.pem"
cp "${GITHUB_WORKSPACE}/noisemeter-device/config.h.example" "${GITHUB_WORKSPACE}/noisemeter-device/config.h"
python "${GITHUB_WORKSPACE}/noisemeter-device/certs.py" -s api.tracket.info > "${GITHUB_WORKSPACE}/noisemeter-device/certs.h"
- name: Build signed firmware
run: pio run -t ota -e esp32-pcb

- name: Upload signed firmware
uses: djn24/add-asset-to-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: 'firmware_signed.bin'
13 changes: 13 additions & 0 deletions bringup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
#
# Run this script with a newly manufactured tRacket board connected to give it
# a unique storage encryption key and flash the latest firmware.
# The "tail" command will show the board's UUID; this needs to be added to the
# server for device registration.

dd if=/dev/urandom of=hmac_key bs=1 count=32
echo "BURN" | pio pkg exec -- espefuse.py --port /dev/ttyACM0 burn_key BLOCK4 hmac_key HMAC_UP
rm hmac_key
pio run -t upload
tail -F /dev/ttyACM0

19 changes: 8 additions & 11 deletions build_hooks.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
Import("env")

env.AddPostAction(
"$BUILD_DIR/${PROGNAME}.bin",
env.VerboseAction(
env.AddCustomTarget(
name="ota",
dependencies="$BUILD_DIR/${PROGNAME}.bin",
actions=[
"openssl dgst -sha256 -sign priv_key.pem -keyform PEM -out $BUILD_DIR/${PROGNAME}.sig -binary $BUILD_DIR/${PROGNAME}.bin",
"Creating OTA signature...")
)

env.AddPostAction(
"$BUILD_DIR/${PROGNAME}.bin",
env.VerboseAction(
"cat $BUILD_DIR/${PROGNAME}.sig $BUILD_DIR/${PROGNAME}.bin > ${PROGNAME}_signed.bin",
"Creating ${PROGNAME}_signed.bin")
"cat $BUILD_DIR/${PROGNAME}.sig $BUILD_DIR/${PROGNAME}.bin > ${PROGNAME}_signed.bin"
],
title="OTA Signing",
description="Create a signed OTA update"
)

Binary file added hardware/pcb-rev3/tracket.FCStd
Binary file not shown.
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include_dir = noisemeter-device
default_envs = esp32-pcb

[env]
extra_scripts = post:build_hooks.py
extra_scripts = build_hooks.py
framework = arduino
platform = [email protected]
board_build.partitions = nmpartitions.csv
Expand Down

0 comments on commit 6ffd9f7

Please sign in to comment.