Format changes from trunk

This commit is contained in:
Jim Whitelaw 2024-03-14 10:26:07 -06:00
parent 5f47ca1f32
commit 436e631774
28 changed files with 267 additions and 197 deletions

View File

@ -1,6 +1,6 @@
version: 0.1 version: 0.1
cli: cli:
version: 1.20.1 version: 1.21.0
plugins: plugins:
sources: sources:
- id: trunk - id: trunk
@ -8,15 +8,15 @@ plugins:
uri: https://github.com/trunk-io/plugins uri: https://github.com/trunk-io/plugins
lint: lint:
enabled: enabled:
- trufflehog@3.68.5 - trufflehog@3.69.0
- yamllint@1.35.1 - yamllint@1.35.1
- bandit@1.7.7 - bandit@1.7.8
- checkov@3.2.32 - checkov@3.2.38
- terrascan@1.19.1 - terrascan@1.19.1
- trivy@0.49.1 - trivy@0.49.1
#- trufflehog@3.63.2-rc0 #- trufflehog@3.63.2-rc0
- taplo@0.8.1 - taplo@0.8.1
- ruff@0.3.1 - ruff@0.3.2
- isort@5.13.2 - isort@5.13.2
- markdownlint@0.39.0 - markdownlint@0.39.0
- oxipng@9.0.0 - oxipng@9.0.0
@ -25,7 +25,7 @@ lint:
- flake8@7.0.0 - flake8@7.0.0
- hadolint@2.12.0 - hadolint@2.12.0
- shfmt@3.6.0 - shfmt@3.6.0
- shellcheck@0.9.0 - shellcheck@0.10.0
- black@24.2.0 - black@24.2.0
- git-diff-check - git-diff-check
- gitleaks@8.18.2 - gitleaks@8.18.2

View File

@ -2,8 +2,9 @@
// See http://go.microsoft.com/fwlink/?LinkId=827846 // See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format // for the documentation about the extensions.json format
"recommendations": [ "recommendations": [
"ms-vscode.cpptools", "platformio.platformio-ide"
"platformio.platformio-ide",
"trunk.io"
], ],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
} }

View File

@ -2,8 +2,8 @@
set -e set -e
VERSION=`bin/buildinfo.py long` VERSION=$(bin/buildinfo.py long)
SHORT_VERSION=`bin/buildinfo.py short` SHORT_VERSION=$(bin/buildinfo.py short)
OUTDIR=release/ OUTDIR=release/

View File

@ -2,8 +2,8 @@
set -e set -e
VERSION=`bin/buildinfo.py long` VERSION=$(bin/buildinfo.py long)
SHORT_VERSION=`bin/buildinfo.py short` SHORT_VERSION=$(bin/buildinfo.py short)
OUTDIR=release/ OUTDIR=release/

View File

@ -2,8 +2,8 @@
set -e set -e
VERSION=`bin/buildinfo.py long` VERSION=$(bin/buildinfo.py long)
SHORT_VERSION=`bin/buildinfo.py short` SHORT_VERSION=$(bin/buildinfo.py short)
OUTDIR=release/ OUTDIR=release/

View File

@ -1,9 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import configparser import configparser
import sys import sys
from readprops import readProps from readprops import readProps
verObj = readProps("version.properties")
verObj = readProps('version.properties')
propName = sys.argv[1] propName = sys.argv[1]
print(f"{verObj[propName]}") print(f"{verObj[propName]}")

View File

@ -3,14 +3,14 @@
lines = None lines = None
with open('version.properties', 'r', encoding='utf-8') as f: with open("version.properties", "r", encoding="utf-8") as f:
lines = f.readlines() lines = f.readlines()
with open('version.properties', 'w', encoding='utf-8') as f: with open("version.properties", "w", encoding="utf-8") as f:
for line in lines: for line in lines:
if line.lstrip().startswith("build = "): if line.lstrip().startswith("build = "):
words = line.split(" = ") words = line.split(" = ")
ver = f'build = {int(words[1]) + 1}' ver = f"build = {int(words[1]) + 1}"
f.write(f'{ver}\n') f.write(f"{ver}\n")
else: else:
f.write(line) f.write(line)

View File

