The modem's UART heard from boot, and the Stamp-C3 under the sky

The module turned the modem UART's receive interrupt off whenever the
library was closed. With the power pins wired, the modem sends about
500 bytes of boot lines as it comes up, to nobody; on the M5Stamp-C3
they overflowed the UART's 128-byte FIFO, after which begin heard only
repeated fragments of old lines and failed with -EIO, and a second
begin crashed the board in the library's line parser (docs/JSPR.md,
section 8, item 2). The interrupt is now on from boot: bytes heard while
the library is closed are thrown away, and when it opens part-way
through a line the rest of that line is too. On the Stamp, 8 of 8 power
cycles and 12 of 12 with 0 to 5 s between power on and begin, where 1 of
6 and none had worked.

The fake modem's raw and before commands write any bytes, now or just
ahead of its next reply, and test_a_boot_burst_while_closed sends a
680-byte boot burst before begin: that overflow on a board through the
rig, a check that it does no harm on native_sim.

docs/boards/stamp_c3.md records the first run under open sky: the
constellation visible and 3 to 5 bars within seconds of begin. It also
records what is open: on the Stamp's 5V the modem stopped answering 2 to
5 minutes after each begin, four times, indoors and out, most likely
its supply; not yet measured, and the tests that would settle it are
listed there. Not yet provisioned, and no message sent.
This commit is contained in:
scottp committed 2026-10-25 22:21:17 +11:00
1 parent 4f5834a467
commit 0cda7335d6
9 files changed
+169 -10

No files matched your search

+16
View File
@@ -29,6 +29,9 @@ Control is one command per line on stdin, events one per line on stdout:
mo-release send the withheld final status
segment <n> ask for MO segments of n bytes (default 1446)
state <state> the operationalState from now on
raw <text> write text as it is, \r for CR: a line's
tail, junk, a line cut short
before <text> write text just before the next reply
quit
READY <port>
@@ -95,6 +98,7 @@ class FakeModem:
self.mo_refuse = False
self.mo_hold = False # the next MO's final status waits for mo-release
self.held = None # (topic, id, status) withheld
self.before = b"" # written ahead of the next reply
self.imei = "300434030000000"
self.serial = "123456"
self.iccid = "8988169712345678901"
@@ -123,6 +127,9 @@ class FakeModem:
def request(self, line):
self.events("RX " + line)
if self.before:
self.write(self.before)
self.before = b""
parts = line.split(" ", 2)
if len(parts) < 2:
return
@@ -324,6 +331,15 @@ class FakeModem:
self.segment = max(1, min(MO_SEGMENT_MAX, int(w[1])))
elif cmd == "state":
self.state = w[1]
elif cmd in ("raw", "before"):
text = line.split(" ", 1)[1] if " " in line else ""
data = text.encode().decode("unicode_escape").encode("latin-1")
with self.lock:
if cmd == "raw":
self.write(data)
else:
self.before = data
self.events("%s %s" % (cmd.upper(), text))
elif cmd == "quit":
return False
elif cmd:
+32
View File
@@ -5,6 +5,7 @@ Zephyr, through the shell sample, against the fake modem: on native_sim
with --zephyr-exe, on a board with --board-console and --board-modem.
"""
import time
import zlib
import pytest
@@ -102,6 +103,37 @@ def test_cancel_a_send_the_modem_sits_on(zephyr):
c.out.expect(r"result 0")
def test_a_boot_burst_while_closed(zephyr):
"""A modem powered up before begin talks to nobody: its boot lines,
over 600 bytes here, end part-way through one, finished just before
the first reply. On the M5Stamp-C3 such a burst overflowed the UART's
128-byte FIFO while the module was not listening, and begin then heard
only repeated fragments of old lines; given one, the library read past
its buffer and the board crashed (2026-10-25). The module now empties
the FIFO from boot and skips the rest of a line it opened in.
On a board through the rig this is that overflow. native_sim has no
FIFO to overflow: there it checks that the burst does no harm."""
c, f = zephyr
boot = ('\\x11\\x11299 bootInfo {"image_type":"production","version":{"major":1,'
'"minor":5,"patch":14,"build_info":"SX-250613-A3E9C3E3-P1-P3142-1194848-'
'12516979"},"boot_source":"primary"}\\r')
lines = (boot
+ '299 simStatus {"card_present":true,"sim_connected":true,'
'"iccid":"8988169712345678901"}\\r'
+ '299 operationalState {"state":"inactive","reason":0}\\r' * 4
+ '299 constellationState {"constellation_visible":false,"signal_bars":0}\\r' * 2
+ '299 bootInfo {"image_type":"prod')
f.cmd("raw " + lines)
f.out.expect(r"^RAW ")
time.sleep(0.5)
f.cmd('before uction"}\\r')
f.out.expect(r"^BEFORE ")
begin(zephyr)
c.sh("rb9704 info")
c.out.expect(r"imei\s+300434030000000")
def test_topic_below_64_is_refused_here(zephyr):
c, f = zephyr
begin(zephyr)