From c1a493fb356ba14cd8f1dd203eabf7a6740857bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Mon, 2 Sep 2024 17:16:51 +0200 Subject: [PATCH] update apollo toolchain --- arch/stm32/stm32.ini | 2 +- src/FSCommon.cpp | 9 +++ src/RedirectablePrint.cpp | 2 +- src/main.cpp | 2 +- src/mesh/PhoneAPI.cpp | 2 - src/mesh/StreamAPI.cpp | 2 +- src/meshUtils.cpp | 2 +- src/modules/AdminModule.cpp | 2 +- src/platform/apollo3/Apollo3CryptoEngine.cpp | 66 -------------------- src/xmodem.h | 2 +- 10 files changed, 16 insertions(+), 75 deletions(-) delete mode 100644 src/platform/apollo3/Apollo3CryptoEngine.cpp diff --git a/arch/stm32/stm32.ini b/arch/stm32/stm32.ini index 050dbf7f0..80bd0017c 100644 --- a/arch/stm32/stm32.ini +++ b/arch/stm32/stm32.ini @@ -22,7 +22,7 @@ build_flags = -fdata-sections build_src_filter = - ${arduino_base.build_src_filter} - - - - - - - - - - - - - - + ${arduino_base.build_src_filter} - - - - - - - - - - - - - - - board_upload.offset_address = 0x08000000 upload_protocol = stlink diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp index a0b3ef737..0f78f3e8b 100644 --- a/src/FSCommon.cpp +++ b/src/FSCommon.cpp @@ -53,6 +53,15 @@ void OSFS::writeNBytes(uint16_t address, unsigned int num, const byte *input) } #endif +bool lfs_assert_failed = + false; // Note: we use this global on all platforms, though it can only be set true on nrf52 (in our modified lfs_util.h) + +extern "C" void lfs_assert(const char *reason) +{ + LOG_ERROR("LFS assert: %s\n", reason); + lfs_assert_failed = true; +} + /** * @brief Copies a file from one location to another. * diff --git a/src/RedirectablePrint.cpp b/src/RedirectablePrint.cpp index a8b43120f..d837b98bb 100644 --- a/src/RedirectablePrint.cpp +++ b/src/RedirectablePrint.cpp @@ -1,8 +1,8 @@ #include "RedirectablePrint.h" #include "NodeDB.h" -#include "gps/RTC.h" #include "concurrency/OSThread.h" #include "configuration.h" +#include "gps/RTC.h" #include "main.h" #include "mesh/generated/meshtastic/mesh.pb.h" #include diff --git a/src/main.cpp b/src/main.cpp index 6bc569eab..c8345eaa1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,11 +16,11 @@ // #include "debug.h" #include "FSCommon.h" #include "Led.h" -#include "gps/RTC.h" #include "SPILock.h" #include "concurrency/OSThread.h" #include "concurrency/Periodic.h" #include "detect/ScanI2C.h" +#include "gps/RTC.h" #if !MESHTASTIC_EXCLUDE_I2C #include "detect/ScanI2CTwoWire.h" diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index c2ca0844b..0ca89b1ef 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -42,7 +42,6 @@ void PhoneAPI::handleStartConfig() if (!isConnected()) { onConnectionChanged(true); observe(&service->fromNumChanged); -#ifdef FSCom #ifdef FSCom observe(&xModem.packetReady); #endif @@ -65,7 +64,6 @@ void PhoneAPI::close() state = STATE_SEND_NOTHING; unobserve(&service->fromNumChanged); -#ifdef FSCom #ifdef FSCom unobserve(&xModem.packetReady); #endif diff --git a/src/mesh/StreamAPI.cpp b/src/mesh/StreamAPI.cpp index 9f59aa971..e10638c03 100644 --- a/src/mesh/StreamAPI.cpp +++ b/src/mesh/StreamAPI.cpp @@ -1,7 +1,7 @@ #include "StreamAPI.h" #include "PowerFSM.h" -#include "RTC.h" #include "configuration.h" +#include "gps/RTC.h" #define START1 0x94 #define START2 0xc3 diff --git a/src/meshUtils.cpp b/src/meshUtils.cpp index 99fcd2a57..c6f2c69b4 100644 --- a/src/meshUtils.cpp +++ b/src/meshUtils.cpp @@ -68,7 +68,7 @@ void printBytes(const char *label, const uint8_t *p, size_t numbytes) bool memfll(const uint8_t *mem, uint8_t find, size_t numbytes) { - for (int i = 0; i < numbytes; i++) { + for (uint8_t i = 0; i < numbytes; i++) { if (mem[i] != find) return false; } diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index bfe3a9ba5..a88079aab 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -3,7 +3,7 @@ #include "MeshService.h" #include "NodeDB.h" #include "PowerFSM.h" -#include "RTC.h" +#include "gps/RTC.h" #include "meshUtils.h" #include #if defined(ARCH_ESP32) && !MESHTASTIC_EXCLUDE_BLUETOOTH diff --git a/src/platform/apollo3/Apollo3CryptoEngine.cpp b/src/platform/apollo3/Apollo3CryptoEngine.cpp deleted file mode 100644 index da63dc3ec..000000000 --- a/src/platform/apollo3/Apollo3CryptoEngine.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "AES.h" -#include "CTR.h" -#include "CryptoEngine.h" -#include "configuration.h" - -class Apollo3CryptoEngine : public CryptoEngine -{ - - CTRCommon *ctr = NULL; - - public: - Apollo3CryptoEngine() {} - - ~Apollo3CryptoEngine() {} - - virtual void setKey(const CryptoKey &k) override - { - CryptoEngine::setKey(k); - LOG_DEBUG("Installing AES%d key!\n", key.length * 8); - if (ctr) { - delete ctr; - ctr = NULL; - } - if (key.length != 0) { - if (key.length == 16) - ctr = new CTR(); - else - ctr = new CTR(); - - ctr->setKey(key.bytes, key.length); - } - } - /** - * Encrypt a packet - * - * @param bytes is updated in place - */ - virtual void encrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override - { - if (key.length > 0) { - initNonce(fromNode, packetId); - if (numBytes <= MAX_BLOCKSIZE) { - static uint8_t scratch[MAX_BLOCKSIZE]; - memcpy(scratch, bytes, numBytes); - memset(scratch + numBytes, 0, - sizeof(scratch) - numBytes); // Fill rest of buffer with zero (in case cypher looks at it) - - ctr->setIV(nonce, sizeof(nonce)); - ctr->setCounterSize(4); - ctr->encrypt(bytes, scratch, numBytes); - } else { - LOG_ERROR("Packet too large for crypto engine: %d. noop encryption!\n", numBytes); - } - } - } - - virtual void decrypt(uint32_t fromNode, uint64_t packetId, size_t numBytes, uint8_t *bytes) override - { - // For CTR, the implementation is the same - encrypt(fromNode, packetId, numBytes, bytes); - } - - private: -}; - -CryptoEngine *crypto = new Apollo3CryptoEngine(); diff --git a/src/xmodem.h b/src/xmodem.h index 795fab302..4cfcb43e1 100644 --- a/src/xmodem.h +++ b/src/xmodem.h @@ -61,7 +61,7 @@ class XModemAdapter uint16_t packetno = 0; -#if defined(ARCH_NRF52) +#if defined(ARCH_NRF52) || defined(ARCH_STM32WL) File file = File(FSCom); #else File file;