@ -1,10 +1,10 @@
#!/bin/sh #!/bin/sh
PYTHON=${PYTHON:-$(which python3 python|head -n 1)} PYTHON=${PYTHON:-$(which python3 python | head -n 1)}
# Usage info # Usage info
show_help() { show_help() {
cat << EOF cat <<EOF
Usage: $(basename $0) [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME|FILENAME] Usage: $(basename $0) [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME|FILENAME]
Flash image file to device, leave existing system intact." Flash image file to device, leave existing system intact."
@ -16,18 +16,20 @@ Flash image file to device, leave existing system intact."
EOF EOF
} }
while getopts ":hp:P:f:" opt; do while getopts ":hp:P:f:" opt; do
case "${opt}" in case "${opt}" in
h) h)
show_help show_help
exit 0 exit 0
;; ;;
p) export ESPTOOL_PORT=${OPTARG} p)
export ESPTOOL_PORT=${OPTARG}
;; ;;
P) PYTHON=${OPTARG} P)
PYTHON=${OPTARG}
;; ;;
f) FILENAME=${OPTARG} f)
FILENAME=${OPTARG}
;; ;;
*) *)
echo "Invalid flag." echo "Invalid flag."
@ -36,7 +38,7 @@ while getopts ":hp:P:f:" opt; do
;; ;;
esac esac
done done
shift "$((OPTIND-1))" shift "$((OPTIND - 1))"
[ -z "$FILENAME" -a -n "$1" ] && { [ -z "$FILENAME" -a -n "$1" ] && {
FILENAME=$1 FILENAME=$1

View File

@ -10,7 +10,9 @@
start = 0x9000 start = 0x9000
nvssys = 0x3000 nvssys = 0x3000
nvsuser = 0x2000 # NOTE: ti seems total size of nvssys MUST be 0x5000 or device will bootloop nvsuser = (
0x2000 # NOTE: ti seems total size of nvssys MUST be 0x5000 or device will bootloop
)
nvs = nvssys + nvsuser nvs = nvssys + nvsuser
ota = 0x2000 ota = 0x2000
# app = 0x1c0000 # app = 0x1c0000
@ -36,6 +38,8 @@ nvs, data, nvs, 0x{start:x}, 0x{nvs:x},
otadata, data, ota, , 0x{ota:x}, otadata, data, ota, , 0x{ota:x},
app0, app, ota_0, , 0x{app:x}, app0, app, ota_0, , 0x{app:x},
app1, app, ota_1, , 0x{app:x}, app1, app, ota_1, , 0x{app:x},
spiffs, data, spiffs, , 0x{spi:x} """.format(**locals()) spiffs, data, spiffs, , 0x{spi:x} """.format(
**locals()
)
print(table) print(table)

View File

@ -1,13 +1,15 @@
import subprocess
import configparser import configparser
import traceback import subprocess
import sys import sys
import traceback
from os.path import join from os.path import join
from readprops import readProps from readprops import readProps
Import("env") Import("env")
platform = env.PioPlatform() platform = env.PioPlatform()
def esp32_create_combined_bin(source, target, env): def esp32_create_combined_bin(source, target, env):
# this sub is borrowed from ESPEasy build toolchain. It's licensed under GPL V3 # this sub is borrowed from ESPEasy build toolchain. It's licensed under GPL V3
# https://github.com/letscontrolit/ESPEasy/blob/mega/tools/pio/post_esp32.py # https://github.com/letscontrolit/ESPEasy/blob/mega/tools/pio/post_esp32.py
@ -20,8 +22,8 @@ def esp32_create_combined_bin(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin") firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
chip = env.get("BOARD_MCU") chip = env.get("BOARD_MCU")
flash_size = env.BoardConfig().get("upload.flash_size") flash_size = env.BoardConfig().get("upload.flash_size")
flash_freq = env.BoardConfig().get("build.f_flash", '40m') flash_freq = env.BoardConfig().get("build.f_flash", "40m")
flash_freq = flash_freq.replace('000000L', 'm') flash_freq = flash_freq.replace("000000L", "m")
flash_mode = env.BoardConfig().get("build.flash_mode", "dio") flash_mode = env.BoardConfig().get("build.flash_mode", "dio")
memory_type = env.BoardConfig().get("build.arduino.memory_type", "qio_qspi") memory_type = env.BoardConfig().get("build.arduino.memory_type", "qio_qspi")
if flash_mode == "qio" or flash_mode == "qout": if flash_mode == "qio" or flash_mode == "qout":
@ -51,23 +53,27 @@ def esp32_create_combined_bin(source, target, env):
print(f" - {hex(app_offset)} | {firmware_name}") print(f" - {hex(app_offset)} | {firmware_name}")
cmd += [hex(app_offset), firmware_name] cmd += [hex(app_offset), firmware_name]
print('Using esptool.py arguments: %s' % ' '.join(cmd)) print("Using esptool.py arguments: %s" % " ".join(cmd))
esptool.main(cmd) esptool.main(cmd)
if (platform.name == "espressif32"):
if platform.name == "espressif32":
sys.path.append(join(platform.get_package_dir("tool-esptoolpy"))) sys.path.append(join(platform.get_package_dir("tool-esptoolpy")))
import esptool import esptool
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin) env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin)
Import("projenv") Import("projenv")
prefsLoc = projenv["PROJECT_DIR"] + "/version.properties" prefsLoc = projenv["PROJECT_DIR"] + "/version.properties"
verObj = readProps(prefsLoc) verObj = readProps(prefsLoc)
print("Using meshtastic platformio-custom.py, firmware version " + verObj['long']) print("Using meshtastic platformio-custom.py, firmware version " + verObj["long"])
# General options that are passed to the C and C++ compilers # General options that are passed to the C and C++ compilers
projenv.Append(CCFLAGS=[ projenv.Append(
"-DAPP_VERSION=" + verObj['long'], CCFLAGS=[
"-DAPP_VERSION_SHORT=" + verObj['short'] "-DAPP_VERSION=" + verObj["long"],
]) "-DAPP_VERSION_SHORT=" + verObj["short"],
]
)

