From 6ce90b9949a4712f3b6f0c74bd8d6cce50beccbe Mon Sep 17 00:00:00 2001 From: nakoeppen Date: Fri, 17 Jul 2026 19:58:15 -0500 Subject: [PATCH] Add support for ESP32-S3 --- firmware/ESP32/.gitignore | 3 ++- firmware/ESP32/CMakeLists.txt | 4 ++-- firmware/ESP32/README.md | 7 ++++++- firmware/ESP32/platformio.ini | 8 +++++++- firmware/ESP32/sdkconfig.defaults | 9 +++++++++ firmware/ESP32/src/openhaystack_main.c | 4 ++++ 6 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 firmware/ESP32/sdkconfig.defaults diff --git a/firmware/ESP32/.gitignore b/firmware/ESP32/.gitignore index 4282ed0..8f12b07 100644 --- a/firmware/ESP32/.gitignore +++ b/firmware/ESP32/.gitignore @@ -1,4 +1,5 @@ build/** venv/** .vscode/** -**/*.code-workspace \ No newline at end of file +**/*.code-workspace +sdkconfig.esp32-s3-devkitc-1 diff --git a/firmware/ESP32/CMakeLists.txt b/firmware/ESP32/CMakeLists.txt index 4969c7c..9a333fd 100644 --- a/firmware/ESP32/CMakeLists.txt +++ b/firmware/ESP32/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.5) -set(SUPPORTED_TARGETS esp32) +set(SUPPORTED_TARGETS esp32 esp32s3) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -project(openhaystack) \ No newline at end of file +project(openhaystack) diff --git a/firmware/ESP32/README.md b/firmware/ESP32/README.md index 97ab2e8..6dd5aaf 100644 --- a/firmware/ESP32/README.md +++ b/firmware/ESP32/README.md @@ -1,6 +1,6 @@ ## Macless Haystack Firmware for ESP32 -This project contains a battery-optimzed PoC firmware for Espressif ESP32 chips (like ESP32-WROOM or ESP32-WROVER, but _not_ ESP32-S2). +This project contains a battery-optimzed PoC firmware for Espressif ESP32 chips with BLE support (like ESP32-WROOM, ESP32-WROVER, or ESP32-S3, but _not_ ESP32-S2). After flashing our firmware, the device sends out Bluetooth Low Energy advertisements such that it can be found by [Apple's Find My network](https://developer.apple.com/find-my/). This firmware consumes slightly more power when more than 1 key is used. The controller wakes up every 30 minutes and switches the key. @@ -13,6 +13,11 @@ This firmware consumes slightly more power when more than 1 key is used. The con - Download and unpack the firmware - Copy your previously generated PREFIX_keyfile in the same folder +- For ESP32-S3 builds with PlatformIO, use the `esp32-s3-devkitc-1` environment: + +```bash +pio run -e esp32-s3-devkitc-1 +``` ```bash esptool.py write_flash 0x1000 bootloader.bin \ diff --git a/firmware/ESP32/platformio.ini b/firmware/ESP32/platformio.ini index be03b17..b0bca2d 100644 --- a/firmware/ESP32/platformio.ini +++ b/firmware/ESP32/platformio.ini @@ -15,4 +15,10 @@ framework = espidf monitor_speed = 115200 board_build.partitions = with_key.csv - +[env:esp32-s3-devkitc-1] +platform = espressif32 +board = esp32-s3-devkitc-1 +framework = espidf +monitor_speed = 115200 +board_build.partitions = with_key.csv +board_upload.flash_size = 4MB diff --git a/firmware/ESP32/sdkconfig.defaults b/firmware/ESP32/sdkconfig.defaults new file mode 100644 index 0000000..129d113 --- /dev/null +++ b/firmware/ESP32/sdkconfig.defaults @@ -0,0 +1,9 @@ +CONFIG_BT_ENABLED=y +CONFIG_BT_BLUEDROID_ENABLED=y +# CONFIG_BT_NIMBLE_ENABLED is not set +# CONFIG_BT_CLASSIC_ENABLED is not set +CONFIG_BT_BLE_ENABLED=y +CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y +CONFIG_BT_BLE_42_ADV_EN=y +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" diff --git a/firmware/ESP32/src/openhaystack_main.c b/firmware/ESP32/src/openhaystack_main.c index 4812afb..172536a 100644 --- a/firmware/ESP32/src/openhaystack_main.c +++ b/firmware/ESP32/src/openhaystack_main.c @@ -17,11 +17,13 @@ #include "esp_log.h" #include "esp_sleep.h" #include "esp_random.h" +#include "soc/soc_caps.h" /* Delay between advertisement. Advertisment will only be transmitted for a short period of time (20ms) and the device will go to sleep. Higher delay = less power consumption, but more inaccurate tracking */ #define DELAY_IN_S 60 + /* Define how often (long) a key will be reused after switching to the next one This is for using less keys after all. The interval for one key is (DELAY_IN_S * REUSE_CYCLES => 60s * 30 cycles = changes key every 30 min) Smaller number of cycles = key changes more often, but more keys needed. @@ -167,7 +169,9 @@ void app_main(void) // vTaskDelay(pdMS_TO_TICKS(2000)); ESP_ERROR_CHECK(nvs_flash_init()); +#if SOC_BT_CLASSIC_SUPPORTED ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT)); +#endif esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT(); esp_bt_controller_init(&bt_cfg); esp_bt_controller_enable(ESP_BT_MODE_BLE);