From 1640fb105dad55a1d227d3978da1342fb8059ec5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sat, 15 Mar 2025 14:15:35 +0100 Subject: [PATCH 01/12] new device: Lilygo T-Eth-Elite (#6321) --- src/DebugConfiguration.h | 9 +++- src/Power.cpp | 5 ++ src/gps/GPS.cpp | 6 ++- src/main.cpp | 4 +- src/mesh/InterfacesTemplates.cpp | 2 +- src/mesh/api/WiFiServerAPI.h | 5 ++ src/mesh/api/ethServerAPI.cpp | 2 +- src/mesh/api/ethServerAPI.h | 2 + src/mesh/http/WebServer.cpp | 9 +++- src/mesh/udp/UdpMulticastThread.h | 5 ++ src/mesh/wifi/WiFiAPClient.cpp | 48 +++++++++++++++-- src/mesh/wifi/WiFiAPClient.h | 12 ++++- src/modules/AdminModule.cpp | 2 +- src/mqtt/MQTT.cpp | 9 ++++ src/mqtt/MQTT.h | 2 +- src/platform/esp32/architecture.h | 2 + src/platform/esp32/main-esp32.cpp | 4 +- variants/t-eth-elite/pins_arduino.h | 26 +++++++++ variants/t-eth-elite/platformio.ini | 16 ++++++ variants/t-eth-elite/rfswitch.h | 11 ++++ variants/t-eth-elite/variant.h | 83 +++++++++++++++++++++++++++++ 21 files changed, 247 insertions(+), 17 deletions(-) create mode 100644 variants/t-eth-elite/pins_arduino.h create mode 100644 variants/t-eth-elite/platformio.ini create mode 100644 variants/t-eth-elite/rfswitch.h create mode 100644 variants/t-eth-elite/variant.h diff --git a/src/DebugConfiguration.h b/src/DebugConfiguration.h index 7987e7fa1..a34710eb0 100644 --- a/src/DebugConfiguration.h +++ b/src/DebugConfiguration.h @@ -121,10 +121,15 @@ extern "C" void logLegacy(const char *level, const char *fmt, ...); // Default Bluetooth PIN #define defaultBLEPin 123456 -#if HAS_ETHERNET +#if HAS_ETHERNET && !defined(USE_WS5500) #include #endif // HAS_ETHERNET +#if HAS_ETHERNET && defined(USE_WS5500) +#include +#define ETH ETH2 +#endif // HAS_ETHERNET + #if HAS_WIFI #include #endif // HAS_WIFI @@ -164,4 +169,4 @@ class Syslog bool vlogf(uint16_t pri, const char *appName, const char *fmt, va_list args) __attribute__((format(printf, 3, 0))); }; -#endif // HAS_ETHERNET || HAS_WIFI \ No newline at end of file +#endif // HAS_NETWORKING \ No newline at end of file diff --git a/src/Power.cpp b/src/Power.cpp index 8d5fe1c32..5768e9908 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -32,6 +32,11 @@ #include #endif +#if HAS_ETHERNET && defined(USE_WS5500) +#include +#define ETH ETH2 +#endif // HAS_ETHERNET + #endif #ifndef DELAY_FOREVER diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 7dcb77fcc..7f490ea3c 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -1104,12 +1104,16 @@ int32_t GPS::runOnce() return (powerState == GPS_ACTIVE) ? GPS_THREAD_INTERVAL : 5000; } -// clear the GPS rx buffer as quickly as possible +// clear the GPS rx/tx buffer as quickly as possible void GPS::clearBuffer() { +#ifdef ARCH_ESP32 + _serial_gps->flush(false); +#else int x = _serial_gps->available(); while (x--) _serial_gps->read(); +#endif } /// Prepare the GPS for the cpu entering deep or light sleep, expect to be gone for at least 100s of msecs diff --git a/src/main.cpp b/src/main.cpp index 4634c7c14..797d911d1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -55,12 +55,12 @@ NimbleBluetooth *nimbleBluetooth = nullptr; NRF52Bluetooth *nrf52Bluetooth = nullptr; #endif -#if HAS_WIFI +#if HAS_WIFI || defined(USE_WS5500) #include "mesh/api/WiFiServerAPI.h" #include "mesh/wifi/WiFiAPClient.h" #endif -#if HAS_ETHERNET +#if HAS_ETHERNET && !defined(USE_WS5500) #include "mesh/api/ethServerAPI.h" #include "mesh/eth/ethClient.h" #endif diff --git a/src/mesh/InterfacesTemplates.cpp b/src/mesh/InterfacesTemplates.cpp index 2720e8525..57abbf0ee 100644 --- a/src/mesh/InterfacesTemplates.cpp +++ b/src/mesh/InterfacesTemplates.cpp @@ -25,7 +25,7 @@ template class LR11x0Interface; template class SX126xInterface; #endif -#if HAS_ETHERNET +#if HAS_ETHERNET && !defined(USE_WS5500) #include "api/ethServerAPI.h" template class ServerAPI; template class APIServerPort; diff --git a/src/mesh/api/WiFiServerAPI.h b/src/mesh/api/WiFiServerAPI.h index 6e60bb678..5f2019983 100644 --- a/src/mesh/api/WiFiServerAPI.h +++ b/src/mesh/api/WiFiServerAPI.h @@ -3,6 +3,11 @@ #include "ServerAPI.h" #include +#if HAS_ETHERNET && defined(USE_WS5500) +#include +#define ETH ETH2 +#endif // HAS_ETHERNET + /** * Provides both debug printing and, if the client starts sending protobufs to us, switches to send/receive protobufs * (and starts dropping debug printing - FIXME, eventually those prints should be encapsulated in protobufs). diff --git a/src/mesh/api/ethServerAPI.cpp b/src/mesh/api/ethServerAPI.cpp index a8701848a..0ccf92df7 100644 --- a/src/mesh/api/ethServerAPI.cpp +++ b/src/mesh/api/ethServerAPI.cpp @@ -1,7 +1,7 @@ #include "configuration.h" #include -#if HAS_ETHERNET +#if HAS_ETHERNET && !defined(USE_WS5500) #include "ethServerAPI.h" diff --git a/src/mesh/api/ethServerAPI.h b/src/mesh/api/ethServerAPI.h index 9d25a2fc1..c616c87be 100644 --- a/src/mesh/api/ethServerAPI.h +++ b/src/mesh/api/ethServerAPI.h @@ -1,6 +1,7 @@ #pragma once #include "ServerAPI.h" +#ifndef USE_WS5500 #include /** @@ -23,3 +24,4 @@ class ethServerPort : public APIServerPort }; void initApiServer(int port = SERVER_API_DEFAULT_PORT); +#endif diff --git a/src/mesh/http/WebServer.cpp b/src/mesh/http/WebServer.cpp index d9856e157..5f6ad9eb3 100644 --- a/src/mesh/http/WebServer.cpp +++ b/src/mesh/http/WebServer.cpp @@ -12,6 +12,11 @@ #include #include +#if HAS_ETHERNET && defined(USE_WS5500) +#include +#define ETH ETH2 +#endif // HAS_ETHERNET + #ifdef ARCH_ESP32 #include "esp_task_wdt.h" #endif @@ -166,14 +171,14 @@ WebServerThread *webServerThread; WebServerThread::WebServerThread() : concurrency::OSThread("WebServer") { - if (!config.network.wifi_enabled) { + if (!config.network.wifi_enabled && !config.network.eth_enabled) { disable(); } } int32_t WebServerThread::runOnce() { - if (!config.network.wifi_enabled) { + if (!config.network.wifi_enabled && !config.network.eth_enabled) { disable(); } diff --git a/src/mesh/udp/UdpMulticastThread.h b/src/mesh/udp/UdpMulticastThread.h index 9128d3b5c..69b1d2282 100644 --- a/src/mesh/udp/UdpMulticastThread.h +++ b/src/mesh/udp/UdpMulticastThread.h @@ -7,6 +7,11 @@ #include #include +#if HAS_ETHERNET && defined(USE_WS5500) +#include +#define ETH ETH2 +#endif // HAS_ETHERNET + #define UDP_MULTICAST_DEFAUL_PORT 4403 // Default port for UDP multicast is same as TCP api server #define UDP_MULTICAST_THREAD_INTERVAL_MS 15000 diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp index ee50ee56f..92388d52a 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -9,6 +9,12 @@ #include "mesh/api/WiFiServerAPI.h" #include "target_specific.h" #include + +#if HAS_ETHERNET && defined(USE_WS5500) +#include +#define ETH ETH2 +#endif // HAS_ETHERNET + #include #ifdef ARCH_ESP32 #if !MESHTASTIC_EXCLUDE_WEBSERVER @@ -52,11 +58,28 @@ Syslog syslog(syslogClient); Periodic *wifiReconnect; +#ifdef USE_WS5500 +// Startup Ethernet +bool initEthernet() +{ + if ((config.network.eth_enabled) && (ETH.begin(ETH_PHY_W5500, 1, ETH_CS_PIN, ETH_INT_PIN, ETH_RST_PIN, SPI3_HOST, + ETH_SCLK_PIN, ETH_MISO_PIN, ETH_MOSI_PIN))) { + WiFi.onEvent(WiFiEvent); +#if !MESHTASTIC_EXCLUDE_WEBSERVER + createSSLCert(); // For WebServer +#endif + return true; + } + + return false; +} +#endif + static void onNetworkConnected() { if (!APStartupComplete) { // Start web server - LOG_INFO("Start WiFi network services"); + LOG_INFO("Start network services"); // start mdns if (!MDNS.begin("Meshtastic")) { @@ -188,6 +211,10 @@ bool isWifiAvailable() if (config.network.wifi_enabled && (config.network.wifi_ssid[0])) { return true; +#ifdef USE_WS5500 + } else if (config.network.eth_enabled) { + return true; +#endif } else { return false; } @@ -282,7 +309,7 @@ bool initWifi() // Called by the Espressif SDK to static void WiFiEvent(WiFiEvent_t event) { - LOG_DEBUG("WiFi-Event %d: ", event); + LOG_DEBUG("Network-Event %d: ", event); switch (event) { case ARDUINO_EVENT_WIFI_READY: @@ -377,19 +404,32 @@ static void WiFiEvent(WiFiEvent_t event) LOG_INFO("Ethernet started"); break; case ARDUINO_EVENT_ETH_STOP: + syslog.disable(); LOG_INFO("Ethernet stopped"); break; case ARDUINO_EVENT_ETH_CONNECTED: LOG_INFO("Ethernet connected"); break; case ARDUINO_EVENT_ETH_DISCONNECTED: + syslog.disable(); LOG_INFO("Ethernet disconnected"); break; case ARDUINO_EVENT_ETH_GOT_IP: - LOG_INFO("Obtained IP address (ARDUINO_EVENT_ETH_GOT_IP)"); +#ifdef USE_WS5500 + LOG_INFO("Obtained IP address: %s, %u Mbps, %s", ETH.localIP().toString().c_str(), ETH.linkSpeed(), + ETH.fullDuplex() ? "FULL_DUPLEX" : "HALF_DUPLEX"); + onNetworkConnected(); +#endif break; case ARDUINO_EVENT_ETH_GOT_IP6: - LOG_INFO("Obtained IP6 address (ARDUINO_EVENT_ETH_GOT_IP6)"); +#ifdef USE_WS5500 +#if ESP_ARDUINO_VERSION >= ESP_ARDUINO_VERSION_VAL(3, 0, 0) + LOG_INFO("Obtained Local IP6 address: %s", ETH.linkLocalIPv6().toString().c_str()); + LOG_INFO("Obtained GlobalIP6 address: %s", ETH.globalIPv6().toString().c_str()); +#else + LOG_INFO("Obtained IP6 address: %s", ETH.localIPv6().toString().c_str()); +#endif +#endif break; case ARDUINO_EVENT_SC_SCAN_DONE: LOG_INFO("SmartConfig: Scan done"); diff --git a/src/mesh/wifi/WiFiAPClient.h b/src/mesh/wifi/WiFiAPClient.h index 5f4e2f5c9..078c40193 100644 --- a/src/mesh/wifi/WiFiAPClient.h +++ b/src/mesh/wifi/WiFiAPClient.h @@ -9,6 +9,11 @@ #include #endif +#if HAS_ETHERNET && defined(USE_WS5500) +#include +#define ETH ETH2 +#endif // HAS_ETHERNET + extern bool needReconnect; extern concurrency::Periodic *wifiReconnect; @@ -19,4 +24,9 @@ void deinitWifi(); bool isWifiAvailable(); -uint8_t getWifiDisconnectReason(); \ No newline at end of file +uint8_t getWifiDisconnectReason(); + +#ifdef USE_WS5500 +// Startup Ethernet +bool initEthernet(); +#endif \ No newline at end of file diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index ac0a8c0de..a765fb0b1 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -988,7 +988,7 @@ void AdminModule::handleGetDeviceConnectionStatus(const meshtastic_MeshPacket &r } #endif -#if HAS_ETHERNET +#if HAS_ETHERNET && !defined(USE_WS5500) conn.has_ethernet = true; conn.ethernet.has_status = true; if (Ethernet.linkStatus() == LinkON) { diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 5f16f909f..226bee44d 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -19,6 +19,10 @@ #include "mesh/wifi/WiFiAPClient.h" #include #endif +#if HAS_ETHERNET && defined(USE_WS5500) +#include +#define ETH ETH2 +#endif // HAS_ETHERNET #include "Default.h" #if !defined(ARCH_NRF52) || NRF52_USE_JSON #include "serialization/JSON.h" @@ -295,6 +299,11 @@ bool connectPubSub(const PubSubConfig &config, PubSubClient &pubSub, Client &cli inline bool isConnectedToNetwork() { +#ifdef USE_WS5500 + if (ETH.connected()) + return true; +#endif + #if HAS_WIFI return WiFi.isConnected(); #elif HAS_ETHERNET diff --git a/src/mqtt/MQTT.h b/src/mqtt/MQTT.h index 5cda90218..0c260dc9c 100644 --- a/src/mqtt/MQTT.h +++ b/src/mqtt/MQTT.h @@ -14,7 +14,7 @@ #include #endif #endif -#if HAS_ETHERNET +#if HAS_ETHERNET && !defined(USE_WS5500) #include #endif diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index 742b295b5..e4f8b49a0 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -176,6 +176,8 @@ #define HW_VENDOR meshtastic_HardwareModel_SEEED_XIAO_S3 #elif defined(MESH_TAB) #define HW_VENDOR meshtastic_HardwareModel_MESH_TAB +#elif defined(T_ETH_ELITE) +#define HW_VENDOR meshtastic_HardwareModel_T_ETH_ELITE #endif // ----------------------------------------------------------------------------- diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp index 679222af5..3b3557e95 100644 --- a/src/platform/esp32/main-esp32.cpp +++ b/src/platform/esp32/main-esp32.cpp @@ -26,7 +26,9 @@ #if !defined(CONFIG_IDF_TARGET_ESP32S2) && !MESHTASTIC_EXCLUDE_BLUETOOTH void setBluetoothEnable(bool enable) { -#if HAS_WIFI +#ifdef USE_WS5500 + if ((config.bluetooth.enabled == true) && (config.network.wifi_enabled == false)) +#elif HAS_WIFI if (!isWifiAvailable() && config.bluetooth.enabled == true) #else if (config.bluetooth.enabled == true) diff --git a/variants/t-eth-elite/pins_arduino.h b/variants/t-eth-elite/pins_arduino.h new file mode 100644 index 000000000..cddd8d0b9 --- /dev/null +++ b/variants/t-eth-elite/pins_arduino.h @@ -0,0 +1,26 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +// The default Wire will be mapped to PMU and RTC +static const uint8_t SDA = 17; +static const uint8_t SCL = 18; + +// Default SPI will be mapped to Radio +static const uint8_t SS = 40; +static const uint8_t MOSI = 11; +static const uint8_t MISO = 9; +static const uint8_t SCK = 10; + +#define SPI_MOSI (11) +#define SPI_SCK (10) +#define SPI_MISO (9) +#define SPI_CS (12) + +#define SDCARD_CS SPI_CS + +#endif /* Pins_Arduino_h */ \ No newline at end of file diff --git a/variants/t-eth-elite/platformio.ini b/variants/t-eth-elite/platformio.ini new file mode 100644 index 000000000..8c2f3bc37 --- /dev/null +++ b/variants/t-eth-elite/platformio.ini @@ -0,0 +1,16 @@ +[env:t-eth-elite] +extends = esp32s3_base +board = esp32s3box +board_check = true +build_flags = + ${esp32s3_base.build_flags} + -D T_ETH_ELITE + -I variants/t-eth-elite + -DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. + +lib_ignore = + Ethernet + +lib_deps = + ${esp32s3_base.lib_deps} + https://github.com/meshtastic/ETHClass2#v1.0.0 diff --git a/variants/t-eth-elite/rfswitch.h b/variants/t-eth-elite/rfswitch.h new file mode 100644 index 000000000..589f24767 --- /dev/null +++ b/variants/t-eth-elite/rfswitch.h @@ -0,0 +1,11 @@ +#include "RadioLib.h" + +static const uint32_t rfswitch_dio_pins[] = {RADIOLIB_LR11X0_DIO5, RADIOLIB_LR11X0_DIO6, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC}; + +static const Module::RfSwitchMode_t rfswitch_table[] = { + // mode DIO5 DIO6 + {LR11x0::MODE_STBY, {LOW, LOW}}, {LR11x0::MODE_RX, {HIGH, LOW}}, + {LR11x0::MODE_TX, {LOW, HIGH}}, {LR11x0::MODE_TX_HP, {LOW, HIGH}}, + {LR11x0::MODE_TX_HF, {LOW, LOW}}, {LR11x0::MODE_GNSS, {LOW, LOW}}, + {LR11x0::MODE_WIFI, {LOW, LOW}}, END_OF_MODE_TABLE, +}; diff --git a/variants/t-eth-elite/variant.h b/variants/t-eth-elite/variant.h new file mode 100644 index 000000000..b7ac05872 --- /dev/null +++ b/variants/t-eth-elite/variant.h @@ -0,0 +1,83 @@ +#define HAS_SDCARD +#define SDCARD_USE_SPI1 + +#define HAS_GPS 1 +#define GPS_RX_PIN 39 +#define GPS_TX_PIN 42 +#define GPS_BAUDRATE_FIXED 1 +#define GPS_BAUDRATE 9600 + +#define I2C_SDA 17 // I2C pins for this board +#define I2C_SCL 18 + +#define HAS_SCREEN 1 // Allow for OLED Screens on I2C Header of shield + +#define LED_PIN 38 // If defined we will blink this LED +#define BUTTON_PIN 0 // If defined, this will be used for user button presses, + +#define BUTTON_NEED_PULLUP + +// TTGO uses a common pinout for their SX1262 vs RF95 modules - both can be enabled and we will probe at runtime for RF95 and if +// not found then probe for SX1262 +#define USE_RF95 // RFM95/SX127x +#define USE_SX1262 +#define USE_SX1280 +#define USE_LR1121 + +#define LORA_SCK 10 +#define LORA_MISO 9 +#define LORA_MOSI 11 +#define LORA_CS 40 +#define LORA_RESET 46 + +// per SX1276_Receive_Interrupt/utilities.h +#define LORA_DIO0 8 +#define LORA_DIO1 16 +#define LORA_DIO2 RADIOLIB_NC + +// per SX1262_Receive_Interrupt/utilities.h +#ifdef USE_SX1262 +#define SX126X_CS LORA_CS +#define SX126X_DIO1 8 +#define SX126X_BUSY 16 +#define SX126X_RESET LORA_RESET +#define SX126X_DIO2_AS_RF_SWITCH +#define SX126X_DIO3_TCXO_VOLTAGE 1.8 +#endif + +// per SX128x_Receive_Interrupt/utilities.h +#ifdef USE_SX1280 +#define SX128X_CS LORA_CS +#define SX128X_DIO1 8 +#define SX128X_DIO2 33 +#define SX128X_DIO3 34 +#define SX128X_BUSY 16 +#define SX128X_RESET LORA_RESET +#define SX128X_RXEN 13 +#define SX128X_TXEN 38 +#define SX128X_MAX_POWER 3 +#endif + +// LR1121 +#ifdef USE_LR1121 +#define LR1121_IRQ_PIN 8 +#define LR1121_NRESET_PIN LORA_RESET +#define LR1121_BUSY_PIN 16 +#define LR1121_SPI_NSS_PIN LORA_CS +#define LR1121_SPI_SCK_PIN LORA_SCK +#define LR1121_SPI_MOSI_PIN LORA_MOSI +#define LR1121_SPI_MISO_PIN LORA_MISO +#define LR11X0_DIO3_TCXO_VOLTAGE 3.0 +#define LR11X0_DIO_AS_RF_SWITCH +#endif + +#define HAS_ETHERNET 1 +#define USE_WS5500 1 // this driver uses the same stack as the ESP32 Wifi driver + +#define ETH_MISO_PIN 47 +#define ETH_MOSI_PIN 21 +#define ETH_SCLK_PIN 48 +#define ETH_CS_PIN 45 +#define ETH_INT_PIN 14 +#define ETH_RST_PIN -1 +#define ETH_ADDR 1 \ No newline at end of file From dc100e4d3e3dfbf58d3ead8141a49cddb0cbdc19 Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 16 Mar 2025 08:19:17 -0500 Subject: [PATCH 02/12] Cleanup --- src/SafeFile.cpp | 8 ++++- src/mesh/MeshService.cpp | 6 ++-- src/mesh/MeshService.h | 2 +- src/mesh/NodeDB.cpp | 18 ++--------- src/mesh/NodeDB.h | 2 +- src/mesh/RadioInterface.cpp | 2 +- src/mesh/Router.cpp | 61 +++++++++++++++++++++++------------ src/mesh/Router.h | 5 ++- src/modules/RoutingModule.cpp | 5 --- src/mqtt/MQTT.cpp | 3 +- 10 files changed, 61 insertions(+), 51 deletions(-) diff --git a/src/SafeFile.cpp b/src/SafeFile.cpp index c942aa0ee..45b96ad07 100644 --- a/src/SafeFile.cpp +++ b/src/SafeFile.cpp @@ -11,12 +11,18 @@ static File openFile(const char *filename, bool fullAtomic) FSCom.remove(filename); return FSCom.open(filename, FILE_O_WRITE); #endif - if (!fullAtomic) + if (!fullAtomic) { FSCom.remove(filename); // Nuke the old file to make space (ignore if it !exists) + } String filenameTmp = filename; filenameTmp += ".tmp"; + // FIXME: If we are doing a full atomic write, we may need to remove the old tmp file now + // if (fullAtomic) { + // FSCom.remove(filename); + // } + // clear any previous LFS errors return FSCom.open(filenameTmp.c_str(), FILE_O_WRITE); } diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 3bb1f2776..f293559ad 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -125,17 +125,15 @@ void MeshService::loop() } /// The radioConfig object just changed, call this to force the hw to change to the new settings -bool MeshService::reloadConfig(int saveWhat) +void MeshService::reloadConfig(int saveWhat) { // If we can successfully set this radio to these settings, save them to disk // This will also update the region as needed - bool didReset = nodeDB->resetRadioConfig(); // Don't let the phone send us fatally bad settings + nodeDB->resetRadioConfig(); // Don't let the phone send us fatally bad settings configChanged.notifyObservers(NULL); // This will cause radio hardware to change freqs etc nodeDB->saveToDisk(saveWhat); - - return didReset; } /// The owner User record just got updated, update our node DB and broadcast the info into the mesh diff --git a/src/mesh/MeshService.h b/src/mesh/MeshService.h index 42f701d5c..e2e430c03 100644 --- a/src/mesh/MeshService.h +++ b/src/mesh/MeshService.h @@ -118,7 +118,7 @@ class MeshService /** The radioConfig object just changed, call this to force the hw to change to the new settings * @return true if client devices should be sent a new set of radio configs */ - bool reloadConfig(int saveWhat = SEGMENT_CONFIG | SEGMENT_MODULECONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS); + void reloadConfig(int saveWhat = SEGMENT_CONFIG | SEGMENT_MODULECONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS); /// The owner User record just got updated, update our node DB and broadcast the info into the mesh void reloadOwner(bool shouldSave = true); diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 62ab675bc..b40c7153a 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -400,18 +400,12 @@ bool isBroadcast(uint32_t dest) return dest == NODENUM_BROADCAST || dest == NODENUM_BROADCAST_NO_LORA; } -bool NodeDB::resetRadioConfig(bool factory_reset, bool is_fresh_install) +void NodeDB::resetRadioConfig(bool is_fresh_install) { - bool didFactoryReset = false; - if (is_fresh_install) { radioGeneration++; } - if (factory_reset) { - didFactoryReset = factoryReset(); - } - if (channelFile.channels_count != MAX_NUM_CHANNELS) { LOG_INFO("Set default channel and radio preferences!"); @@ -422,14 +416,6 @@ bool NodeDB::resetRadioConfig(bool factory_reset, bool is_fresh_install) // Update the global myRegion initRegion(); - - if (didFactoryReset) { - LOG_INFO("Reboot due to factory reset"); - screen->startAlert("Rebooting..."); - rebootAtMsec = millis() + (5 * 1000); - } - - return didFactoryReset; } bool NodeDB::factoryReset(bool eraseBleBonds) @@ -591,7 +577,7 @@ void NodeDB::installDefaultConfig(bool preserveKey = false) config.device.node_info_broadcast_secs = default_node_info_broadcast_secs; config.security.serial_enabled = true; config.security.admin_channel_enabled = false; - resetRadioConfig(false, true); // This also triggers NodeInfo/Position requests since we're fresh + resetRadioConfig(true); // This also triggers NodeInfo/Position requests since we're fresh strncpy(config.network.ntp_server, "meshtastic.pool.ntp.org", 32); #if (defined(T_DECK) || defined(T_WATCH_S3) || defined(UNPHONE) || defined(PICOMPUTER_S3) || defined(SENSECAP_INDICATOR)) && \ diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 25f1e9083..a31f33250 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -103,7 +103,7 @@ class NodeDB * @param is_fresh_install set to true after a fresh install, to trigger NodeInfo/Position requests * @return true if the config was completely reset, in that case, we should send it back to the client */ - bool resetRadioConfig(bool factory_reset = false, bool is_fresh_install = false); + void resetRadioConfig(bool is_fresh_install = false); /// given a subpacket sniffed from the network, update our DB state /// we updateGUI and updateGUIforNode if we think our this change is big enough for a redraw diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 36f4a5342..2e50c0168 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -656,7 +656,7 @@ size_t RadioInterface::beginSending(meshtastic_MeshPacket *p) // if the sender nodenum is zero, that means uninitialized assert(radioBuffer.header.from); - + assert(p->encrypted.size <= sizeof(radioBuffer.payload)); memcpy(radioBuffer.payload, p->encrypted.bytes, p->encrypted.size); sendingPacket = p; diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 9e1e41d53..9503109db 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -198,6 +198,14 @@ ErrorCode Router::sendLocal(meshtastic_MeshPacket *p, RxSource src) return send(p); } } +/** + * Send a packet on a suitable interface. + */ +ErrorCode Router::rawSend(meshtastic_MeshPacket *p) +{ + assert(iface); // This should have been detected already in sendLocal (or we just received a packet from outside) + return iface->send(p); +} /** * Send a packet on a suitable interface. This routine will @@ -319,27 +327,27 @@ void Router::sniffReceived(const meshtastic_MeshPacket *p, const meshtastic_Rout // FIXME, update nodedb here for any packet that passes through us } -bool perhapsDecode(meshtastic_MeshPacket *p) +DecodeState perhapsDecode(meshtastic_MeshPacket *p) { concurrency::LockGuard g(cryptLock); if (config.device.role == meshtastic_Config_DeviceConfig_Role_REPEATER && config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_ALL_SKIP_DECODING) - return false; + return DecodeState::DECODE_FAILURE; if (config.device.rebroadcast_mode == meshtastic_Config_DeviceConfig_RebroadcastMode_KNOWN_ONLY && (nodeDB->getMeshNode(p->from) == NULL || !nodeDB->getMeshNode(p->from)->has_user)) { LOG_DEBUG("Node 0x%x not in nodeDB-> Rebroadcast mode KNOWN_ONLY will ignore packet", p->from); - return false; + return DecodeState::DECODE_FAILURE; } if (p->which_payload_variant == meshtastic_MeshPacket_decoded_tag) - return true; // If packet was already decoded just return + return DecodeState::DECODE_SUCCESS; // If packet was already decoded just return size_t rawSize = p->encrypted.size; if (rawSize > sizeof(bytes)) { LOG_ERROR("Packet too large to attempt decryption! (rawSize=%d > 256)", rawSize); - return false; + return DecodeState::DECODE_FATAL; } bool decrypted = false; ChannelIndex chIndex = 0; @@ -353,18 +361,22 @@ bool perhapsDecode(meshtastic_MeshPacket *p) if (crypto->decryptCurve25519(p->from, nodeDB->getMeshNode(p->from)->user.public_key, p->id, rawSize, p->encrypted.bytes, bytes)) { LOG_INFO("PKI Decryption worked!"); - memset(&p->decoded, 0, sizeof(p->decoded)); + + meshtastic_Data decodedtmp; + memset(&decodedtmp, 0, sizeof(decodedtmp)); rawSize -= MESHTASTIC_PKC_OVERHEAD; - if (pb_decode_from_bytes(bytes, rawSize, &meshtastic_Data_msg, &p->decoded) && - p->decoded.portnum != meshtastic_PortNum_UNKNOWN_APP) { + if (pb_decode_from_bytes(bytes, rawSize, &meshtastic_Data_msg, &decodedtmp) && + decodedtmp.portnum != meshtastic_PortNum_UNKNOWN_APP) { decrypted = true; LOG_INFO("Packet decrypted using PKI!"); p->pki_encrypted = true; memcpy(&p->public_key.bytes, nodeDB->getMeshNode(p->from)->user.public_key.bytes, 32); p->public_key.size = 32; + memcpy(&p->decoded, &decodedtmp, sizeof(meshtastic_Data_msg)); + p->which_payload_variant = meshtastic_MeshPacket_decoded_tag; // change type to decoded } else { LOG_ERROR("PKC Decrypted, but pb_decode failed!"); - return false; + return DecodeState::DECODE_FAILURE; } } else { LOG_WARN("PKC decrypt attempted but failed!"); @@ -387,12 +399,15 @@ bool perhapsDecode(meshtastic_MeshPacket *p) // printBytes("plaintext", bytes, p->encrypted.size); // Take those raw bytes and convert them back into a well structured protobuf we can understand - memset(&p->decoded, 0, sizeof(p->decoded)); - if (!pb_decode_from_bytes(bytes, rawSize, &meshtastic_Data_msg, &p->decoded)) { + meshtastic_Data decodedtmp; + memset(&decodedtmp, 0, sizeof(decodedtmp)); + if (!pb_decode_from_bytes(bytes, rawSize, &meshtastic_Data_msg, &decodedtmp)) { LOG_ERROR("Invalid protobufs in received mesh packet id=0x%08x (bad psk?)!", p->id); - } else if (p->decoded.portnum == meshtastic_PortNum_UNKNOWN_APP) { + } else if (decodedtmp.portnum == meshtastic_PortNum_UNKNOWN_APP) { LOG_ERROR("Invalid portnum (bad psk?)!"); } else { + p->decoded = decodedtmp; + p->which_payload_variant = meshtastic_MeshPacket_decoded_tag; // change type to decoded decrypted = true; break; } @@ -401,8 +416,7 @@ bool perhapsDecode(meshtastic_MeshPacket *p) } if (decrypted) { // parsing was successful - p->which_payload_variant = meshtastic_MeshPacket_decoded_tag; // change type to decoded - p->channel = chIndex; // change to store the index instead of the hash + p->channel = chIndex; // change to store the index instead of the hash if (p->decoded.has_bitfield) p->decoded.want_response |= p->decoded.bitfield & BITFIELD_WANT_RESPONSE_MASK; @@ -434,10 +448,10 @@ bool perhapsDecode(meshtastic_MeshPacket *p) LOG_TRACE("%s", MeshPacketSerializer::JsonSerialize(p, false).c_str()); } #endif - return true; + return DecodeState::DECODE_SUCCESS; } else { LOG_WARN("No suitable channel found for decoding, hash was 0x%x!", p->channel); - return false; + return DecodeState::DECODE_FAILURE; } } @@ -592,8 +606,13 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src) meshtastic_MeshPacket *p_encrypted = packetPool.allocCopy(*p); // Take those raw bytes and convert them back into a well structured protobuf we can understand - bool decoded = perhapsDecode(p); - if (decoded) { + auto decodedState = perhapsDecode(p); + if (decodedState == DecodeState::DECODE_FATAL) { + // Fatal decoding error, we can't do anything with this packet + LOG_WARN("Fatal decode error, dropping packet"); + cancelSending(p->from, p->id); + skipHandle = true; + } else if (decodedState == DecodeState::DECODE_SUCCESS) { // parsing was successful, queue for our recipient if (src == RX_SRC_LOCAL) printPacket("handleReceived(LOCAL)", p); @@ -636,10 +655,12 @@ void Router::handleReceived(meshtastic_MeshPacket *p, RxSource src) #if !MESHTASTIC_EXCLUDE_MQTT // Mark as pki_encrypted if it is not yet decoded and MQTT encryption is also enabled, hash matches and it's a DM not to // us (because we would be able to decrypt it) - if (!decoded && moduleConfig.mqtt.encryption_enabled && p->channel == 0x00 && !isBroadcast(p->to) && !isToUs(p)) + if (decodedState == DecodeState::DECODE_FAILURE && moduleConfig.mqtt.encryption_enabled && p->channel == 0x00 && + !isBroadcast(p->to) && !isToUs(p)) p_encrypted->pki_encrypted = true; // After potentially altering it, publish received message to MQTT if we're not the original transmitter of the packet - if ((decoded || p_encrypted->pki_encrypted) && moduleConfig.mqtt.enabled && !isFromUs(p) && mqtt) + if ((decodedState == DecodeState::DECODE_SUCCESS || p_encrypted->pki_encrypted) && moduleConfig.mqtt.enabled && + !isFromUs(p) && mqtt) mqtt->onSend(*p_encrypted, *p, p->channel); #endif } diff --git a/src/mesh/Router.h b/src/mesh/Router.h index bf6b77226..58ca50f3d 100644 --- a/src/mesh/Router.h +++ b/src/mesh/Router.h @@ -85,6 +85,7 @@ class Router : protected concurrency::OSThread, protected PacketHistory * NOTE: This method will free the provided packet (even if we return an error code) */ virtual ErrorCode send(meshtastic_MeshPacket *p); + virtual ErrorCode rawSend(meshtastic_MeshPacket *p); /* Statistics for the amount of duplicate received packets and the amount of times we cancel a relay because someone did it before us */ @@ -139,12 +140,14 @@ class Router : protected concurrency::OSThread, protected PacketHistory void abortSendAndNak(meshtastic_Routing_Error err, meshtastic_MeshPacket *p); }; +enum DecodeState { DECODE_SUCCESS, DECODE_FAILURE, DECODE_FATAL }; + /** FIXME - move this into a mesh packet class * Remove any encryption and decode the protobufs inside this packet (if necessary). * * @return true for success, false for corrupt packet. */ -bool perhapsDecode(meshtastic_MeshPacket *p); +DecodeState perhapsDecode(meshtastic_MeshPacket *p); /** Return 0 for success or a Routing_Error code for failure */ diff --git a/src/modules/RoutingModule.cpp b/src/modules/RoutingModule.cpp index 34ef2ddd1..e7e92c79a 100644 --- a/src/modules/RoutingModule.cpp +++ b/src/modules/RoutingModule.cpp @@ -46,11 +46,6 @@ meshtastic_MeshPacket *RoutingModule::allocReply() return NULL; assert(currentRequest); - // We only consider making replies if the request was a legit routing packet (not just something we were sniffing) - if (currentRequest->decoded.portnum == meshtastic_PortNum_ROUTING_APP) { - assert(0); // 1.2 refactoring fixme, Not sure if anything needs this yet? - // return allocDataProtobuf(u); - } return NULL; } diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 226bee44d..799f953b4 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -117,7 +117,8 @@ inline void onReceiveProto(char *topic, byte *payload, size_t length) // likely they discovered each other via a channel we have downlink enabled for if (isToUs(p.get()) || (tx && tx->has_user && rx && rx->has_user)) router->enqueueReceivedMessage(p.release()); - } else if (router && perhapsDecode(p.get())) // ignore messages if we don't have the channel key + } else if (router && + perhapsDecode(p.get()) == DecodeState::DECODE_SUCCESS) // ignore messages if we don't have the channel key router->enqueueReceivedMessage(p.release()); } From 64b9cfe1994a6fb17743e3d17c558c6f7b214d3b Mon Sep 17 00:00:00 2001 From: dylanli Date: Sun, 16 Mar 2025 23:04:24 +0800 Subject: [PATCH 03/12] update seeed-xiao-nrf52840-kit board defination (#6318) - Due to the lack of pins, we have temporarily removed the button. There are some technical solutions that can solve this problem, and we are currently exploring and researching them --- variants/seeed_xiao_nrf52840_kit/variant.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/variants/seeed_xiao_nrf52840_kit/variant.h b/variants/seeed_xiao_nrf52840_kit/variant.h index eae5e04fd..9d6345f0a 100644 --- a/variants/seeed_xiao_nrf52840_kit/variant.h +++ b/variants/seeed_xiao_nrf52840_kit/variant.h @@ -57,11 +57,15 @@ extern "C" { #define D9 (9ul) #define D10 (10ul) +/*Due to the lack of pins,and have to make sure gps standby work well we have temporarily removed the button. +There are some technical solutions that can solve this problem, +and we are currently exploring and researching them*/ + +// #define BUTTON_PIN D0 // This is the Program Button +// // #define BUTTON_NEED_PULLUP 1 +// #define BUTTON_ACTIVE_LOW true +// #define BUTTON_ACTIVE_PULLUP false -#define BUTTON_PIN D0 // This is the Program Button -// #define BUTTON_NEED_PULLUP 1 -#define BUTTON_ACTIVE_LOW true -#define BUTTON_ACTIVE_PULLUP false /* * Analog pins */ @@ -135,14 +139,14 @@ static const uint8_t SCL = PIN_WIRE_SCL; // GPS L76KB #define GPS_L76K #ifdef GPS_L76K -#define PIN_GPS_RX 32+12 // 44 -#define PIN_GPS_TX 32+11 // 43 +#define PIN_GPS_RX D6 +#define PIN_GPS_TX D7 #define HAS_GPS 1 #define GPS_BAUDRATE 9600 #define GPS_THREAD_INTERVAL 50 #define PIN_SERIAL1_RX PIN_GPS_TX #define PIN_SERIAL1_TX PIN_GPS_RX -#define PIN_GPS_STANDBY 2 +#define PIN_GPS_STANDBY D0 #endif From 2525111c39cd5081d794f3ebabaae2310395fc66 Mon Sep 17 00:00:00 2001 From: HarukiToreda <116696711+HarukiToreda@users.noreply.github.com> Date: Sun, 16 Mar 2025 11:15:33 -0400 Subject: [PATCH 04/12] E-ink partial refresh limitation removed for free text screen (#6201) --- src/graphics/EInkDynamicDisplay.cpp | 8 ++++++++ src/graphics/EInkDynamicDisplay.h | 5 +++++ src/modules/CannedMessageModule.cpp | 5 +++++ 3 files changed, 18 insertions(+) diff --git a/src/graphics/EInkDynamicDisplay.cpp b/src/graphics/EInkDynamicDisplay.cpp index 47012ca47..4a062cf7e 100644 --- a/src/graphics/EInkDynamicDisplay.cpp +++ b/src/graphics/EInkDynamicDisplay.cpp @@ -324,6 +324,14 @@ void EInkDynamicDisplay::checkConsecutiveFastRefreshes() if (refresh != UNSPECIFIED) return; + // Bypass limit if UNLIMITED_FAST mode is active + if (frameFlags & UNLIMITED_FAST) { + refresh = FAST; + reason = NO_OBJECTIONS; + LOG_DEBUG("refresh=FAST, reason=UNLIMITED_FAST_MODE_ACTIVE, frameFlags=0x%x", frameFlags); + return; + } + // If too many FAST refreshes consecutively - force a FULL refresh if (fastRefreshCount >= EINK_LIMIT_FASTREFRESH) { refresh = FULL; diff --git a/src/graphics/EInkDynamicDisplay.h b/src/graphics/EInkDynamicDisplay.h index 9e131dca7..d5e29e3f0 100644 --- a/src/graphics/EInkDynamicDisplay.h +++ b/src/graphics/EInkDynamicDisplay.h @@ -23,6 +23,10 @@ class EInkDynamicDisplay : public EInkDisplay, protected concurrency::NotifiedWo EInkDynamicDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY geometry, HW_I2C i2cBus); ~EInkDynamicDisplay(); + // Methods to enable or disable unlimited fast refresh mode + void enableUnlimitedFastMode() { addFrameFlag(UNLIMITED_FAST); } + void disableUnlimitedFastMode() { frameFlags = (frameFlagTypes)(frameFlags & ~UNLIMITED_FAST); } + // What kind of frame is this enum frameFlagTypes : uint8_t { BACKGROUND = (1 << 0), // For frames via display() @@ -30,6 +34,7 @@ class EInkDynamicDisplay : public EInkDisplay, protected concurrency::NotifiedWo COSMETIC = (1 << 2), // For splashes DEMAND_FAST = (1 << 3), // Special case only BLOCKING = (1 << 4), // Modifier - block while refresh runs + UNLIMITED_FAST = (1 << 5) }; void addFrameFlag(frameFlagTypes flag); diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 5fb32fff5..5f623720a 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -1057,6 +1057,11 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st display->drawString(10 + x, 0 + y + FONT_HEIGHT_SMALL, "Canned Message\nModule disabled."); } else if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) { requestFocus(); // Tell Screen::setFrames to move to our module's frame +#if defined(USE_EINK) && defined(USE_EINK_DYNAMICDISPLAY) + EInkDynamicDisplay* einkDisplay = static_cast(display); + einkDisplay->enableUnlimitedFastMode(); // Enable unlimited fast refresh while typing +#endif + #if defined(USE_VIRTUAL_KEYBOARD) drawKeyboard(display, state, 0, 0); #else From 2d565c292106a87ebb4b7d022a52f297b0bda41b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Sun, 16 Mar 2025 16:18:12 +0100 Subject: [PATCH 05/12] trunk'd --- .trunk/trunk.yaml | 6 +++--- src/graphics/EInkDynamicDisplay.cpp | 2 +- src/modules/CannedMessageModule.cpp | 4 ++-- variants/seeed_xiao_nrf52840_kit/variant.cpp | 5 +---- variants/seeed_xiao_nrf52840_kit/variant.h | 21 +++++++------------- 5 files changed, 14 insertions(+), 24 deletions(-) diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index b42e2be31..b0561679a 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -9,14 +9,14 @@ plugins: lint: enabled: - prettier@3.5.3 - - trufflehog@3.88.16 + - trufflehog@3.88.17 - yamllint@1.36.0 - bandit@1.8.3 - - checkov@3.2.384 + - checkov@3.2.386 - terrascan@1.19.9 - trivy@0.60.0 - taplo@0.9.3 - - ruff@0.9.10 + - ruff@0.10.0 - isort@6.0.1 - markdownlint@0.44.0 - oxipng@9.1.4 diff --git a/src/graphics/EInkDynamicDisplay.cpp b/src/graphics/EInkDynamicDisplay.cpp index 4a062cf7e..8e4adf87e 100644 --- a/src/graphics/EInkDynamicDisplay.cpp +++ b/src/graphics/EInkDynamicDisplay.cpp @@ -331,7 +331,7 @@ void EInkDynamicDisplay::checkConsecutiveFastRefreshes() LOG_DEBUG("refresh=FAST, reason=UNLIMITED_FAST_MODE_ACTIVE, frameFlags=0x%x", frameFlags); return; } - + // If too many FAST refreshes consecutively - force a FULL refresh if (fastRefreshCount >= EINK_LIMIT_FASTREFRESH) { refresh = FULL; diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index 5f623720a..2a5ec00ab 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -1058,8 +1058,8 @@ void CannedMessageModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *st } else if (cannedMessageModule->runState == CANNED_MESSAGE_RUN_STATE_FREETEXT) { requestFocus(); // Tell Screen::setFrames to move to our module's frame #if defined(USE_EINK) && defined(USE_EINK_DYNAMICDISPLAY) - EInkDynamicDisplay* einkDisplay = static_cast(display); - einkDisplay->enableUnlimitedFastMode(); // Enable unlimited fast refresh while typing + EInkDynamicDisplay *einkDisplay = static_cast(display); + einkDisplay->enableUnlimitedFastMode(); // Enable unlimited fast refresh while typing #endif #if defined(USE_VIRTUAL_KEYBOARD) diff --git a/variants/seeed_xiao_nrf52840_kit/variant.cpp b/variants/seeed_xiao_nrf52840_kit/variant.cpp index f7e175f2d..22072312a 100644 --- a/variants/seeed_xiao_nrf52840_kit/variant.cpp +++ b/variants/seeed_xiao_nrf52840_kit/variant.cpp @@ -1,8 +1,8 @@ #include "variant.h" +#include "configuration.h" #include "nrf.h" #include "wiring_constants.h" #include "wiring_digital.h" -#include "configuration.h" #include #include #include @@ -58,8 +58,6 @@ const uint32_t g_ADigitalPinMap[] = { 31, // D32 is P0.10 (VBAT) }; - - /* Copyright (c) 2014-2015 Arduino LLC. All right reserved. Copyright (c) 2016 Sandeep Mistry All right reserved. @@ -80,7 +78,6 @@ const uint32_t g_ADigitalPinMap[] = { Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - void initVariant() { // LED1 & LED2 diff --git a/variants/seeed_xiao_nrf52840_kit/variant.h b/variants/seeed_xiao_nrf52840_kit/variant.h index 9d6345f0a..20362cb52 100644 --- a/variants/seeed_xiao_nrf52840_kit/variant.h +++ b/variants/seeed_xiao_nrf52840_kit/variant.h @@ -43,7 +43,6 @@ extern "C" { * Buttons */ - // Digital PINs #define D0 (0ul) #define D1 (1ul) @@ -57,8 +56,8 @@ extern "C" { #define D9 (9ul) #define D10 (10ul) -/*Due to the lack of pins,and have to make sure gps standby work well we have temporarily removed the button. -There are some technical solutions that can solve this problem, +/*Due to the lack of pins,and have to make sure gps standby work well we have temporarily removed the button. +There are some technical solutions that can solve this problem, and we are currently exploring and researching them*/ // #define BUTTON_PIN D0 // This is the Program Button @@ -86,7 +85,6 @@ static const uint8_t A4 = PIN_A4; static const uint8_t A5 = PIN_A5; #define ADC_RESOLUTION 12 - #define PIN_SERIAL2_RX (-1) #define PIN_SERIAL2_TX (-1) @@ -99,7 +97,6 @@ static const uint8_t A5 = PIN_A5; #define PIN_SPI_MOSI (10) #define PIN_SPI_SCK (8) - static const uint8_t SS = D4; static const uint8_t MOSI = PIN_SPI_MOSI; static const uint8_t MISO = PIN_SPI_MISO; @@ -117,29 +114,27 @@ static const uint8_t SCK = PIN_SPI_SCK; #define SX126X_TXEN RADIOLIB_NC - #define SX126X_RXEN D4 -#define SX126X_DIO2_AS_RF_SWITCH // DIO2 is used to control the RF switch really necessary!!! +#define SX126X_DIO2_AS_RF_SWITCH // DIO2 is used to control the RF switch really necessary!!! #define SX126X_DIO3_TCXO_VOLTAGE 1.8 /* * Wire Interfaces */ -#define I2C_NO_RESCAN // I2C is a bit finicky, don't scan too much +#define I2C_NO_RESCAN // I2C is a bit finicky, don't scan too much #define WIRE_INTERFACES_COUNT 1 // 2 -#define PIN_WIRE_SDA (24) //change to use the correct pins if needed -#define PIN_WIRE_SCL (25) //change to use the correct pins if needed +#define PIN_WIRE_SDA (24) // change to use the correct pins if needed +#define PIN_WIRE_SCL (25) // change to use the correct pins if needed static const uint8_t SDA = PIN_WIRE_SDA; static const uint8_t SCL = PIN_WIRE_SCL; - // GPS L76KB #define GPS_L76K #ifdef GPS_L76K -#define PIN_GPS_RX D6 +#define PIN_GPS_RX D6 #define PIN_GPS_TX D7 #define HAS_GPS 1 #define GPS_BAUDRATE 9600 @@ -149,8 +144,6 @@ static const uint8_t SCL = PIN_WIRE_SCL; #define PIN_GPS_STANDBY D0 #endif - - // Battery #define BAT_READ \ From 96ba94843b25f787148e3353a7476ed175518b3b Mon Sep 17 00:00:00 2001 From: Jorropo Date: Mon, 17 Mar 2025 01:36:02 +0100 Subject: [PATCH 06/12] Send UDP packets to multicast address rather than broadcast address (#6331) A smart router or switch is able to snoop the multicast address to only send the packets to nodes listening on the multicast address. Before all machines reachable on the L2 layer would receive the packet. --- src/mesh/udp/UdpMulticastThread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/udp/UdpMulticastThread.h b/src/mesh/udp/UdpMulticastThread.h index 69b1d2282..675d4ce15 100644 --- a/src/mesh/udp/UdpMulticastThread.h +++ b/src/mesh/udp/UdpMulticastThread.h @@ -56,7 +56,7 @@ class UdpMulticastThread : public concurrency::OSThread LOG_DEBUG("Broadcasting packet over UDP (id=%u)", mp->id); uint8_t buffer[meshtastic_MeshPacket_size]; size_t encodedLength = pb_encode_to_bytes(buffer, sizeof(buffer), &meshtastic_MeshPacket_msg, mp); - udp.broadcastTo(buffer, encodedLength, UDP_MULTICAST_DEFAUL_PORT); + udp.writeTo(buffer, encodedLength, udpIpAddress, UDP_MULTICAST_DEFAUL_PORT); return true; } From af8b64e84ee60175d7a0e43c6c3458e3a3558708 Mon Sep 17 00:00:00 2001 From: Jorropo Date: Mon, 17 Mar 2025 01:36:33 +0100 Subject: [PATCH 07/12] pass pointer to UDP multicast packet to protobuf decoder (#6333) The packet.readBytes API is not available on all targets: - RP2040 & RP2340 - yet to be written portduino API Instead pass the data buffer as-is. It also removes a memcpy which do not need to exists. I've tested it successfully on a tbeam. Co-authored-by: Ben Meadors --- src/mesh/udp/UdpMulticastThread.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/mesh/udp/UdpMulticastThread.h b/src/mesh/udp/UdpMulticastThread.h index 675d4ce15..e5eb28d00 100644 --- a/src/mesh/udp/UdpMulticastThread.h +++ b/src/mesh/udp/UdpMulticastThread.h @@ -35,10 +35,8 @@ class UdpMulticastThread : public concurrency::OSThread size_t packetLength = packet.length(); LOG_DEBUG("UDP broadcast from: %s, len=%u", packet.remoteIP().toString().c_str(), packetLength); meshtastic_MeshPacket mp; - uint8_t bytes[meshtastic_MeshPacket_size]; // Allocate buffer for the data - size_t packetSize = packet.readBytes(bytes, packet.length()); - LOG_DEBUG("Decoding MeshPacket from UDP len=%u", packetSize); - bool isPacketDecoded = pb_decode_from_bytes(bytes, packetLength, &meshtastic_MeshPacket_msg, &mp); + LOG_DEBUG("Decoding MeshPacket from UDP len=%u", packetLength); + bool isPacketDecoded = pb_decode_from_bytes(packet.data(), packetLength, &meshtastic_MeshPacket_msg, &mp); if (isPacketDecoded && router) { UniquePacketPoolPacket p = packetPool.allocUniqueCopy(mp); // Unset received SNR/RSSI From 9cc13e628a4960e71d700d03629c2752945fbccb Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 17 Mar 2025 19:24:47 -0500 Subject: [PATCH 08/12] Stubbed out backup / restore methods for now and fixed bug --- src/mesh/NodeDB.cpp | 88 +++++++++++++++++++++++++++++++++++++ src/mesh/NodeDB.h | 8 +++- src/mesh/Router.cpp | 2 +- src/modules/AdminModule.cpp | 36 +++++++++++++++ 4 files changed, 132 insertions(+), 2 deletions(-) diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index b40c7153a..e8efa7566 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -1598,6 +1598,94 @@ UserLicenseStatus NodeDB::getLicenseStatus(uint32_t nodeNum) return info->user.is_licensed ? UserLicenseStatus::Licensed : UserLicenseStatus::NotLicensed; } +bool NodeDB::backupPreferences(meshtastic_AdminMessage_BackupLocation location) +{ + bool success = false; + lastBackupAttempt = millis(); +#ifdef FSCom + if (location == meshtastic_AdminMessage_BackupLocation_FLASH) { + meshtastic_BackupPreferences backup = meshtastic_BackupPreferences_init_zero; + backup.version = DEVICESTATE_CUR_VER; + backup.timestamp = getValidTime(RTCQuality::RTCQualityDevice, false); + backup.has_config = true; + backup.config = config; + backup.has_module_config = true; + backup.module_config = moduleConfig; + backup.has_channels = true; + backup.channels = channelFile; + backup.has_owner = true; + backup.owner = owner; + + size_t backupSize; + pb_get_encoded_size(&backupSize, meshtastic_BackupPreferences_fields, &backup); + + spiLock->lock(); + FSCom.mkdir("/backups"); + spiLock->unlock(); + success = saveProto(backupFileName, backupSize, &meshtastic_BackupPreferences_msg, &backup); + + if (success) { + LOG_INFO("Saved backup preferences"); + } else { + LOG_ERROR("Failed to save backup preferences to file"); + } + } else if (location == meshtastic_AdminMessage_BackupLocation_SD) { + // TODO: After more mainline SD card support + } +#endif + return success; +} + +bool NodeDB::restorePreferences(meshtastic_AdminMessage_BackupLocation location, int restoreWhat) +{ + bool success = false; +#ifdef FSCom + if (location == meshtastic_AdminMessage_BackupLocation_FLASH) { + spiLock->lock(); + if (!FSCom.exists(backupFileName)) { + spiLock->unlock(); + LOG_WARN("Could not restore. No backup file found"); + return false; + } else { + spiLock->unlock(); + } + meshtastic_BackupPreferences backup = meshtastic_BackupPreferences_init_zero; + success = loadProto(backupFileName, meshtastic_BackupPreferences_size, sizeof(meshtastic_BackupPreferences), + &meshtastic_BackupPreferences_msg, &backup); + if (success) { + if (restoreWhat & SEGMENT_CONFIG) { + config = backup.config; + LOG_DEBUG("Restored config"); + } + if (restoreWhat & SEGMENT_MODULECONFIG) { + moduleConfig = backup.module_config; + LOG_DEBUG("Restored module config"); + } + if (restoreWhat & SEGMENT_DEVICESTATE) { + devicestate.owner = backup.owner; + LOG_DEBUG("Restored device state"); + } + if (restoreWhat & SEGMENT_CHANNELS) { + channelFile = backup.channels; + LOG_DEBUG("Restored channels"); + } + + success = saveToDisk(restoreWhat); + if (success) { + LOG_INFO("Restored preferences from backup"); + } else { + LOG_ERROR("Failed to save restored preferences to flash"); + } + } else { + LOG_ERROR("Failed to restore preferences from backup file"); + } + } else if (location == meshtastic_AdminMessage_BackupLocation_SD) { + // TODO: After more mainline SD card support + } + return success; +#endif +} + /// Record an error that should be reported via analytics void recordCriticalError(meshtastic_CriticalErrorCode code, uint32_t address, const char *filename) { diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index a31f33250..291c3804b 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -48,6 +48,7 @@ static constexpr const char *configFileName = "/prefs/config.proto"; static constexpr const char *uiconfigFileName = "/prefs/uiconfig.proto"; static constexpr const char *moduleConfigFileName = "/prefs/module.proto"; static constexpr const char *channelFileName = "/prefs/channels.proto"; +static constexpr const char *backupFileName = "/backups/backup.proto"; /// Given a node, return how many seconds in the past (vs now) that we last heard from it uint32_t sinceLastSeen(const meshtastic_NodeInfoLite *n); @@ -202,8 +203,13 @@ class NodeDB bool hasValidPosition(const meshtastic_NodeInfoLite *n); + bool backupPreferences(meshtastic_AdminMessage_BackupLocation location); + bool restorePreferences(meshtastic_AdminMessage_BackupLocation location, + int restoreWhat = SEGMENT_CONFIG | SEGMENT_MODULECONFIG | SEGMENT_DEVICESTATE | SEGMENT_CHANNELS); + private: - uint32_t lastNodeDbSave = 0; // when we last saved our db to flash + uint32_t lastNodeDbSave = 0; // when we last saved our db to flash + uint32_t lastBackupAttempt = 0; // when we last tried a backup automatically or manually /// Find a node in our DB, create an empty NodeInfoLite if missing meshtastic_NodeInfoLite *getOrCreateMeshNode(NodeNum n); diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index 9503109db..992f38ff4 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -372,7 +372,7 @@ DecodeState perhapsDecode(meshtastic_MeshPacket *p) p->pki_encrypted = true; memcpy(&p->public_key.bytes, nodeDB->getMeshNode(p->from)->user.public_key.bytes, 32); p->public_key.size = 32; - memcpy(&p->decoded, &decodedtmp, sizeof(meshtastic_Data_msg)); + p->decoded = decodedtmp; p->which_payload_variant = meshtastic_MeshPacket_decoded_tag; // change type to decoded } else { LOG_ERROR("PKC Decrypted, but pb_decode failed!"); diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index a765fb0b1..ae25ea3fc 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -370,6 +370,42 @@ bool AdminModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshta LOG_DEBUG("Failed to delete file"); } spiLock->unlock(); +#endif + break; + } + case meshtastic_AdminMessage_backup_preferences_tag: { + LOG_INFO("Client requesting to backup preferences"); + if (nodeDB->backupPreferences(r->backup_preferences)) { + myReply = allocErrorResponse(meshtastic_Routing_Error_NONE, &mp); + } else { + myReply = allocErrorResponse(meshtastic_Routing_Error_BAD_REQUEST, &mp); + } + break; + } + case meshtastic_AdminMessage_restore_preferences_tag: { + LOG_INFO("Client requesting to restore preferences"); + if (nodeDB->restorePreferences(r->backup_preferences, + SEGMENT_DEVICESTATE | SEGMENT_CONFIG | SEGMENT_MODULECONFIG | SEGMENT_CHANNELS)) { + myReply = allocErrorResponse(meshtastic_Routing_Error_NONE, &mp); + LOG_DEBUG("Rebooting after successful restore of preferences"); + reboot(1000); + disableBluetooth(); + } else { + myReply = allocErrorResponse(meshtastic_Routing_Error_BAD_REQUEST, &mp); + } + break; + } + case meshtastic_AdminMessage_remove_backup_preferences_tag: { + LOG_INFO("Client requesting to remove backup preferences"); +#ifdef FSCom + if (r->remove_backup_preferences == meshtastic_AdminMessage_BackupLocation_FLASH) { + spiLock->lock(); + FSCom.remove(backupFileName); + spiLock->unlock(); + } else if (r->remove_backup_preferences == meshtastic_AdminMessage_BackupLocation_SD) { + // TODO: After more mainline SD card support + LOG_ERROR("SD backup removal not implemented yet"); + } #endif break; } From 2876eec7ed9004271115495063151a028c0777e8 Mon Sep 17 00:00:00 2001 From: Austin Date: Mon, 17 Mar 2025 21:14:01 -0400 Subject: [PATCH 09/12] MeshToad - USB 1W 'MeshStick' (#6339) --- bin/config.d/lora-usb-meshtoad-e22.yaml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 bin/config.d/lora-usb-meshtoad-e22.yaml diff --git a/bin/config.d/lora-usb-meshtoad-e22.yaml b/bin/config.d/lora-usb-meshtoad-e22.yaml new file mode 100644 index 000000000..b6cb61c6b --- /dev/null +++ b/bin/config.d/lora-usb-meshtoad-e22.yaml @@ -0,0 +1,17 @@ +Lora: + Module: sx1262 + CS: 0 + IRQ: 6 + Reset: 2 + Busy: 4 + RXen: 1 + DIO2_AS_RF_SWITCH: true + DIO3_TCXO_VOLTAGE: true + spidev: ch341 + USB_PID: 0x5512 + USB_VID: 0x1A86 + # Optional: Reduce power to 10 dBm to + # avoid over-drawing the USB port + # SX126X_MAX_POWER: 10 + # Optional: Set the serial number for multi-radio support + # USB_Serialnum: 13374201 From 8efc9702d34fb579f22ae8e782949ef47340e348 Mon Sep 17 00:00:00 2001 From: Kalle Lilja <15094562+ThatKalle@users.noreply.github.com> Date: Tue, 18 Mar 2025 02:16:16 +0100 Subject: [PATCH 10/12] device-install/update: fix esptool --port (#6341) * fix errorlevel check * add esptool --port if supplied * match device-install * add --port if supplied * update logmessage * bump version --------- Co-authored-by: Ben Meadors --- bin/device-install.bat | 5 +++-- bin/device-install.sh | 4 ++-- bin/device-update.bat | 11 ++++++----- bin/device-update.sh | 4 ++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/bin/device-install.bat b/bin/device-install.bat index 926338464..7eb5c1b30 100755 --- a/bin/device-install.bat +++ b/bin/device-install.bat @@ -34,7 +34,7 @@ ECHO Example: %SCRIPT_NAME% -f firmware-unphone-2.6.0.0b106d4.bin -p COM11 --web GOTO eof :version -ECHO %SCRIPT_NAME% [Version 2.6.0] +ECHO %SCRIPT_NAME% [Version 2.6.1] ECHO Meshtastic GOTO eof @@ -106,7 +106,7 @@ IF NOT "__%PYTHON%__"=="____" ( CALL :LOG_MESSAGE DEBUG "Checking esptool command !ESPTOOL_CMD!..." !ESPTOOL_CMD! >nul 2>&1 -IF %ERRORLEVEL% GTR 2 ( +IF %ERRORLEVEL% GEQ 2 ( @REM esptool exits with code 1 if help is displayed. CALL :LOG_MESSAGE ERROR "esptool not found: !ESPTOOL_CMD!" EXIT /B 1 @@ -121,6 +121,7 @@ CALL :LOG_MESSAGE DEBUG "Using esptool command: !ESPTOOL_CMD!" IF "__!ESPTOOL_PORT!__" == "____" ( CALL :LOG_MESSAGE WARN "Using esptool port: UNSET." ) ELSE ( + SET "ESPTOOL_CMD=!ESPTOOL_CMD! --port !ESPTOOL_PORT!" CALL :LOG_MESSAGE INFO "Using esptool port: !ESPTOOL_PORT!." ) CALL :LOG_MESSAGE INFO "Using esptool baud: !ESPTOOL_BAUD!." diff --git a/bin/device-install.sh b/bin/device-install.sh index 61c72bc2e..56e1abdb2 100755 --- a/bin/device-install.sh +++ b/bin/device-install.sh @@ -42,8 +42,8 @@ while [ $# -gt 0 ]; do exit 0 ;; -p) - ESPTOOL_PORT="$2" - shift # Shift past the option argument + ESPTOOL_CMD="$ESPTOOL_CMD --port $2" + shift ;; -P) PYTHON="$2" diff --git a/bin/device-update.bat b/bin/device-update.bat index ecfeec187..d9a4bd19a 100755 --- a/bin/device-update.bat +++ b/bin/device-update.bat @@ -16,7 +16,7 @@ ECHO. ECHO Usage: %SCRIPT_NAME% -f filename [-p PORT] [-P python] ECHO. ECHO Options: -ECHO -f filename The .bin file to flash. Custom to your device type and region. (required) +ECHO -f filename The update .bin file to flash. Custom to your device type and region. (required) ECHO The file must be located in this current directory. ECHO -p PORT Set the environment variable for ESPTOOL_PORT. ECHO If not set, ESPTOOL iterates all ports (Dangerous). @@ -28,7 +28,7 @@ ECHO Example: %SCRIPT_NAME% -f firmware-t-deck-tft-2.6.0.0b106d4-update.bin -p C GOTO eof :version -ECHO %SCRIPT_NAME% [Version 2.6.0] +ECHO %SCRIPT_NAME% [Version 2.6.1] ECHO Meshtastic GOTO eof @@ -53,6 +53,7 @@ IF "__!FILENAME!__"=="____" ( CALL :LOG_MESSAGE DEBUG "Missing -f filename input." GOTO help ) ELSE ( + CALL :LOG_MESSAGE DEBUG "Filename: !FILENAME!" IF NOT "__!FILENAME: =!__"=="__!FILENAME!__" ( CALL :LOG_MESSAGE ERROR "Filename containing spaces are not supported." GOTO help @@ -62,7 +63,6 @@ IF "__!FILENAME!__"=="____" ( SET "FILENAME=!FILENAME:./=!" ) -CALL :LOG_MESSAGE DEBUG "Filename: !FILENAME!" CALL :LOG_MESSAGE DEBUG "Checking if !FILENAME! exists..." IF NOT EXIST !FILENAME! ( CALL :LOG_MESSAGE ERROR "File does not exist: !FILENAME!. Terminating." @@ -71,7 +71,7 @@ IF NOT EXIST !FILENAME! ( IF "!FILENAME:update=!"=="!FILENAME!" ( CALL :LOG_MESSAGE DEBUG "We are NOT working with a *update* file. !FILENAME!" - CALL :LOG_MESSAGE INFO "Use script device-install.bat to flash update !FILENAME!." + CALL :LOG_MESSAGE INFO "Use script device-install.bat to flash !FILENAME!." GOTO eof ) ELSE ( CALL :LOG_MESSAGE DEBUG "We are working with a *update* file. !FILENAME!" @@ -95,7 +95,7 @@ IF NOT "__%PYTHON%__"=="____" ( CALL :LOG_MESSAGE DEBUG "Checking esptool command !ESPTOOL_CMD!..." !ESPTOOL_CMD! >nul 2>&1 -IF %ERRORLEVEL% GTR 2 ( +IF %ERRORLEVEL% GEQ 2 ( @REM esptool exits with code 1 if help is displayed. CALL :LOG_MESSAGE ERROR "esptool not found: !ESPTOOL_CMD!" EXIT /B 1 @@ -110,6 +110,7 @@ CALL :LOG_MESSAGE DEBUG "Using esptool command: !ESPTOOL_CMD!" IF "__!ESPTOOL_PORT!__" == "____" ( CALL :LOG_MESSAGE WARN "Using esptool port: UNSET." ) ELSE ( + SET "ESPTOOL_CMD=!ESPTOOL_CMD! --port !ESPTOOL_PORT!" CALL :LOG_MESSAGE INFO "Using esptool port: !ESPTOOL_PORT!." ) CALL :LOG_MESSAGE INFO "Using esptool baud: !ESPTOOL_BAUD!." diff --git a/bin/device-update.sh b/bin/device-update.sh index 67281dc4f..ae7b52ea2 100755 --- a/bin/device-update.sh +++ b/bin/device-update.sh @@ -35,8 +35,8 @@ while getopts ":hp:P:f:" opt; do show_help exit 0 ;; - p) export ESPTOOL_PORT=${OPTARG} - ;; + p) ESPTOOL_CMD="$ESPTOOL_CMD --port ${OPTARG}" + ;; P) PYTHON=${OPTARG} ;; f) FILENAME=${OPTARG} From 6673cb929226c4b6abf256ad96993585b2231f15 Mon Sep 17 00:00:00 2001 From: Austin Date: Tue, 18 Mar 2025 21:19:51 -0400 Subject: [PATCH 11/12] Increase MAX_NUM_NODES on high-flash ESP32_S3 (#6311) --- arch/nrf52/nrf52.ini | 1 - bin/device-install.bat | 52 ++++++----- bin/device-install.sh | 86 ++++++++++++++----- src/mesh/mesh-pb-constants.h | 22 ++++- variants/CDEBYTE_E77-MBL/variant.h | 1 - .../crowpanel-esp32s3-5-epaper/platformio.ini | 3 + variants/diy/platformio.ini | 3 +- variants/dreamcatcher/platformio.ini | 6 +- variants/esp32-s3-pico/platformio.ini | 1 + .../heltec_capsule_sensor_v3/platformio.ini | 2 +- variants/heltec_v3/platformio.ini | 4 +- .../heltec_vision_master_e213/platformio.ini | 4 +- .../heltec_vision_master_e290/platformio.ini | 2 + .../heltec_vision_master_t190/platformio.ini | 4 +- variants/heltec_wireless_paper/platformio.ini | 2 + .../heltec_wireless_paper_v1/platformio.ini | 1 + .../heltec_wireless_tracker/platformio.ini | 1 + .../platformio.ini | 1 + variants/heltec_wsl_v3/platformio.ini | 3 +- variants/icarus/platformio.ini | 4 +- variants/m5stack_cores3/platformio.ini | 1 + variants/mesh-tab/platformio.ini | 1 - variants/picomputer-s3/platformio.ini | 3 +- variants/rak3172/variant.h | 1 - .../seeed-sensecap-indicator/platformio.ini | 3 +- variants/seeed_xiao_s3/platformio.ini | 2 +- variants/station-g2/platformio.ini | 5 +- variants/t-deck/platformio.ini | 3 +- variants/t-eth-elite/platformio.ini | 3 +- variants/t-watch-s3/platformio.ini | 1 + variants/tbeam-s3-core/platformio.ini | 1 + variants/tracksenger/platformio.ini | 3 + variants/unphone/platformio.ini | 3 +- variants/wio-e5/variant.h | 1 - 34 files changed, 155 insertions(+), 79 deletions(-) diff --git a/arch/nrf52/nrf52.ini b/arch/nrf52/nrf52.ini index 606cabac6..d4e88af1f 100644 --- a/arch/nrf52/nrf52.ini +++ b/arch/nrf52/nrf52.ini @@ -17,7 +17,6 @@ build_flags = -DLFS_NO_ASSERT ; Disable LFS assertions , see https://github.com/meshtastic/firmware/pull/3818 -DMESHTASTIC_EXCLUDE_AUDIO=1 -DMESHTASTIC_EXCLUDE_PAXCOUNTER=1 - -DMAX_NUM_NODES=80 build_src_filter = ${arduino_base.build_src_filter} - - - - - - - - - - diff --git a/bin/device-install.bat b/bin/device-install.bat index 7eb5c1b30..3ffca0b63 100755 --- a/bin/device-install.bat +++ b/bin/device-install.bat @@ -7,12 +7,19 @@ SET "DEBUG=0" SET "PYTHON=" SET "WEB_APP=0" SET "TFT_BUILD=0" -SET "TFT8=0" -SET "TFT16=0" +SET "BIGDB8=0" +SET "BIGDB16=0" SET "ESPTOOL_BAUD=115200" SET "ESPTOOL_CMD=" SET "LOGCOUNTER=0" +@REM FIXME: Determine mcu from PlatformIO variant, this is unmaintainable. +SET "S3=s3 v3 t-deck wireless-paper wireless-tracker station-g2 unphone" +SET "C3=esp32c3" +@REM FIXME: Determine flash size from PlatformIO variant, this is unmaintainable. +SET "BIGDB_8MB=picomputer-s3 unphone seeed-sensecap-indicator crowpanel-esp32s3 heltec_capsule_sensor_v3 heltec-v3 heltec-vision-master-e213 heltec-vision-master-e290 heltec-vision-master-t190 heltec-wireless-paper heltec-wireless-tracker heltec-wsl-v3 icarus seeed-xiao-s3 tbeam-s3-core tracksenger" +SET "BIGDB_16MB=t-deck mesh-tab t-energy-s3 dreamcatcher ESP32-S3-Pico m5stack-cores3 station-g2 t-eth-elite t-watch-s3" + GOTO getopts :help ECHO Flash image file to device, but first erasing and writing system information. @@ -134,44 +141,36 @@ IF NOT "!FILENAME:-tft-=!"=="!FILENAME!" ( CALL :LOG_MESSAGE ERROR "Cannot enable WebUI (--web) and MUI." & GOTO eof ) SET "TFT_BUILD=1" - GOTO tft ) ELSE ( CALL :LOG_MESSAGE DEBUG "We are NOT working with a *-tft-* file. !FILENAME!" - GOTO no_tft ) -:tft -SET "TFT8MB=picomputer-s3 unphone seeed-sensecap-indicator" -FOR %%a IN (%TFT8MB%) DO ( +FOR %%a IN (%BIGDB_8MB%) DO ( IF NOT "!FILENAME:%%a=!"=="!FILENAME!" ( - @REM We are working with any of %TFT8MB%. - SET "TFT8=1" - GOTO end_loop_tft8mb + @REM We are working with any of %BIGDB_8MB%. + SET "BIGDB8=1" + GOTO end_loop_bigdb_8mb ) ) -:end_loop_tft8mb +:end_loop_bigdb_8mb -SET "TFT16MB=t-deck" -FOR %%a IN (%TFT16MB%) DO ( +FOR %%a IN (%BIGDB_16MB%) DO ( IF NOT "!FILENAME:%%a=!"=="!FILENAME!" ( - @REM We are working with any of %TFT16MB%. - SET "TFT16=1" - GOTO end_loop_tft16mb + @REM We are working with any of %BIGDB_16MB%. + SET "BIGDB16=1" + GOTO end_loop_bigdb_16mb ) ) -:end_loop_tft16mb +:end_loop_bigdb_16mb -IF %TFT8% EQU 1 CALL :LOG_MESSAGE INFO "tft and MUI 8mb selected." -IF %TFT16% EQU 1 CALL :LOG_MESSAGE INFO "tft and MUI 16mb selected." - -:no_tft +IF %BIGDB8% EQU 1 CALL :LOG_MESSAGE INFO "BigDB 8mb partition selected." +IF %BIGDB16% EQU 1 CALL :LOG_MESSAGE INFO "BigDB 16mb partition selected." @REM Extract BASENAME from %FILENAME% for later use. SET "BASENAME=!FILENAME:firmware-=!" CALL :LOG_MESSAGE DEBUG "Computed firmware basename: !BASENAME!" @REM Account for S3 and C3 board's different OTA partition. -SET "S3=s3 v3 t-deck wireless-paper wireless-tracker station-g2 unphone" FOR %%a IN (%S3%) DO ( IF NOT "!FILENAME:%%a=!"=="!FILENAME!" ( @REM We are working with any of %S3%. @@ -180,7 +179,6 @@ FOR %%a IN (%S3%) DO ( ) ) -SET "C3=esp32c3" FOR %%a IN (%C3%) DO ( IF NOT "!FILENAME:%%a=!"=="!FILENAME!" ( @REM We are working with any of %C3%. @@ -209,14 +207,14 @@ CALL :LOG_MESSAGE DEBUG "Set SPIFFS_FILENAME to: !SPIFFS_FILENAME!" SET "OTA_OFFSET=0x260000" SET "SPIFFS_OFFSET=0x300000" -@REM Offsets for MUI 8mb. -IF %TFT8% EQU 1 IF %TFT_BUILD% EQU 1 ( +@REM Offsets for BigDB 8mb. +IF %BIGDB8% EQU 1 ( SET "OTA_OFFSET=0x340000" SET "SPIFFS_OFFSET=0x670000" ) -@REM Offsets for MUI 16mb. -IF %TFT16% EQU 1 IF %TFT_BUILD% EQU 1 ( +@REM Offsets for BigDB 16mb. +IF %BIGDB16% EQU 1 ( SET "OTA_OFFSET=0x650000" SET "SPIFFS_OFFSET=0xc90000" ) diff --git a/bin/device-install.sh b/bin/device-install.sh index 56e1abdb2..b5322b9d1 100755 --- a/bin/device-install.sh +++ b/bin/device-install.sh @@ -2,9 +2,48 @@ PYTHON=${PYTHON:-$(which python3 python | head -n 1)} WEB_APP=false -TFT8=false -TFT16=false TFT_BUILD=false +MCU="" + +# Variant groups +BIGDB_8MB=( + "picomputer-s3" + "unphone" + "seeed-sensecap-indicator" + "crowpanel-esp32s3" + "heltec_capsule_sensor_v3" + "heltec-v3" + "heltec-vision-master-e213" + "heltec-vision-master-e290" + "heltec-vision-master-t190" + "heltec-wireless-paper" + "heltec-wireless-tracker" + "heltec-wsl-v3" + "icarus" + "seeed-xiao-s3" + "tbeam-s3-core" + "tracksenger" +) +BIGDB_16MB=( + "t-deck" + "mesh-tab" + "t-energy-s3" + "dreamcatcher" + "ESP32-S3-Pico" + "m5stack-cores3" + "station-g2" + "t-eth-elite" + "t-watch-s3" +) +S3_VARIANTS=( + "s3" + "-v3" + "t-deck" + "wireless-paper" + "wireless-tracker" + "station-g2" + "unphone" +) # Determine the correct esptool command to use if "$PYTHON" -m esptool version >/dev/null 2>&1; then @@ -78,21 +117,13 @@ if [[ $FILENAME != firmware-* ]]; then exit 1 fi -# Check if FILENAME contains "-tft-" and set target partitionScheme accordingly. +# Check if FILENAME contains "-tft-" and prevent web/mui comingling. if [[ ${FILENAME//-tft-/} != "$FILENAME" ]]; then TFT_BUILD=true if [[ $WEB_APP == true ]] && [[ $TFT_BUILD == true ]]; then echo "Cannot enable WebUI (--web) and MUI." exit 1 fi - - if [[ $FILENAME == *"picomputer-s3"* || $FILENAME == *"unphone"* || $FILENAME == *"seeed-sensecap-indicator"* ]]; then - TFT8=true - fi - - if [[ $FILENAME == *"t-deck"* ]]; then - TFT16=true - fi fi # Extract BASENAME from %FILENAME% for later use. @@ -105,20 +136,31 @@ if [ -f "${FILENAME}" ] && [ -n "${FILENAME##*"update"*}" ]; then # Default OTA Offset OTA_OFFSET=0x260000 - # littlefs* offset for MUI 8mb and OTA OFFSET. - if [ "$TFT8" = true ] && [ "$TFT_BUILD" = true ]; then - OFFSET=0x670000 - OTA_OFFSET=0x340000 - fi + # littlefs* offset for BigDB 8mb and OTA OFFSET. + for variant in "${BIGDB_8MB[@]}"; do + if [ -n "${FILENAME##*"$variant"*}" ]; then + OFFSET=0x670000 + OTA_OFFSET=0x340000 + fi + done - # littlefs* offset for MUI 16mb and OTA OFFSET. - if [ "$TFT16" = true ] && [ "$TFT_BUILD" = true ]; then - OFFSET=0xc90000 - OTA_OFFSET=0x650000 - fi + # littlefs* offset for BigDB 16mb and OTA OFFSET. + for variant in "${BIGDB_16MB[@]}"; do + if [ -n "${FILENAME##*"$variant"*}" ]; then + OFFSET=0xc90000 + OTA_OFFSET=0x650000 + fi + done # Account for S3 board's different OTA partition - if [ -n "${FILENAME##*"s3"*}" ] && [ -n "${FILENAME##*"-v3"*}" ] && [ -n "${FILENAME##*"t-deck"*}" ] && [ -n "${FILENAME##*"wireless-paper"*}" ] && [ -n "${FILENAME##*"wireless-tracker"*}" ] && [ -n "${FILENAME##*"station-g2"*}" ] && [ -n "${FILENAME##*"unphone"*}" ]; then + # FIXME: Use PlatformIO info to determine MCU type, this is unmaintainable + for variant in "${S3_VARIANTS[@]}"; do + if [ -n "${FILENAME##*"$variant"*}" ]; then + MCU="esp32s3" + fi + done + + if [ "$MCU" != "esp32s3" ]; then if [ -n "${FILENAME##*"esp32c3"*}" ]; then OTAFILE=bleota.bin else diff --git a/src/mesh/mesh-pb-constants.h b/src/mesh/mesh-pb-constants.h index f91c48560..1c86653dc 100644 --- a/src/mesh/mesh-pb-constants.h +++ b/src/mesh/mesh-pb-constants.h @@ -18,10 +18,30 @@ #define MAX_RX_TOPHONE 32 #endif -/// max number of nodes allowed in the mesh +/// max number of nodes allowed in the nodeDB #ifndef MAX_NUM_NODES +#if defined(ARCH_STM32WL) +#define MAX_NUM_NODES 10 +#elif defined(ARCH_NRF52) +#define MAX_NUM_NODES 80 +#elif defined(CONFIG_IDF_TARGET_ESP32S3) +#include "Esp.h" +static inline int get_max_num_nodes() +{ + uint32_t flash_size = ESP.getFlashChipSize() / (1024 * 1024); // Convert Bytes to MB + if (flash_size >= 15) { + return 250; + } else if (flash_size >= 7) { + return 200; + } else { + return 100; + } +} +#define MAX_NUM_NODES get_max_num_nodes() +#else #define MAX_NUM_NODES 100 #endif +#endif /// Max number of channels allowed #define MAX_NUM_CHANNELS (member_size(meshtastic_ChannelFile, channels) / member_size(meshtastic_ChannelFile, channels[0])) diff --git a/variants/CDEBYTE_E77-MBL/variant.h b/variants/CDEBYTE_E77-MBL/variant.h index 7331dcedc..52801dac7 100644 --- a/variants/CDEBYTE_E77-MBL/variant.h +++ b/variants/CDEBYTE_E77-MBL/variant.h @@ -14,7 +14,6 @@ Do not expect a working Meshtastic device with this target. #define _VARIANT_EBYTE_E77_ #define USE_STM32WLx -#define MAX_NUM_NODES 10 #define LED_PIN PB4 // LED1 // #define LED_PIN PB3 // LED2 diff --git a/variants/crowpanel-esp32s3-5-epaper/platformio.ini b/variants/crowpanel-esp32s3-5-epaper/platformio.ini index 7e95a5fcf..36816d616 100644 --- a/variants/crowpanel-esp32s3-5-epaper/platformio.ini +++ b/variants/crowpanel-esp32s3-5-epaper/platformio.ini @@ -5,6 +5,7 @@ board_build.flash_mode = qio board_build.psram_type = opi board_upload.flash_size = 8MB board_upload.maximum_size = 8388608 +board_build.partitions = default_8MB.csv board = esp32-s3-devkitc-1 ;upload_port = /dev/ttyUSB0 board_level = extra @@ -32,6 +33,7 @@ board_build.flash_mode = qio board_build.psram_type = opi board_upload.flash_size = 8MB board_upload.maximum_size = 8388608 +board_build.partitions = default_8MB.csv board = esp32-s3-devkitc-1 ;upload_port = /dev/ttyUSB0 board_level = extra @@ -59,6 +61,7 @@ board_build.flash_mode = qio board_build.psram_type = opi board_upload.flash_size = 8MB board_upload.maximum_size = 8388608 +board_build.partitions = default_8MB.csv board = esp32-s3-devkitc-1 ;upload_port = /dev/ttyUSB0 board_level = extra diff --git a/variants/diy/platformio.ini b/variants/diy/platformio.ini index 229f48bbf..825c464a2 100644 --- a/variants/diy/platformio.ini +++ b/variants/diy/platformio.ini @@ -88,6 +88,7 @@ debug_tool = jlink [env:t-energy-s3_e22] extends = esp32s3_base board = esp32-s3-devkitc-1 +board_build.partitions = default_16MB.csv board_level = extra board_upload.flash_size = 16MB ;Specify the FLASH capacity as 16MB board_build.arduino.memory_type = qio_opi ;Enable internal PSRAM @@ -100,4 +101,4 @@ build_flags = -D BOARD_HAS_PSRAM -D ARDUINO_USB_MODE=0 -D ARDUINO_USB_CDC_ON_BOOT=1 - -I variants/diy/t-energy-s3_e22 \ No newline at end of file + -I variants/diy/t-energy-s3_e22 diff --git a/variants/dreamcatcher/platformio.ini b/variants/dreamcatcher/platformio.ini index c57849d96..6527d89be 100644 --- a/variants/dreamcatcher/platformio.ini +++ b/variants/dreamcatcher/platformio.ini @@ -1,6 +1,7 @@ [env:dreamcatcher] ; 2301, latest revision extends = esp32s3_base board = esp32s3box +board_build.partitions = default_16MB.csv board_level = extra build_flags = @@ -8,7 +9,7 @@ build_flags = -D PRIVATE_HW -D OTHERNET_DC_REV=2301 -I variants/dreamcatcher - -DARDUINO_USB_CDC_ON_BOOT=1 + -D ARDUINO_USB_CDC_ON_BOOT=1 lib_deps = ${esp32s3_base.lib_deps} earlephilhower/ESP8266Audio@^1.9.9 @@ -17,6 +18,7 @@ lib_deps = ${esp32s3_base.lib_deps} [env:dreamcatcher-2206] extends = esp32s3_base board = esp32s3box +board_build.partitions = default_16MB.csv board_level = extra build_flags = @@ -24,4 +26,4 @@ build_flags = -D PRIVATE_HW -D OTHERNET_DC_REV=2206 -I variants/dreamcatcher - -DARDUINO_USB_CDC_ON_BOOT=1 \ No newline at end of file + -D ARDUINO_USB_CDC_ON_BOOT=1 diff --git a/variants/esp32-s3-pico/platformio.ini b/variants/esp32-s3-pico/platformio.ini index 20a41ba56..69969c601 100644 --- a/variants/esp32-s3-pico/platformio.ini +++ b/variants/esp32-s3-pico/platformio.ini @@ -4,6 +4,7 @@ board_level = extra extends = esp32s3_base upload_protocol = esptool board = esp32-s3-pico +board_build.partitions = default_16MB.csv board_upload.use_1200bps_touch = yes board_upload.wait_for_upload_port = yes diff --git a/variants/heltec_capsule_sensor_v3/platformio.ini b/variants/heltec_capsule_sensor_v3/platformio.ini index b5ffb65c2..8d1c039c1 100644 --- a/variants/heltec_capsule_sensor_v3/platformio.ini +++ b/variants/heltec_capsule_sensor_v3/platformio.ini @@ -2,7 +2,7 @@ extends = esp32s3_base board = heltec_wifi_lora_32_V3 board_check = true - +board_build.partitions = default_8MB.csv build_flags = ${esp32s3_base.build_flags} -I variants/heltec_capsule_sensor_v3 -D HELTEC_CAPSULE_SENSOR_V3 diff --git a/variants/heltec_v3/platformio.ini b/variants/heltec_v3/platformio.ini index e8f73e1ef..4be96b019 100644 --- a/variants/heltec_v3/platformio.ini +++ b/variants/heltec_v3/platformio.ini @@ -2,7 +2,7 @@ extends = esp32s3_base board = heltec_wifi_lora_32_V3 board_check = true -# Temporary until espressif creates a release with this new target +board_build.partitions = default_8MB.csv build_flags = ${esp32s3_base.build_flags} -D HELTEC_V3 -I variants/heltec_v3 - -DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. \ No newline at end of file + -D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. diff --git a/variants/heltec_vision_master_e213/platformio.ini b/variants/heltec_vision_master_e213/platformio.ini index 6ba597200..4bed30324 100644 --- a/variants/heltec_vision_master_e213/platformio.ini +++ b/variants/heltec_vision_master_e213/platformio.ini @@ -1,8 +1,9 @@ [env:heltec-vision-master-e213] extends = esp32s3_base board = heltec_vision_master_e213 +board_build.partitions = default_8MB.csv build_flags = - ${esp32s3_base.build_flags} + ${esp32s3_base.build_flags} -Ivariants/heltec_vision_master_e213 -DHELTEC_VISION_MASTER_E213 -DUSE_EINK @@ -22,6 +23,7 @@ upload_speed = 115200 [env:heltec-vision-master-e213-inkhud] extends = esp32s3_base, inkhud board = heltec_vision_master_e213 +board_build.partitions = default_8MB.csv build_src_filter = ${esp32_base.build_src_filter} ${inkhud.build_src_filter} diff --git a/variants/heltec_vision_master_e290/platformio.ini b/variants/heltec_vision_master_e290/platformio.ini index cfea81a7e..d28c2015b 100644 --- a/variants/heltec_vision_master_e290/platformio.ini +++ b/variants/heltec_vision_master_e290/platformio.ini @@ -2,6 +2,7 @@ [env:heltec-vision-master-e290] extends = esp32s3_base board = heltec_vision_master_e290 +board_build.partitions = default_8MB.csv build_flags = ${esp32s3_base.build_flags} -I variants/heltec_vision_master_e290 @@ -26,6 +27,7 @@ upload_speed = 115200 [env:heltec-vision-master-e290-inkhud] extends = esp32s3_base, inkhud board = heltec_vision_master_e290 +board_build.partitions = default_8MB.csv build_src_filter = ${esp32_base.build_src_filter} ${inkhud.build_src_filter} diff --git a/variants/heltec_vision_master_t190/platformio.ini b/variants/heltec_vision_master_t190/platformio.ini index 0c504d62b..53b56f57d 100644 --- a/variants/heltec_vision_master_t190/platformio.ini +++ b/variants/heltec_vision_master_t190/platformio.ini @@ -1,11 +1,11 @@ [env:heltec-vision-master-t190] extends = esp32s3_base board = heltec_vision_master_t190 +board_build.partitions = default_8MB.csv build_flags = ${esp32s3_base.build_flags} -Ivariants/heltec_vision_master_t190 - -DHELTEC_VISION_MASTER_T190 - ; -D PRIVATE_HW + -DHELTEC_VISION_MASTER_T190 lib_deps = ${esp32s3_base.lib_deps} lewisxhe/PCF8563_Library@^1.0.1 diff --git a/variants/heltec_wireless_paper/platformio.ini b/variants/heltec_wireless_paper/platformio.ini index 9979e1c1d..bd25a932a 100644 --- a/variants/heltec_wireless_paper/platformio.ini +++ b/variants/heltec_wireless_paper/platformio.ini @@ -2,6 +2,7 @@ [env:heltec-wireless-paper] extends = esp32s3_base board = heltec_wifi_lora_32_V3 +board_build.partitions = default_8MB.csv build_flags = ${esp32s3_base.build_flags} -I variants/heltec_wireless_paper @@ -23,6 +24,7 @@ upload_speed = 115200 [env:heltec-wireless-paper-inkhud] extends = esp32s3_base, inkhud board = heltec_wifi_lora_32_V3 +board_build.partitions = default_8MB.csv build_src_filter = ${esp32_base.build_src_filter} ${inkhud.build_src_filter} diff --git a/variants/heltec_wireless_paper_v1/platformio.ini b/variants/heltec_wireless_paper_v1/platformio.ini index 2ce7559f9..ec5fe2408 100644 --- a/variants/heltec_wireless_paper_v1/platformio.ini +++ b/variants/heltec_wireless_paper_v1/platformio.ini @@ -2,6 +2,7 @@ extends = esp32s3_base board_level = extra board = heltec_wifi_lora_32_V3 +board_build.partitions = default_8MB.csv build_flags = ${esp32s3_base.build_flags} -I variants/heltec_wireless_paper_v1 diff --git a/variants/heltec_wireless_tracker/platformio.ini b/variants/heltec_wireless_tracker/platformio.ini index 4f686d289..5c19c37e6 100644 --- a/variants/heltec_wireless_tracker/platformio.ini +++ b/variants/heltec_wireless_tracker/platformio.ini @@ -1,6 +1,7 @@ [env:heltec-wireless-tracker] extends = esp32s3_base board = heltec_wireless_tracker +board_build.partitions = default_8MB.csv upload_protocol = esptool build_flags = diff --git a/variants/heltec_wireless_tracker_V1_0/platformio.ini b/variants/heltec_wireless_tracker_V1_0/platformio.ini index 5f512b816..08b0ae95c 100644 --- a/variants/heltec_wireless_tracker_V1_0/platformio.ini +++ b/variants/heltec_wireless_tracker_V1_0/platformio.ini @@ -2,6 +2,7 @@ extends = esp32s3_base board_level = extra board = heltec_wireless_tracker +board_build.partitions = default_8MB.csv upload_protocol = esptool build_flags = ${esp32s3_base.build_flags} -I variants/heltec_wireless_tracker_V1_0 diff --git a/variants/heltec_wsl_v3/platformio.ini b/variants/heltec_wsl_v3/platformio.ini index c95659156..bc3e6ada1 100644 --- a/variants/heltec_wsl_v3/platformio.ini +++ b/variants/heltec_wsl_v3/platformio.ini @@ -1,7 +1,8 @@ [env:heltec-wsl-v3] extends = esp32s3_base board = heltec_wifi_lora_32_V3 +board_build.partitions = default_8MB.csv # Temporary until espressif creates a release with this new target build_flags = ${esp32s3_base.build_flags} -D HELTEC_WSL_V3 -I variants/heltec_wsl_v3 - -DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. \ No newline at end of file + -D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. diff --git a/variants/icarus/platformio.ini b/variants/icarus/platformio.ini index b1dc01fc1..b4ea125cf 100644 --- a/variants/icarus/platformio.ini +++ b/variants/icarus/platformio.ini @@ -4,6 +4,7 @@ board = icarus board_level = extra board_check = true board_build.mcu = esp32s3 +board_build.partitions = default_8MB.csv upload_protocol = esptool upload_speed = 921600 platform_packages = platformio/framework-arduinoespressif32@https://github.com/PowerFeather/powerfeather-meshtastic-arduino-lib/releases/download/2.0.16a/esp32-2.0.16.zip @@ -15,5 +16,4 @@ build_unflags = build_flags = ${esp32s3_base.build_flags} -D PRIVATE_HW -I variants/icarus -DBOARD_HAS_PSRAM - - -DARDUINO_USB_MODE=0 \ No newline at end of file + -DARDUINO_USB_MODE=0 diff --git a/variants/m5stack_cores3/platformio.ini b/variants/m5stack_cores3/platformio.ini index fc73fabae..2253e75e2 100644 --- a/variants/m5stack_cores3/platformio.ini +++ b/variants/m5stack_cores3/platformio.ini @@ -3,6 +3,7 @@ extends = esp32s3_base board = m5stack-cores3 board_check = true +board_build.partitions = default_16MB.csv upload_protocol = esptool build_flags = ${esp32_base.build_flags} diff --git a/variants/mesh-tab/platformio.ini b/variants/mesh-tab/platformio.ini index 9e3429ac5..728fa5100 100644 --- a/variants/mesh-tab/platformio.ini +++ b/variants/mesh-tab/platformio.ini @@ -28,7 +28,6 @@ build_flags = ${esp32s3_base.build_flags} -D USE_LOG_DEBUG -D LOG_DEBUG_INC=\"DebugConfiguration.h\" -D RADIOLIB_SPI_PARANOID=0 - -D MAX_NUM_NODES=250 -D MAX_THREADS=40 -D HAS_SCREEN=0 -D HAS_TFT=1 diff --git a/variants/picomputer-s3/platformio.ini b/variants/picomputer-s3/platformio.ini index 7f769253c..df2d0dfdc 100644 --- a/variants/picomputer-s3/platformio.ini +++ b/variants/picomputer-s3/platformio.ini @@ -2,6 +2,7 @@ extends = esp32s3_base board = bpi_picow_esp32_s3 board_check = true +board_build.partitions = default_8MB.csv ;OpenOCD flash method ;upload_protocol = esp-builtin ;Normal method @@ -22,7 +23,6 @@ build_src_filter = [env:picomputer-s3-tft] extends = env:picomputer-s3 -board_build.partitions = default_8MB.csv ; just for test build_flags = ${env:picomputer-s3.build_flags} @@ -35,7 +35,6 @@ build_flags = -D INPUTDRIVER_MATRIX_TYPE=1 -D USE_PIN_BUZZER=PIN_BUZZER -D USE_SX127x - -D MAX_NUM_NODES=200 -D HAS_SCREEN=0 -D HAS_TFT=1 -D RAM_SIZE=1024 diff --git a/variants/rak3172/variant.h b/variants/rak3172/variant.h index 21de65b2c..dd12fe393 100644 --- a/variants/rak3172/variant.h +++ b/variants/rak3172/variant.h @@ -7,6 +7,5 @@ Do not expect a working Meshtastic device with this target. #define _VARIANT_RAK3172_ #define USE_STM32WLx -#define MAX_NUM_NODES 10 #endif \ No newline at end of file diff --git a/variants/seeed-sensecap-indicator/platformio.ini b/variants/seeed-sensecap-indicator/platformio.ini index d351713d7..da11953b7 100644 --- a/variants/seeed-sensecap-indicator/platformio.ini +++ b/variants/seeed-sensecap-indicator/platformio.ini @@ -6,6 +6,7 @@ platform_packages = board = seeed-sensecap-indicator board_check = true +board_build.partitions = default_8MB.csv upload_protocol = esptool build_flags = ${esp32_base.build_flags} @@ -32,7 +33,6 @@ lib_deps = ${esp32s3_base.lib_deps} extends = env:seeed-sensecap-indicator board_level = main upload_speed = 460800 -board_build.partitions = default_8MB.csv ; must be here for some reason, board.json is not enough !? build_flags = ${env:seeed-sensecap-indicator.build_flags} @@ -46,7 +46,6 @@ build_flags = -D INPUTDRIVER_BUTTON_TYPE=38 -D HAS_TELEMETRY=0 -D CONFIG_DISABLE_HAL_LOCKS=1 - -D MAX_NUM_NODES=250 -D HAS_SCREEN=0 -D HAS_TFT=1 -D DISPLAY_SET_RESOLUTION diff --git a/variants/seeed_xiao_s3/platformio.ini b/variants/seeed_xiao_s3/platformio.ini index 3d10d7136..9d935e2e0 100644 --- a/variants/seeed_xiao_s3/platformio.ini +++ b/variants/seeed_xiao_s3/platformio.ini @@ -2,7 +2,7 @@ extends = esp32s3_base board = seeed-xiao-s3 board_check = true -board_build.mcu = esp32s3 +board_build.partitions = default_8MB.csv upload_protocol = esptool upload_speed = 921600 lib_deps = diff --git a/variants/station-g2/platformio.ini b/variants/station-g2/platformio.ini index b674c8bae..4ddd28f1c 100755 --- a/variants/station-g2/platformio.ini +++ b/variants/station-g2/platformio.ini @@ -2,6 +2,7 @@ extends = esp32s3_base board = station-g2 board_check = true +board_build.partitions = default_16MB.csv board_build.mcu = esp32s3 upload_protocol = esptool ;upload_port = /dev/ttyACM0 @@ -13,6 +14,6 @@ build_unflags = -DARDUINO_USB_MODE=1 build_flags = ${esp32s3_base.build_flags} -D STATION_G2 -I variants/station-g2 - -DBOARD_HAS_PSRAM + -DBOARD_HAS_PSRAM -DSTATION_G2 - -DARDUINO_USB_MODE=0 \ No newline at end of file + -DARDUINO_USB_MODE=0 diff --git a/variants/t-deck/platformio.ini b/variants/t-deck/platformio.ini index a0005c9c6..4671a5a9b 100644 --- a/variants/t-deck/platformio.ini +++ b/variants/t-deck/platformio.ini @@ -3,6 +3,7 @@ extends = esp32s3_base board = t-deck board_check = true +board_build.partitions = default_16MB.csv upload_protocol = esptool build_flags = ${esp32s3_base.build_flags} @@ -20,7 +21,6 @@ lib_deps = ${esp32s3_base.lib_deps} [env:t-deck-tft] extends = env:t-deck -board_build.partitions = default_16MB.csv build_flags = ${env:t-deck.build_flags} @@ -38,7 +38,6 @@ build_flags = -D INPUTDRIVER_ENCODER_DOWN=15 -D INPUTDRIVER_ENCODER_BTN=0 -D INPUTDRIVER_BUTTON_TYPE=0 - -D MAX_NUM_NODES=250 -D HAS_SDCARD -D HAS_SCREEN=0 -D HAS_TFT=1 diff --git a/variants/t-eth-elite/platformio.ini b/variants/t-eth-elite/platformio.ini index 8c2f3bc37..ec6c82a5d 100644 --- a/variants/t-eth-elite/platformio.ini +++ b/variants/t-eth-elite/platformio.ini @@ -2,11 +2,12 @@ extends = esp32s3_base board = esp32s3box board_check = true +board_build.partitions = default_16MB.csv build_flags = ${esp32s3_base.build_flags} -D T_ETH_ELITE -I variants/t-eth-elite - -DGPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. + -D GPS_POWER_TOGGLE ; comment this line to disable triple press function on the user button to turn off gps entirely. lib_ignore = Ethernet diff --git a/variants/t-watch-s3/platformio.ini b/variants/t-watch-s3/platformio.ini index 8f48cf6c4..f98237943 100644 --- a/variants/t-watch-s3/platformio.ini +++ b/variants/t-watch-s3/platformio.ini @@ -3,6 +3,7 @@ extends = esp32s3_base board = t-watch-s3 board_check = true +board_build.partitions = default_16MB.csv upload_protocol = esptool build_flags = ${esp32_base.build_flags} diff --git a/variants/tbeam-s3-core/platformio.ini b/variants/tbeam-s3-core/platformio.ini index e50d506b9..a7bdf963f 100644 --- a/variants/tbeam-s3-core/platformio.ini +++ b/variants/tbeam-s3-core/platformio.ini @@ -2,6 +2,7 @@ [env:tbeam-s3-core] extends = esp32s3_base board = tbeam-s3-core +board_build.partitions = default_8MB.csv board_check = true lib_deps = diff --git a/variants/tracksenger/platformio.ini b/variants/tracksenger/platformio.ini index 796a3b7d5..b36b9c45a 100644 --- a/variants/tracksenger/platformio.ini +++ b/variants/tracksenger/platformio.ini @@ -1,6 +1,7 @@ [env:tracksenger] extends = esp32s3_base board = heltec_wireless_tracker +board_build.partitions = default_8MB.csv upload_protocol = esp-builtin build_flags = @@ -16,6 +17,7 @@ lib_deps = [env:tracksenger-lcd] extends = esp32s3_base board = heltec_wireless_tracker +board_build.partitions = default_8MB.csv upload_protocol = esp-builtin build_flags = @@ -31,6 +33,7 @@ lib_deps = [env:tracksenger-oled] extends = esp32s3_base board = heltec_wireless_tracker +board_build.partitions = default_8MB.csv upload_protocol = esp-builtin build_flags = diff --git a/variants/unphone/platformio.ini b/variants/unphone/platformio.ini index 88f6e7469..18efbb157 100644 --- a/variants/unphone/platformio.ini +++ b/variants/unphone/platformio.ini @@ -3,6 +3,7 @@ [env:unphone] extends = esp32s3_base board = unphone +board_build.partitions = default_8MB.csv upload_speed = 921600 monitor_speed = 115200 monitor_filters = esp32_exception_decoder @@ -32,7 +33,6 @@ lib_deps = ${esp32s3_base.lib_deps} [env:unphone-tft] extends = env:unphone -board_build.partitions = default_8MB.csv build_flags = ${env:unphone.build_flags} -D MESHTASTIC_EXCLUDE_CANNEDMESSAGES=1 @@ -42,7 +42,6 @@ build_flags = -D MESHTASTIC_EXCLUDE_SERIAL=1 -D MESHTASTIC_EXCLUDE_SOCKETAPI=1 -D INPUTDRIVER_BUTTON_TYPE=21 - -D MAX_NUM_NODES=200 -D MAX_THREADS=40 -D HAS_SCREEN=0 -D HAS_TFT=1 diff --git a/variants/wio-e5/variant.h b/variants/wio-e5/variant.h index ac92915bb..1de424d1d 100644 --- a/variants/wio-e5/variant.h +++ b/variants/wio-e5/variant.h @@ -13,7 +13,6 @@ Do not expect a working Meshtastic device with this target. #define _VARIANT_WIOE5_ #define USE_STM32WLx -#define MAX_NUM_NODES 10 #define LED_PIN PB5 #define LED_STATE_ON 1 From 22aa2d7582df3f22caddff975d5e651407dd5472 Mon Sep 17 00:00:00 2001 From: Bob Reese Date: Tue, 18 Mar 2025 20:20:15 -0500 Subject: [PATCH 12/12] Fixed UF2 generation problem with sys.executable path has spaces in it (#6346) --- bin/platformio-custom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/platformio-custom.py b/bin/platformio-custom.py index af228899f..600f9447f 100644 --- a/bin/platformio-custom.py +++ b/bin/platformio-custom.py @@ -83,7 +83,7 @@ if platform.name == "espressif32": if platform.name == "nordicnrf52": env.AddPostAction("$BUILD_DIR/${PROGNAME}.hex", - env.VerboseAction(f"{sys.executable} ./bin/uf2conv.py $BUILD_DIR/firmware.hex -c -f 0xADA52840 -o $BUILD_DIR/firmware.uf2", + env.VerboseAction(f"\"{sys.executable}\" ./bin/uf2conv.py $BUILD_DIR/firmware.hex -c -f 0xADA52840 -o $BUILD_DIR/firmware.uf2", "Generating UF2 file")) Import("projenv")