View File

@ -4,7 +4,7 @@ set -e
echo "This script is only for developers who are publishing new builds on github. Most users don't need it" echo "This script is only for developers who are publishing new builds on github. Most users don't need it"
VERSION=`bin/buildinfo.py long` VERSION=$(bin/buildinfo.py long)
# Must have a V prefix to trigger github # Must have a V prefix to trigger github
git tag "v${VERSION}" git tag "v${VERSION}"

View File

@ -1,9 +1,7 @@
import subprocess
import configparser import configparser
import traceback import subprocess
import sys import sys
import traceback
def readProps(prefsLoc): def readProps(prefsLoc):
@ -11,27 +9,36 @@ def readProps(prefsLoc):
config = configparser.RawConfigParser() config = configparser.RawConfigParser()
config.read(prefsLoc) config.read(prefsLoc)
version = dict(config.items('VERSION')) version = dict(config.items("VERSION"))
verObj = dict(short = "{}.{}.{}".format(version["major"], version["minor"], version["build"]), verObj = dict(
long = "unset") short="{}.{}.{}".format(version["major"], version["minor"], version["build"]),
long="unset",
)
# Try to find current build SHA if if the workspace is clean. This could fail if git is not installed # Try to find current build SHA if if the workspace is clean. This could fail if git is not installed
try: try:
sha = subprocess.check_output( sha = (
['git', 'rev-parse', '--short', 'HEAD']).decode("utf-8").strip() subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
isDirty = subprocess.check_output( .decode("utf-8")
['git', 'diff', 'HEAD']).decode("utf-8").strip() .strip()
)
isDirty = (
subprocess.check_output(["git", "diff", "HEAD"]).decode("utf-8").strip()
)
suffix = sha suffix = sha
# if isDirty: # if isDirty:
# # short for 'dirty', we want to keep our verstrings source for protobuf reasons # # short for 'dirty', we want to keep our verstrings source for protobuf reasons
# suffix = sha + "-d" # suffix = sha + "-d"
verObj['long'] = "{}.{}.{}.{}".format( verObj["long"] = "{}.{}.{}.{}".format(
version["major"], version["minor"], version["build"], suffix) version["major"], version["minor"], version["build"], suffix
)
except: except:
# print("Unexpected error:", sys.exc_info()[0]) # print("Unexpected error:", sys.exc_info()[0])
# traceback.print_exc() # traceback.print_exc()
verObj['long'] = verObj['short'] verObj["long"] = verObj["short"]
# print("firmware version " + verStr) # print("firmware version " + verStr)
return verObj return verObj
# print("path is" + ','.join(sys.path)) # print("path is" + ','.join(sys.path))

View File

@ -8,4 +8,3 @@ sleep 20 # 5 seconds was not enough
echo "Simulator started, launching python test..." echo "Simulator started, launching python test..."
python3 -c 'from meshtastic.test import testSimulator; testSimulator()' python3 -c 'from meshtastic.test import testSimulator; testSimulator()'

View File

