Add MeshPocket message board and worldwide map
This commit is contained in:
1 parent
7d0709bf03
commit
5d31a839c5
41 files changed
+6852
-7
No files matched your search
@@ -15,6 +15,8 @@ from rp2040_application import read_application as read_rp2040_application
|
||||
from package_meshtext_license import (CAPABILITY as MESHTEXT_CAPABILITY,
|
||||
meshtext_evidence, notice_bytes as meshtext_notice_bytes,
|
||||
notice_record as meshtext_notice_record)
|
||||
from package_pocket_gui_license import (pocket_gui_evidence,
|
||||
notice_bytes as pocket_gui_notice_bytes, notice_record as pocket_gui_notice_record)
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "tools" / "mota"))
|
||||
from motalib import parse_nrf52_layout
|
||||
@@ -217,6 +219,13 @@ def main() -> int:
|
||||
except (OSError, ValueError) as error:
|
||||
print(f"capability check: cannot qualify linked Meshtext code: {error}", file=sys.stderr)
|
||||
malformed = True
|
||||
try:
|
||||
if pocket_gui_evidence(args.image):
|
||||
stem = args.output.name.removesuffix(".capabilities.json")
|
||||
third_party_notices.append(pocket_gui_notice_record(stem, pocket_gui_notice_bytes()))
|
||||
except (OSError, ValueError) as error:
|
||||
print(f"capability check: cannot qualify linked MeshPocket GUI/fonts: {error}", file=sys.stderr)
|
||||
malformed = True
|
||||
if args.require_meshtext and not chat_symbols:
|
||||
checks.append({"capability": MESHTEXT_CAPABILITY,
|
||||
"evidence": "Meshtext encode/decode, Companion send/receive, and Dispatcher raw-frame queue implementations",
|
||||
|
||||
@@ -385,7 +385,9 @@ def requirements(platform, defines, target):
|
||||
external_ota)
|
||||
if display and display != "NullDisplayDriver":
|
||||
parts["display_pixels_and_driver"] = display_heap
|
||||
screen_budget = integer(defines, "MESH_COMPANION_SCREEN_STARTUP_BYTES", 0)
|
||||
pocket_gui = ("HELTEC_MESH_POCKET" in defines and "COMPANION_RADIO_FULL" in defines
|
||||
and integer(defines, "UI_POCKET_GUI", 1) != 0)
|
||||
screen_budget = integer(defines, "MESH_COMPANION_SCREEN_STARTUP_BYTES", 12288 if pocket_gui else 0)
|
||||
if companion and screen_budget:
|
||||
# A target using this override has a source-side static assertion
|
||||
# that covers its concrete startup screens and allocator overhead.
|
||||
|
||||
@@ -24,7 +24,7 @@ RECIPE_ENVIRONMENT = (
|
||||
)
|
||||
PACKAGE_SUFFIXES = (".bin", "-merged.bin", ".uf2", ".zip", ".hex",
|
||||
".capabilities.json", ".memory.json", ".font-license.txt",
|
||||
".meshtext-license.txt")
|
||||
".meshtext-license.txt", ".pocket-gui-license.txt")
|
||||
|
||||
|
||||
def canonical_digest(value):
|
||||
|
||||
@@ -11,6 +11,7 @@ import sys
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
from package_nrf52_font_license import validate_artifact_notice
|
||||
from package_meshtext_license import validate_artifact_notice as validate_meshtext_notice
|
||||
from package_pocket_gui_license import validate_artifact_notice as validate_pocket_gui_notice
|
||||
|
||||
|
||||
def digest(path):
|
||||
@@ -45,6 +46,7 @@ def artifact_files(stem):
|
||||
for suffix in (".bin", "-merged.bin", ".uf2", ".zip", ".hex", ".capabilities.json",
|
||||
".font-license.txt")]
|
||||
candidates.append(stem.parent / (stem.name + ".meshtext-license.txt"))
|
||||
candidates.append(stem.parent / (stem.name + ".pocket-gui-license.txt"))
|
||||
return [p for p in candidates if p.is_file()]
|
||||
|
||||
|
||||
@@ -53,6 +55,7 @@ def package_report(directory, stem):
|
||||
report = validate_build(directory)
|
||||
validate_artifact_notice(stem)
|
||||
validate_meshtext_notice(stem)
|
||||
validate_pocket_gui_notice(stem)
|
||||
files = artifact_files(stem)
|
||||
if len(files) < 2 or not any(p.suffix in (".bin", ".uf2", ".zip", ".hex") for p in files):
|
||||
raise ValueError("cannot qualify an empty firmware package")
|
||||
@@ -68,6 +71,7 @@ def validate_package(stem):
|
||||
stem = Path(stem)
|
||||
validate_artifact_notice(stem)
|
||||
validate_meshtext_notice(stem)
|
||||
validate_pocket_gui_notice(stem)
|
||||
report = passing_report(stem.parent / (stem.name + ".memory.json"))
|
||||
actual = {p.name: digest(p) for p in artifact_files(stem)}
|
||||
if len(actual) < 2 or actual != report.get("files"):
|
||||
|
||||
@@ -19,6 +19,7 @@ from firmware_memory_manifest import validate_package
|
||||
from check_nrf52_uf2 import check_uf2
|
||||
from package_nrf52_font_license import validate_artifact_notice
|
||||
from package_meshtext_license import validate_artifact_notice as validate_meshtext_notice
|
||||
from package_pocket_gui_license import validate_artifact_notice as validate_pocket_gui_notice
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
@@ -243,6 +244,9 @@ def collect_artifacts(directory, version):
|
||||
meshtext_notice = validate_meshtext_notice(directory / stem)
|
||||
if meshtext_notice is not None:
|
||||
files.append(meshtext_notice)
|
||||
pocket_gui_notice = validate_pocket_gui_notice(directory / stem)
|
||||
if pocket_gui_notice is not None:
|
||||
files.append(pocket_gui_notice)
|
||||
manifest["runtime_ram"] = {key: memory[key] for key in (
|
||||
"passed", "available_internal_bytes", "required_heap_bytes", "elf_sha256")}
|
||||
accounted.update(files)
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Carry MeshPocket GUI and font notices beside firmware containing that code."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
from firmware_elf import FirmwareElf
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
NOTICE_PATH = ROOT / "tools/meshpocket_map/PocketGui-NOTICE.txt"
|
||||
SIDECAR_SUFFIX = ".pocket-gui-license.txt"
|
||||
COMPONENT = "meshpocket-gui-and-fonts"
|
||||
LICENSE = "MIT AND BSD-2-Clause AND LicenseRef-Adobe-X11"
|
||||
FONTS = {"u8g2_font_helvR08_tf", "u8g2_font_helvB08_tf",
|
||||
"u8g2_font_helvR10_tf", "u8g2_font_helvB10_tf"}
|
||||
|
||||
|
||||
def valid_notice(data):
|
||||
return (0 < len(data) <= 262144 and all(text in data for text in (
|
||||
b"jackywashere/MeshCore-Mesh-Pocket-MessageBoard",
|
||||
b"Copyright (c) 2025 Scott Powell", b"Permission is hereby granted, free of charge",
|
||||
b"copies or substantial portions of the Software", b'THE SOFTWARE IS PROVIDED "AS IS"',
|
||||
b"Copyright (c) 2018, olikraus", b"Redistribution and use in source and binary forms",
|
||||
b"Copyright 1984-1989, 1994 Adobe Systems Incorporated.",
|
||||
b"Copyright 1988, 1994 Digital Equipment Corporation.",
|
||||
b"Permission to use, copy, modify, distribute and sell this software",
|
||||
b"without express or implied warranty.")))
|
||||
|
||||
|
||||
def notice_bytes():
|
||||
data = NOTICE_PATH.read_bytes()
|
||||
if not valid_notice(data):
|
||||
raise ValueError("MeshPocket GUI/font source notice is incomplete")
|
||||
return data
|
||||
|
||||
|
||||
def pocket_gui_evidence(path):
|
||||
"""Only allocated definitions qualify, never target names or debug strings."""
|
||||
if Path(path).read_bytes()[:4] != b"\x7fELF":
|
||||
return []
|
||||
elf = FirmwareElf(path)
|
||||
evidence = []
|
||||
for name, (_address, size, index) in elf.symbols.items():
|
||||
if size <= 0 or index >= len(elf.sections):
|
||||
continue
|
||||
section = elf.sections[index]
|
||||
if section[1] == 8 or not section[2] & 2:
|
||||
continue
|
||||
gui = (section[2] & 4 and name.startswith((
|
||||
"_ZN4mesh2ui6pocket9PocketGui", "_ZNK4mesh2ui6pocket9PocketGui")))
|
||||
if gui or name in FONTS:
|
||||
evidence.append(name)
|
||||
return sorted(evidence)
|
||||
|
||||
|
||||
def sidecar(stem):
|
||||
stem = Path(stem)
|
||||
return stem.parent / (stem.name + SIDECAR_SUFFIX)
|
||||
|
||||
|
||||
def notice_record(stem, data):
|
||||
return {"component": COMPONENT, "license": LICENSE,
|
||||
"file": sidecar(stem).name, "sha256": hashlib.sha256(data).hexdigest()}
|
||||
|
||||
|
||||
def manifest_record(stem):
|
||||
stem = Path(stem)
|
||||
manifest = json.loads((stem.parent / (stem.name + ".capabilities.json")).read_text())
|
||||
records = [record for record in manifest.get("third_party_notices", [])
|
||||
if record.get("component") == COMPONENT]
|
||||
if len(records) > 1:
|
||||
raise ValueError(f"{stem}: duplicate MeshPocket GUI/font notice declarations")
|
||||
if not records:
|
||||
return None
|
||||
record = records[0]
|
||||
if (record.get("file") != sidecar(stem).name or record.get("license") != LICENSE
|
||||
or not re.fullmatch(r"[0-9a-f]{64}", str(record.get("sha256", "")))):
|
||||
raise ValueError(f"{stem}: invalid MeshPocket GUI/font notice declaration")
|
||||
return record
|
||||
|
||||
|
||||
def validate_artifact_notice(stem):
|
||||
record = manifest_record(stem)
|
||||
output = sidecar(stem)
|
||||
if record is None:
|
||||
if output.exists():
|
||||
raise ValueError(f"{output}: stale notice for unaffected firmware")
|
||||
return None
|
||||
if not output.is_file():
|
||||
raise ValueError(f"{output}: missing MeshPocket GUI/font notice")
|
||||
data = output.read_bytes()
|
||||
if not valid_notice(data) or hashlib.sha256(data).hexdigest() != record["sha256"]:
|
||||
raise ValueError(f"{output}: incomplete or mismatched MeshPocket GUI/font notice")
|
||||
return output
|
||||
|
||||
|
||||
def collect_build_notice(directory, stem):
|
||||
evidence = pocket_gui_evidence(Path(directory) / "firmware.elf")
|
||||
record = manifest_record(stem)
|
||||
if bool(evidence) != bool(record):
|
||||
raise ValueError("MeshPocket GUI/font notice declaration does not match the linked ELF")
|
||||
if not evidence:
|
||||
return validate_artifact_notice(stem)
|
||||
data = notice_bytes()
|
||||
if record != notice_record(stem, data):
|
||||
raise ValueError("MeshPocket GUI/font notice declaration does not match the source notice")
|
||||
output = sidecar(stem)
|
||||
if not output.exists():
|
||||
temporary = output.with_name(f".{output.name}.{os.getpid()}.tmp")
|
||||
try:
|
||||
temporary.write_bytes(data)
|
||||
temporary.replace(output)
|
||||
finally:
|
||||
temporary.unlink(missing_ok=True)
|
||||
return validate_artifact_notice(stem)
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("action", choices=("collect", "validate"))
|
||||
parser.add_argument("path", type=Path)
|
||||
parser.add_argument("--stem", type=Path)
|
||||
args = parser.parse_args()
|
||||
try:
|
||||
if args.action == "collect":
|
||||
if args.stem is None:
|
||||
parser.error("collect requires --stem")
|
||||
collect_build_notice(args.path, args.stem)
|
||||
else:
|
||||
validate_artifact_notice(args.path)
|
||||
except (OSError, ValueError, KeyError, TypeError) as error:
|
||||
parser.exit(1, f"MeshPocket GUI/font notice qualification failed: {error}\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in new issue
Block a user