Skip to content

Commit

Permalink
Format changes from trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
jimwhitelaw committed Mar 14, 2024
1 parent 5f47ca1 commit 436e631
Show file tree
Hide file tree
Showing 28 changed files with 267 additions and 197 deletions.
12 changes: 6 additions & 6 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
version: 0.1
cli:
version: 1.20.1
version: 1.21.0
plugins:
sources:
- id: trunk
ref: v1.4.4
uri: https://github.com/trunk-io/plugins
lint:
enabled:
- trufflehog@3.68.5
- trufflehog@3.69.0
- [email protected]
- [email protected].7
- [email protected].32
- [email protected].8
- [email protected].38
- [email protected]
- [email protected]
#- [email protected]
- [email protected]
- [email protected].1
- [email protected].2
- [email protected]
- [email protected]
- [email protected]
Expand All @@ -25,7 +25,7 @@ lint:
- [email protected]
- [email protected]
- [email protected]
- shellcheck@0.9.0
- shellcheck@0.10.0
- [email protected]
- git-diff-check
- [email protected]
Expand Down
7 changes: 4 additions & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"ms-vscode.cpptools",
"platformio.platformio-ide",
"trunk.io"
"platformio.platformio-ide"
],
"unwantedRecommendations": [
"ms-vscode.cpptools-extension-pack"
]
}
6 changes: 3 additions & 3 deletions bin/build-esp32.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

set -e

VERSION=`bin/buildinfo.py long`
SHORT_VERSION=`bin/buildinfo.py short`
VERSION=$(bin/buildinfo.py long)
SHORT_VERSION=$(bin/buildinfo.py short)

OUTDIR=release/