@ -1,39 +1,38 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import sys import argparse
import struct
import subprocess
import re
import os import os
import os.path import os.path
import argparse import re
import struct
import subprocess
import sys
UF2_MAGIC_START0 = 0x0A324655 # "UF2\n" UF2_MAGIC_START0 = 0x0A324655 # "UF2\n"
UF2_MAGIC_START1 = 0x9E5D5157 # Randomly selected UF2_MAGIC_START1 = 0x9E5D5157 # Randomly selected
UF2_MAGIC_END = 0x0AB16F30 # Ditto UF2_MAGIC_END = 0x0AB16F30 # Ditto
families = { families = {
'SAMD21': 0x68ed2b88, "SAMD21": 0x68ED2B88,
'SAML21': 0x1851780a, "SAML21": 0x1851780A,
'SAMD51': 0x55114460, "SAMD51": 0x55114460,
'NRF52': 0x1b57745f, "NRF52": 0x1B57745F,
'STM32F0': 0x647824b6, "STM32F0": 0x647824B6,
'STM32F1': 0x5ee21072, "STM32F1": 0x5EE21072,
'STM32F2': 0x5d1a0a2e, "STM32F2": 0x5D1A0A2E,
'STM32F3': 0x6b846188, "STM32F3": 0x6B846188,
'STM32F4': 0x57755a57, "STM32F4": 0x57755A57,
'STM32F7': 0x53b80f00, "STM32F7": 0x53B80F00,
'STM32G0': 0x300f5633, "STM32G0": 0x300F5633,
'STM32G4': 0x4c71240a, "STM32G4": 0x4C71240A,
'STM32H7': 0x6db66082, "STM32H7": 0x6DB66082,
'STM32L0': 0x202e3a91, "STM32L0": 0x202E3A91,
'STM32L1': 0x1e1f432d, "STM32L1": 0x1E1F432D,
'STM32L4': 0x00ff6919, "STM32L4": 0x00FF6919,
'STM32L5': 0x04240bdf, "STM32L5": 0x04240BDF,
'STM32WB': 0x70d16653, "STM32WB": 0x70D16653,
'STM32WL': 0x21460ff0, "STM32WL": 0x21460FF0,
'ATMEGA32': 0x16573617, "ATMEGA32": 0x16573617,
'MIMXRT10XX': 0x4FB2D5BD "MIMXRT10XX": 0x4FB2D5BD,
} }
INFO_FILE = "/INFO_UF2.TXT" INFO_FILE = "/INFO_UF2.TXT"
@ -46,15 +45,17 @@ def is_uf2(buf):
w = struct.unpack("<II", buf[0:8]) w = struct.unpack("<II", buf[0:8])
return w[0] == UF2_MAGIC_START0 and w[1] == UF2_MAGIC_START1 return w[0] == UF2_MAGIC_START0 and w[1] == UF2_MAGIC_START1
def is_hex(buf): def is_hex(buf):
try: try:
w = buf[0:30].decode("utf-8") w = buf[0:30].decode("utf-8")
except UnicodeDecodeError: except UnicodeDecodeError:
return False return False
if w[0] == ':' and re.match(b"^[:0-9a-fA-F\r\n]+$", buf): if w[0] == ":" and re.match(b"^[:0-9a-fA-F\r\n]+$", buf):
return True return True
return False return False
def convert_from_uf2(buf): def convert_from_uf2(buf):
global appstartaddr global appstartaddr
numblocks = len(buf) // 512 numblocks = len(buf) // 512
@ -62,7 +63,7 @@ def convert_from_uf2(buf):
outp = b"" outp = b""
for blockno in range(numblocks): for blockno in range(numblocks):
ptr = blockno * 512 ptr = blockno * 512
block = buf[ptr:ptr + 512] block = buf[ptr : ptr + 512]
hd = struct.unpack(b"<IIIIIIII", block[0:32]) hd = struct.unpack(b"<IIIIIIII", block[0:32])
if hd[0] != UF2_MAGIC_START0 or hd[1] != UF2_MAGIC_START1: if hd[0] != UF2_MAGIC_START0 or hd[1] != UF2_MAGIC_START1:
print("Skipping block at " + ptr + "; bad magic") print("Skipping block at " + ptr + "; bad magic")
@ -80,7 +81,7 @@ def convert_from_uf2(buf):
padding = newaddr - curraddr padding = newaddr - curraddr
if padding < 0: if padding < 0:
assert False, "Block out of order at " + ptr assert False, "Block out of order at " + ptr
if padding > 10*1024*1024: if padding > 10 * 1024 * 1024:
assert False, "More than 10M of padding needed at " + ptr assert False, "More than 10M of padding needed at " + ptr
if padding % 4 != 0: if padding % 4 != 0:
assert False, "Non-word padding size at " + ptr assert False, "Non-word padding size at " + ptr
@ -91,6 +92,7 @@ def convert_from_uf2(buf):
curraddr = newaddr + datalen curraddr = newaddr + datalen
return outp return outp
def convert_to_carray(file_content): def convert_to_carray(file_content):
outp = "const unsigned char bindata[] __attribute__((aligned(16))) = {" outp = "const unsigned char bindata[] __attribute__((aligned(16))) = {"
for i in range(len(file_content)): for i in range(len(file_content)):
@ -100,6 +102,7 @@ def convert_to_carray(file_content):
outp += "\n};\n" outp += "\n};\n"
return outp return outp
def convert_to_uf2(file_content): def convert_to_uf2(file_content):
global familyid global familyid
datapadding = b"" datapadding = b""
@ -109,13 +112,21 @@ def convert_to_uf2(file_content):
outp = b"" outp = b""
for blockno in range(numblocks): for blockno in range(numblocks):
ptr = 256 * blockno ptr = 256 * blockno
chunk = file_content[ptr:ptr + 256] chunk = file_content[ptr : ptr + 256]
flags = 0x0 flags = 0x0
if familyid: if familyid:
flags |= 0x2000 flags |= 0x2000
hd = struct.pack(b"<IIIIIIII", hd = struct.pack(
UF2_MAGIC_START0, UF2_MAGIC_START1, b"<IIIIIIII",
flags, ptr + appstartaddr, 256, blockno, numblocks, familyid) UF2_MAGIC_START0,
UF2_MAGIC_START1,
flags,
ptr + appstartaddr,
256,
blockno,
numblocks,
familyid,
)
while len(chunk) < 256: while len(chunk) < 256:
chunk += b"\x00" chunk += b"\x00"
block = hd + chunk + datapadding + struct.pack(b"<I", UF2_MAGIC_END) block = hd + chunk + datapadding + struct.pack(b"<I", UF2_MAGIC_END)
@ -123,6 +134,7 @@ def convert_to_uf2(file_content):
outp += block outp += block
return outp return outp
class Block: class Block:
def __init__(self, addr): def __init__(self, addr):
self.addr = addr self.addr = addr
@ -133,35 +145,44 @@ class Block:
flags = 0x0 flags = 0x0
if familyid: if familyid:
flags |= 0x2000 flags |= 0x2000
hd = struct.pack("<IIIIIIII", hd = struct.pack(
UF2_MAGIC_START0, UF2_MAGIC_START1, "<IIIIIIII",
flags, self.addr, 256, blockno, numblocks, familyid) UF2_MAGIC_START0,
UF2_MAGIC_START1,
flags,
self.addr,
256,
blockno,
numblocks,
familyid,
)
hd += self.bytes[0:256] hd += self.bytes[0:256]
while len(hd) < 512 - 4: while len(hd) < 512 - 4:
hd += b"\x00" hd += b"\x00"
hd += struct.pack("<I", UF2_MAGIC_END) hd += struct.pack("<I", UF2_MAGIC_END)
return hd return hd
def convert_from_hex_to_uf2(buf): def convert_from_hex_to_uf2(buf):
global appstartaddr global appstartaddr
appstartaddr = None appstartaddr = None
upper = 0 upper = 0
currblock = None currblock = None
blocks = [] blocks = []
for line in buf.split('\n'): for line in buf.split("\n"):
if line[0] != ":": if line[0] != ":":
continue continue
i = 1 i = 1
rec = [] rec = []
while i < len(line) - 1: while i < len(line) - 1:
rec.append(int(line[i:i+2], 16)) rec.append(int(line[i : i + 2], 16))
i += 2 i += 2
tp = rec[3] tp = rec[3]
if tp == 4: if tp == 4:
upper = ((rec[4] << 8) | rec[5]) << 16 upper = ((rec[4] << 8) | rec[5]) << 16
elif tp == 2: elif tp == 2:
upper = ((rec[4] << 8) | rec[5]) << 4 upper = ((rec[4] << 8) | rec[5]) << 4
assert (upper & 0xffff) == 0 assert (upper & 0xFFFF) == 0
elif tp == 1: elif tp == 1:
break break
elif tp == 0: elif tp == 0:
@ -170,10 +191,10 @@ def convert_from_hex_to_uf2(buf):
appstartaddr = addr appstartaddr = addr
i = 4 i = 4
while i < len(rec) - 1: while i < len(rec) - 1:
if not currblock or currblock.addr & ~0xff != addr & ~0xff: if not currblock or currblock.addr & ~0xFF != addr & ~0xFF:
currblock = Block(addr & ~0xff) currblock = Block(addr & ~0xFF)
blocks.append(currblock) blocks.append(currblock)
currblock.bytes[addr & 0xff] = rec[i] currblock.bytes[addr & 0xFF] = rec[i]
addr += 1 addr += 1
i += 1 i += 1
numblocks = len(blocks) numblocks = len(blocks)
@ -182,17 +203,28 @@ def convert_from_hex_to_uf2(buf):
resfile += blocks[i].encode(i, numblocks) resfile += blocks[i].encode(i, numblocks)
return resfile return resfile
def to_str(b): def to_str(b):
return b.decode("utf-8") return b.decode("utf-8")
def get_drives(): def get_drives():
drives = [] drives = []
if sys.platform == "win32": if sys.platform == "win32":
r = subprocess.check_output(["wmic", "PATH", "Win32_LogicalDisk", r = subprocess.check_output(
"get", "DeviceID,", "VolumeName,", [
"FileSystem,", "DriveType"]) "wmic",
for line in to_str(r).split('\n'): "PATH",
words = re.split('\s+', line) "Win32_LogicalDisk",
"get",
"DeviceID,",
"VolumeName,",
"FileSystem,",
"DriveType",
]
)
for line in to_str(r).split("\n"):
words = re.split("\s+", line)
if len(words) >= 3 and words[1] == "2" and words[2] == "FAT": if len(words) >= 3 and words[1] == "2" and words[2] == "FAT":
drives.append(words[0]) drives.append(words[0])
else: else:
@ -206,7 +238,6 @@ def get_drives():
for d in os.listdir(rootpath): for d in os.listdir(rootpath):
drives.append(os.path.join(rootpath, d)) drives.append(os.path.join(rootpath, d))
def has_info(d): def has_info(d):
try: try:
return os.path.isfile(d + INFO_FILE) return os.path.isfile(d + INFO_FILE)
@ -217,7 +248,7 @@ def get_drives():
def board_id(path): def board_id(path):
with open(path + INFO_FILE, mode='r') as file: with open(path + INFO_FILE, mode="r") as file:
file_content = file.read() file_content = file.read()
return re.search("Board-ID: ([^\r\n]*)", file_content).group(1) return re.search("Board-ID: ([^\r\n]*)", file_content).group(1)
@ -235,30 +266,61 @@ def write_file(name, buf):
def main(): def main():
global appstartaddr, familyid global appstartaddr, familyid
def error(msg): def error(msg):
print(msg) print(msg)
sys.exit(1) sys.exit(1)
parser = argparse.ArgumentParser(description='Convert to UF2 or flash directly.')
parser.add_argument('input', metavar='INPUT', type=str, nargs='?', parser = argparse.ArgumentParser(description="Convert to UF2 or flash directly.")
help='input file (HEX, BIN or UF2)') parser.add_argument(
parser.add_argument('-b' , '--base', dest='base', type=str, "input",
metavar="INPUT",
type=str,
nargs="?",
help="input file (HEX, BIN or UF2)",
)
parser.add_argument(
"-b",
"--base",
dest="base",
type=str,
default="0x2000", default="0x2000",
help='set base address of application for BIN format (default: 0x2000)') help="set base address of application for BIN format (default: 0x2000)",
parser.add_argument('-o' , '--output', metavar="FILE", dest='output', type=str, )
help='write output to named file; defaults to "flash.uf2" or "flash.bin" where sensible') parser.add_argument(
parser.add_argument('-d' , '--device', dest="device_path", "-o",
help='select a device path to flash') "--output",
parser.add_argument('-l' , '--list', action='store_true', metavar="FILE",
help='list connected devices') dest="output",
parser.add_argument('-c' , '--convert', action='store_true', type=str,
help='do not flash, just convert') help='write output to named file; defaults to "flash.uf2" or "flash.bin" where sensible',
parser.add_argument('-D' , '--deploy', action='store_true', )
help='just flash, do not convert') parser.add_argument(
parser.add_argument('-f' , '--family', dest='family', type=str, "-d", "--device", dest="device_path", help="select a device path to flash"
)
parser.add_argument(
"-l", "--list", action="store_true", help="list connected devices"
)
parser.add_argument(
"-c", "--convert", action="store_true", help="do not flash, just convert"
)
parser.add_argument(
"-D", "--deploy", action="store_true", help="just flash, do not convert"
)
parser.add_argument(
"-f",
"--family",
dest="family",
type=str,
default="0x0", default="0x0",
help='specify familyID - number or name (default: 0x0)') help="specify familyID - number or name (default: 0x0)",
parser.add_argument('-C' , '--carray', action='store_true', )
help='convert binary file to a C array, not UF2') parser.add_argument(
"-C",
"--carray",
action="store_true",
help="convert binary file to a C array, not UF2",
)
args = parser.parse_args() args = parser.parse_args()
appstartaddr = int(args.base, 0) appstartaddr = int(args.base, 0)
@ -268,14 +330,17 @@ def main():
try: try:
familyid = int(args.family, 0) familyid = int(args.family, 0)
except ValueError: except ValueError:
error("Family ID needs to be a number or one of: " + ", ".join(families.keys())) error(
"Family ID needs to be a number or one of: "
+ ", ".join(families.keys())
)
if args.list: if args.list:
list_drives() list_drives()
else: else:
if not args.input: if not args.input:
error("Need input file") error("Need input file")
with open(args.input, mode='rb') as f: with open(args.input, mode="rb") as f:
inpbuf = f.read() inpbuf = f.read()
from_uf2 = is_uf2(inpbuf) from_uf2 = is_uf2(inpbuf)
ext = "uf2" ext = "uf2"
@ -291,8 +356,10 @@ def main():
ext = "h" ext = "h"
else: else:
outbuf = convert_to_uf2(inpbuf) outbuf = convert_to_uf2(inpbuf)
print("Converting to %s, output size: %d, start address: 0x%x" % print(
(ext, len(outbuf), appstartaddr)) "Converting to %s, output size: %d, start address: 0x%x"
% (ext, len(outbuf), appstartaddr)
)
if args.convert or ext != "uf2": if args.convert or ext != "uf2":
drives = [] drives = []
if args.output == None: if args.output == None:

