NodeMaintenance, build_version.py: back to the original formatting
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
46d33bd2b0
commit
73c1a7beb2
3 files changed
+26
-47
No files matched your search
@@ -33,17 +33,17 @@ void NodeMaintenance::printBootDiag() {
|
|||||||
Serial.printf("boot: FIRMWARE_BUILD_EPOCH=%lu\n", (unsigned long) FIRMWARE_BUILD_EPOCH);
|
Serial.printf("boot: FIRMWARE_BUILD_EPOCH=%lu\n", (unsigned long) FIRMWARE_BUILD_EPOCH);
|
||||||
Serial.printf("boot: RESETREAS=0x%08lX%s%s%s%s%s\n", (unsigned long)rr,
|
Serial.printf("boot: RESETREAS=0x%08lX%s%s%s%s%s\n", (unsigned long)rr,
|
||||||
rr == 0 ? " (none set = power-on/brownout: power was removed)" : "",
|
rr == 0 ? " (none set = power-on/brownout: power was removed)" : "",
|
||||||
(rr & 0x01) ? " RESETPIN" : "", (rr & 0x02) ? " WATCHDOG" : "",
|
(rr & 0x01) ? " RESETPIN" : "",
|
||||||
(rr & 0x04) ? " SREQ(sw reset, e.g. `dfu`/`reboot`)" : "", (rr & 0x08) ? " LOCKUP(!)" : "");
|
(rr & 0x02) ? " WATCHDOG" : "",
|
||||||
|
(rr & 0x04) ? " SREQ(sw reset, e.g. `dfu`/`reboot`)" : "",
|
||||||
|
(rr & 0x08) ? " LOCKUP(!)" : "");
|
||||||
|
|
||||||
volatile uint32_t* hf = g_hardfault_record;
|
volatile uint32_t* hf = g_hardfault_record;
|
||||||
if (hf[0] == 0xFA010DEB) {
|
if (hf[0] == 0xFA010DEB) {
|
||||||
_hardfault[0] = hf[1];
|
_hardfault[0] = hf[1]; _hardfault[1] = hf[2]; _hardfault[2] = hf[3];
|
||||||
_hardfault[1] = hf[2];
|
|
||||||
_hardfault[2] = hf[3];
|
|
||||||
_hardfault_seen = true;
|
_hardfault_seen = true;
|
||||||
Serial.printf("!!! HARDFAULT before last reboot: PC=%08lX LR=%08lX PSR=%08lX\n", (unsigned long)hf[1],
|
Serial.printf("!!! HARDFAULT before last reboot: PC=%08lX LR=%08lX PSR=%08lX\n",
|
||||||
(unsigned long)hf[2], (unsigned long)hf[3]);
|
(unsigned long)hf[1], (unsigned long)hf[2], (unsigned long)hf[3]);
|
||||||
hf[0] = 0; // printed once; `get boot` keeps it until the next reset
|
hf[0] = 0; // printed once; `get boot` keeps it until the next reset
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -130,9 +130,9 @@ bool NodeMaintenance::silenceCommand(const char *command, char *reply) {
|
|||||||
if (_silence.minutes() == 0) {
|
if (_silence.minutes() == 0) {
|
||||||
strcpy(reply, "> off");
|
strcpy(reply, "> off");
|
||||||
} else {
|
} else {
|
||||||
sprintf(reply, "> %u min (now x%u), quiet %lu min, stage %u", (unsigned)_silence.minutes(),
|
sprintf(reply, "> %u min (now x%u), quiet %lu min, stage %u",
|
||||||
(unsigned)(1u << _silence.backoff()), (unsigned long)(_silence.quietMs(millis()) / 60000),
|
(unsigned) _silence.minutes(), (unsigned) (1u << _silence.backoff()),
|
||||||
(unsigned)_silence.stage());
|
(unsigned long) (_silence.quietMs(millis()) / 60000), (unsigned) _silence.stage());
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -214,12 +214,9 @@ void NodeMaintenance::dfuTick() {
|
|||||||
// from here, and it is exactly what detach() does on this chip.
|
// from here, and it is exactly what detach() does on this chip.
|
||||||
NRF_USBD->USBPULLUP = 0;
|
NRF_USBD->USBPULLUP = 0;
|
||||||
delay(150);
|
delay(150);
|
||||||
if (_dfu_mode == 1)
|
if (_dfu_mode == 1) enterSerialDfu();
|
||||||
enterSerialDfu();
|
else if (_dfu_mode == 2) enterOTADfu();
|
||||||
else if (_dfu_mode == 2)
|
else enterUf2Dfu();
|
||||||
enterOTADfu();
|
|
||||||
else
|
|
||||||
enterUf2Dfu();
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,8 +228,7 @@ bool NodeMaintenance::dfuCommand(uint32_t sender_timestamp, const char *command,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
const char* arg = (command[3] == ' ') ? &command[4] : "";
|
const char* arg = (command[3] == ' ') ? &command[4] : "";
|
||||||
while (*arg == ' ')
|
while (*arg == ' ') arg++;
|
||||||
arg++;
|
|
||||||
if (strcmp(arg, "serial") == 0) {
|
if (strcmp(arg, "serial") == 0) {
|
||||||
strcpy(reply, "OK - rebooting into serial DFU (CDC only, no drive)");
|
strcpy(reply, "OK - rebooting into serial DFU (CDC only, no drive)");
|
||||||
} else if (strcmp(arg, "ota") == 0) {
|
} else if (strcmp(arg, "ota") == 0) {
|
||||||
@@ -259,8 +255,8 @@ bool NodeMaintenance::handleCommand(uint32_t sender_timestamp, const char *comma
|
|||||||
#if defined(NRF52_PLATFORM)
|
#if defined(NRF52_PLATFORM)
|
||||||
if (_hardfault_seen) {
|
if (_hardfault_seen) {
|
||||||
sprintf(reply, "> RESETREAS=0x%08lX, HARDFAULT before it: PC=%08lX LR=%08lX PSR=%08lX",
|
sprintf(reply, "> RESETREAS=0x%08lX, HARDFAULT before it: PC=%08lX LR=%08lX PSR=%08lX",
|
||||||
(unsigned long)_reset_reason, (unsigned long)_hardfault[0], (unsigned long)_hardfault[1],
|
(unsigned long) _reset_reason, (unsigned long) _hardfault[0],
|
||||||
(unsigned long)_hardfault[2]);
|
(unsigned long) _hardfault[1], (unsigned long) _hardfault[2]);
|
||||||
} else {
|
} else {
|
||||||
sprintf(reply, "> RESETREAS=0x%08lX, no hardfault", (unsigned long) _reset_reason);
|
sprintf(reply, "> RESETREAS=0x%08lX, no hardfault", (unsigned long) _reset_reason);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,7 @@
|
|||||||
|
|
||||||
class NodeMaintenance {
|
class NodeMaintenance {
|
||||||
public:
|
public:
|
||||||
NodeMaintenance(mesh::MainBoard &board, RadioLibWrapper &radio)
|
NodeMaintenance(mesh::MainBoard& board, RadioLibWrapper& radio) : _board(board), _radio(radio), _fw(board) { }
|
||||||
: _board(board), _radio(radio), _fw(board) {}
|
|
||||||
|
|
||||||
// Prints (and latches for `get boot`) the reset reason and the hardfault record.
|
// Prints (and latches for `get boot`) the reset reason and the hardfault record.
|
||||||
// The record is cleared once read, so call it once, as early as Serial is up.
|
// The record is cleared once read, so call it once, as early as Serial is up.
|
||||||
|
|||||||
+9
-25
@@ -25,11 +25,8 @@ from datetime import datetime
|
|||||||
|
|
||||||
|
|
||||||
def git(cwd, *args):
|
def git(cwd, *args):
|
||||||
return (
|
return subprocess.check_output(("git",) + args, cwd=cwd,
|
||||||
subprocess.check_output(("git",) + args, cwd=cwd, stderr=subprocess.DEVNULL)
|
stderr=subprocess.DEVNULL).decode().strip()
|
||||||
.decode()
|
|
||||||
.strip()
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
cwd = env.subst("$PROJECT_DIR")
|
cwd = env.subst("$PROJECT_DIR")
|
||||||
@@ -47,18 +44,9 @@ cwd = env.subst("$PROJECT_DIR")
|
|||||||
# version string of the thing it was protecting.
|
# version string of the thing it was protecting.
|
||||||
base = "nover"
|
base = "nover"
|
||||||
try:
|
try:
|
||||||
tag = git(
|
tag = git(cwd, "describe", "--tags", "--abbrev=0",
|
||||||
cwd,
|
"--match", "*v[0-9]*", "--exclude", "*+tth*",
|
||||||
"describe",
|
"--exclude", "backup/*")
|
||||||
"--tags",
|
|
||||||
"--abbrev=0",
|
|
||||||
"--match",
|
|
||||||
"*v[0-9]*",
|
|
||||||
"--exclude",
|
|
||||||
"*+tth*",
|
|
||||||
"--exclude",
|
|
||||||
"backup/*",
|
|
||||||
)
|
|
||||||
# Cut at the 'v' that STARTS THE VERSION, not at the first 'v' in the tag:
|
# Cut at the 'v' that STARTS THE VERSION, not at the first 'v' in the tag:
|
||||||
# "room-server-v1.17.0" has one in "server", and find("v") turned the base
|
# "room-server-v1.17.0" has one in "server", and find("v") turned the base
|
||||||
# into "ver-v1.17.0". Every earlier upstream tag we saw (companion-, repeater-)
|
# into "ver-v1.17.0". Every earlier upstream tag we saw (companion-, repeater-)
|
||||||
@@ -93,10 +81,8 @@ marker = "-tth"
|
|||||||
room = VER_LIMIT - len(base) - len(marker) - len(dirty)
|
room = VER_LIMIT - len(base) - len(marker) - len(dirty)
|
||||||
version = "%s%s%s%s" % (base, marker, sha[:max(4, room)], dirty)
|
version = "%s%s%s%s" % (base, marker, sha[:max(4, room)], dirty)
|
||||||
if len(version) > VER_LIMIT:
|
if len(version) > VER_LIMIT:
|
||||||
print(
|
print("build_version.py: WARNING: %r is %d chars, will truncate to %d on "
|
||||||
"build_version.py: WARNING: %r is %d chars, will truncate to %d on "
|
"the companion protocol" % (version, len(version), VER_LIMIT))
|
||||||
"the companion protocol" % (version, len(version), VER_LIMIT)
|
|
||||||
)
|
|
||||||
|
|
||||||
# yymmdd hhmm = exactly 11. Not pretty, but complete and sortable; the readable
|
# yymmdd hhmm = exactly 11. Not pretty, but complete and sortable; the readable
|
||||||
# "%d %b %Y %H:%M" is 17 and lost its time to the 12-byte field.
|
# "%d %b %Y %H:%M" is 17 and lost its time to the 12-byte field.
|
||||||
@@ -121,13 +107,11 @@ build_date = now.strftime("%y%m%d %H%M")[:DATE_LIMIT]
|
|||||||
# the tree is already fully recompiled each time.
|
# the tree is already fully recompiled each time.
|
||||||
build_epoch = int(now.timestamp())
|
build_epoch = int(now.timestamp())
|
||||||
|
|
||||||
env.Append(
|
env.Append(CPPDEFINES=[
|
||||||
CPPDEFINES=[
|
|
||||||
("FIRMWARE_VERSION", env.StringifyMacro(version)),
|
("FIRMWARE_VERSION", env.StringifyMacro(version)),
|
||||||
("FIRMWARE_BUILD_DATE", env.StringifyMacro(build_date)),
|
("FIRMWARE_BUILD_DATE", env.StringifyMacro(build_date)),
|
||||||
("FIRMWARE_BUILD_EPOCH", str(build_epoch)),
|
("FIRMWARE_BUILD_EPOCH", str(build_epoch)),
|
||||||
# src/helpers/FwUpdate refuses a package built for another env
|
# src/helpers/FwUpdate refuses a package built for another env
|
||||||
("FW_OTA_TARGET", env.StringifyMacro(env["PIOENV"])),
|
("FW_OTA_TARGET", env.StringifyMacro(env["PIOENV"])),
|
||||||
]
|
])
|
||||||
)
|
|
||||||
print("build_version.py: %s (Build: %s, epoch %d)" % (version, build_date, build_epoch))
|
print("build_version.py: %s (Build: %s, epoch %d)" % (version, build_date, build_epoch))
|
||||||
Reference in new issue
Block a user