Skip to content

Commit

Permalink
remove arduino ide support
Browse files Browse the repository at this point in the history
tcsullivan committed May 28, 2024
1 parent e9566d7 commit 5c72e52
Showing 8 changed files with 15 additions and 62 deletions.
1 change: 0 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -25,7 +25,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"
- name: Build PlatformIO Project (esp32-pcb)
14 changes: 3 additions & 11 deletions noisemeter-device/BUILD.md
Original file line number Diff line number Diff line change
@@ -7,9 +7,7 @@
python certs.py -s api.tracket.info > certs.h
```

2. Copy `config.h.example` to `config.h`; if compiling with the Arduino IDE, edit the file to select your board type.

## Code compiling and upload
## Code compilation and upload

### PlatformIO

@@ -19,14 +17,6 @@ python certs.py -s api.tracket.info > certs.h

3. Run `pio run -t upload` to upload to the device (this also compiles the code if there have been any changes).

### Arduino

1. Install the Arduino IDE and [follow these instructions](https://docs.espressif.com/projects/arduino-esp32/en/latest/installing.html) to add support for ESP32 microcontrollers.

2. Under "Tools" > "Board: " > "ESP32 Arduino", select either "ESP32C3 Dev Module" for the PCB boards or "ESP32-WROOM-DA Module" for the ESP32 breadboard prototype.

3. Compile the sketch and upload it to the device.

## HMAC encryption key

Data stored on the device (e.g. WiFi credentials) are encrypted with an "eFuse" key. This key can only be written once, and is not be read or written after that.
@@ -38,6 +28,8 @@ dd if=/dev/urandom of=hmac_key bs=1 count=32
pio pkg exec -- espefuse.py --port /dev/ttyACM0 burn_key BLOCK4 hmac_key HMAC_UP
```

**Please generate a unique hmac_key for each device.**

## Enable secure download mode

Enabling secure download mode prevents users from using USB/serial download mode to dump memory contents (WiFi credentials and API token):
2 changes: 1 addition & 1 deletion noisemeter-device/Doxyfile
Original file line number Diff line number Diff line change
@@ -1003,7 +1003,7 @@ RECURSIVE = YES
# Note that relative paths are relative to the directory from which doxygen is
# run.

EXCLUDE = doc certs.h secret.h config.h
EXCLUDE = doc certs.h secret.h

# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
# directories that are symbolic links (a Unix file system feature) are excluded
6 changes: 1 addition & 5 deletions noisemeter-device/board.h
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
///
/// Each supported board must have a defined section here to specify the
/// hardware pins and peripherals being used. Selecting a board for
/// compilation is done either through PlatformIO or config.h.
/// compilation is done through PlatformIO.
/* noisemeter-device - Firmware for CivicTechTO's Noisemeter Device
* Copyright (C) 2024 Clyne Sullivan, Nick Barnard
*
@@ -23,8 +23,6 @@
#ifndef BOARD_H
#define BOARD_H

#include "config.h"

#undef SERIAL

#if defined(BOARD_ESP32_PCB)
@@ -52,10 +50,8 @@
/** Serial instance to use for logging output. */
#define SERIAL USBSerial

#if defined(BUILD_PLATFORMIO)
#include <HWCDC.h>
extern HWCDC USBSerial;
#endif

#elif defined(BOARD_ESP32_BREADBOARD)

37 changes: 0 additions & 37 deletions noisemeter-device/config.h.example

This file was deleted.

5 changes: 1 addition & 4 deletions noisemeter-device/noisemeter-device.ino
Original file line number Diff line number Diff line change
@@ -34,13 +34,10 @@
#include <list>
#include <optional>

#if defined(BUILD_PLATFORMIO) && defined(BOARD_ESP32_PCB)
#ifdef BOARD_ESP32_PCB
HWCDC USBSerial;
#endif

// Uncomment these to disable WiFi and/or data upload
//#define UPLOAD_DISABLED

/** Maximum number of seconds to wait for successful WiFi connection. */
constexpr auto WIFI_CONNECT_TIMEOUT_SEC = MIN_TO_SEC(2);
/** Maximum number of seconds to try making new WiFi connection. */
1 change: 0 additions & 1 deletion noisemeter-device/storage.cpp
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "storage.h"

#include <Arduino.h>
11 changes: 9 additions & 2 deletions platformio.ini
Original file line number Diff line number Diff line change
@@ -25,11 +25,18 @@ build_unflags =
-std=gnu++11
build_flags =
-std=gnu++17
-DBUILD_PLATFORMIO
-DNO_GLOBAL_EEPROM
-DNOISEMETER_VERSION=\"0.2.0\"
-DNOISEMETER_VERSION=\"0.2.0\"
-Wall -Wextra

# Optional build flags:
# Print credentials over serial (for debugging):
# -DSTORAGE_SHOW_CREDENTIALS
# Print verbose API logging over serial (for debugging):
# -DAPI_VERBOSE
# Disable WiFi and data upload:
# -DUPLOAD_DISABLED

[env:esp32-pcb]
board = esp32-c3-devkitm-1
board_build.f_cpu = 80000000L

0 comments on commit 5c72e52

Please sign in to comment.