From 12481b568ab2d7cd16b0a42161024583c03d269f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 26 Sep 2024 02:09:06 +0200 Subject: [PATCH 01/16] fix a lot of nuisances reported by cppcheck (#4872) * fix a lot of nuisances reported by cppcheck * fix portduino --- src/SafeFile.h | 2 +- src/gps/GPS.cpp | 2 +- src/graphics/Screen.cpp | 2 +- src/mesh/CryptoEngine.cpp | 4 ++-- src/mesh/ProtobufModule.h | 2 +- src/mesh/aes-ccm.cpp | 2 +- src/mesh/compression/unishox2.cpp | 4 ++-- src/meshUtils.cpp | 3 +-- src/modules/AdminModule.cpp | 4 ++-- src/modules/AdminModule.h | 4 ++-- src/modules/CannedMessageModule.cpp | 8 ++++---- src/modules/Telemetry/EnvironmentTelemetry.cpp | 2 +- src/modules/Telemetry/PowerTelemetry.cpp | 2 +- src/modules/TraceRouteModule.cpp | 2 +- src/modules/WaypointModule.cpp | 2 +- src/mqtt/MQTT.cpp | 4 ++-- src/platform/nrf52/BLEDfuScure.cpp | 3 +-- src/serialization/JSONValue.cpp | 16 ++++++++-------- 18 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/SafeFile.h b/src/SafeFile.h index 7088074cd..61361d312 100644 --- a/src/SafeFile.h +++ b/src/SafeFile.h @@ -24,7 +24,7 @@ class SafeFile : public Print { public: - SafeFile(char const *filepath, bool fullAtomic = false); + explicit SafeFile(char const *filepath, bool fullAtomic = false); virtual size_t write(uint8_t); virtual size_t write(const uint8_t *buffer, size_t size); diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index b13ca4b06..569254d02 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -405,9 +405,9 @@ int GPS::getACK(uint8_t *buffer, uint16_t size, uint8_t requestedClass, uint8_t bool GPS::setup() { - int msglen = 0; if (!didSerialInit) { + int msglen = 0; if (tx_gpio && gnssModel == GNSS_MODEL_UNKNOWN) { // if GPS_BAUDRATE is specified in variant (i.e. not 9600), skip to the specified rate. diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index f8a64cc61..f95146318 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -2201,7 +2201,7 @@ void Screen::setFrames(FrameFocus focus) case FOCUS_PRESERVE: // If we can identify which type of frame "originalPosition" was, can move directly to it in the new frameset - FramesetInfo &oldFsi = this->framesetInfo; + const FramesetInfo &oldFsi = this->framesetInfo; if (originalPosition == oldFsi.positions.log) ui->switchToFrame(fsi.positions.log); else if (originalPosition == oldFsi.positions.settings) diff --git a/src/mesh/CryptoEngine.cpp b/src/mesh/CryptoEngine.cpp index 79666b321..f705bae03 100644 --- a/src/mesh/CryptoEngine.cpp +++ b/src/mesh/CryptoEngine.cpp @@ -167,12 +167,12 @@ bool CryptoEngine::setDHKey(uint32_t nodeNum) void CryptoEngine::hash(uint8_t *bytes, size_t numBytes) { SHA256 hash; - size_t posn, len; + size_t posn; uint8_t size = numBytes; uint8_t inc = 16; hash.reset(); for (posn = 0; posn < size; posn += inc) { - len = size - posn; + size_t len = size - posn; if (len > inc) len = inc; hash.update(bytes + posn, len); diff --git a/src/mesh/ProtobufModule.h b/src/mesh/ProtobufModule.h index 3b438ebeb..e4d4e5c09 100644 --- a/src/mesh/ProtobufModule.h +++ b/src/mesh/ProtobufModule.h @@ -108,7 +108,7 @@ template class ProtobufModule : protected SinglePortModule T *decoded = NULL; if (mp.which_payload_variant == meshtastic_MeshPacket_decoded_tag && mp.decoded.portnum == ourPortNum) { memset(&scratch, 0, sizeof(scratch)); - auto &p = mp.decoded; + const meshtastic_Data &p = mp.decoded; if (pb_decode_from_bytes(p.payload.bytes, p.payload.size, fields, &scratch)) { decoded = &scratch; } else { diff --git a/src/mesh/aes-ccm.cpp b/src/mesh/aes-ccm.cpp index cd18ae6c5..b9af14fdb 100644 --- a/src/mesh/aes-ccm.cpp +++ b/src/mesh/aes-ccm.cpp @@ -95,7 +95,7 @@ static void aes_ccm_encr(size_t L, const uint8_t *in, size_t len, uint8_t *out, *out++ ^= *in++; } } -static void aes_ccm_encr_auth(size_t M, uint8_t *x, uint8_t *a, uint8_t *auth) +static void aes_ccm_encr_auth(size_t M, const uint8_t *x, uint8_t *a, uint8_t *auth) { size_t i; uint8_t tmp[AES_BLOCK_SIZE]; diff --git a/src/mesh/compression/unishox2.cpp b/src/mesh/compression/unishox2.cpp index 4e239d489..9fc012a76 100644 --- a/src/mesh/compression/unishox2.cpp +++ b/src/mesh/compression/unishox2.cpp @@ -339,7 +339,7 @@ int32_t readUTF8(const char *in, int len, int l, int *utf8len) /// This is also used for Unicode strings \n /// This is a crude implementation that is not optimized. Assuming only short strings \n /// are encoded, this is not much of an issue. -int matchOccurance(const char *in, int len, int l, char *out, int olen, int *ol, uint8_t *state, const uint8_t usx_hcodes[], +int matchOccurance(const char *in, int len, int l, char *out, int olen, int *ol, const uint8_t *state, const uint8_t usx_hcodes[], const uint8_t usx_hcode_lens[]) { int j, k; @@ -383,7 +383,7 @@ int matchOccurance(const char *in, int len, int l, char *out, int olen, int *ol, /// This is also used for Unicode strings \n /// This is a crude implementation that is not optimized. Assuming only short strings \n /// are encoded, this is not much of an issue. -int matchLine(const char *in, int len, int l, char *out, int olen, int *ol, struct us_lnk_lst *prev_lines, uint8_t *state, +int matchLine(const char *in, int len, int l, char *out, int olen, int *ol, struct us_lnk_lst *prev_lines, const uint8_t *state, const uint8_t usx_hcodes[], const uint8_t usx_hcode_lens[]) { int last_ol = *ol; diff --git a/src/meshUtils.cpp b/src/meshUtils.cpp index 853193a12..2789a143c 100644 --- a/src/meshUtils.cpp +++ b/src/meshUtils.cpp @@ -60,10 +60,9 @@ char *strnstr(const char *s, const char *find, size_t slen) void printBytes(const char *label, const uint8_t *p, size_t numbytes) { - char *messageBuffer; int labelSize = strlen(label); if (labelSize < 100 && numbytes < 64) { - messageBuffer = new char[labelSize + (numbytes * 3) + 2]; + char *messageBuffer = new char[labelSize + (numbytes * 3) + 2]; strncpy(messageBuffer, label, labelSize); for (size_t i = 0; i < numbytes; i++) snprintf(messageBuffer + labelSize + i * 3, 4, " %02x", p[i]); diff --git a/src/modules/AdminModule.cpp b/src/modules/AdminModule.cpp index 389a0db8d..09311abda 100644 --- a/src/modules/AdminModule.cpp +++ b/src/modules/AdminModule.cpp @@ -1026,7 +1026,7 @@ bool AdminModule::checkPassKey(meshtastic_AdminMessage *res) memcmp(res->session_passkey.bytes, session_passkey, 8) == 0); } -bool AdminModule::messageIsResponse(meshtastic_AdminMessage *r) +bool AdminModule::messageIsResponse(const meshtastic_AdminMessage *r) { if (r->which_payload_variant == meshtastic_AdminMessage_get_channel_response_tag || r->which_payload_variant == meshtastic_AdminMessage_get_owner_response_tag || @@ -1043,7 +1043,7 @@ bool AdminModule::messageIsResponse(meshtastic_AdminMessage *r) return false; } -bool AdminModule::messageIsRequest(meshtastic_AdminMessage *r) +bool AdminModule::messageIsRequest(const meshtastic_AdminMessage *r) { if (r->which_payload_variant == meshtastic_AdminMessage_get_channel_request_tag || r->which_payload_variant == meshtastic_AdminMessage_get_owner_request_tag || diff --git a/src/modules/AdminModule.h b/src/modules/AdminModule.h index 328e1c824..d6c0a7343 100644 --- a/src/modules/AdminModule.h +++ b/src/modules/AdminModule.h @@ -55,8 +55,8 @@ class AdminModule : public ProtobufModule, public Obser void setPassKey(meshtastic_AdminMessage *res); bool checkPassKey(meshtastic_AdminMessage *res); - bool messageIsResponse(meshtastic_AdminMessage *r); - bool messageIsRequest(meshtastic_AdminMessage *r); + bool messageIsResponse(const meshtastic_AdminMessage *r); + bool messageIsRequest(const meshtastic_AdminMessage *r); }; extern AdminModule *adminModule; diff --git a/src/modules/CannedMessageModule.cpp b/src/modules/CannedMessageModule.cpp index d4d112f90..e38b7e063 100644 --- a/src/modules/CannedMessageModule.cpp +++ b/src/modules/CannedMessageModule.cpp @@ -78,16 +78,16 @@ int CannedMessageModule::splitConfiguredMessages() int messageIndex = 0; int i = 0; - String messages = cannedMessageModuleConfig.messages; + String canned_messages = cannedMessageModuleConfig.messages; #if defined(T_WATCH_S3) || defined(RAK14014) - String separator = messages.length() ? "|" : ""; + String separator = canned_messages.length() ? "|" : ""; - messages = "[---- Free Text ----]" + separator + messages; + canned_messages = "[---- Free Text ----]" + separator + canned_messages; #endif // collect all the message parts - strncpy(this->messageStore, messages.c_str(), sizeof(this->messageStore)); + strncpy(this->messageStore, canned_messages.c_str(), sizeof(this->messageStore)); // The first message points to the beginning of the store. this->messages[messageIndex++] = this->messageStore; diff --git a/src/modules/Telemetry/EnvironmentTelemetry.cpp b/src/modules/Telemetry/EnvironmentTelemetry.cpp index 8f891593a..ac291c4ab 100644 --- a/src/modules/Telemetry/EnvironmentTelemetry.cpp +++ b/src/modules/Telemetry/EnvironmentTelemetry.cpp @@ -216,7 +216,7 @@ void EnvironmentTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiSt uint32_t agoSecs = GetTimeSinceMeshPacket(lastMeasurementPacket); const char *lastSender = getSenderShortName(*lastMeasurementPacket); - auto &p = lastMeasurementPacket->decoded; + const meshtastic_Data &p = lastMeasurementPacket->decoded; if (!pb_decode_from_bytes(p.payload.bytes, p.payload.size, &meshtastic_Telemetry_msg, &lastMeasurement)) { display->drawString(x, y, "Measurement Error"); LOG_ERROR("Unable to decode last packet"); diff --git a/src/modules/Telemetry/PowerTelemetry.cpp b/src/modules/Telemetry/PowerTelemetry.cpp index 6130c2c83..d31892042 100644 --- a/src/modules/Telemetry/PowerTelemetry.cpp +++ b/src/modules/Telemetry/PowerTelemetry.cpp @@ -122,7 +122,7 @@ void PowerTelemetryModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *s uint32_t agoSecs = GetTimeyWimeySinceMeshPacket(lastMeasurementPacket); const char *lastSender = getSenderShortName(*lastMeasurementPacket); - auto &p = lastMeasurementPacket->decoded; + const meshtastic_Data &p = lastMeasurementPacket->decoded; if (!pb_decode_from_bytes(p.payload.bytes, p.payload.size, &meshtastic_Telemetry_msg, &lastMeasurement)) { display->setFont(FONT_SMALL); display->drawString(x, y += _fontHeight(FONT_MEDIUM), "Measurement Error"); diff --git a/src/modules/TraceRouteModule.cpp b/src/modules/TraceRouteModule.cpp index 23b4f1ccf..1f652dbf6 100644 --- a/src/modules/TraceRouteModule.cpp +++ b/src/modules/TraceRouteModule.cpp @@ -11,7 +11,7 @@ bool TraceRouteModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, m void TraceRouteModule::alterReceivedProtobuf(meshtastic_MeshPacket &p, meshtastic_RouteDiscovery *r) { - auto &incoming = p.decoded; + const meshtastic_Data &incoming = p.decoded; // Insert unknown hops if necessary insertUnknownHops(p, r, !incoming.request_id); diff --git a/src/modules/WaypointModule.cpp b/src/modules/WaypointModule.cpp index e1974db73..628d7f62c 100644 --- a/src/modules/WaypointModule.cpp +++ b/src/modules/WaypointModule.cpp @@ -89,7 +89,7 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, display->fillRect(0 + x, 0 + y, x + display->getWidth(), y + FONT_HEIGHT_SMALL); // Decode the waypoint - meshtastic_MeshPacket &mp = devicestate.rx_waypoint; + const meshtastic_MeshPacket &mp = devicestate.rx_waypoint; meshtastic_Waypoint wp; memset(&wp, 0, sizeof(wp)); if (!pb_decode_from_bytes(mp.decoded.payload.bytes, mp.decoded.payload.size, &meshtastic_Waypoint_msg, &wp)) { diff --git a/src/mqtt/MQTT.cpp b/src/mqtt/MQTT.cpp index 2ce5cd755..891d4b549 100644 --- a/src/mqtt/MQTT.cpp +++ b/src/mqtt/MQTT.cpp @@ -184,8 +184,8 @@ void MQTT::onReceive(char *topic, byte *payload, size_t length) // PKI messages get accepted even if we can't decrypt if (router && p->which_payload_variant == meshtastic_MeshPacket_encrypted_tag && strcmp(e.channel_id, "PKI") == 0) { - meshtastic_NodeInfoLite *tx = nodeDB->getMeshNode(getFrom(p)); - meshtastic_NodeInfoLite *rx = nodeDB->getMeshNode(p->to); + const meshtastic_NodeInfoLite *tx = nodeDB->getMeshNode(getFrom(p)); + const meshtastic_NodeInfoLite *rx = nodeDB->getMeshNode(p->to); // Only accept PKI messages to us, or if we have both the sender and receiver in our nodeDB, as then it's // likely they discovered each other via a channel we have downlink enabled for if (p->to == nodeDB->getNodeNum() || (tx && tx->has_user && rx && rx->has_user)) diff --git a/src/platform/nrf52/BLEDfuScure.cpp b/src/platform/nrf52/BLEDfuScure.cpp index 8f7a327c4..82cb8905a 100644 --- a/src/platform/nrf52/BLEDfuScure.cpp +++ b/src/platform/nrf52/BLEDfuScure.cpp @@ -48,11 +48,10 @@ extern "C" void bootloader_util_app_start(uint32_t start_addr); static uint16_t crc16(const uint8_t *data_p, uint8_t length) { - uint8_t x; uint16_t crc = 0xFFFF; while (length--) { - x = crc >> 8 ^ *data_p++; + uint8_t x = crc >> 8 ^ *data_p++; x ^= x >> 4; crc = (crc << 8) ^ ((uint16_t)(x << 12)) ^ ((uint16_t)(x << 5)) ^ ((uint16_t)x); } diff --git a/src/serialization/JSONValue.cpp b/src/serialization/JSONValue.cpp index 51e0c1a3b..b2e9575bf 100644 --- a/src/serialization/JSONValue.cpp +++ b/src/serialization/JSONValue.cpp @@ -37,14 +37,14 @@ #define FREE_ARRAY(x) \ { \ JSONArray::iterator iter; \ - for (iter = x.begin(); iter != x.end(); iter++) { \ + for (iter = x.begin(); iter != x.end(); ++iter) { \ delete *iter; \ } \ } #define FREE_OBJECT(x) \ { \ JSONObject::iterator iter; \ - for (iter = x.begin(); iter != x.end(); iter++) { \ + for (iter = x.begin(); iter != x.end(); ++iter) { \ delete (*iter).second; \ } \ } @@ -430,7 +430,7 @@ JSONValue::JSONValue(const JSONValue &m_source) JSONArray source_array = *m_source.array_value; JSONArray::iterator iter; array_value = new JSONArray(); - for (iter = source_array.begin(); iter != source_array.end(); iter++) + for (iter = source_array.begin(); iter != source_array.end(); ++iter) array_value->push_back(new JSONValue(**iter)); break; } @@ -439,7 +439,7 @@ JSONValue::JSONValue(const JSONValue &m_source) JSONObject source_object = *m_source.object_value; object_value = new JSONObject(); JSONObject::iterator iter; - for (iter = source_object.begin(); iter != source_object.end(); iter++) { + for (iter = source_object.begin(); iter != source_object.end(); ++iter) { std::string name = (*iter).first; (*object_value)[name] = new JSONValue(*((*iter).second)); } @@ -462,12 +462,12 @@ JSONValue::~JSONValue() { if (type == JSONType_Array) { JSONArray::iterator iter; - for (iter = array_value->begin(); iter != array_value->end(); iter++) + for (iter = array_value->begin(); iter != array_value->end(); ++iter) delete *iter; delete array_value; } else if (type == JSONType_Object) { JSONObject::iterator iter; - for (iter = object_value->begin(); iter != object_value->end(); iter++) { + for (iter = object_value->begin(); iter != object_value->end(); ++iter) { delete (*iter).second; } delete object_value; @@ -722,7 +722,7 @@ std::vector JSONValue::ObjectKeys() const while (iter != object_value->end()) { keys.push_back(iter->first); - iter++; + ++iter; } } @@ -865,7 +865,7 @@ std::string JSONValue::StringifyString(const std::string &str) str_out += chr; } - iter++; + ++iter; } str_out += "\""; From 14019f2afa093174a6e1fbf6ef3a0b2154fc997d Mon Sep 17 00:00:00 2001 From: Szetya Date: Thu, 26 Sep 2024 02:09:27 +0200 Subject: [PATCH 02/16] Update WaypointModule.cpp (#4870) In INVERTED display mode, the compass ring was not visible. --- src/modules/WaypointModule.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/modules/WaypointModule.cpp b/src/modules/WaypointModule.cpp index 628d7f62c..8194c3d01 100644 --- a/src/modules/WaypointModule.cpp +++ b/src/modules/WaypointModule.cpp @@ -170,17 +170,17 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, else strncpy(distStr, "? km", sizeof(distStr)); } - + + // Draw compass circle + display->drawCircle(compassX, compassY, compassDiam / 2); + // Undo color-inversion, if set prior to drawing header // Unsure of expected behavior? For now: copy drawNodeInfo if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) { display->setColor(BLACK); } - - // Draw compass circle - display->drawCircle(compassX, compassY, compassDiam / 2); - + // Must be after distStr is populated screen->drawColumns(display, x, y, fields); } -#endif \ No newline at end of file +#endif From 9bebad2dbe3650c133d6efac5e028d52ce7fa12a Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 25 Sep 2024 19:54:14 -0500 Subject: [PATCH 03/16] Trunkt --- src/modules/WaypointModule.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/modules/WaypointModule.cpp b/src/modules/WaypointModule.cpp index 8194c3d01..a4611e780 100644 --- a/src/modules/WaypointModule.cpp +++ b/src/modules/WaypointModule.cpp @@ -170,16 +170,16 @@ void WaypointModule::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, else strncpy(distStr, "? km", sizeof(distStr)); } - + // Draw compass circle display->drawCircle(compassX, compassY, compassDiam / 2); - + // Undo color-inversion, if set prior to drawing header // Unsure of expected behavior? For now: copy drawNodeInfo if (config.display.displaymode == meshtastic_Config_DisplayConfig_DisplayMode_INVERTED) { display->setColor(BLACK); } - + // Must be after distStr is populated screen->drawColumns(display, x, y, fields); } From 8f84a96b6985c586a901ccd443fc2cf25478141f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Thu, 26 Sep 2024 12:12:08 +0200 Subject: [PATCH 04/16] refactor: typo fix in macro definition --- src/main.cpp | 4 ++-- variants/ME25LS01-4Y10TD/variant.h | 2 +- variants/ME25LS01-4Y10TD_e-ink/variant.h | 2 +- variants/tracker-t1000-e/variant.h | 2 +- variants/wio-sdk-wm1110/variant.h | 2 +- variants/wio-t1000-s/variant.h | 2 +- variants/wio-tracker-wm1110/variant.h | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 87a4db97c..cbde2ce39 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -972,7 +972,7 @@ void setup() #if defined(USE_LR1110) if (!rIf) { - rIf = new LR1110Interface(RadioLibHAL, LR1110_SPI_NSS_PIN, LR1110_IRQ_PIN, LR1110_NRESER_PIN, LR1110_BUSY_PIN); + rIf = new LR1110Interface(RadioLibHAL, LR1110_SPI_NSS_PIN, LR1110_IRQ_PIN, LR1110_NRESET_PIN, LR1110_BUSY_PIN); if (!rIf->init()) { LOG_WARN("Failed to find LR1110 radio\n"); delete rIf; @@ -985,7 +985,7 @@ void setup() #if defined(USE_LR1120) if (!rIf) { - rIf = new LR1120Interface(RadioLibHAL, LR1120_SPI_NSS_PIN, LR1120_IRQ_PIN, LR1120_NRESER_PIN, LR1120_BUSY_PIN); + rIf = new LR1120Interface(RadioLibHAL, LR1120_SPI_NSS_PIN, LR1120_IRQ_PIN, LR1120_NRESET_PIN, LR1120_BUSY_PIN); if (!rIf->init()) { LOG_WARN("Failed to find LR1120 radio\n"); delete rIf; diff --git a/variants/ME25LS01-4Y10TD/variant.h b/variants/ME25LS01-4Y10TD/variant.h index 715de8ee6..0da391f0b 100644 --- a/variants/ME25LS01-4Y10TD/variant.h +++ b/variants/ME25LS01-4Y10TD/variant.h @@ -94,7 +94,7 @@ extern "C" { #define USE_LR1110 #define LR1110_IRQ_PIN LORA_DIO1 -#define LR1110_NRESER_PIN LORA_RESET +#define LR1110_NRESET_PIN LORA_RESET #define LR1110_BUSY_PIN LORA_DIO2 #define LR1110_SPI_NSS_PIN LORA_CS #define LR1110_SPI_SCK_PIN LORA_SCK diff --git a/variants/ME25LS01-4Y10TD_e-ink/variant.h b/variants/ME25LS01-4Y10TD_e-ink/variant.h index 0b2b13068..105f9b873 100644 --- a/variants/ME25LS01-4Y10TD_e-ink/variant.h +++ b/variants/ME25LS01-4Y10TD_e-ink/variant.h @@ -117,7 +117,7 @@ static const uint8_t SCK = PIN_SPI_SCK; #define USE_LR1110 #define LR1110_IRQ_PIN LORA_DIO1 -#define LR1110_NRESER_PIN LORA_RESET +#define LR1110_NRESET_PIN LORA_RESET #define LR1110_BUSY_PIN LORA_DIO2 #define LR1110_SPI_NSS_PIN LORA_CS #define LR1110_SPI_SCK_PIN LORA_SCK diff --git a/variants/tracker-t1000-e/variant.h b/variants/tracker-t1000-e/variant.h index 470edd08c..b8eb59b31 100644 --- a/variants/tracker-t1000-e/variant.h +++ b/variants/tracker-t1000-e/variant.h @@ -93,7 +93,7 @@ extern "C" { #define USE_LR1110 #define LR1110_IRQ_PIN LORA_DIO1 -#define LR1110_NRESER_PIN LORA_RESET +#define LR1110_NRESET_PIN LORA_RESET #define LR1110_BUSY_PIN LORA_DIO2 #define LR1110_SPI_NSS_PIN LORA_CS #define LR1110_SPI_SCK_PIN LORA_SCK diff --git a/variants/wio-sdk-wm1110/variant.h b/variants/wio-sdk-wm1110/variant.h index 8f66b1f8c..b6e5c79df 100644 --- a/variants/wio-sdk-wm1110/variant.h +++ b/variants/wio-sdk-wm1110/variant.h @@ -95,7 +95,7 @@ extern "C" { #define USE_LR1110 #define LR1110_IRQ_PIN LORA_DIO1 -#define LR1110_NRESER_PIN LORA_RESET +#define LR1110_NRESET_PIN LORA_RESET #define LR1110_BUSY_PIN LORA_DIO2 #define LR1110_SPI_NSS_PIN LORA_CS #define LR1110_SPI_SCK_PIN LORA_SCK diff --git a/variants/wio-t1000-s/variant.h b/variants/wio-t1000-s/variant.h index fa6ea4abc..8894a40c5 100644 --- a/variants/wio-t1000-s/variant.h +++ b/variants/wio-t1000-s/variant.h @@ -94,7 +94,7 @@ extern "C" { #define USE_LR1110 #define LR1110_IRQ_PIN LORA_DIO1 -#define LR1110_NRESER_PIN LORA_RESET +#define LR1110_NRESET_PIN LORA_RESET #define LR1110_BUSY_PIN LORA_DIO2 #define LR1110_SPI_NSS_PIN LORA_CS #define LR1110_SPI_SCK_PIN LORA_SCK diff --git a/variants/wio-tracker-wm1110/variant.h b/variants/wio-tracker-wm1110/variant.h index de7da9911..32e84485d 100644 --- a/variants/wio-tracker-wm1110/variant.h +++ b/variants/wio-tracker-wm1110/variant.h @@ -91,7 +91,7 @@ extern "C" { #define USE_LR1110 #define LR1110_IRQ_PIN LORA_DIO1 -#define LR1110_NRESER_PIN LORA_RESET +#define LR1110_NRESET_PIN LORA_RESET #define LR1110_BUSY_PIN LORA_DIO2 #define LR1110_SPI_NSS_PIN LORA_CS #define LR1110_SPI_SCK_PIN LORA_SCK From 4794cdb12004fc2cb17369297c0b087f546ef3f9 Mon Sep 17 00:00:00 2001 From: TheMalkavien Date: Fri, 27 Sep 2024 00:44:11 +0200 Subject: [PATCH 05/16] Fix (some ?) memory alignment issues on the crypto part - resulting in crashes or strange behavior (#4867) * Replace multiple potentially non aligned pointer dereference (#4855) First step to fix some Crypto crashes or strange behaviors * Makes the two Crypto byte buffers aligned (#4855) Fix #4855, and probably multiple Crypto problems depending on hardware --------- Co-authored-by: Ben Meadors Co-authored-by: GUVWAF <78759985+GUVWAF@users.noreply.github.com> --- src/mesh/CryptoEngine.cpp | 18 +++++++++--------- src/mesh/Router.cpp | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/mesh/CryptoEngine.cpp b/src/mesh/CryptoEngine.cpp index f705bae03..f9d7b4ad2 100644 --- a/src/mesh/CryptoEngine.cpp +++ b/src/mesh/CryptoEngine.cpp @@ -70,8 +70,8 @@ bool CryptoEngine::encryptCurve25519(uint32_t toNode, uint32_t fromNode, uint64_ long extraNonceTmp = random(); auth = bytesOut + numBytes; extraNonce = (uint32_t *)(auth + 8); - *extraNonce = extraNonceTmp; - LOG_INFO("Random nonce value: %d\n", *extraNonce); + memcpy(extraNonce, &extraNonceTmp, 4); // do not use dereference on potential non aligned pointers : *extraNonce = extraNonceTmp; + LOG_INFO("Random nonce value: %d\n", extraNonceTmp); meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(toNode); if (node->num < 1 || node->user.public_key.size == 0) { LOG_DEBUG("Node %d or their public_key not found\n", toNode); @@ -80,14 +80,14 @@ bool CryptoEngine::encryptCurve25519(uint32_t toNode, uint32_t fromNode, uint64_ if (!crypto->setDHKey(toNode)) { return false; } - initNonce(fromNode, packetNum, *extraNonce); + initNonce(fromNode, packetNum, extraNonceTmp); // Calculate the shared secret with the destination node and encrypt printBytes("Attempting encrypt using nonce: ", nonce, 13); printBytes("Attempting encrypt using shared_key starting with: ", shared_key, 8); aes_ccm_ae(shared_key, 32, nonce, 8, bytes, numBytes, nullptr, 0, bytesOut, auth); // this can write up to 15 bytes longer than numbytes past bytesOut - *extraNonce = extraNonceTmp; + memcpy(extraNonce, &extraNonceTmp, 4); // do not use dereference on potential non aligned pointers : *extraNonce = extraNonceTmp; return true; } @@ -100,12 +100,12 @@ bool CryptoEngine::encryptCurve25519(uint32_t toNode, uint32_t fromNode, uint64_ bool CryptoEngine::decryptCurve25519(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes, uint8_t *bytesOut) { uint8_t *auth; // set to last 8 bytes of text? - uint32_t *extraNonce; + uint32_t extraNonce; // pointer was not really used auth = bytes + numBytes - 12; - extraNonce = (uint32_t *)(auth + 8); - LOG_INFO("Random nonce value: %d\n", *extraNonce); + memcpy(&extraNonce, auth +8, 4); // do not use dereference on potential non aligned pointers : (uint32_t *)(auth + 8); + LOG_INFO("Random nonce value: %d\n", extraNonce); meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(fromNode); - + if (node == nullptr || node->num < 1 || node->user.public_key.size == 0) { LOG_DEBUG("Node or its public key not found in database\n"); return false; @@ -115,7 +115,7 @@ bool CryptoEngine::decryptCurve25519(uint32_t fromNode, uint64_t packetNum, size if (!crypto->setDHKey(fromNode)) { return false; } - initNonce(fromNode, packetNum, *extraNonce); + initNonce(fromNode, packetNum, extraNonce); printBytes("Attempting decrypt using nonce: ", nonce, 13); printBytes("Attempting decrypt using shared_key starting with: ", shared_key, 8); return aes_ccm_ad(shared_key, 32, nonce, 8, bytes, numBytes - 12, nullptr, 0, auth, bytesOut); diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index a993ee7c0..f06f54165 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -36,8 +36,8 @@ static MemoryDynamic staticPool; Allocator &packetPool = staticPool; -static uint8_t bytes[MAX_LORA_PAYLOAD_LEN + 1]; -static uint8_t ScratchEncrypted[MAX_LORA_PAYLOAD_LEN + 1]; +static uint8_t bytes[MAX_LORA_PAYLOAD_LEN + 1] __attribute__ ((__aligned__)); +static uint8_t ScratchEncrypted[MAX_LORA_PAYLOAD_LEN + 1] __attribute__ ((__aligned__)); /** * Constructor From 5f6d9c3e27b1bc3d85b0b729ee924399dc4b7486 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Thu, 26 Sep 2024 19:33:08 -0500 Subject: [PATCH 06/16] Add pkc test (#4878) * Add a second delay() to get the unit tests running on Rak4631 * Add test_PKC_Decrypt * Remove cruft from test case --- src/mesh/CryptoEngine.cpp | 2 ++ test/test_crypto/test_main.cpp | 38 ++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/src/mesh/CryptoEngine.cpp b/src/mesh/CryptoEngine.cpp index f9d7b4ad2..7b5c8f2bd 100644 --- a/src/mesh/CryptoEngine.cpp +++ b/src/mesh/CryptoEngine.cpp @@ -102,6 +102,7 @@ bool CryptoEngine::decryptCurve25519(uint32_t fromNode, uint64_t packetNum, size uint8_t *auth; // set to last 8 bytes of text? uint32_t extraNonce; // pointer was not really used auth = bytes + numBytes - 12; +#ifndef PIO_UNIT_TESTING memcpy(&extraNonce, auth +8, 4); // do not use dereference on potential non aligned pointers : (uint32_t *)(auth + 8); LOG_INFO("Random nonce value: %d\n", extraNonce); meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(fromNode); @@ -115,6 +116,7 @@ bool CryptoEngine::decryptCurve25519(uint32_t fromNode, uint64_t packetNum, size if (!crypto->setDHKey(fromNode)) { return false; } +#endif initNonce(fromNode, packetNum, extraNonce); printBytes("Attempting decrypt using nonce: ", nonce, 13); printBytes("Attempting decrypt using shared_key starting with: ", shared_key, 8); diff --git a/test/test_crypto/test_main.cpp b/test/test_crypto/test_main.cpp index 0c820178a..cbe366048 100644 --- a/test/test_crypto/test_main.cpp +++ b/test/test_crypto/test_main.cpp @@ -98,7 +98,44 @@ void test_DH25519(void) HexToBytes(private_key, "18630f93598637c35da623a74559cf944374a559114c7937811041fc8605564a"); crypto->setDHPrivateKey(private_key); TEST_ASSERT(!crypto->setDHPublicKey(public_key)); // Weak public key results in 0 shared key + + HexToBytes(public_key, "f7e13a1a067d2f4e1061bf9936fde5be6b0c2494a8f809cbac7f290ef719e91c"); + HexToBytes(private_key, "10300724f3bea134eb1575245ef26ff9b8ccd59849cd98ce1a59002fe1d5986c"); + HexToBytes(expected_shared, "24becd5dfed9e9289ba2e15b82b0d54f8e9aacb72f5e4248c58d8d74b451ce76"); + crypto->setDHPrivateKey(private_key); + TEST_ASSERT(crypto->setDHPublicKey(public_key)); + crypto->hash(crypto->shared_key, 32); + TEST_ASSERT_EQUAL_MEMORY(expected_shared, crypto->shared_key, 32); } + +void test_PKC_Decrypt(void) +{ + uint8_t private_key[32]; + uint8_t public_key[32]; + uint8_t expected_shared[32]; + uint8_t expected_decrypted[32]; + uint8_t radioBytes[128] __attribute__((__aligned__)); + uint8_t decrypted[128] __attribute__((__aligned__)); + uint8_t expected_nonce[16]; + + uint32_t fromNode; + HexToBytes(public_key, "db18fc50eea47f00251cb784819a3cf5fc361882597f589f0d7ff820e8064457"); + HexToBytes(private_key, "a00330633e63522f8a4d81ec6d9d1e6617f6c8ffd3a4c698229537d44e522277"); + HexToBytes(expected_shared, "777b1545c9d6f9a2"); + HexToBytes(expected_decrypted, "08011204746573744800"); + HexToBytes(radioBytes, "8c646d7a2909000062d6b2136b00000040df24abfcc30a17a3d9046726099e796a1c036a792b"); + HexToBytes(expected_nonce, "62d6b213036a792b2909000000"); + fromNode = 0x0929; + crypto->setDHPrivateKey(private_key); + TEST_ASSERT(crypto->setDHPublicKey(public_key)); + crypto->hash(crypto->shared_key, 32); + crypto->decryptCurve25519(fromNode, 0x13b2d662, 22, radioBytes + 16, decrypted); + TEST_ASSERT_EQUAL_MEMORY(expected_shared, crypto->shared_key, 8); + TEST_ASSERT_EQUAL_MEMORY(expected_nonce, crypto->nonce, 13); + + TEST_ASSERT_EQUAL_MEMORY(expected_decrypted, decrypted, 10); +} + void test_AES_CTR(void) { uint8_t expected[32]; @@ -137,6 +174,7 @@ void setup() RUN_TEST(test_ECB_AES256); RUN_TEST(test_DH25519); RUN_TEST(test_AES_CTR); + RUN_TEST(test_PKC_Decrypt); } void loop() From 30356dcd970cef2c33e8cbf74ddcf7ba71a6c66c Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Thu, 26 Sep 2024 19:46:17 -0500 Subject: [PATCH 07/16] Retroactive trunkinate --- src/mesh/CryptoEngine.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/mesh/CryptoEngine.cpp b/src/mesh/CryptoEngine.cpp index 7b5c8f2bd..535e11e9b 100644 --- a/src/mesh/CryptoEngine.cpp +++ b/src/mesh/CryptoEngine.cpp @@ -70,7 +70,8 @@ bool CryptoEngine::encryptCurve25519(uint32_t toNode, uint32_t fromNode, uint64_ long extraNonceTmp = random(); auth = bytesOut + numBytes; extraNonce = (uint32_t *)(auth + 8); - memcpy(extraNonce, &extraNonceTmp, 4); // do not use dereference on potential non aligned pointers : *extraNonce = extraNonceTmp; + memcpy(extraNonce, &extraNonceTmp, + 4); // do not use dereference on potential non aligned pointers : *extraNonce = extraNonceTmp; LOG_INFO("Random nonce value: %d\n", extraNonceTmp); meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(toNode); if (node->num < 1 || node->user.public_key.size == 0) { @@ -87,7 +88,8 @@ bool CryptoEngine::encryptCurve25519(uint32_t toNode, uint32_t fromNode, uint64_ printBytes("Attempting encrypt using shared_key starting with: ", shared_key, 8); aes_ccm_ae(shared_key, 32, nonce, 8, bytes, numBytes, nullptr, 0, bytesOut, auth); // this can write up to 15 bytes longer than numbytes past bytesOut - memcpy(extraNonce, &extraNonceTmp, 4); // do not use dereference on potential non aligned pointers : *extraNonce = extraNonceTmp; + memcpy(extraNonce, &extraNonceTmp, + 4); // do not use dereference on potential non aligned pointers : *extraNonce = extraNonceTmp; return true; } @@ -99,14 +101,14 @@ bool CryptoEngine::encryptCurve25519(uint32_t toNode, uint32_t fromNode, uint64_ */ bool CryptoEngine::decryptCurve25519(uint32_t fromNode, uint64_t packetNum, size_t numBytes, uint8_t *bytes, uint8_t *bytesOut) { - uint8_t *auth; // set to last 8 bytes of text? + uint8_t *auth; // set to last 8 bytes of text? uint32_t extraNonce; // pointer was not really used auth = bytes + numBytes - 12; #ifndef PIO_UNIT_TESTING - memcpy(&extraNonce, auth +8, 4); // do not use dereference on potential non aligned pointers : (uint32_t *)(auth + 8); + memcpy(&extraNonce, auth + 8, 4); // do not use dereference on potential non aligned pointers : (uint32_t *)(auth + 8); LOG_INFO("Random nonce value: %d\n", extraNonce); meshtastic_NodeInfoLite *node = nodeDB->getMeshNode(fromNode); - + if (node == nullptr || node->num < 1 || node->user.public_key.size == 0) { LOG_DEBUG("Node or its public key not found in database\n"); return false; From 743fc2e812ff1c7ec40dcbdb1bc1656565febd87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 27 Sep 2024 09:07:14 +0200 Subject: [PATCH 08/16] Update radiolib, fixes CRC bug on SX127x and improves LR11xx support --- platformio.ini | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index b3898ba93..799645306 100644 --- a/platformio.ini +++ b/platformio.ini @@ -88,7 +88,9 @@ monitor_speed = 115200 monitor_filters = direct lib_deps = - jgromes/RadioLib@~7.0.0 + ;jgromes/RadioLib@~7.0.0 + ;7.0.1pre needed for LR1121 support and SX127x CRC Bugfix + https://github.com/jgromes/RadioLib.git#42ae7c92ed584317d7206cfc463ba6260295dbbc https://github.com/meshtastic/esp8266-oled-ssd1306.git#e16cee124fe26490cb14880c679321ad8ac89c95 ; ESP8266_SSD1306 https://github.com/mathertel/OneButton@~2.6.1 ; OneButton library for non-blocking button debounce https://github.com/meshtastic/arduino-fsm.git#7db3702bf0cfe97b783d6c72595e3f38e0b19159 From 40932ea06c55d2441ff239fce37de04bc0e6f55d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 27 Sep 2024 10:21:34 +0200 Subject: [PATCH 09/16] update ci builder to include a 'quick' command line option that only outputs 3 random devices or check targets --- bin/generate_ci_matrix.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/generate_ci_matrix.py b/bin/generate_ci_matrix.py index 46398dd59..ea2480c58 100755 --- a/bin/generate_ci_matrix.py +++ b/bin/generate_ci_matrix.py @@ -6,6 +6,7 @@ import configparser import json import os import sys +import random rootdir = "variants/" @@ -39,5 +40,7 @@ for subdir, dirs, files in os.walk(rootdir): "check" in options ): outlist.append(section) - -print(json.dumps(outlist)) +if ("quick" in options): + print(json.dumps(random.sample(outlist, 3))) +else: + print(json.dumps(outlist)) From 39febad63057fd21c8b2a87ed6bcb8872449a646 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 27 Sep 2024 10:25:37 +0200 Subject: [PATCH 10/16] only sample a few builds for CI runs --- .github/workflows/main_matrix.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index ca9f1d37f..bb42f2246 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -20,7 +20,33 @@ on: workflow_dispatch: jobs: + setup-quick: + if: ${{ github.event_name != 'workflow_dispatch' }} + strategy: + fail-fast: false + matrix: + arch: [esp32, esp32s3, esp32c3, nrf52840, rp2040, stm32, check] + runs-on: ubuntu-latest + steps: + - id: checkout + uses: actions/checkout@v4 + name: Checkout base + - id: jsonStep + run: | + TARGETS=$(./bin/generate_ci_matrix.py ${{matrix.arch}} quick) + echo "$TARGETS" + echo "${{matrix.arch}}=$(jq -cn --argjson environments "$TARGETS" '{board: $environments}')" >> $GITHUB_OUTPUT + outputs: + esp32: ${{ steps.jsonStep.outputs.esp32 }} + esp32s3: ${{ steps.jsonStep.outputs.esp32s3 }} + esp32c3: ${{ steps.jsonStep.outputs.esp32c3 }} + nrf52840: ${{ steps.jsonStep.outputs.nrf52840 }} + rp2040: ${{ steps.jsonStep.outputs.rp2040 }} + stm32: ${{ steps.jsonStep.outputs.stm32 }} + check: ${{ steps.jsonStep.outputs.check }} + setup: + if: ${{ github.event_name == 'workflow_dispatch' }} strategy: fail-fast: false matrix: From c35d780236fe235721910e74923367a7568e5397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 27 Sep 2024 10:27:57 +0200 Subject: [PATCH 11/16] only randominze for at least 3 elements --- bin/generate_ci_matrix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/generate_ci_matrix.py b/bin/generate_ci_matrix.py index ea2480c58..4d8759ecc 100755 --- a/bin/generate_ci_matrix.py +++ b/bin/generate_ci_matrix.py @@ -40,7 +40,7 @@ for subdir, dirs, files in os.walk(rootdir): "check" in options ): outlist.append(section) -if ("quick" in options): +if ("quick" in options) & (len(outlist) > 3): print(json.dumps(random.sample(outlist, 3))) else: print(json.dumps(outlist)) From bdb998c7637ab153cc704b407b86b1e5d3f8a786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 27 Sep 2024 10:33:16 +0200 Subject: [PATCH 12/16] pick either setup or setup-quick as valid --- .github/workflows/main_matrix.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index bb42f2246..730241f50 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -71,13 +71,15 @@ jobs: check: ${{ steps.jsonStep.outputs.check }} check: - needs: setup + needs: [ setup, setup-quick ] strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.check) }} runs-on: ubuntu-latest - if: ${{ github.event_name != 'workflow_dispatch' }} + if: | + always() + && ${{ github.event_name != 'workflow_dispatch' }} steps: - uses: actions/checkout@v4 - name: Build base @@ -87,7 +89,8 @@ jobs: run: bin/check-all.sh ${{ matrix.board }} build-esp32: - needs: setup + needs: [ setup, setup-quick ] + if: always() strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.esp32) }} @@ -96,7 +99,8 @@ jobs: board: ${{ matrix.board }} build-esp32-s3: - needs: setup + needs: [ setup, setup-quick ] + if: always() strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.esp32s3) }} @@ -105,7 +109,8 @@ jobs: board: ${{ matrix.board }} build-esp32-c3: - needs: setup + needs: [ setup, setup-quick ] + if: always() strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.esp32c3) }} @@ -114,7 +119,8 @@ jobs: board: ${{ matrix.board }} build-nrf52: - needs: setup + needs: [ setup, setup-quick ] + if: always() strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.nrf52840) }} @@ -123,7 +129,8 @@ jobs: board: ${{ matrix.board }} build-rpi2040: - needs: setup + needs: [ setup, setup-quick ] + if: always() strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.rp2040) }} @@ -132,7 +139,8 @@ jobs: board: ${{ matrix.board }} build-stm32: - needs: setup + needs: [ setup, setup-quick ] + if: always() strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.stm32) }} From e02a7d1c68c9efaa7c2d5ed521d7ac2df6680bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 27 Sep 2024 10:36:00 +0200 Subject: [PATCH 13/16] test if quick is working at all --- .github/workflows/main_matrix.yml | 53 ++++++------------------------- 1 file changed, 10 insertions(+), 43 deletions(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index 730241f50..ffe777f7e 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -20,8 +20,8 @@ on: workflow_dispatch: jobs: - setup-quick: - if: ${{ github.event_name != 'workflow_dispatch' }} + setup: + if: ${{ github.event_name == 'workflow_dispatch' }} strategy: fail-fast: false matrix: @@ -45,41 +45,14 @@ jobs: stm32: ${{ steps.jsonStep.outputs.stm32 }} check: ${{ steps.jsonStep.outputs.check }} - setup: - if: ${{ github.event_name == 'workflow_dispatch' }} - strategy: - fail-fast: false - matrix: - arch: [esp32, esp32s3, esp32c3, nrf52840, rp2040, stm32, check] - runs-on: ubuntu-latest - steps: - - id: checkout - uses: actions/checkout@v4 - name: Checkout base - - id: jsonStep - run: | - TARGETS=$(./bin/generate_ci_matrix.py ${{matrix.arch}}) - echo "$TARGETS" - echo "${{matrix.arch}}=$(jq -cn --argjson environments "$TARGETS" '{board: $environments}')" >> $GITHUB_OUTPUT - outputs: - esp32: ${{ steps.jsonStep.outputs.esp32 }} - esp32s3: ${{ steps.jsonStep.outputs.esp32s3 }} - esp32c3: ${{ steps.jsonStep.outputs.esp32c3 }} - nrf52840: ${{ steps.jsonStep.outputs.nrf52840 }} - rp2040: ${{ steps.jsonStep.outputs.rp2040 }} - stm32: ${{ steps.jsonStep.outputs.stm32 }} - check: ${{ steps.jsonStep.outputs.check }} - check: - needs: [ setup, setup-quick ] + needs: setup strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.check) }} runs-on: ubuntu-latest - if: | - always() - && ${{ github.event_name != 'workflow_dispatch' }} + if: ${{ github.event_name != 'workflow_dispatch' }} steps: - uses: actions/checkout@v4 - name: Build base @@ -89,8 +62,7 @@ jobs: run: bin/check-all.sh ${{ matrix.board }} build-esp32: - needs: [ setup, setup-quick ] - if: always() + needs: setup strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.esp32) }} @@ -99,8 +71,7 @@ jobs: board: ${{ matrix.board }} build-esp32-s3: - needs: [ setup, setup-quick ] - if: always() + needs: setup strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.esp32s3) }} @@ -109,8 +80,7 @@ jobs: board: ${{ matrix.board }} build-esp32-c3: - needs: [ setup, setup-quick ] - if: always() + needs: setup strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.esp32c3) }} @@ -119,8 +89,7 @@ jobs: board: ${{ matrix.board }} build-nrf52: - needs: [ setup, setup-quick ] - if: always() + needs: setup strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.nrf52840) }} @@ -129,8 +98,7 @@ jobs: board: ${{ matrix.board }} build-rpi2040: - needs: [ setup, setup-quick ] - if: always() + needs: setup strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.rp2040) }} @@ -139,8 +107,7 @@ jobs: board: ${{ matrix.board }} build-stm32: - needs: [ setup, setup-quick ] - if: always() + needs: setup strategy: fail-fast: false matrix: ${{ fromJson(needs.setup.outputs.stm32) }} From 747046d3351d8ae0a74862e6c294c37e9348405f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 27 Sep 2024 10:37:15 +0200 Subject: [PATCH 14/16] nope --- .github/workflows/main_matrix.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main_matrix.yml b/.github/workflows/main_matrix.yml index ffe777f7e..87ba8cf85 100644 --- a/.github/workflows/main_matrix.yml +++ b/.github/workflows/main_matrix.yml @@ -21,7 +21,6 @@ on: jobs: setup: - if: ${{ github.event_name == 'workflow_dispatch' }} strategy: fail-fast: false matrix: From ae14ca78703eee9ec4a5c342ff16f21139106041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Fri, 27 Sep 2024 10:42:27 +0200 Subject: [PATCH 15/16] the name is somewhat misleading --- .github/workflows/build_stm32.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_stm32.yml b/.github/workflows/build_stm32.yml index 6858812e1..e78178db3 100644 --- a/.github/workflows/build_stm32.yml +++ b/.github/workflows/build_stm32.yml @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Build Raspberry Pi 2040 + - name: Build STM32WL id: build uses: ./.github/actions/build-variant with: From ef223b1195453f89edef1edbc3ff933e835037d2 Mon Sep 17 00:00:00 2001 From: Jonathan Bennett Date: Fri, 27 Sep 2024 14:55:55 -0500 Subject: [PATCH 16/16] use delete[] to avoid leaking memory (#4883) --- src/meshUtils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/meshUtils.cpp b/src/meshUtils.cpp index 2789a143c..e98a6f1ce 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) snprintf(messageBuffer + labelSize + i * 3, 4, " %02x", p[i]); strcpy(messageBuffer + labelSize + numbytes * 3, "\n"); LOG_DEBUG(messageBuffer); - delete messageBuffer; + delete[] messageBuffer; } }