Binary file not shown.

Before

Width:  |  Height:  |  Size: 845 B

After

Width:  |  Height:  |  Size: 594 B

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M9 11.75c-.69 0-1.25.56-1.25 1.25s.56 1.25 1.25 1.25 1.25-.56 1.25-1.25-.56-1.25-1.25-1.25zm6 0c-.69 0-1.25.56-1.25 1.25s.56 1.25 1.25 1.25 1.25-.56 1.25-1.25-.56-1.25-1.25-1.25zM12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8 0-.29.02-.58.05-.86 2.36-1.05 4.23-2.98 5.21-5.37C11.07 8.33 14.05 10 17.42 10c.78 0 1.53-.09 2.25-.26.21.71.33 1.47.33 2.26 0 4.41-3.59 8-8 8z"/><path d="M0 0h24v24H0z" fill="none"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M9 11.75a1.25 1.25 0 1 0 0 2.5 1.25 1.25 0 0 0 0-2.5m6 0a1.25 1.25 0 1 0 0 2.5 1.25 1.25 0 0 0 0-2.5M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8 0-.29.02-.58.05-.86 2.36-1.05 4.23-2.98 5.21-5.37a9.97 9.97 0 0 0 10.41 3.97c.21.71.33 1.47.33 2.26 0 4.41-3.59 8-8 8"/><path fill="none" d="M0 0h24v24H0z"/></svg>

Before

Width:  |  Height:  |  Size: 550 B

After

Width:  |  Height:  |  Size: 445 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 B

After

Width:  |  Height:  |  Size: 225 B

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M0 0h24v24H0z" fill="none"/><path d="M20.94 11c-.46-4.17-3.77-7.48-7.94-7.94V1h-2v2.06C6.83 3.52 3.52 6.83 3.06 11H1v2h2.06c.46 4.17 3.77 7.48 7.94 7.94V23h2v-2.06c4.17-.46 7.48-3.77 7.94-7.94H23v-2h-2.06zM12 19c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M20.94 11A8.994 8.994 0 0 0 13 3.06V1h-2v2.06A8.994 8.994 0 0 0 3.06 11H1v2h2.06A8.994 8.994 0 0 0 11 20.94V23h2v-2.06A8.994 8.994 0 0 0 20.94 13H23v-2zM12 19c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7"/></svg>

Before

Width:  |  Height:  |  Size: 365 B

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 288 B

After

Width:  |  Height:  |  Size: 203 B

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"/><path d="M0 0h24v24H0z" fill="none"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7m0 9.5a2.5 2.5 0 0 1 0-5 2.5 2.5 0 0 1 0 5"/><path fill="none" d="M0 0h24v24H0z"/></svg>