rm -f $OUTDIR/firmware*
rm -r $OUTDIR/* || true

# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
platformio pkg update
platformio pkg update

echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS"
rm -f .pio/build/$1/firmware.*
Expand Down
6 changes: 3 additions & 3 deletions bin/build-nrf52.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

set -e

VERSION=`bin/buildinfo.py long`
SHORT_VERSION=`bin/buildinfo.py short`
VERSION=$(bin/buildinfo.py long)
SHORT_VERSION=$(bin/buildinfo.py short)

OUTDIR=release/

rm -f $OUTDIR/firmware*
rm -r $OUTDIR/* || true

# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
platformio pkg update
platformio pkg update

echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS"
rm -f .pio/build/$1/firmware.*
Expand Down
6 changes: 3 additions & 3 deletions bin/build-rpi2040.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

set -e

VERSION=`bin/buildinfo.py long`
SHORT_VERSION=`bin/buildinfo.py short`
VERSION=$(bin/buildinfo.py long)
SHORT_VERSION=$(bin/buildinfo.py short)

OUTDIR=release/

rm -f $OUTDIR/firmware*
rm -r $OUTDIR/* || true

# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
platformio pkg update
platformio pkg update

echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS"
rm -f .pio/build/$1/firmware.*
Expand Down
4 changes: 2 additions & 2 deletions bin/buildinfo.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env python3
import configparser
import sys
from readprops import readProps

from readprops import readProps

verObj = readProps('version.properties')
verObj = readProps("version.properties")
propName = sys.argv[1]
print(f"{verObj[propName]}")
8 changes: 4 additions & 4 deletions bin/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

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()

with open('version.properties', 'w', encoding='utf-8') as f:
with open("version.properties", "w", encoding="utf-8") as f:
for line in lines:
if line.lstrip().startswith("build = "):
words = line.split(" = ")
ver = f'build = {int(words[1]) + 1}'
f.write(f'{ver}\n')
ver = f"build = {int(words[1]) + 1}"
f.write(f"{ver}\n")
else:
f.write(line)
48 changes: 25 additions & 23 deletions bin/device-update.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/bin/sh

PYTHON=${PYTHON:-$(which python3 python|head -n 1)}
PYTHON=${PYTHON:-$(which python3 python | head -n 1)}

# Usage info
show_help() {
cat << EOF
cat <<EOF
Usage: $(basename $0) [-h] [-p ESPTOOL_PORT] [-P PYTHON] [-f FILENAME|FILENAME]
Flash image file to device, leave existing system intact."
Expand All @@ -16,31 +16,33 @@ Flash image file to device, leave existing system intact."
EOF
}


while getopts ":hp:P:f:" opt; do
case "${opt}" in
h)
show_help
exit 0
;;
p) export ESPTOOL_PORT=${OPTARG}
;;
P) PYTHON=${OPTARG}
;;
f) FILENAME=${OPTARG}
;;
*)
echo "Invalid flag."
show_help >&2
exit 1
;;
esac
case "${opt}" in
h)
show_help
exit 0
;;
p)
export ESPTOOL_PORT=${OPTARG}
;;
P)
PYTHON=${OPTARG}
;;
f)
FILENAME=${OPTARG}
;;
*)
echo "Invalid flag."
show_help >&2
exit 1
;;
esac
done
shift "$((OPTIND-1))"
shift "$((OPTIND - 1))"

[ -z "$FILENAME" -a -n "$1" ] && {
FILENAME=$1
shift
FILENAME=$1
shift
}

if [ -f "${FILENAME}" ] && [ -z "${FILENAME##*"update"*}" ]; then
Expand Down
2 changes: 1 addition & 1 deletion bin/dump-ram-users.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

arm-none-eabi-readelf -s -e .pio/build/nrf52dk/firmware.elf | head -80

nm -CSr --size-sort .pio/build/nrf52dk/firmware.elf | grep '^200'
nm -CSr --size-sort .pio/build/nrf52dk/firmware.elf | grep '^200'
2 changes: 1 addition & 1 deletion bin/gen-images.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

set -e
set -e

# regen the design bins first
cd design
Expand Down
10 changes: 7 additions & 3 deletions bin/genpartitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@

start = 0x9000
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
ota = 0x2000
# app = 0x1c0000
spi = 128 * 1024

# treat sys part sizes + spiffs size as reserved, then calculate what appsize can be
reserved = start + nvs + ota + spi
maxsize = 0x400000 # 4MB
maxsize = 0x400000 # 4MB

app = (maxsize - reserved) / 2

Expand All @@ -36,6 +38,8 @@
otadata, data, ota, , 0x{ota:x},
app0, app, ota_0, , 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)
30 changes: 18 additions & 12 deletions bin/platformio-custom.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import subprocess
import configparser
import traceback
import subprocess
import sys
import traceback
from os.path import join

from readprops import readProps

Import("env")
platform = env.PioPlatform()


def esp32_create_combined_bin(source, target, env):
# 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
Expand All @@ -20,8 +22,8 @@ def esp32_create_combined_bin(source, target, env):
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
chip = env.get("BOARD_MCU")
flash_size = env.BoardConfig().get("upload.flash_size")
flash_freq = env.BoardConfig().get("build.f_flash", '40m')
flash_freq = flash_freq.replace('000000L', 'm')
flash_freq = env.BoardConfig().get("build.f_flash", "40m")
flash_freq = flash_freq.replace("000000L", "m")
flash_mode = env.BoardConfig().get("build.flash_mode", "dio")
memory_type = env.BoardConfig().get("build.arduino.memory_type", "qio_qspi")
if flash_mode == "qio" or flash_mode == "qout":
Expand Down Expand Up @@ -51,23 +53,27 @@ def esp32_create_combined_bin(source, target, env):
print(f" - {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)

if (platform.name == "espressif32"):

if platform.name == "espressif32":
sys.path.append(join(platform.get_package_dir("tool-esptoolpy")))
import esptool
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin)

env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin)

Import("projenv")

prefsLoc = projenv["PROJECT_DIR"] + "/version.properties"
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
projenv.Append(CCFLAGS=[
"-DAPP_VERSION=" + verObj['long'],
"-DAPP_VERSION_SHORT=" + verObj['short']
])
projenv.Append(
CCFLAGS=[
"-DAPP_VERSION=" + verObj["long"],
"-DAPP_VERSION_SHORT=" + verObj["short"],
]
)
4 changes: 2 additions & 2 deletions bin/promote-release.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env bash

set -e
set -e

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
git tag "v${VERSION}"
Expand Down
35 changes: 21 additions & 14 deletions bin/readprops.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,44 @@


import subprocess
import configparser
import traceback
import subprocess
import sys
import traceback


def readProps(prefsLoc):
"""Read the version of our project as a string"""

config = configparser.RawConfigParser()
config.read(prefsLoc)
version = dict(config.items('VERSION'))
verObj = dict(short = "{}.{}.{}".format(version["major"], version["minor"], version["build"]),
long = "unset")
version = dict(config.items("VERSION"))
verObj = dict(
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:
sha = subprocess.check_output(
['git', 'rev-parse', '--short', 'HEAD']).decode("utf-8").strip()
isDirty = subprocess.check_output(
['git', 'diff', 'HEAD']).decode("utf-8").strip()
sha = (
subprocess.check_output(["git", "rev-parse", "--short", "HEAD"])
.decode("utf-8")
.strip()
)
isDirty = (
subprocess.check_output(["git", "diff", "HEAD"]).decode("utf-8").strip()
)
suffix = sha
# if isDirty:
# # short for 'dirty', we want to keep our verstrings source for protobuf reasons
# suffix = sha + "-d"
verObj['long'] = "{}.{}.{}.{}".format(
version["major"], version["minor"], version["build"], suffix)
verObj["long"] = "{}.{}.{}.{}".format(
version["major"], version["minor"], version["build"], suffix
)
except:
# print("Unexpected error:", sys.exc_info()[0])
# traceback.print_exc()
verObj['long'] = verObj['short']
verObj["long"] = verObj["short"]

# print("firmware version " + verStr)
return verObj


# print("path is" + ','.join(sys.path))
1 change: 0 additions & 1 deletion bin/test-simulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ sleep 20 # 5 seconds was not enough

echo "Simulator started, launching python test..."
python3 -c 'from meshtastic.test import testSimulator; testSimulator()'

Loading

0 comments on commit 436e631

Please sign in to comment.