From de35a9dda0b86586dfd33b14295f9c176a9a5e3c Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Fri, 24 Jan 2025 13:21:24 +0100 Subject: [PATCH 01/24] Updated readme --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 12b4807..2a6dc93 100644 --- a/README.md +++ b/README.md @@ -83,9 +83,7 @@ The RNode Firmware supports the following boards: - Homebrew RNodes based on generic ESP32 boards ## Supported Transceiver Modules -The RNode Firmware supports all transceiver modules based on **Semtech SX1276** or **Semtech SX1278** chips, that have an **SPI interface** and expose the **DIO_0** interrupt pin from the chip. - -Support for **SX1262**, **SX1268** and **SX1280** is being implemented. Please support the project with donations if you want this faster! +The RNode Firmware supports all transceiver modules based on Semtech **SX1276**, **SX1278**, **SX1262**, **SX1268** and **SX1280** chips, that have an **SPI interface** and expose the relevant **DIO** interrupt pins from the chip. ## Getting Started Fast You can download and flash the firmware to all the supported boards using the [RNode Config Utility](https://github.com/markqvist/rnodeconfigutil). All firmware releases are now handled and installed directly through the `rnodeconf` utility, which is included in the `rns` package. It can be installed via `pip`: From 149dff2ee25771f26b9331ff09dc875eb69eb3dd Mon Sep 17 00:00:00 2001 From: "jacob.eva" Date: Thu, 30 Jan 2025 16:54:34 +0000 Subject: [PATCH 02/24] Guard against BT power cycle object duplication bug --- Bluetooth.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Bluetooth.h b/Bluetooth.h index bbb0c82..d14284f 100644 --- a/Bluetooth.h +++ b/Bluetooth.h @@ -38,6 +38,7 @@ BLEUart SerialBT(BLE_RX_BUF); BLEDis bledis; BLEBas blebas; + bool SerialBT_init = false; #endif #define BT_PAIRING_TIMEOUT 35000 @@ -511,12 +512,14 @@ char bt_devname[11]; // start device information service bledis.begin(); - SerialBT.bufferTXD(true); // enable buffering + // Guard to ensure SerialBT service is not duplicated through BT being power cycled + if (!SerialBT_init) { + SerialBT.bufferTXD(true); // enable buffering - SerialBT.setPermission(SECMODE_ENC_WITH_MITM, SECMODE_ENC_WITH_MITM); // enable encryption for BLE serial - SerialBT.begin(); - - blebas.begin(); + SerialBT.setPermission(SECMODE_ENC_WITH_MITM, SECMODE_ENC_WITH_MITM); // enable encryption for BLE serial + SerialBT.begin(); + SerialBT_init = true; + } Bluefruit.Advertising.addFlags(BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE); Bluefruit.Advertising.addTxPower(); From bc97e513e8192eb00ba5d7577adf3d20a3a653e6 Mon Sep 17 00:00:00 2001 From: Kevin Brosius Date: Sun, 23 Feb 2025 06:52:27 -0500 Subject: [PATCH 03/24] Initial support for Seeed ESP32S3 with Wio-SX1262 Work in progress Status: Boots, display works on Xiao espansion base, radio is recognized Todo: PMU Firmware hash fails even if generated and then written Radio testing Buttons / LEDs other? --- Boards.h | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++- Utilities.h | 13 ++++++++++- sx126x.cpp | 10 +++++++-- 3 files changed, 82 insertions(+), 4 deletions(-) diff --git a/Boards.h b/Boards.h index adae722..8ba926c 100644 --- a/Boards.h +++ b/Boards.h @@ -65,6 +65,10 @@ #define MODEL_DB 0xDB // LilyGO T-Beam Supreme, 433 MHz #define MODEL_DC 0xDC // LilyGO T-Beam Supreme, 868 MHz + #define PRODUCT_SEEED_XIAO_ESP32S3 0xEB + #define BOARD_SEEED_XIAO_ESP32S3 0x3E + #define MODEL_DD 0xDD + #define PRODUCT_T32_10 0xB2 #define BOARD_LORA32_V1_0 0x39 #define MODEL_BA 0xBA // LilyGO T3 v1.0, 433 MHz @@ -140,6 +144,9 @@ #endif #endif +// test build - KJB +#define BOARD_MODEL BOARD_SEEED_XIAO_ESP32S3 + #define HAS_DISPLAY false #define HAS_BLUETOOTH false #define HAS_BLE false @@ -150,7 +157,8 @@ #define HAS_INPUT false #define HAS_SLEEP false #define PIN_DISP_SLEEP -1 - #define VALIDATE_FIRMWARE true + //#define VALIDATE_FIRMWARE true + #define VALIDATE_FIRMWARE false #if defined(ENABLE_TCXO) #define HAS_TCXO true @@ -593,6 +601,59 @@ #endif #endif + #elif BOARD_MODEL == BOARD_SEEED_XIAO_ESP32S3 + #define IS_ESP32S3 true + #define MODEM SX1262 + #define DIO2_AS_RF_SWITCH true + #define HAS_BUSY true + #define HAS_TCXO true +// #define OCP_TUNED 0x38 + + #define HAS_DISPLAY true +// #define HAS_CONSOLE true + #define HAS_BLUETOOTH false + #define HAS_BLE true +// #define HAS_PMU true + #define HAS_NP false + #define HAS_SD false + #define HAS_EEPROM true + + #define HAS_INPUT false + #define HAS_SLEEP false + +// #define PMU_IRQ 40 +// #define I2C_SCL 41 +// #define I2C_SDA 42 + + const int pin_btn_usr1 = 0; + + const int pin_cs = 41; //16; + const int pin_reset = 42; //14; + const int pin_sclk = 7; //11; + const int pin_mosi = 9; //15; + const int pin_miso = 8; //13; + const int pin_tcxo_enable = -1; + const int pin_dio = 39; //21; + const int pin_busy = 40; //18; + +// const int SD_MISO = 37; +// const int SD_MOSI = 35; +// const int SD_CLK = 36; +// const int SD_CS = 47; + +// const int IMU_CS = 34; + + // HAS LED/tx on board - 47 + #if HAS_NP == false + #if defined(EXTERNAL_LEDS) + const int pin_led_rx = -1; + const int pin_led_tx = 48; //47; + #else + const int pin_led_rx = -1; + const int pin_led_tx = 48; //47; + #endif + #endif + #else #error An unsupported ESP32 board was selected. Cannot compile RNode firmware. #endif diff --git a/Utilities.h b/Utilities.h index e08461f..a9154e4 100644 --- a/Utilities.h +++ b/Utilities.h @@ -285,6 +285,13 @@ uint8_t boot_vector = 0x00; void led_tx_off() { digitalWrite(pin_led_tx, LOW); } void led_id_on() { } void led_id_off() { } + #elif BOARD_MODEL == BOARD_SEEED_XIAO_ESP32S3 + void led_rx_on() { digitalWrite(pin_led_rx, LED_ON); } + void led_rx_off() { digitalWrite(pin_led_rx, LED_OFF); } + void led_tx_on() { } + void led_tx_off() { } + void led_id_on() { } + void led_id_off() { } #elif BOARD_MODEL == BOARD_HUZZAH32 void led_rx_on() { digitalWrite(pin_led_rx, HIGH); } void led_rx_off() { digitalWrite(pin_led_rx, LOW); } @@ -1264,6 +1271,8 @@ void setTXPower() { if (model == MODEL_DB) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); if (model == MODEL_DC) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); + if (model == MODEL_DD) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); + if (model == MODEL_E4) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); if (model == MODEL_E9) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); if (model == MODEL_E3) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); @@ -1467,7 +1476,7 @@ bool eeprom_product_valid() { #if PLATFORM == PLATFORM_AVR if (rval == PRODUCT_RNODE || rval == PRODUCT_HMBRW) { #elif PLATFORM == PLATFORM_ESP32 - if (rval == PRODUCT_RNODE || rval == BOARD_RNODE_NG_20 || rval == BOARD_RNODE_NG_21 || rval == PRODUCT_HMBRW || rval == PRODUCT_TBEAM || rval == PRODUCT_T32_10 || rval == PRODUCT_T32_20 || rval == PRODUCT_T32_21 || rval == PRODUCT_H32_V2 || rval == PRODUCT_H32_V3 || rval == PRODUCT_TDECK_V1 || rval == PRODUCT_TBEAM_S_V1) { + if (rval == PRODUCT_RNODE || rval == BOARD_RNODE_NG_20 || rval == BOARD_RNODE_NG_21 || rval == PRODUCT_HMBRW || rval == PRODUCT_TBEAM || rval == PRODUCT_T32_10 || rval == PRODUCT_T32_20 || rval == PRODUCT_T32_21 || rval == PRODUCT_H32_V2 || rval == PRODUCT_H32_V3 || rval == PRODUCT_TDECK_V1 || rval == PRODUCT_TBEAM_S_V1 || rval == PRODUCT_SEEED_XIAO_ESP32S3) { #elif PLATFORM == PLATFORM_NRF52 if (rval == PRODUCT_RAK4631 || rval == PRODUCT_HELTEC_T114 || rval == PRODUCT_TECHO || rval == PRODUCT_HMBRW) { #else @@ -1503,6 +1512,8 @@ bool eeprom_model_valid() { if (model == MODEL_16 || model == MODEL_17) { #elif BOARD_MODEL == BOARD_TBEAM_S_V1 if (model == MODEL_DB || model == MODEL_DC) { + #elif BOARD_MODEL == BOARD_SEEED_XIAO_ESP32S3 + if (model == MODEL_DD) { #elif BOARD_MODEL == BOARD_LORA32_V1_0 if (model == MODEL_BA || model == MODEL_BB) { #elif BOARD_MODEL == BOARD_LORA32_V2_0 diff --git a/sx126x.cpp b/sx126x.cpp index 4c06862..ebbde43 100644 --- a/sx126x.cpp +++ b/sx126x.cpp @@ -122,12 +122,17 @@ sx126x::sx126x() : { setTimeout(0); } bool sx126x::preInit() { +// delay(300); + //LoRa->reset(); +// reset(); +// delay(100); + pinMode(_ss, OUTPUT); digitalWrite(_ss, HIGH); #if BOARD_MODEL == BOARD_T3S3 || BOARD_MODEL == BOARD_HELTEC32_V3 || BOARD_MODEL == BOARD_TDECK SPI.begin(pin_sclk, pin_miso, pin_mosi, pin_cs); - #elif BOARD_MODEL == BOARD_TECHO + #elif BOARD_MODEL == BOARD_TECHO // || BOARD_MODEL == BOARD_SEEED_XIAO_ESP32S3 SPI.setPins(pin_miso, pin_sclk, pin_mosi); SPI.begin(); #else @@ -146,6 +151,7 @@ bool sx126x::preInit() { break; } delay(100); + Serial.println( uint16_t(syncmsb << 8 | synclsb) ); } if ( uint16_t(syncmsb << 8 | synclsb) != 0x1424 && uint16_t(syncmsb << 8 | synclsb) != 0x4434) { return false; @@ -570,7 +576,7 @@ void sx126x::sleep() { uint8_t byte = 0x00; executeOpcode(OP_SLEEP_6X, &byte, 1) void sx126x::enableTCXO() { #if HAS_TCXO - #if BOARD_MODEL == BOARD_RAK4631 || BOARD_MODEL == BOARD_HELTEC32_V3 + #if BOARD_MODEL == BOARD_RAK4631 || BOARD_MODEL == BOARD_HELTEC32_V3 || BOARD_MODEL == BOARD_SEEED_XIAO_ESP32S3 uint8_t buf[4] = {MODE_TCXO_3_3V_6X, 0x00, 0x00, 0xFF}; #elif BOARD_MODEL == BOARD_TBEAM uint8_t buf[4] = {MODE_TCXO_1_8V_6X, 0x00, 0x00, 0xFF}; From c3fe3713b00e3647bf0693329aedacb52108823d Mon Sep 17 00:00:00 2001 From: Kevin Brosius Date: Sun, 23 Feb 2025 16:57:36 -0500 Subject: [PATCH 04/24] Seeed ESP32S3 - Enable user button, tied to yellow LED on ESP32S3 board. Can be shared, but configure as button input only for now. Top LED for TX indication. --- Boards.h | 12 +++++++++--- Utilities.h | 12 ++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/Boards.h b/Boards.h index 8ba926c..112d2c9 100644 --- a/Boards.h +++ b/Boards.h @@ -146,6 +146,7 @@ // test build - KJB #define BOARD_MODEL BOARD_SEEED_XIAO_ESP32S3 +//#define BOARD_MODEL BOARD_HELTEC32_V3 #define HAS_DISPLAY false #define HAS_BLUETOOTH false @@ -618,14 +619,17 @@ #define HAS_SD false #define HAS_EEPROM true - #define HAS_INPUT false + #define HAS_INPUT true #define HAS_SLEEP false // #define PMU_IRQ 40 // #define I2C_SCL 41 // #define I2C_SDA 42 - const int pin_btn_usr1 = 0; + // Wio-SX1262 button pulls down GPIO21 + // THis is shared with the Yellow LED + // on the ESP32S3 (also active Low) + const int pin_btn_usr1 = 21; const int pin_cs = 41; //16; const int pin_reset = 42; //14; @@ -643,7 +647,9 @@ // const int IMU_CS = 34; - // HAS LED/tx on board - 47 + // HAS LED/tx on Wio board - 48 Hi/ON + // LED 21 on ESP board - Lo/ON/Yellow + // shared with button input. #if HAS_NP == false #if defined(EXTERNAL_LEDS) const int pin_led_rx = -1; diff --git a/Utilities.h b/Utilities.h index a9154e4..7ec1941 100644 --- a/Utilities.h +++ b/Utilities.h @@ -286,10 +286,14 @@ uint8_t boot_vector = 0x00; void led_id_on() { } void led_id_off() { } #elif BOARD_MODEL == BOARD_SEEED_XIAO_ESP32S3 - void led_rx_on() { digitalWrite(pin_led_rx, LED_ON); } - void led_rx_off() { digitalWrite(pin_led_rx, LED_OFF); } - void led_tx_on() { } - void led_tx_off() { } + // tx pin is active high, rx pin is active low.... + // but shared with LED, choose button for now +// void led_rx_on() { pinMode(pin_led_rx, OUTPUT); digitalWrite(pin_led_rx, LOW); } +// void led_rx_off() { digitalWrite(pin_led_rx, HIGH); pinMode(pin_led_rx, INPUT); } + void led_rx_on() { } + void led_rx_off() { } + void led_tx_on() { digitalWrite(pin_led_tx, LED_ON); } + void led_tx_off() { digitalWrite(pin_led_tx, LED_OFF); } void led_id_on() { } void led_id_off() { } #elif BOARD_MODEL == BOARD_HUZZAH32 From cbedd72993dc2e7b32e32a9c8243a8dffa9016aa Mon Sep 17 00:00:00 2001 From: Kevin Brosius Date: Sun, 23 Feb 2025 18:52:17 -0500 Subject: [PATCH 05/24] Seeed ESP32S3 - enable button sleep, stopRadio at sleep to sleep sx1262 also. --- Boards.h | 6 ++++-- RNode_Firmware.ino | 3 ++- sx126x.cpp | 12 +++++++----- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Boards.h b/Boards.h index 112d2c9..f93790f 100644 --- a/Boards.h +++ b/Boards.h @@ -620,8 +620,10 @@ #define HAS_EEPROM true #define HAS_INPUT true - #define HAS_SLEEP false - + #define HAS_SLEEP true + #define PIN_WAKEUP GPIO_NUM_21 + #define WAKEUP_LEVEL 0 + // #define PMU_IRQ 40 // #define I2C_SCL 41 // #define I2C_SDA 42 diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index c2b9886..79bff2f 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -1612,7 +1612,7 @@ void loop() { void sleep_now() { #if HAS_SLEEP == true #if PLATFORM == PLATFORM_ESP32 - #if BOARD_MODEL == BOARD_T3S3 + #if BOARD_MODEL == BOARD_T3S3 || BOARD_MODEL == BOARD_SEEED_XIAO_ESP32S3 display_intensity = 0; update_display(true); #endif @@ -1626,6 +1626,7 @@ void sleep_now() { delay(100); } #endif + stopRadio(); esp_sleep_enable_ext0_wakeup(PIN_WAKEUP, WAKEUP_LEVEL); esp_deep_sleep_start(); #elif PLATFORM == PLATFORM_NRF52 diff --git a/sx126x.cpp b/sx126x.cpp index ebbde43..68bf7b1 100644 --- a/sx126x.cpp +++ b/sx126x.cpp @@ -122,17 +122,19 @@ sx126x::sx126x() : { setTimeout(0); } bool sx126x::preInit() { -// delay(300); - //LoRa->reset(); -// reset(); -// delay(100); + #if BOARD_MODEL == BOARD_SEEED_XIAO_ESP32S3 + // Improve wakeup from sleep + delay(300); + reset(); + delay(100); + #endif pinMode(_ss, OUTPUT); digitalWrite(_ss, HIGH); #if BOARD_MODEL == BOARD_T3S3 || BOARD_MODEL == BOARD_HELTEC32_V3 || BOARD_MODEL == BOARD_TDECK SPI.begin(pin_sclk, pin_miso, pin_mosi, pin_cs); - #elif BOARD_MODEL == BOARD_TECHO // || BOARD_MODEL == BOARD_SEEED_XIAO_ESP32S3 + #elif BOARD_MODEL == BOARD_TECHO SPI.setPins(pin_miso, pin_sclk, pin_mosi); SPI.begin(); #else From 3df940c79158bf9b67c2649f23e3b48947db1b5c Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Thu, 10 Apr 2025 13:02:10 +0200 Subject: [PATCH 06/24] Fixed typo --- Display.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Display.h b/Display.h index 862a2e5..58b96c5 100644 --- a/Display.h +++ b/Display.h @@ -609,7 +609,7 @@ void draw_quality_bars(int px, int py) { } } -#if MODE == SX1280 +#if MODEM == SX1280 #define S_RSSI_MIN -105.0 #define S_RSSI_MAX -65.0 #else From 33dedb202fbba66e3cd411b3217767e8f7c2d67e Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 12 Apr 2025 20:59:00 +0200 Subject: [PATCH 07/24] Cleanup --- Display.h | 2 +- Framing.h | 5 +++++ Makefile | 8 ++++---- esp32_btbufs.py | 7 ++++--- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Display.h b/Display.h index 58b96c5..7062e0d 100644 --- a/Display.h +++ b/Display.h @@ -655,7 +655,7 @@ void draw_waterfall(int px, int py) { if (rssi_val > WF_RSSI_MAX) rssi_val = WF_RSSI_MAX; int rssi_normalised = ((rssi_val - WF_RSSI_MIN)*(1.0/WF_RSSI_SPAN))*WF_PIXEL_WIDTH; if (display_tx) { - for (uint8_t i; i < WF_TX_SIZE; i++) { + for (uint8_t i = 0; i < WF_TX_SIZE; i++) { waterfall[waterfall_head++] = -1; if (waterfall_head >= WATERFALL_SIZE) waterfall_head = 0; } diff --git a/Framing.h b/Framing.h index 89e1039..6dffb98 100644 --- a/Framing.h +++ b/Framing.h @@ -82,6 +82,11 @@ #define CMD_RESET 0x55 #define CMD_RESET_BYTE 0xF8 + #define CMD_LOG 0x70 + #define CMD_TIME 0x70 + #define CMD_MUX_CHAIN 0x80 + #define CMD_MUX_DSCVR 0x81 + #define DETECT_REQ 0x73 #define DETECT_RESP 0x46 diff --git a/Makefile b/Makefile index 2a244ac..13bd23b 100644 --- a/Makefile +++ b/Makefile @@ -192,11 +192,11 @@ upload-heltec32_v2: python ./Release/esptool/esptool.py --chip esp32 --port /dev/ttyUSB1 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin upload-heltec32_v3: - arduino-cli upload -p /dev/ttyUSB1 --fqbn esp32:esp32:heltec_wifi_lora_32_V3 + arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:heltec_wifi_lora_32_V3 @sleep 1 - rnodeconf /dev/ttyUSB1 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.heltec_wifi_lora_32_V3/RNode_Firmware.ino.bin) + rnodeconf /dev/ttyUSB0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.heltec_wifi_lora_32_V3/RNode_Firmware.ino.bin) @sleep 3 - python ./Release/esptool/esptool.py --chip esp32-s3 --port /dev/ttyUSB1 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin + python ./Release/esptool/esptool.py --chip esp32-s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin upload-tdeck: arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:esp32s3 @@ -357,7 +357,7 @@ release-heltec32_v2: check_bt_buffers zip --junk-paths ./Release/rnode_firmware_heltec32v2.zip ./Release/esptool/esptool.py ./Release/console_image.bin build/rnode_firmware_heltec32v2.boot_app0 build/rnode_firmware_heltec32v2.bin build/rnode_firmware_heltec32v2.bootloader build/rnode_firmware_heltec32v2.partitions rm -r build -release-heltec32_v3: +release-heltec32_v3: check_bt_buffers arduino-cli compile --fqbn esp32:esp32:heltec_wifi_lora_32_V3 -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x3A\"" cp ~/.arduino15/packages/esp32/hardware/esp32/$(ARDUINO_ESP_CORE_VER)/tools/partitions/boot_app0.bin build/rnode_firmware_heltec32v3.boot_app0 cp build/esp32.esp32.heltec_wifi_lora_32_V3/RNode_Firmware.ino.bin build/rnode_firmware_heltec32v3.bin diff --git a/esp32_btbufs.py b/esp32_btbufs.py index 8a5b15e..ad0ae70 100755 --- a/esp32_btbufs.py +++ b/esp32_btbufs.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import sys +import re try: target_path = sys.argv[1] @@ -12,7 +13,7 @@ try: for line in sf: line_index += 1 if line.startswith("#define RX_QUEUE_SIZE"): - ents = line.split(" ") + ents = re.sub(" +", " ", line).split(" ") try: rxbuf_size = int(ents[2]) rx_line_index = line_index @@ -20,12 +21,12 @@ try: print(f"Could not parse Bluetooth RX_QUEUE_SIZE: {e}") if line.startswith("#define TX_QUEUE_SIZE"): - ents = line.split(" ") + ents = re.sub(" +", " ", line).split(" ") try: txbuf_size = int(ents[2]) tx_line_index = line_index except Exception as e: - print(f"Could not parse Bluetooth RX_QUEUE_SIZE: {e}") + print(f"Could not parse Bluetooth TX_QUEUE_SIZE: {e}") if rxbuf_size != 0 and txbuf_size != 0: break From f48e99a03378725dc11e31e5a63979642905ed08 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sat, 12 Apr 2025 21:04:32 +0200 Subject: [PATCH 08/24] Re-enable BLE battery service --- Bluetooth.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Bluetooth.h b/Bluetooth.h index 2305dd3..a93a2df 100644 --- a/Bluetooth.h +++ b/Bluetooth.h @@ -524,6 +524,7 @@ char bt_devname[11]; bledis.setModel(BLE_MODEL); // start device information service bledis.begin(); + blebas.begin(); // Guard to ensure SerialBT service is not duplicated through BT being power cycled if (!SerialBT_init) { From 7d868b4db62f49ab96c04f2b699dc8538238cdc5 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 13 Apr 2025 00:11:21 +0200 Subject: [PATCH 09/24] Support for XIAO ESP32S3 --- Boards.h | 59 ++++++++++++++-------------------------------- Display.h | 8 +++++++ Makefile | 10 ++++++++ RNode_Firmware.ino | 17 +++++++++---- Utilities.h | 17 ++++++------- sx126x.cpp | 12 ++-------- sx126x.h | 2 +- 7 files changed, 59 insertions(+), 66 deletions(-) diff --git a/Boards.h b/Boards.h index f93790f..e76e38b 100644 --- a/Boards.h +++ b/Boards.h @@ -65,9 +65,10 @@ #define MODEL_DB 0xDB // LilyGO T-Beam Supreme, 433 MHz #define MODEL_DC 0xDC // LilyGO T-Beam Supreme, 868 MHz - #define PRODUCT_SEEED_XIAO_ESP32S3 0xEB - #define BOARD_SEEED_XIAO_ESP32S3 0x3E - #define MODEL_DD 0xDD + #define PRODUCT_XIAO_S3 0xEB + #define BOARD_XIAO_S3 0x3E + #define MODEL_DE 0xDE // Xiao ESP32S3 with Wio-SX1262 module, 433 MHz + #define MODEL_DD 0xDD // Xiao ESP32S3 with Wio-SX1262 module, 868 MHz #define PRODUCT_T32_10 0xB2 #define BOARD_LORA32_V1_0 0x39 @@ -144,10 +145,6 @@ #endif #endif -// test build - KJB -#define BOARD_MODEL BOARD_SEEED_XIAO_ESP32S3 -//#define BOARD_MODEL BOARD_HELTEC32_V3 - #define HAS_DISPLAY false #define HAS_BLUETOOTH false #define HAS_BLE false @@ -602,19 +599,17 @@ #endif #endif - #elif BOARD_MODEL == BOARD_SEEED_XIAO_ESP32S3 + #elif BOARD_MODEL == BOARD_XIAO_S3 #define IS_ESP32S3 true #define MODEM SX1262 #define DIO2_AS_RF_SWITCH true #define HAS_BUSY true #define HAS_TCXO true -// #define OCP_TUNED 0x38 - #define HAS_DISPLAY true -// #define HAS_CONSOLE true + #define HAS_DISPLAY false + #define HAS_CONSOLE true #define HAS_BLUETOOTH false #define HAS_BLE true -// #define HAS_PMU true #define HAS_NP false #define HAS_SD false #define HAS_EEPROM true @@ -624,41 +619,23 @@ #define PIN_WAKEUP GPIO_NUM_21 #define WAKEUP_LEVEL 0 -// #define PMU_IRQ 40 -// #define I2C_SCL 41 -// #define I2C_SDA 42 - - // Wio-SX1262 button pulls down GPIO21 - // THis is shared with the Yellow LED - // on the ESP32S3 (also active Low) const int pin_btn_usr1 = 21; - - const int pin_cs = 41; //16; - const int pin_reset = 42; //14; - const int pin_sclk = 7; //11; - const int pin_mosi = 9; //15; - const int pin_miso = 8; //13; + const int pin_cs = 41; + const int pin_reset = 42; + const int pin_sclk = 7; + const int pin_mosi = 9; + const int pin_miso = 8; const int pin_tcxo_enable = -1; - const int pin_dio = 39; //21; - const int pin_busy = 40; //18; + const int pin_dio = 39; + const int pin_busy = 40; -// const int SD_MISO = 37; -// const int SD_MOSI = 35; -// const int SD_CLK = 36; -// const int SD_CS = 47; - -// const int IMU_CS = 34; - - // HAS LED/tx on Wio board - 48 Hi/ON - // LED 21 on ESP board - Lo/ON/Yellow - // shared with button input. #if HAS_NP == false #if defined(EXTERNAL_LEDS) - const int pin_led_rx = -1; - const int pin_led_tx = 48; //47; + const int pin_led_rx = 48; + const int pin_led_tx = 48; #else - const int pin_led_rx = -1; - const int pin_led_tx = 48; //47; + const int pin_led_rx = 48; + const int pin_led_tx = 48; #endif #endif diff --git a/Display.h b/Display.h index 7062e0d..c42283c 100644 --- a/Display.h +++ b/Display.h @@ -85,6 +85,12 @@ #define SCL_OLED 18 #define SDA_OLED 17 #define DISP_CUSTOM_ADDR false +#elif BOARD_MODEL == BOARD_XIAO_S3 + #define DISP_RST -1 + #define DISP_ADDR 0x3C + #define SCL_OLED 6 + #define SDA_OLED 5 + #define DISP_CUSTOM_ADDR true #else #define DISP_RST -1 #define DISP_ADDR 0x3C @@ -278,6 +284,8 @@ bool display_init() { #endif #elif BOARD_MODEL == BOARD_TBEAM_S_V1 Wire.begin(SDA_OLED, SCL_OLED); + #elif BOARD_MODEL == BOARD_XIAO_S3 + Wire.begin(SDA_OLED, SCL_OLED); #endif #if HAS_EEPROM diff --git a/Makefile b/Makefile index 13bd23b..8611107 100644 --- a/Makefile +++ b/Makefile @@ -143,6 +143,9 @@ firmware-heltec_t114: firmware-techo: arduino-cli compile --log --fqbn adafruit:nrf52:pca10056 -e --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x44\"" +firmware-xiao_s3: + arduino-cli compile --log --fqbn "esp32:esp32:XIAO_ESP32S3" -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x3E\"" + upload: arduino-cli upload -p /dev/ttyUSB0 --fqbn unsignedio:avr:rnode @@ -255,6 +258,13 @@ upload-techo: @sleep 6 rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes from_device /dev/ttyACM0) +upload-xiao_s3: + arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:XIAO_ESP32S3 + @sleep 1 + rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.XIAO_ESP32S3/RNode_Firmware.ino.bin) +# @sleep 3 +# python ./Release/esptool/esptool.py --chip esp32s3 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin + release: release-all release-all: console-site spiffs-image release-tbeam release-tbeam_sx1262 release-lora32_v10 release-lora32_v20 release-lora32_v21 release-lora32_v10_extled release-lora32_v20_extled release-lora32_v21_extled release-lora32_v21_tcxo release-featheresp32 release-genericesp32 release-heltec32_v2 release-heltec32_v3 release-heltec32_v2_extled release-heltec_t114 release-techo release-rnode_ng_20 release-rnode_ng_21 release-t3s3 release-t3s3_sx127x release-t3s3_sx1280_pa release-tdeck release-tbeam_supreme release-rak4631 release-hashes diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index 79bff2f..a116b3d 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -179,6 +179,13 @@ void setup() { #endif #endif + #if BOARD_MODEL == BOARD_XIAO_S3 + // Improve wakeup from sleep + delay(300); + LoRa->reset(); + delay(100); + #endif + // Check installed transceiver chip and // probe boot parameters. if (LoRa->preInit()) { @@ -1611,10 +1618,13 @@ void loop() { void sleep_now() { #if HAS_SLEEP == true + stopRadio(); // TODO: Check this on all platforms #if PLATFORM == PLATFORM_ESP32 - #if BOARD_MODEL == BOARD_T3S3 || BOARD_MODEL == BOARD_SEEED_XIAO_ESP32S3 - display_intensity = 0; - update_display(true); + #if BOARD_MODEL == BOARD_T3S3 || BOARD_MODEL == BOARD_XIAO_S3 + #if HAS_DISPLAY + display_intensity = 0; + update_display(true); + #endif #endif #if PIN_DISP_SLEEP >= 0 pinMode(PIN_DISP_SLEEP, OUTPUT); @@ -1626,7 +1636,6 @@ void sleep_now() { delay(100); } #endif - stopRadio(); esp_sleep_enable_ext0_wakeup(PIN_WAKEUP, WAKEUP_LEVEL); esp_deep_sleep_start(); #elif PLATFORM == PLATFORM_NRF52 diff --git a/Utilities.h b/Utilities.h index 7ec1941..3d46027 100644 --- a/Utilities.h +++ b/Utilities.h @@ -285,13 +285,9 @@ uint8_t boot_vector = 0x00; void led_tx_off() { digitalWrite(pin_led_tx, LOW); } void led_id_on() { } void led_id_off() { } - #elif BOARD_MODEL == BOARD_SEEED_XIAO_ESP32S3 - // tx pin is active high, rx pin is active low.... - // but shared with LED, choose button for now -// void led_rx_on() { pinMode(pin_led_rx, OUTPUT); digitalWrite(pin_led_rx, LOW); } -// void led_rx_off() { digitalWrite(pin_led_rx, HIGH); pinMode(pin_led_rx, INPUT); } - void led_rx_on() { } - void led_rx_off() { } + #elif BOARD_MODEL == BOARD_XIAO_S3 + void led_rx_on() { digitalWrite(pin_led_rx, LED_ON); } + void led_rx_off() { digitalWrite(pin_led_rx, LED_OFF); } void led_tx_on() { digitalWrite(pin_led_tx, LED_ON); } void led_tx_off() { digitalWrite(pin_led_tx, LED_OFF); } void led_id_on() { } @@ -1276,6 +1272,7 @@ void setTXPower() { if (model == MODEL_DC) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); if (model == MODEL_DD) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); + if (model == MODEL_DE) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); if (model == MODEL_E4) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); if (model == MODEL_E9) LoRa->setTxPower(lora_txp, PA_OUTPUT_PA_BOOST_PIN); @@ -1480,7 +1477,7 @@ bool eeprom_product_valid() { #if PLATFORM == PLATFORM_AVR if (rval == PRODUCT_RNODE || rval == PRODUCT_HMBRW) { #elif PLATFORM == PLATFORM_ESP32 - if (rval == PRODUCT_RNODE || rval == BOARD_RNODE_NG_20 || rval == BOARD_RNODE_NG_21 || rval == PRODUCT_HMBRW || rval == PRODUCT_TBEAM || rval == PRODUCT_T32_10 || rval == PRODUCT_T32_20 || rval == PRODUCT_T32_21 || rval == PRODUCT_H32_V2 || rval == PRODUCT_H32_V3 || rval == PRODUCT_TDECK_V1 || rval == PRODUCT_TBEAM_S_V1 || rval == PRODUCT_SEEED_XIAO_ESP32S3) { + if (rval == PRODUCT_RNODE || rval == BOARD_RNODE_NG_20 || rval == BOARD_RNODE_NG_21 || rval == PRODUCT_HMBRW || rval == PRODUCT_TBEAM || rval == PRODUCT_T32_10 || rval == PRODUCT_T32_20 || rval == PRODUCT_T32_21 || rval == PRODUCT_H32_V2 || rval == PRODUCT_H32_V3 || rval == PRODUCT_TDECK_V1 || rval == PRODUCT_TBEAM_S_V1 || rval == PRODUCT_XIAO_S3) { #elif PLATFORM == PLATFORM_NRF52 if (rval == PRODUCT_RAK4631 || rval == PRODUCT_HELTEC_T114 || rval == PRODUCT_TECHO || rval == PRODUCT_HMBRW) { #else @@ -1516,8 +1513,8 @@ bool eeprom_model_valid() { if (model == MODEL_16 || model == MODEL_17) { #elif BOARD_MODEL == BOARD_TBEAM_S_V1 if (model == MODEL_DB || model == MODEL_DC) { - #elif BOARD_MODEL == BOARD_SEEED_XIAO_ESP32S3 - if (model == MODEL_DD) { + #elif BOARD_MODEL == BOARD_XIAO_S3 + if (model == MODEL_DD || model == MODEL_DE) { #elif BOARD_MODEL == BOARD_LORA32_V1_0 if (model == MODEL_BA || model == MODEL_BB) { #elif BOARD_MODEL == BOARD_LORA32_V2_0 diff --git a/sx126x.cpp b/sx126x.cpp index 68bf7b1..30c22d9 100644 --- a/sx126x.cpp +++ b/sx126x.cpp @@ -122,17 +122,10 @@ sx126x::sx126x() : { setTimeout(0); } bool sx126x::preInit() { - #if BOARD_MODEL == BOARD_SEEED_XIAO_ESP32S3 - // Improve wakeup from sleep - delay(300); - reset(); - delay(100); - #endif - pinMode(_ss, OUTPUT); digitalWrite(_ss, HIGH); - #if BOARD_MODEL == BOARD_T3S3 || BOARD_MODEL == BOARD_HELTEC32_V3 || BOARD_MODEL == BOARD_TDECK + #if BOARD_MODEL == BOARD_T3S3 || BOARD_MODEL == BOARD_HELTEC32_V3 || BOARD_MODEL == BOARD_TDECK || BOARD_MODEL == BOARD_XIAO_S3 SPI.begin(pin_sclk, pin_miso, pin_mosi, pin_cs); #elif BOARD_MODEL == BOARD_TECHO SPI.setPins(pin_miso, pin_sclk, pin_mosi); @@ -153,7 +146,6 @@ bool sx126x::preInit() { break; } delay(100); - Serial.println( uint16_t(syncmsb << 8 | synclsb) ); } if ( uint16_t(syncmsb << 8 | synclsb) != 0x1424 && uint16_t(syncmsb << 8 | synclsb) != 0x4434) { return false; @@ -578,7 +570,7 @@ void sx126x::sleep() { uint8_t byte = 0x00; executeOpcode(OP_SLEEP_6X, &byte, 1) void sx126x::enableTCXO() { #if HAS_TCXO - #if BOARD_MODEL == BOARD_RAK4631 || BOARD_MODEL == BOARD_HELTEC32_V3 || BOARD_MODEL == BOARD_SEEED_XIAO_ESP32S3 + #if BOARD_MODEL == BOARD_RAK4631 || BOARD_MODEL == BOARD_HELTEC32_V3 || BOARD_MODEL == BOARD_XIAO_S3 uint8_t buf[4] = {MODE_TCXO_3_3V_6X, 0x00, 0x00, 0xFF}; #elif BOARD_MODEL == BOARD_TBEAM uint8_t buf[4] = {MODE_TCXO_1_8V_6X, 0x00, 0x00, 0xFF}; diff --git a/sx126x.h b/sx126x.h index 1703a8f..068a1bb 100644 --- a/sx126x.h +++ b/sx126x.h @@ -56,6 +56,7 @@ public: void receive(int size = 0); void standby(); void sleep(); + void reset(void); bool preInit(); uint8_t getTxPower(); @@ -111,7 +112,6 @@ private: void handleLowDataRate(); void optimizeModemSensitivity(); - void reset(void); void calibrate(void); void calibrate_image(long frequency); From e291f3bcaea9b406760d52b03800d767adb3dbf9 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 13 Apr 2025 00:21:43 +0200 Subject: [PATCH 10/24] Added XIAO ESP32S3 to release --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 8611107..59a73dd 100644 --- a/Makefile +++ b/Makefile @@ -485,3 +485,12 @@ release-techo: arduino-cli compile --log --fqbn adafruit:nrf52:pca10056 -e --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x44\"" cp build/adafruit.nrf52.pca10056/RNode_Firmware.ino.hex build/rnode_firmware_techo.hex adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application build/rnode_firmware_techo.hex Release/rnode_firmware_techo.zip + +release-xiao_s3: + arduino-cli compile --fqbn "esp32:esp32:XIAO_ESP32S3" -e --build-property "build.partitions=no_ota" --build-property "upload.maximum_size=2097152" --build-property "compiler.cpp.extra_flags=\"-DBOARD_MODEL=0x3E\"" + cp ~/.arduino15/packages/esp32/hardware/esp32/$(ARDUINO_ESP_CORE_VER)/tools/partitions/boot_app0.bin build/rnode_firmware_xiao_esp32s3.boot_app0 + cp build/esp32.esp32.XIAO_ESP32S3/RNode_Firmware.ino.bin build/rnode_firmware_xiao_esp32s3.bin + cp build/esp32.esp32.XIAO_ESP32S3/RNode_Firmware.ino.bootloader.bin build/rnode_firmware_xiao_esp32s3.bootloader + cp build/esp32.esp32.XIAO_ESP32S3/RNode_Firmware.ino.partitions.bin build/rnode_firmware_xiao_esp32s3.partitions + zip --junk-paths ./Release/rnode_firmware_xiao_esp32s3.zip ./Release/esptool/esptool.py ./Release/console_image.bin build/rnode_firmware_xiao_esp32s3.boot_app0 build/rnode_firmware_xiao_esp32s3.bin build/rnode_firmware_xiao_esp32s3.bootloader build/rnode_firmware_xiao_esp32s3.partitions + rm -r build \ No newline at end of file From 4ba0965931f99bacb37daeaf0d37d0f7894d3b03 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 13 Apr 2025 00:23:11 +0200 Subject: [PATCH 11/24] Updated readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 2a6dc93..253ac31 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,7 @@ The RNode Firmware supports the following boards: - Heltec LoRa32 v3 devices - Heltec T114 devices - RAK4631 devices +- SeeedStudio XIAO ESP32S3 devices (with Wio-SX1262) - Homebrew RNodes based on ATmega1284p boards - Homebrew RNodes based on ATmega2560 boards - Homebrew RNodes based on Adafruit Feather ESP32 boards From 9d2da569c9022496b79170f5fc35e99b2e3c20bb Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 13 Apr 2025 01:28:19 +0200 Subject: [PATCH 12/24] Cleanup --- Boards.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Boards.h b/Boards.h index e76e38b..410afd3 100644 --- a/Boards.h +++ b/Boards.h @@ -155,8 +155,7 @@ #define HAS_INPUT false #define HAS_SLEEP false #define PIN_DISP_SLEEP -1 - //#define VALIDATE_FIRMWARE true - #define VALIDATE_FIRMWARE false + #define VALIDATE_FIRMWARE true #if defined(ENABLE_TCXO) #define HAS_TCXO true From 16dedc72c24acc83a667ff16071ca75142d52a86 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 13 Apr 2025 02:23:01 +0200 Subject: [PATCH 13/24] BLE improvements --- BLESerial.cpp | 8 ++++++++ BLESerial.h | 2 ++ Bluetooth.h | 1 + 3 files changed, 11 insertions(+) diff --git a/BLESerial.cpp b/BLESerial.cpp index 3460a86..80bcaf2 100644 --- a/BLESerial.cpp +++ b/BLESerial.cpp @@ -110,7 +110,10 @@ void BLESerial::begin(const char *name) { BLEDevice::setSecurityCallbacks(this); SetupSerialService(); + this->startAdvertising(); +} +void BLESerial::startAdvertising() { ble_adv = BLEDevice::getAdvertising(); ble_adv->addServiceUUID(BLE_SERIAL_SERVICE_UUID); ble_adv->setMinPreferred(0x20); @@ -119,6 +122,11 @@ void BLESerial::begin(const char *name) { ble_adv->start(); } +void BLESerial::stopAdvertising() { + ble_adv = BLEDevice::getAdvertising(); + ble_adv->stop(); +} + void BLESerial::end() { BLEDevice::deinit(); } void BLESerial::onWrite(BLECharacteristic *characteristic) { diff --git a/BLESerial.h b/BLESerial.h index 7b6d1c6..1dcae99 100644 --- a/BLESerial.h +++ b/BLESerial.h @@ -78,6 +78,8 @@ public: void begin(const char *name); void end(); + void startAdvertising(); + void stopAdvertising(); void onWrite(BLECharacteristic *characteristic); int available(); int peek(); diff --git a/Bluetooth.h b/Bluetooth.h index a93a2df..3d29178 100644 --- a/Bluetooth.h +++ b/Bluetooth.h @@ -266,6 +266,7 @@ char bt_devname[11]; // Serial.println("Authentication fail"); ble_authenticated = false; bt_state = BT_STATE_ON; + bt_update_passkey(); bt_security_setup(); } bt_allow_pairing = false; From 0a95f6f1074b91f7a42d4a0c76ecd5a087798cc7 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 13 Apr 2025 14:45:31 +0200 Subject: [PATCH 14/24] Added nRF hardware RNG --- RNode_Firmware.ino | 16 +++++++++++++--- Utilities.h | 25 ++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index a116b3d..9c5d5ce 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -94,14 +94,24 @@ void setup() { #endif // Seed the PRNG for CSMA R-value selection - # if MCU_VARIANT == MCU_ESP32 + #if MCU_VARIANT == MCU_ESP32 // On ESP32, get the seed value from the // hardware RNG - int seed_val = (int)esp_random(); + unsigned long seed_val = (unsigned long)esp_random(); + #elif MCU_VARIANT == MCU_NRF52 + // On nRF, get the seed value from the + // hardware RNG + unsigned long seed_val = get_rng_seed(); #else // Otherwise, get a pseudo-random seed // value from an unconnected analog pin - int seed_val = analogRead(0); + // + // CAUTION! If you are implementing the + // firmware on a platform that does not + // have a hardware RNG, you MUST take + // care to get a seed value with enough + // entropy at each device reset! + unsigned long seed_val = analogRead(0); #endif randomSeed(seed_val); diff --git a/Utilities.h b/Utilities.h index 3d46027..cfd523c 100644 --- a/Utilities.h +++ b/Utilities.h @@ -18,6 +18,7 @@ #if HAS_EEPROM #include #elif PLATFORM == PLATFORM_NRF52 + #include #include #include using namespace Adafruit_LittleFS_Namespace; @@ -103,6 +104,28 @@ uint8_t boot_vector = 0x00; // TODO: Get NRF52 boot flags #endif +#if MCU_VARIANT == MCU_NRF52 + unsigned long get_rng_seed() { + nrf_rng_error_correction_enable(NRF_RNG); + nrf_rng_shorts_disable(NRF_RNG, NRF_RNG_SHORT_VALRDY_STOP_MASK); + nrf_rng_task_trigger(NRF_RNG, NRF_RNG_TASK_START); + while (!nrf_rng_event_check(NRF_RNG, NRF_RNG_EVENT_VALRDY)); + uint8_t rb_a = nrf_rng_random_value_get(NRF_RNG); + nrf_rng_event_clear(NRF_RNG, NRF_RNG_EVENT_VALRDY); + while (!nrf_rng_event_check(NRF_RNG, NRF_RNG_EVENT_VALRDY)); + uint8_t rb_b = nrf_rng_random_value_get(NRF_RNG); + nrf_rng_event_clear(NRF_RNG, NRF_RNG_EVENT_VALRDY); + while (!nrf_rng_event_check(NRF_RNG, NRF_RNG_EVENT_VALRDY)); + uint8_t rb_c = nrf_rng_random_value_get(NRF_RNG); + nrf_rng_event_clear(NRF_RNG, NRF_RNG_EVENT_VALRDY); + while (!nrf_rng_event_check(NRF_RNG, NRF_RNG_EVENT_VALRDY)); + uint8_t rb_d = nrf_rng_random_value_get(NRF_RNG); + nrf_rng_event_clear(NRF_RNG, NRF_RNG_EVENT_VALRDY); + nrf_rng_task_trigger(NRF_RNG, NRF_RNG_TASK_STOP); + return rb_a << 24 | rb_b << 16 | rb_c << 8 | rb_d; + } +#endif + #if HAS_NP == true #include #define NUMPIXELS 1 @@ -349,7 +372,7 @@ void hard_reset(void) { #elif MCU_VARIANT == MCU_ESP32 ESP.restart(); #elif MCU_VARIANT == MCU_NRF52 - NVIC_SystemReset(); + NVIC_SystemReset(); #endif } From e1a2cc02bbc7358925c98c52d5c588ec37176b59 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 13 Apr 2025 14:47:31 +0200 Subject: [PATCH 15/24] Improved nRF BLE pairing --- Bluetooth.h | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/Bluetooth.h b/Bluetooth.h index 3d29178..6347a45 100644 --- a/Bluetooth.h +++ b/Bluetooth.h @@ -381,6 +381,7 @@ char bt_devname[11]; uint8_t eeprom_read(uint32_t mapped_addr); void bt_stop() { + // Serial.println("BT Stop"); if (bt_state != BT_STATE_OFF) { bt_allow_pairing = false; bt_state = BT_STATE_OFF; @@ -390,16 +391,19 @@ char bt_devname[11]; void bt_flush() { if (bt_state == BT_STATE_CONNECTED) { SerialBT.flushTXD(); } } void bt_disable_pairing() { + // Serial.println("BT Disable pairing"); bt_allow_pairing = false; + pairing_pin = 0; bt_ssp_pin = 0; bt_state = BT_STATE_ON; } void bt_pairing_complete(uint16_t conn_handle, uint8_t auth_status) { + // Serial.println("BT pairing complete"); + BLEConnection* connection = Bluefruit.Connection(conn_handle); if (auth_status == BLE_GAP_SEC_STATUS_SUCCESS) { - BLEConnection* connection = Bluefruit.Connection(conn_handle); - ble_gap_conn_sec_mode_t security = connection->getSecureMode(); + // Serial.println("Bonding success"); // On the NRF52 it is not possible with the Arduino library to reject // requests from devices with no IO capabilities, which would allow @@ -416,21 +420,26 @@ char bt_devname[11]; // Requires investigation. if (security.sm == 1 && security.lv >= 3) { + // Serial.println("Auth level success"); bt_state = BT_STATE_CONNECTED; cable_state = CABLE_STATE_DISCONNECTED; + connection->disconnect(); bt_disable_pairing(); } else { - if (connection->bonded()) { - connection->removeBondKey(); - } + // Serial.println("Auth level failure, debonding"); + if (connection->bonded()) { connection->removeBondKey(); } connection->disconnect(); + bt_disable_pairing(); } } else { - bt_ssp_pin = 0; + // Serial.println("Bonding failure"); + connection->disconnect(); + bt_disable_pairing(); } } bool bt_passkey_callback(uint16_t conn_handle, uint8_t const passkey[6], bool match_request) { + // Serial.println("Passkey callback"); if (bt_allow_pairing) { return true; } @@ -438,6 +447,7 @@ char bt_devname[11]; } void bt_connect_callback(uint16_t conn_handle) { + // Serial.println("Connect callback"); bt_state = BT_STATE_CONNECTED; cable_state = CABLE_STATE_DISCONNECTED; @@ -448,14 +458,16 @@ char bt_devname[11]; } void bt_disconnect_callback(uint16_t conn_handle, uint8_t reason) { + // Serial.println("Disconnect callback"); if (reason != BLE_GAP_SEC_STATUS_SUCCESS) { bt_state = BT_STATE_ON; } } void bt_update_passkey() { - pairing_pin = random(899999)+100000; - bt_ssp_pin = pairing_pin; + // Serial.println("Update passkey"); + pairing_pin = random(899999)+100000; + bt_ssp_pin = pairing_pin; } uint32_t bt_get_passkey() { @@ -465,6 +477,7 @@ char bt_devname[11]; } bool bt_setup_hw() { + // Serial.println("Setup HW"); if (!bt_ready) { #if HAS_EEPROM if (EEPROM.read(eeprom_addr(ADDR_CONF_BT)) == BT_ENABLE_BYTE) { @@ -519,6 +532,7 @@ char bt_devname[11]; } void bt_start() { + // Serial.println("BT Start"); if (bt_state == BT_STATE_OFF) { Bluefruit.setName(bt_devname); bledis.setManufacturer(BLE_MANUFACTURER); @@ -553,6 +567,7 @@ char bt_devname[11]; } bool bt_init() { + // Serial.println("BT init"); bt_state = BT_STATE_OFF; if (bt_setup_hw()) { if (bt_enabled && !console_active) bt_start(); @@ -563,7 +578,14 @@ char bt_devname[11]; } void bt_enable_pairing() { + // Serial.println("BT enable pairing"); if (bt_state == BT_STATE_OFF) bt_start(); + + uint32_t pin = bt_get_passkey(); + char pin_char[6]; + sprintf(pin_char,"%lu", pin); + Bluefruit.Security.setPIN(pin_char); + bt_allow_pairing = true; bt_pairing_started = millis(); bt_state = BT_STATE_PAIRING; From 9ef504392b96173b3772b537f68e860ae601a73a Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 13 Apr 2025 16:56:45 +0200 Subject: [PATCH 16/24] Improved ESP32 BLE pairing. Added unpair command. --- BLESerial.cpp | 11 +++ BLESerial.h | 1 + Bluetooth.h | 169 ++++++++++++++++++++++++--------------------- Framing.h | 9 +-- Makefile | 8 +-- RNode_Firmware.ino | 4 ++ 6 files changed, 116 insertions(+), 86 deletions(-) diff --git a/BLESerial.cpp b/BLESerial.cpp index 80bcaf2..ee3b531 100644 --- a/BLESerial.cpp +++ b/BLESerial.cpp @@ -96,6 +96,17 @@ void BLESerial::flush() { } } +void BLESerial::disconnect() { + if (ble_server->getConnectedCount() > 0) { + uint16_t conn_id = ble_server->getConnId(); + Serial.printf("Have connected: %d\n", conn_id); + ble_server->disconnect(conn_id); + Serial.println("Disconnected"); + } else { + Serial.println("No connected"); + } +} + void BLESerial::begin(const char *name) { ConnectedDeviceCount = 0; BLEDevice::init(name); diff --git a/BLESerial.h b/BLESerial.h index 1dcae99..f845b56 100644 --- a/BLESerial.h +++ b/BLESerial.h @@ -78,6 +78,7 @@ public: void begin(const char *name); void end(); + void disconnect(); void startAdvertising(); void stopAdvertising(); void onWrite(BLECharacteristic *characteristic); diff --git a/Bluetooth.h b/Bluetooth.h index 6347a45..e5165e1 100644 --- a/Bluetooth.h +++ b/Bluetooth.h @@ -170,31 +170,42 @@ char bt_devname[11]; } #elif HAS_BLE == true + bool bt_setup_hw(); void bt_security_setup(); BLESecurity *ble_security = new BLESecurity(); bool ble_authenticated = false; uint32_t pairing_pin = 0; void bt_flush() { if (bt_state == BT_STATE_CONNECTED) { SerialBT.flush(); } } - void bt_disable_pairing() { + void bt_start() { + // Serial.println("BT start"); display_unblank(); - bt_allow_pairing = false; - bt_ssp_pin = 0; - bt_state = BT_STATE_ON; + if (bt_state == BT_STATE_OFF) { + bt_state = BT_STATE_ON; + SerialBT.begin(bt_devname); + SerialBT.setTimeout(10); + } } - void bt_passkey_notify_callback(uint32_t passkey) { - // Serial.printf("Got passkey notification: %d\n", passkey); - bt_ssp_pin = passkey; - bt_state = BT_STATE_PAIRING; - bt_allow_pairing = true; - bt_pairing_started = millis(); - kiss_indicate_btpin(); + void bt_stop() { + // Serial.println("BT stop"); + display_unblank(); + if (bt_state != BT_STATE_OFF) { + bt_allow_pairing = false; + bt_state = BT_STATE_OFF; + SerialBT.end(); + } } - bool bt_confirm_pin_callback(uint32_t pin) { - // Serial.printf("Confirm PIN callback: %d\n", pin); - return true; + bool bt_init() { + // Serial.println("BT init"); + bt_state = BT_STATE_OFF; + if (bt_setup_hw()) { + if (bt_enabled && !console_active) bt_start(); + return true; + } else { + return false; + } } void bt_debond_all() { @@ -206,6 +217,44 @@ char bt_devname[11]; free(dev_list); } + void bt_enable_pairing() { + // Serial.println("BT enable pairing"); + display_unblank(); + if (bt_state == BT_STATE_OFF) bt_start(); + + bt_security_setup(); + + bt_allow_pairing = true; + bt_pairing_started = millis(); + bt_state = BT_STATE_PAIRING; + bt_ssp_pin = pairing_pin; + } + + void bt_disable_pairing() { + // Serial.println("BT disable pairing"); + display_unblank(); + bt_allow_pairing = false; + bt_ssp_pin = 0; + bt_state = BT_STATE_ON; + } + + void bt_passkey_notify_callback(uint32_t passkey) { + // Serial.printf("Got passkey notification: %d\n", passkey); + if (bt_allow_pairing) { + bt_ssp_pin = passkey; + bt_pairing_started = millis(); + kiss_indicate_btpin(); + } else { + // Serial.println("Pairing not allowed, re-init"); + SerialBT.disconnect(); + } + } + + bool bt_confirm_pin_callback(uint32_t pin) { + // Serial.printf("Confirm PIN callback: %d\n", pin); + return true; + } + void bt_update_passkey() { // Serial.println("Updating passkey"); pairing_pin = random(899999)+100000; @@ -222,31 +271,6 @@ char bt_devname[11]; return ble_authenticated; } - void bt_security_setup() { - uint32_t passkey = bt_passkey_callback(); - - // Serial.printf("Executing BT security setup, passkey is %d\n", passkey); - - uint8_t key_size = 16; - uint8_t init_key = ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK; - uint8_t rsp_key = ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK; - - esp_ble_auth_req_t auth_req = ESP_LE_AUTH_REQ_SC_MITM_BOND; - uint8_t auth_option = ESP_BLE_ONLY_ACCEPT_SPECIFIED_AUTH_ENABLE; - uint8_t oob_support = ESP_BLE_OOB_DISABLE; - - esp_ble_io_cap_t iocap = ESP_IO_CAP_OUT; - - esp_ble_gap_set_security_param(ESP_BLE_SM_SET_STATIC_PASSKEY, &passkey, sizeof(uint32_t)); - esp_ble_gap_set_security_param(ESP_BLE_SM_AUTHEN_REQ_MODE, &auth_req, sizeof(uint8_t)); - esp_ble_gap_set_security_param(ESP_BLE_SM_IOCAP_MODE, &iocap, sizeof(uint8_t)); - esp_ble_gap_set_security_param(ESP_BLE_SM_MAX_KEY_SIZE, &key_size, sizeof(uint8_t)); - esp_ble_gap_set_security_param(ESP_BLE_SM_ONLY_ACCEPT_SPECIFIED_SEC_AUTH, &auth_option, sizeof(uint8_t)); - esp_ble_gap_set_security_param(ESP_BLE_SM_OOB_SUPPORT, &oob_support, sizeof(uint8_t)); - esp_ble_gap_set_security_param(ESP_BLE_SM_SET_INIT_KEY, &init_key, sizeof(uint8_t)); - esp_ble_gap_set_security_param(ESP_BLE_SM_SET_RSP_KEY, &rsp_key, sizeof(uint8_t)); - } - bool bt_security_request_callback() { if (bt_allow_pairing) { // Serial.println("Accepting security request"); @@ -261,7 +285,10 @@ char bt_devname[11]; if (auth_result.success == true) { // Serial.println("Authentication success"); ble_authenticated = true; - bt_state = BT_STATE_CONNECTED; + if (bt_state == BT_STATE_PAIRING) { + // Serial.println("Pairing complete, disconnecting"); + delay(2000); SerialBT.disconnect(); + } else { bt_state = BT_STATE_CONNECTED; } } else { // Serial.println("Authentication fail"); ble_authenticated = false; @@ -274,16 +301,16 @@ char bt_devname[11]; } void bt_connect_callback(BLEServer *server) { - // uint16_t conn_id = server->getConnId(); + uint16_t conn_id = server->getConnId(); // Serial.printf("Connected: %d\n", conn_id); display_unblank(); ble_authenticated = false; - bt_state = BT_STATE_CONNECTED; + if (bt_state != BT_STATE_PAIRING) { bt_state = BT_STATE_CONNECTED; } cable_state = CABLE_STATE_DISCONNECTED; } void bt_disconnect_callback(BLEServer *server) { - // uint16_t conn_id = server->getConnId(); + uint16_t conn_id = server->getConnId(); // Serial.printf("Disconnected: %d\n", conn_id); display_unblank(); ble_authenticated = false; @@ -291,6 +318,7 @@ char bt_devname[11]; } bool bt_setup_hw() { + // Serial.println("BT setup hw"); if (!bt_ready) { if (EEPROM.read(eeprom_addr(ADDR_CONF_BT)) == BT_ENABLE_BYTE) { bt_enabled = true; @@ -322,45 +350,30 @@ char bt_devname[11]; } else { return false; } } - void bt_start() { - display_unblank(); - if (bt_state == BT_STATE_OFF) { - bt_state = BT_STATE_ON; - SerialBT.begin(bt_devname); - SerialBT.setTimeout(10); - } - } + void bt_security_setup() { + // Serial.println("Executing BT security setup"); + if (pairing_pin == 0) { bt_update_passkey(); } + uint32_t passkey = pairing_pin; + // Serial.printf("Passkey is %d\n", passkey); - void bt_stop() { - display_unblank(); - if (bt_state != BT_STATE_OFF) { - bt_allow_pairing = false; - bt_state = BT_STATE_OFF; - SerialBT.end(); - } - } + uint8_t key_size = 16; + uint8_t init_key = ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK; + uint8_t rsp_key = ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK; - bool bt_init() { - bt_state = BT_STATE_OFF; - if (bt_setup_hw()) { - if (bt_enabled && !console_active) bt_start(); - return true; - } else { - return false; - } - } + esp_ble_auth_req_t auth_req = ESP_LE_AUTH_REQ_SC_MITM_BOND; + uint8_t auth_option = ESP_BLE_ONLY_ACCEPT_SPECIFIED_AUTH_ENABLE; + uint8_t oob_support = ESP_BLE_OOB_DISABLE; - void bt_enable_pairing() { - display_unblank(); - if (bt_state == BT_STATE_OFF) bt_start(); + esp_ble_io_cap_t iocap = ESP_IO_CAP_OUT; - bt_security_setup(); - //bt_debond_all(); - //bt_update_passkey(); - - bt_allow_pairing = true; - bt_pairing_started = millis(); - bt_state = BT_STATE_PAIRING; + esp_ble_gap_set_security_param(ESP_BLE_SM_SET_STATIC_PASSKEY, &passkey, sizeof(uint32_t)); + esp_ble_gap_set_security_param(ESP_BLE_SM_AUTHEN_REQ_MODE, &auth_req, sizeof(uint8_t)); + esp_ble_gap_set_security_param(ESP_BLE_SM_IOCAP_MODE, &iocap, sizeof(uint8_t)); + esp_ble_gap_set_security_param(ESP_BLE_SM_MAX_KEY_SIZE, &key_size, sizeof(uint8_t)); + esp_ble_gap_set_security_param(ESP_BLE_SM_ONLY_ACCEPT_SPECIFIED_SEC_AUTH, &auth_option, sizeof(uint8_t)); + esp_ble_gap_set_security_param(ESP_BLE_SM_OOB_SUPPORT, &oob_support, sizeof(uint8_t)); + esp_ble_gap_set_security_param(ESP_BLE_SM_SET_INIT_KEY, &init_key, sizeof(uint8_t)); + esp_ble_gap_set_security_param(ESP_BLE_SM_SET_RSP_KEY, &rsp_key, sizeof(uint8_t)); } void update_bt() { diff --git a/Framing.h b/Framing.h index 6dffb98..9346f70 100644 --- a/Framing.h +++ b/Framing.h @@ -61,6 +61,7 @@ #define CMD_DISP_RCND 0x68 #define CMD_NP_INT 0x65 #define CMD_BT_CTRL 0x46 + #define CMD_BT_UNPAIR 0x70 #define CMD_BT_PIN 0x62 #define CMD_DIS_IA 0x69 @@ -82,10 +83,10 @@ #define CMD_RESET 0x55 #define CMD_RESET_BYTE 0xF8 - #define CMD_LOG 0x70 - #define CMD_TIME 0x70 - #define CMD_MUX_CHAIN 0x80 - #define CMD_MUX_DSCVR 0x81 + #define CMD_LOG 0x80 + #define CMD_TIME 0x81 + #define CMD_MUX_CHAIN 0x82 + #define CMD_MUX_DSCVR 0x83 #define DETECT_REQ 0x73 #define DETECT_RESP 0x46 diff --git a/Makefile b/Makefile index 59a73dd..c17bf38 100644 --- a/Makefile +++ b/Makefile @@ -198,8 +198,8 @@ upload-heltec32_v3: arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:heltec_wifi_lora_32_V3 @sleep 1 rnodeconf /dev/ttyUSB0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.heltec_wifi_lora_32_V3/RNode_Firmware.ino.bin) - @sleep 3 - python ./Release/esptool/esptool.py --chip esp32-s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin +# @sleep 3 +# python ./Release/esptool/esptool.py --chip esp32-s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin upload-tdeck: arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:esp32s3 @@ -233,8 +233,8 @@ upload-t3s3: arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:esp32s3 @sleep 1 rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.esp32s3/RNode_Firmware.ino.bin) - @sleep 3 - python ./Release/esptool/esptool.py --chip esp32s3 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin +# @sleep 3 +# python ./Release/esptool/esptool.py --chip esp32s3 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin upload-featheresp32: arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:featheresp32 diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index 9c5d5ce..24e10a2 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -1144,6 +1144,10 @@ void serial_callback(uint8_t sbyte) { } } #endif + } else if (command == CMD_BT_UNPAIR) { + #if HAS_BLE + if (sbyte == 0x01) { bt_debond_all(); } + #endif } else if (command == CMD_DISP_INT) { #if HAS_DISPLAY if (sbyte == FESC) { From e0fc80f2cba531f644fd8b1799dd9c30b52b3196 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 13 Apr 2025 17:32:29 +0200 Subject: [PATCH 17/24] Cleanup --- BLESerial.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/BLESerial.cpp b/BLESerial.cpp index ee3b531..2957755 100644 --- a/BLESerial.cpp +++ b/BLESerial.cpp @@ -99,11 +99,11 @@ void BLESerial::flush() { void BLESerial::disconnect() { if (ble_server->getConnectedCount() > 0) { uint16_t conn_id = ble_server->getConnId(); - Serial.printf("Have connected: %d\n", conn_id); + // Serial.printf("Have connected: %d\n", conn_id); ble_server->disconnect(conn_id); - Serial.println("Disconnected"); + // Serial.println("Disconnected"); } else { - Serial.println("No connected"); + // Serial.println("No connected"); } } From c56df7e8b5506fe78daf9662465bd0cdd288b162 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 13 Apr 2025 17:54:17 +0200 Subject: [PATCH 18/24] Updated version --- Config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Config.h b/Config.h index d827b68..9df3c47 100644 --- a/Config.h +++ b/Config.h @@ -20,7 +20,7 @@ #define CONFIG_H #define MAJ_VERS 0x01 - #define MIN_VERS 0x51 + #define MIN_VERS 0x52 #define MODE_HOST 0x11 #define MODE_TNC 0x12 From d80f866418b538e02cdba847a3dce2e4ed11f8f1 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Sun, 13 Apr 2025 18:46:20 +0200 Subject: [PATCH 19/24] Cleanup --- Bluetooth.h | 2 ++ Makefile | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Bluetooth.h b/Bluetooth.h index e5165e1..616c4b6 100644 --- a/Bluetooth.h +++ b/Bluetooth.h @@ -605,6 +605,8 @@ char bt_devname[11]; kiss_indicate_btpin(); } + void bt_debond_all() { } + void update_bt() { if (bt_allow_pairing && millis()-bt_pairing_started >= BT_PAIRING_TIMEOUT) { bt_disable_pairing(); diff --git a/Makefile b/Makefile index c17bf38..ceec2eb 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,10 @@ # along with this program. If not, see . # Version 2.0.17 of the Arduino ESP core is based on ESP-IDF v4.4.7 -ARDUINO_ESP_CORE_VER = 2.0.17 +# ARDUINO_ESP_CORE_VER = 2.0.17 + +# Version 3.2.0 of the Arduino ESP core is based on ESP-IDF v5.4.1 +ARDUINO_ESP_CORE_VER = 3.2.0 all: release From e157f82b8e8ac6f3d3f7ec54181aaea2b81988ed Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 15 Apr 2025 16:26:16 +0200 Subject: [PATCH 20/24] Cleanup --- RNode_Firmware.ino | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RNode_Firmware.ino b/RNode_Firmware.ino index 24e10a2..d2437f1 100644 --- a/RNode_Firmware.ino +++ b/RNode_Firmware.ino @@ -125,6 +125,10 @@ void setup() { led_init(); #endif + #if MCU_VARIANT == MCU_NRF52 && HAS_NP == true + boot_seq(); + #endif + #if BOARD_MODEL != BOARD_RAK4631 && BOARD_MODEL != BOARD_HELTEC_T114 && BOARD_MODEL != BOARD_TECHO && BOARD_MODEL != BOARD_T3S3 && BOARD_MODEL != BOARD_TBEAM_S_V1 // Some boards need to wait until the hardware UART is set up before booting // the full firmware. In the case of the RAK4631 and Heltec T114, the line below will wait From 1ec84743f4e78647ac42fb5c8c8631aca2a388f7 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 15 Apr 2025 16:27:01 +0200 Subject: [PATCH 21/24] Cleanup --- Makefile | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index ceec2eb..444d3b2 100644 --- a/Makefile +++ b/Makefile @@ -14,10 +14,10 @@ # along with this program. If not, see . # Version 2.0.17 of the Arduino ESP core is based on ESP-IDF v4.4.7 -# ARDUINO_ESP_CORE_VER = 2.0.17 +ARDUINO_ESP_CORE_VER = 2.0.17 # Version 3.2.0 of the Arduino ESP core is based on ESP-IDF v5.4.1 -ARDUINO_ESP_CORE_VER = 3.2.0 +# ARDUINO_ESP_CORE_VER = 3.2.0 all: release @@ -201,8 +201,8 @@ upload-heltec32_v3: arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:heltec_wifi_lora_32_V3 @sleep 1 rnodeconf /dev/ttyUSB0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.heltec_wifi_lora_32_V3/RNode_Firmware.ino.bin) -# @sleep 3 -# python ./Release/esptool/esptool.py --chip esp32-s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin + @sleep 3 + python ./Release/esptool/esptool.py --chip esp32-s3 --port /dev/ttyUSB0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin upload-tdeck: arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:esp32s3 @@ -236,8 +236,8 @@ upload-t3s3: arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:esp32s3 @sleep 1 rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.esp32s3/RNode_Firmware.ino.bin) -# @sleep 3 -# python ./Release/esptool/esptool.py --chip esp32s3 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin + @sleep 3 + python ./Release/esptool/esptool.py --chip esp32s3 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin upload-featheresp32: arduino-cli upload -p /dev/ttyUSB0 --fqbn esp32:esp32:featheresp32 @@ -265,8 +265,8 @@ upload-xiao_s3: arduino-cli upload -p /dev/ttyACM0 --fqbn esp32:esp32:XIAO_ESP32S3 @sleep 1 rnodeconf /dev/ttyACM0 --firmware-hash $$(./partition_hashes ./build/esp32.esp32.XIAO_ESP32S3/RNode_Firmware.ino.bin) -# @sleep 3 -# python ./Release/esptool/esptool.py --chip esp32s3 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin + @sleep 3 + python ./Release/esptool/esptool.py --chip esp32s3 --port /dev/ttyACM0 --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 80m --flash_size 4MB 0x210000 ./Release/console_image.bin release: release-all From dd35c067b42d5a994623659f0b8ab26062b9fdec Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 15 Apr 2025 16:28:02 +0200 Subject: [PATCH 22/24] Updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 253ac31..cd424d4 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ The RNode system is primarily software, which *transforms* different kinds of av ## Latest Release -The latest release, installable through `rnodeconf`, is version `1.81`. You must have at least version `2.4.0` of `rnodeconf` installed to update the RNode Firmware to version `1.81`. Get it by updating the `rns` package to at least version `0.9.0`. +The latest release, installable through `rnodeconf`, is version `1.82`. You must have at least version `2.4.1` of `rnodeconf` installed to update the RNode Firmware to version `1.82`. Get it by updating the `rns` package to at least version `0.9.4`. ## A Self-Replicating System From 23c580d0df859b18ea952e6ae251a9dd8e38ba48 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 15 Apr 2025 16:45:24 +0200 Subject: [PATCH 23/24] Cleanup --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 444d3b2..b6f5a7b 100644 --- a/Makefile +++ b/Makefile @@ -270,7 +270,7 @@ upload-xiao_s3: release: release-all -release-all: console-site spiffs-image release-tbeam release-tbeam_sx1262 release-lora32_v10 release-lora32_v20 release-lora32_v21 release-lora32_v10_extled release-lora32_v20_extled release-lora32_v21_extled release-lora32_v21_tcxo release-featheresp32 release-genericesp32 release-heltec32_v2 release-heltec32_v3 release-heltec32_v2_extled release-heltec_t114 release-techo release-rnode_ng_20 release-rnode_ng_21 release-t3s3 release-t3s3_sx127x release-t3s3_sx1280_pa release-tdeck release-tbeam_supreme release-rak4631 release-hashes +release-all: release-tbeam release-tbeam_sx1262 release-lora32_v10 release-lora32_v20 release-lora32_v21 release-lora32_v10_extled release-lora32_v20_extled release-lora32_v21_extled release-lora32_v21_tcxo release-featheresp32 release-genericesp32 release-heltec32_v2 release-heltec32_v3 release-heltec32_v2_extled release-heltec_t114 release-techo release-rnode_ng_20 release-rnode_ng_21 release-t3s3 release-t3s3_sx127x release-t3s3_sx1280_pa release-tdeck release-tbeam_supreme release-rak4631 release-xiao_s3 release-hashes release-hashes: python ./release_hashes.py > ./Release/release.json From fff96fb5c0f6e14f948ec2d92c408ae2cc1ddb65 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Tue, 29 Apr 2025 11:48:02 +0200 Subject: [PATCH 24/24] Updated readme --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index cd424d4..d6cf721 100644 --- a/README.md +++ b/README.md @@ -120,16 +120,17 @@ You can help support the continued development of open, free and private communi ``` 84FpY1QbxHcgdseePYNmhTHcrgMX4nFfBYtz2GKYToqHVVhJp8Eaw1Z1EedRnKD19b3B8NiLCGVxzKV17UMmmeEsCrPyA5w ``` -- Ethereum - ``` - 0xFDabC71AC4c0C78C95aDDDe3B4FA19d6273c5E73 - ``` - Bitcoin ``` - 35G9uWVzrpJJibzUwpNUQGQNFzLirhrYAH + bc1p4a6axuvl7n9hpapfj8sv5reqj8kz6uxa67d5en70vzrttj0fmcusgxsfk5 + ``` +- Ethereum + ``` + 0xae89F3B94fC4AD6563F0864a55F9a697a90261ff ``` - Ko-Fi: https://ko-fi.com/markqvist + ## License & Use The RNode Firmware is Copyright © 2024 Mark Qvist / [unsigned.io](https://unsigned.io), and is made available under the **GNU General Public License v3.0**. The source code includes an SX1276 driver that is released under MIT License, and Copyright © 2018 Sandeep Mistry / Mark Qvist.