Before

Width:  |  Height:  |  Size: 292 B

After

Width:  |  Height:  |  Size: 250 B

View File

@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24"><path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zM9 11H7V9h2v2zm4 0h-2V9h2v2zm4 0h-2V9h2v2z"/><path d="M0 0h24v24H0z" fill="none"/></svg> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path d="M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2M9 11H7V9h2zm4 0h-2V9h2zm4 0h-2V9h2z"/><path fill="none" d="M0 0h24v24H0z"/></svg>

Before

Width:  |  Height:  |  Size: 253 B

After

Width:  |  Height:  |  Size: 246 B

View File

@ -18,10 +18,7 @@ import subprocess
import sys import sys
from platformio.project.exception import PlatformioException from platformio.project.exception import PlatformioException
from platformio.public import ( from platformio.public import DeviceMonitorFilterBase, load_build_metadata
DeviceMonitorFilterBase,
load_build_metadata,
)
# By design, __init__ is called inside miniterm and we can't pass context to it. # By design, __init__ is called inside miniterm and we can't pass context to it.
# pylint: disable=attribute-defined-outside-init # pylint: disable=attribute-defined-outside-init
@ -32,7 +29,7 @@ IS_WINDOWS = sys.platform.startswith("win")
class Esp32C3ExceptionDecoder(DeviceMonitorFilterBase): class Esp32C3ExceptionDecoder(DeviceMonitorFilterBase):
NAME = "esp32_c3_exception_decoder" NAME = "esp32_c3_exception_decoder"
PCADDR_PATTERN = re.compile(r'0x4[0-9a-f]{7}', re.IGNORECASE) PCADDR_PATTERN = re.compile(r"0x4[0-9a-f]{7}", re.IGNORECASE)
def __call__(self): def __call__(self):
self.buffer = "" self.buffer = ""
@ -117,7 +114,7 @@ See https://docs.platformio.org/page/projectconf/build_configurations.html
trace = self.get_backtrace(m) trace = self.get_backtrace(m)
if len(trace) != "": if len(trace) != "":
text = text[: last] + trace + text[last :] text = text[:last] + trace + text[last:]
last += len(trace) last += len(trace)
return text return text
@ -125,14 +122,10 @@ See https://docs.platformio.org/page/projectconf/build_configurations.html
def get_backtrace(self, match): def get_backtrace(self, match):
trace = "\n" trace = "\n"
enc = "mbcs" if IS_WINDOWS else "utf-8" enc = "mbcs" if IS_WINDOWS else "utf-8"
args = [self.addr2line_path, u"-fipC", u"-e", self.firmware_path] args = [self.addr2line_path, "-fipC", "-e", self.firmware_path]
try: try:
addr = match.group() addr = match.group()
output = ( output = subprocess.check_output(args + [addr]).decode(enc).strip()
subprocess.check_output(args + [addr])
.decode(enc)
.strip()
)
output = output.replace( output = output.replace(
"\n", "\n " "\n", "\n "
) # newlines happen with inlined methods ) # newlines happen with inlined methods

View File

@ -88,20 +88,11 @@ class GPSStatus : public Status
} }
} }
uint32_t getDOP() const uint32_t getDOP() const { return p.PDOP; }
{
return p.PDOP;
}
uint32_t getHeading() const uint32_t getHeading() const { return p.ground_track; }
{
return p.ground_track;
}
uint32_t getNumSatellites() const uint32_t getNumSatellites() const { return p.sats_in_view; }
{
return p.sats_in_view;
}
bool matches(const GPSStatus *newStatus) const bool matches(const GPSStatus *newStatus) const
{ {

View File

@ -251,8 +251,8 @@ template <typename T> void SX128xInterface<T>::startReceive()
#endif #endif
// We use the PREAMBLE_DETECTED and HEADER_VALID IRQ flag to detect whether we are actively receiving // We use the PREAMBLE_DETECTED and HEADER_VALID IRQ flag to detect whether we are actively receiving
int err = lora.startReceive(RADIOLIB_SX128X_RX_TIMEOUT_INF, RADIOLIB_SX128X_IRQ_RX_DEFAULT | int err =
RADIOLIB_SX128X_IRQ_PREAMBLE_DETECTED | lora.startReceive(RADIOLIB_SX128X_RX_TIMEOUT_INF, RADIOLIB_SX128X_IRQ_RX_DEFAULT | RADIOLIB_SX128X_IRQ_PREAMBLE_DETECTED |
RADIOLIB_SX128X_IRQ_HEADER_VALID); RADIOLIB_SX128X_IRQ_HEADER_VALID);
assert(err == RADIOLIB_ERR_NONE); assert(err == RADIOLIB_ERR_NONE);

View File

@ -156,8 +156,8 @@
3, 1, 3, 3, 3 \ 3, 1, 3, 3, 3 \
} }
//#define USX_HCODES_FAVOR_UMLAUT {0x00, 0x40, 0xE0, 0xC0, 0x80} // #define USX_HCODES_FAVOR_UMLAUT {0x00, 0x40, 0xE0, 0xC0, 0x80}
//#define USX_HCODE_LENS_FAVOR_UMLAUT {2, 2, 3, 3, 2} // #define USX_HCODE_LENS_FAVOR_UMLAUT {2, 2, 3, 3, 2}
/// Horizontal codes preset favouring umlaut letters /// Horizontal codes preset favouring umlaut letters
#define USX_HCODES_FAVOR_UMLAUT \ #define USX_HCODES_FAVOR_UMLAUT \

View File

@ -10,7 +10,7 @@
#define LED_PIN 13 // 13 red, 2 blue, 15 red #define LED_PIN 13 // 13 red, 2 blue, 15 red
//#define HAS_BUTTON 0 // #define HAS_BUTTON 0
#define BUTTON_PIN 0 #define BUTTON_PIN 0
#define BUTTON_NEED_PULLUP #define BUTTON_NEED_PULLUP
@ -42,5 +42,5 @@
#define ADC_MULTIPLIER VBAT_DIVIDER_COMP #define ADC_MULTIPLIER VBAT_DIVIDER_COMP
#define VBAT_RAW_TO_SCALED(x) (REAL_VBAT_MV_PER_LSB * x) #define VBAT_RAW_TO_SCALED(x) (REAL_VBAT_MV_PER_LSB * x)
//#define BATTERY_SENSE_SAMPLES 15 // Set the number of samples, It has an effect of increasing sensitivity. // #define BATTERY_SENSE_SAMPLES 15 // Set the number of samples, It has an effect of increasing sensitivity.
//#define ADC_MULTIPLIER 3.3 // #define ADC_MULTIPLIER 3.3