diff --git a/.github/workflows/test_native.yml b/.github/workflows/test_native.yml index a2328022e..decd23954 100644 --- a/.github/workflows/test_native.yml +++ b/.github/workflows/test_native.yml @@ -143,7 +143,7 @@ jobs: merge-multiple: true - name: Test Report - uses: dorny/test-reporter@v2.2.0 + uses: dorny/test-reporter@v2.3.0 with: name: PlatformIO Tests path: testreport.xml diff --git a/.trunk/trunk.yaml b/.trunk/trunk.yaml index ccb426745..342d9d4a2 100644 --- a/.trunk/trunk.yaml +++ b/.trunk/trunk.yaml @@ -9,14 +9,14 @@ plugins: lint: enabled: - checkov@3.2.495 - - renovate@42.24.1 - - prettier@3.6.2 + - renovate@42.27.1 + - prettier@3.7.3 - trufflehog@3.91.1 - yamllint@1.37.1 - bandit@1.9.2 - trivy@0.67.2 - taplo@0.10.0 - - ruff@0.14.6 + - ruff@0.14.7 - isort@7.0.0 - markdownlint@0.46.0 - oxipng@9.1.5 diff --git a/arch/esp32/esp32.ini b/arch/esp32/esp32.ini index 810c9780e..08a547ca6 100644 --- a/arch/esp32/esp32.ini +++ b/arch/esp32/esp32.ini @@ -57,7 +57,7 @@ lib_deps = # renovate: datasource=git-refs depName=libpax packageName=https://github.com/dbinfrago/libpax gitBranch=master https://github.com/dbinfrago/libpax/archive/3cdc0371c375676a97967547f4065607d4c53fd1.zip # renovate: datasource=github-tags depName=XPowersLib packageName=lewisxhe/XPowersLib - https://github.com/lewisxhe/XPowersLib/archive/v0.3.1.zip + https://github.com/lewisxhe/XPowersLib/archive/v0.3.2.zip # renovate: datasource=git-refs depName=meshtastic-ESP32_Codec2 packageName=https://github.com/meshtastic/ESP32_Codec2 gitBranch=master https://github.com/meshtastic/ESP32_Codec2/archive/633326c78ac251c059ab3a8c430fcdf25b41672f.zip # renovate: datasource=custom.pio depName=rweather/Crypto packageName=rweather/library/Crypto diff --git a/arch/esp32/esp32c6.ini b/arch/esp32/esp32c6.ini index 7b06f4cd8..b07a2dcd4 100644 --- a/arch/esp32/esp32c6.ini +++ b/arch/esp32/esp32c6.ini @@ -28,7 +28,7 @@ lib_deps = ${environmental_extra.lib_deps} ${radiolib_base.lib_deps} # renovate: datasource=custom.pio depName=XPowersLib packageName=lewisxhe/library/XPowersLib - lewisxhe/XPowersLib@0.3.1 + lewisxhe/XPowersLib@0.3.2 # renovate: datasource=git-refs depName=meshtastic-ESP32_Codec2 packageName=https://github.com/meshtastic/ESP32_Codec2 gitBranch=master https://github.com/meshtastic/ESP32_Codec2/archive/633326c78ac251c059ab3a8c430fcdf25b41672f.zip # renovate: datasource=custom.pio depName=rweather/Crypto packageName=rweather/library/Crypto diff --git a/bin/analyze_map.py b/bin/analyze_map.py new file mode 100644 index 000000000..99997c703 --- /dev/null +++ b/bin/analyze_map.py @@ -0,0 +1,165 @@ +#!/usr/bin/env python3 +"""Summarise linker map output to highlight heavy object files and libraries. + +Usage: + python bin/analyze_map.py --map .pio/build/rak4631/output.map --top 20 + +The script parses GNU ld map files and aggregates section sizes per object file +and per archive/library, then prints sortable tables that make it easy to spot +modules worth trimming or hiding behind feature flags. +""" +from __future__ import annotations + +import argparse +import collections +import os +import re +import sys +from typing import DefaultDict, Dict, Tuple + + +SECTION_LINE_RE = re.compile(r"^\s+(?P
\S+)\s+0x[0-9A-Fa-f]+\s+0x(?P[0-9A-Fa-f]+)\s+(?P.+)$") +ARCHIVE_MEMBER_RE = re.compile(r"^(?P.+)\((?P[^)]+)\)$") + + +def human_size(num_bytes: int) -> str: + """Return a friendly size string with one decimal place.""" + if num_bytes < 1024: + return f"{num_bytes:,} B" + num = float(num_bytes) + for unit in ("KB", "MB", "GB"): + num /= 1024.0 + if num < 1024.0: + return f"{num:.1f} {unit}" + return f"{num:.1f} TB" + + +def shorten_path(path: str, root: str) -> str: + """Prefer repository-relative paths for readability.""" + path = path.strip() + if not path: + return path + + # Normalise Windows archives (backslashes) to POSIX style for consistency. + path = path.replace("\\", "/") + + # Attempt to strip the root when an absolute path lives inside the repo. + if os.path.isabs(path): + try: + rel = os.path.relpath(path, root) + if not rel.startswith(".."): + return rel + except ValueError: + # relpath can fail on mixed drives on Windows; fall back to basename. + pass + return path + + +def describe_object(raw_object: str, root: str) -> Tuple[str, str]: + """Return a human friendly object label and the library it belongs to.""" + raw_object = raw_object.strip() + lib_label = "[app]" + match = ARCHIVE_MEMBER_RE.match(raw_object) + if match: + archive = shorten_path(match.group("archive"), root) + obj = match.group("object") + lib_label = os.path.basename(archive) or archive + label = f"{archive}:{obj}" + else: + label = shorten_path(raw_object, root) + # If the object lives under libs, hint at the containing directory. + parent = os.path.basename(os.path.dirname(label)) + if parent: + lib_label = parent + return label, lib_label + + +def parse_map(map_path: str, repo_root: str) -> Tuple[Dict[str, int], Dict[str, int], Dict[str, Dict[str, int]]]: + per_object: DefaultDict[str, int] = collections.defaultdict(int) + per_library: DefaultDict[str, int] = collections.defaultdict(int) + per_object_sections: DefaultDict[str, DefaultDict[str, int]] = collections.defaultdict(lambda: collections.defaultdict(int)) + + try: + with open(map_path, "r", encoding="utf-8", errors="ignore") as handle: + for line in handle: + match = SECTION_LINE_RE.match(line) + if not match: + continue + + section = match.group("section") + if section.startswith("*") or section in {"LOAD", "ORIGIN"}: + continue + + size = int(match.group("size"), 16) + if size == 0: + continue + + obj_token = match.group("object").strip() + if not obj_token or obj_token.startswith("*") or "load address" in obj_token: + continue + + label, lib_label = describe_object(obj_token, repo_root) + per_object[label] += size + per_library[lib_label] += size + per_object_sections[label][section] += size + except FileNotFoundError: + raise SystemExit(f"error: map file '{map_path}' not found. Run a build first.") + + return per_object, per_library, per_object_sections + + +def format_section_breakdown(section_sizes: Dict[str, int], total: int, limit: int = 3) -> str: + items = sorted(section_sizes.items(), key=lambda kv: kv[1], reverse=True) + parts = [] + for section, size in items[:limit]: + pct = (size / total) * 100 if total else 0 + parts.append(f"{section} {pct:.1f}%") + if len(items) > limit: + remainder = total - sum(size for _, size in items[:limit]) + pct = (remainder / total) * 100 if total else 0 + parts.append(f"other {pct:.1f}%") + return ", ".join(parts) + + +def print_report(map_path: str, top_n: int, per_object: Dict[str, int], per_library: Dict[str, int], per_object_sections: Dict[str, Dict[str, int]]): + total_bytes = sum(per_object.values()) + if total_bytes == 0: + print("No section data found in map file.") + return + + print(f"Map file: {map_path}") + print(f"Accounted size: {human_size(total_bytes)} across {len(per_object)} object files\n") + + sorted_objects = sorted(per_object.items(), key=lambda kv: kv[1], reverse=True) + print(f"Top {min(top_n, len(sorted_objects))} object files by linked size:") + for idx, (obj, size) in enumerate(sorted_objects[:top_n], 1): + pct = (size / total_bytes) * 100 + breakdown = format_section_breakdown(per_object_sections[obj], size) + print(f"{idx:2}. {human_size(size):>9} ({size:,} B, {pct:5.2f}% of linked size)") + print(f" {obj}") + if breakdown: + print(f" sections: {breakdown}") + print() + + sorted_libs = sorted(per_library.items(), key=lambda kv: kv[1], reverse=True) + print(f"Top {min(top_n, len(sorted_libs))} libraries or source roots:") + for idx, (lib, size) in enumerate(sorted_libs[:top_n], 1): + pct = (size / total_bytes) * 100 + print(f"{idx:2}. {human_size(size):>9} ({size:,} B, {pct:5.2f}% of linked size) {lib}") + + +def main() -> None: + parser = argparse.ArgumentParser(description="Highlight heavy object files from a GNU ld map file.") + parser.add_argument("--map", default=".pio/build/rak4631/output.map", help="Path to the map file (default: %(default)s)") + parser.add_argument("--top", type=int, default=20, help="Number of entries to display per table (default: %(default)s)") + args = parser.parse_args() + + map_path = os.path.abspath(args.map) + repo_root = os.path.abspath(os.getcwd()) + + per_object, per_library, per_object_sections = parse_map(map_path, repo_root) + print_report(os.path.relpath(map_path, repo_root), args.top, per_object, per_library, per_object_sections) + + +if __name__ == "__main__": + main() diff --git a/meshtasticd.spec.rpkg b/meshtasticd.spec.rpkg index b9152c4a3..e2da172c3 100644 --- a/meshtasticd.spec.rpkg +++ b/meshtasticd.spec.rpkg @@ -33,7 +33,6 @@ BuildRequires: python3dist(grpcio[protobuf]) BuildRequires: python3dist(grpcio-tools) BuildRequires: git-core BuildRequires: gcc-c++ -BuildRequires: (glibc-devel >= 2.38) or pkgconfig(libbsd-overlay) BuildRequires: pkgconfig(yaml-cpp) BuildRequires: pkgconfig(libgpiod) BuildRequires: pkgconfig(bluez) diff --git a/platformio.ini b/platformio.ini index 1363a63fc..5b9d965ef 100644 --- a/platformio.ini +++ b/platformio.ini @@ -121,7 +121,7 @@ lib_deps = [device-ui_base] lib_deps = # renovate: datasource=git-refs depName=meshtastic/device-ui packageName=https://github.com/meshtastic/device-ui gitBranch=master - https://github.com/meshtastic/device-ui/archive/28167c67dfd13015a0b5eef1828f95fe8e3ab7c3.zip + https://github.com/meshtastic/device-ui/archive/3bf332240416c5cb8c919fac2a0ec7260eb3be75.zip ; Common libs for environmental measurements in telemetry module [environmental_base] diff --git a/src/graphics/VirtualKeyboard.cpp b/src/graphics/VirtualKeyboard.cpp index 8062a0338..a332aad9a 100644 --- a/src/graphics/VirtualKeyboard.cpp +++ b/src/graphics/VirtualKeyboard.cpp @@ -506,6 +506,9 @@ void VirtualKeyboard::drawKey(OLEDDisplay *display, const VirtualKey &key, bool centeredTextY -= 1; } } +#ifdef MUZI_BASE // Correct issue with character vertical position on MUZI_BASE + centeredTextY -= 2; +#endif display->drawString(textX, centeredTextY, keyText.c_str()); } diff --git a/src/graphics/niche/InkHUD/AppletFont.cpp b/src/graphics/niche/InkHUD/AppletFont.cpp index db7097f3f..6c7a7b491 100644 --- a/src/graphics/niche/InkHUD/AppletFont.cpp +++ b/src/graphics/niche/InkHUD/AppletFont.cpp @@ -124,7 +124,7 @@ uint32_t InkHUD::AppletFont::toUtf32(std::string utf8) utf32 |= (utf8.at(3) & 0b00111111); break; default: - assert(false); + return 0; } return utf32; diff --git a/variants/nrf52840/rak4631/platformio.ini b/variants/nrf52840/rak4631/platformio.ini index 205966529..c95d477f9 100644 --- a/variants/nrf52840/rak4631/platformio.ini +++ b/variants/nrf52840/rak4631/platformio.ini @@ -4,16 +4,33 @@ extends = nrf52840_base board = wiscore_rak4631 board_level = pr board_check = true +build_type = release build_flags = ${nrf52840_base.build_flags} -I variants/nrf52840/rak4631 -D RAK_4631 -DEINK_DISPLAY_MODEL=GxEPD2_213_BN -DEINK_WIDTH=250 - -DEINK_HEIGHT=122 + -DEINK_HEIGHT=122 -DRADIOLIB_EXCLUDE_SX128X=1 -DRADIOLIB_EXCLUDE_SX127X=1 -DRADIOLIB_EXCLUDE_LR11X0=1 -build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/rak4631> + + + + -Os + -Wl,-Map=$BUILD_DIR/output.map +build_unflags = + -Ofast + -Og + -ggdb3 + -ggdb2 + -g3 + -g2 + -g + -g1 + -g0 +build_src_filter = ${nrf52_base.build_src_filter} \ + +<../variants/nrf52840/rak4631> \ + + \ + + \ + + lib_deps = ${nrf52840_base.lib_deps} ${nrf52_networking_base.lib_deps}