From a8bd1ee0da3a0e68bb9449314d1b0e77f1f12067 Mon Sep 17 00:00:00 2001 From: mverch67 Date: Fri, 25 Oct 2024 16:09:49 +0200 Subject: [PATCH 1/5] stability: add SPI lock before saving via littleFS --- src/main.cpp | 3 ++- src/mesh/NodeDB.cpp | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index e71d1df5f..6bf38b524 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -642,6 +642,8 @@ void setup() rp2040Setup(); #endif + initSPI(); // needed here before reading from littleFS + // We do this as early as possible because this loads preferences from flash // but we need to do this after main cpu init (esp32setup), because we need the random seed set nodeDB = new NodeDB; @@ -705,7 +707,6 @@ void setup() #endif // Init our SPI controller (must be before screen and lora) - initSPI(); #ifdef ARCH_RP2040 #ifdef HW_SPI1_DEVICE SPI1.setSCK(LORA_SCK); diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 87a7ad091..69cd631c0 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -32,6 +32,7 @@ #if HAS_WIFI #include "mesh/wifi/WiFiAPClient.h" #endif +#include "SPILock.h" #include "modules/StoreForwardModule.h" #include #include @@ -870,6 +871,9 @@ void NodeDB::loadFromDisk() bool NodeDB::saveProto(const char *filename, size_t protoSize, const pb_msgdesc_t *fields, const void *dest_struct, bool fullAtomic) { +#ifdef ARCH_ESP32 + concurrency::LockGuard g(spiLock); +#endif bool okay = false; #ifdef FSCom auto f = SafeFile(filename, fullAtomic); From e37369a25fdef1ca715fdf49779fbf7835402348 Mon Sep 17 00:00:00 2001 From: Muhammad Shah <80623330+Babyyoda777@users.noreply.github.com> Date: Sun, 27 Oct 2024 01:24:30 +0100 Subject: [PATCH 2/5] Icarus - Custom PCB (#5155) * added Icarus * added Icarus * Update platformio.ini * Fixed I2C ports * Update variant.h --- boards/icarus.json | 41 ++++++++++++++++++++++++++++++++++ variants/icarus/pins_arduino.h | 22 ++++++++++++++++++ variants/icarus/platformio.ini | 19 ++++++++++++++++ variants/icarus/variant.h | 30 +++++++++++++++++++++++++ 4 files changed, 112 insertions(+) create mode 100644 boards/icarus.json create mode 100644 variants/icarus/pins_arduino.h create mode 100644 variants/icarus/platformio.ini create mode 100644 variants/icarus/variant.h diff --git a/boards/icarus.json b/boards/icarus.json new file mode 100644 index 000000000..03da4682f --- /dev/null +++ b/boards/icarus.json @@ -0,0 +1,41 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=0", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=0" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [["0x2886", "0x0059"]], + "mcu": "esp32s3", + "variant": "icarus" + }, + "connectivity": ["wifi", "bluetooth", "lora"], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": ["esp-builtin"], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": ["arduino", "espidf"], + "name": "icarus", + "upload": { + "flash_size": "8MB", + "maximum_ram_size": 8388608, + "maximum_size": 8388608, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://icarus.azlan.works", + "vendor": "Muhammad Shah" +} diff --git a/variants/icarus/pins_arduino.h b/variants/icarus/pins_arduino.h new file mode 100644 index 000000000..9837a3b34 --- /dev/null +++ b/variants/icarus/pins_arduino.h @@ -0,0 +1,22 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x2886 +#define USB_PID 0x0059 + +// GPIO48 Reference: https://github.com/espressif/arduino-esp32/pull/8600 + +// The default Wire will be mapped to Screen and Sensors +static const uint8_t SDA = 8; +static const uint8_t SCL = 9; + +// Default SPI will be mapped to Radio +static const uint8_t MISO = 39; +static const uint8_t SCK = 21; +static const uint8_t MOSI = 38; +static const uint8_t SS = 17; + +#endif /* Pins_Arduino_h */ + \ No newline at end of file diff --git a/variants/icarus/platformio.ini b/variants/icarus/platformio.ini new file mode 100644 index 000000000..116df130d --- /dev/null +++ b/variants/icarus/platformio.ini @@ -0,0 +1,19 @@ +[env:icarus] +extends = esp32s3_base +board = icarus +board_level = extra +board_check = true +board_build.mcu = esp32s3 +upload_protocol = esptool +upload_speed = 921600 +platform_packages = framework-arduinoespressif32@https://github.com/PowerFeather/powerfeather-meshtastic-arduino-lib/releases/download/2.0.16b/esp32-2.0.16.zip +lib_deps = + ${esp32s3_base.lib_deps} +build_unflags = + ${esp32s3_base.build_unflags} + -DARDUINO_USB_MODE=1 +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 diff --git a/variants/icarus/variant.h b/variants/icarus/variant.h new file mode 100644 index 000000000..f78f27e39 --- /dev/null +++ b/variants/icarus/variant.h @@ -0,0 +1,30 @@ +// Icarus has a 1.3 inch OLED Screen +#define SCREEN_SSD106 + +#define I2C_SDA 8 +#define I2C_SCL 9 + +#define I2C_SDA1 18 +#define I2C_SCL1 6 + + +// XIAO S3 LORA module +#define USE_SX1262 + +#define LORA_MISO 39 +#define LORA_SCK 21 +#define LORA_MOSI 38 +#define LORA_CS 17 + +#define LORA_RESET 42 +#define LORA_DIO1 5 + +#ifdef USE_SX1262 +#define SX126X_CS LORA_CS +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY 47 +#define SX126X_RESET LORA_RESET + +// DIO2 controlls an antenna switch +#define SX126X_DIO2_AS_RF_SWITCH +#endif From 94ff67e927bb7a3a3bc9fba62fff8fc54a1d5ae1 Mon Sep 17 00:00:00 2001 From: mverch67 Date: Sun, 25 Aug 2024 12:37:50 +0200 Subject: [PATCH 3/5] fix spiLock in RadioLibInterface --- src/mesh/RadioLibInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index f44d50d36..9bf1f27ba 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -20,9 +20,9 @@ void LockingArduinoHal::spiBeginTransaction() void LockingArduinoHal::spiEndTransaction() { - spiLock->unlock(); - ArduinoHal::spiEndTransaction(); + + spiLock->unlock(); } #if ARCH_PORTDUINO void LockingArduinoHal::spiTransfer(uint8_t *out, size_t len, uint8_t *in) From bf760a44bac738f6435423ae7fc888a1ac646c0c Mon Sep 17 00:00:00 2001 From: Muhammad Shah <80623330+Babyyoda777@users.noreply.github.com> Date: Sun, 27 Oct 2024 10:51:51 +0000 Subject: [PATCH 4/5] Icarus - Fix platform dependency version and add selection button (#5161) * Update variant.h * Update platformio.ini --- variants/icarus/platformio.ini | 4 ++-- variants/icarus/variant.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/variants/icarus/platformio.ini b/variants/icarus/platformio.ini index 116df130d..11f09cab4 100644 --- a/variants/icarus/platformio.ini +++ b/variants/icarus/platformio.ini @@ -6,7 +6,7 @@ board_check = true board_build.mcu = esp32s3 upload_protocol = esptool upload_speed = 921600 -platform_packages = framework-arduinoespressif32@https://github.com/PowerFeather/powerfeather-meshtastic-arduino-lib/releases/download/2.0.16b/esp32-2.0.16.zip +platform_packages = framework-arduinoespressif32@https://github.com/PowerFeather/powerfeather-meshtastic-arduino-lib/releases/download/2.0.16a/esp32-2.0.16.zip lib_deps = ${esp32s3_base.lib_deps} build_unflags = @@ -16,4 +16,4 @@ 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/icarus/variant.h b/variants/icarus/variant.h index f78f27e39..c9c74b45a 100644 --- a/variants/icarus/variant.h +++ b/variants/icarus/variant.h @@ -7,8 +7,9 @@ #define I2C_SDA1 18 #define I2C_SCL1 6 +#define BUTTON_PIN 7 // Selection button -// XIAO S3 LORA module +// RA-01SH/HT-RA62 LORA module #define USE_SX1262 #define LORA_MISO 39 From 1334d07c6ae53f1f069b2df120c69d1ac2348ebc Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Sun, 27 Oct 2024 06:57:11 -0500 Subject: [PATCH 5/5] Trunk updates --- .trunk/trunk.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index ea4045a16..ad8864ab7 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -1,22 +1,22 @@ version: 0.1 cli: - version: 1.22.6 + version: 1.22.7 plugins: sources: - id: trunk - ref: v1.6.3 + ref: v1.6.4 uri: https://github.com/trunk-io/plugins lint: enabled: - - trufflehog@3.82.6 + - trufflehog@3.82.12 - yamllint@1.35.1 - bandit@1.7.10 - checkov@3.2.256 - - terrascan@1.19.1 + - terrascan@1.19.9 - trivy@0.55.2 #- trufflehog@3.63.2-rc0 - taplo@0.9.3 - - ruff@0.6.8 + - ruff@0.7.0 - isort@5.13.2 - markdownlint@0.42.0 - oxipng@9.1.2 @@ -26,9 +26,9 @@ lint: - hadolint@2.12.0 - shfmt@3.6.0 - shellcheck@0.10.0 - - black@24.8.0 + - black@24.10.0 - git-diff-check - - gitleaks@8.20.0 + - gitleaks@8.21.1 - clang-format@16.0.3 - prettier@3.3.3 ignore: