Power pins on by default, and a request slot that came back

CONFIG_RB9704_POWER's default read a DT_COMPAT_ variable nothing defined,
so it was never y on its own and the pins went undriven; define it.

A request that ended in -ETIMEDOUT of its own accord, a begin whose
modem never signalled booted, looked to the caller like one it had
abandoned, so neither side gave the slot back and every later call got
-EAGAIN. submit() now reports abandonment apart from the result.

On that boot timeout the supply and enable pins are dropped again, so the
next attempt starts from off. The CLI's messages named paths from the
tree it was carried over from.

Checked on native_sim: the suite against the fake, and begin twice with
the pins on the GPIO emulator, where the second begin now times out
instead of returning EAGAIN.
This commit is contained in:
scottp committed 2026-10-21 22:38:00 +11:00
1 parent 97affae86c
commit 509b9b5b6d
5 files changed
+54 -22

No files matched your search

+14
View File
@@ -1,5 +1,19 @@
# Changes
## Unreleased
- `CONFIG_RB9704_POWER` now defaults on when the devicetree node has
`power-gpios`, as documented. The Kconfig default referred to a compat
variable nothing defined, so the pins were never driven unless the
option was set by hand.
- A request whose own result was `-ETIMEDOUT`, such as a begin whose modem
never signalled booted, lost the request slot for good and every later
call returned `-EAGAIN`. The caller's abandonment of a request is now
reported apart from the request's result.
- When the booted pin does not rise in time, the supply and enable pins are
dropped again, so the next attempt starts from off.
- `rb9704`: paths in its messages that belonged to the tree it came from.
## 0.1.0, 2026-10-09
The first release.
+2
View File
@@ -26,6 +26,8 @@ config RB9704_MESSAGE_MAX
this module for the copy rb9704_send takes. 2 kB is three buffers of
2 kB; raise it as far as the RAM allows.
DT_COMPAT_ROCK7_ROCKBLOCK_9704 := rock7,rockblock-9704
config RB9704_POWER
bool "Drive the power pins from devicetree"
default y if $(dt_compat_any_has_prop,$(DT_COMPAT_ROCK7_ROCKBLOCK_9704),power-gpios)
+6 -6
View File
@@ -76,7 +76,7 @@ def find_ports():
try:
from serial.tools import list_ports
except ImportError:
die("pyserial is missing; run host/rockblock/install.sh")
die("pyserial is missing; run python/install.sh")
out = []
for p in list_ports.comports():
is_rb = p.vid == FTDI_VID and p.pid == FT234X_PID
@@ -95,7 +95,7 @@ def pick_port(arg):
return rbs[0].device
if not rbs:
die("no FTDI FT234XD attached; plug the 9704's USB-C in, or give -p PORT "
"(rb9704.py ports lists them)")
"(rb9704 ports lists them)")
die("more than one FT234XD attached (" + ", ".join(p.device for p in rbs) +
"); give -p PORT")
@@ -122,7 +122,7 @@ def open_rb(port):
try:
from rockblock9704 import RockBlock9704
except ImportError:
die("rockblock9704 is missing; run host/rockblock/install.sh")
die("rockblock9704 is missing; run python/install.sh")
rb = RockBlock9704()
if not rb.begin(port):
die(f"begin({port}) failed: wrong port, modem not booted (green RDY "
@@ -311,9 +311,9 @@ def cmd_listen(a):
def cmd_session(a):
"""One MO, then listen until a.quiet seconds pass with no new MT. This is
the 9704 session designed in docs/PLAN.md, "The session", run from the
host so the quiet window can be chosen from what is seen."""
"""One MO, then listen until a.quiet seconds pass with no new MT: a
buoy's or a hub's session, run from the host so the quiet window can
be chosen from what is seen."""
data = payload(a)
port = pick_port(a.port)
confirm(data, a.topic, a.yes)
+5
View File
@@ -83,6 +83,11 @@ int rb9704_power_set(bool want)
while (gpio_pin_get_dt(&btd) != 1) {
if (k_uptime_get() > until) {
LOG_ERR("modem did not signal booted in %d ms", BOOT_TIMEOUT_MS);
/* Back down, so the next attempt starts from off. */
if (en.port != NULL) {
(void)gpio_pin_set_dt(&en, 0);
}
(void)gpio_pin_set_dt(&pwr, 0);
return -ETIMEDOUT;
}
k_msleep(50);
+27 -16
View File
@@ -377,8 +377,11 @@ static void complete(void)
}
/* Caller side. The slot is held from here until the caller has read the
* result, or until the worker finishes a request the caller gave up on. */
static int submit(k_timeout_t timeout, bool async_ok)
* result, or until the worker finishes a request the caller gave up on.
* Abandonment is reported apart from the result: a request can itself end
* in -ETIMEDOUT (a begin whose modem never signals booted), and then the
* slot is still the caller's to give back. */
static int submit(k_timeout_t timeout, bool *abandoned)
{
k_spinlock_key_t key;
int rc;
@@ -388,13 +391,12 @@ static int submit(k_timeout_t timeout, bool async_ok)
k_event_post(&rb9704_ev, EV_REQ);
rc = k_sem_take(&rb9704_done, timeout);
key = k_spin_lock(&req_lock);
if (rc != 0 && req.state != REQ_DONE) {
*abandoned = rc != 0 && req.state != REQ_DONE;
if (*abandoned) {
req.state = REQ_ABANDONED;
k_spin_unlock(&req_lock, key);
return async_ok ? -EINPROGRESS : -ETIMEDOUT;
}
k_spin_unlock(&req_lock, key);
return req.result;
return *abandoned ? 0 : req.result;
}
static int take_slot(k_timeout_t timeout)
@@ -407,16 +409,18 @@ static int take_slot(k_timeout_t timeout)
static int simple(enum op op, k_timeout_t timeout)
{
bool abandoned;
int rc = take_slot(timeout);
if (rc != 0) {
return rc;
}
req.op = op;
rc = submit(timeout, false);
if (rc != -ETIMEDOUT) {
k_sem_give(&rb9704_slot);
rc = submit(timeout, &abandoned);
if (abandoned) {
return -ETIMEDOUT;
}
k_sem_give(&rb9704_slot);
return rc;
}
@@ -429,6 +433,7 @@ void rb9704_set_callbacks(const struct rb9704_callbacks *cb)
int rb9704_power(bool on)
{
bool abandoned;
int rc;
if (!rb9704_power_present()) {
@@ -440,7 +445,10 @@ int rb9704_power(bool on)
}
req.op = OP_POWER;
req.on = on;
rc = submit(K_FOREVER, false);
rc = submit(K_FOREVER, &abandoned);
if (abandoned) {
return -ETIMEDOUT;
}
k_sem_give(&rb9704_slot);
return rc;
}
@@ -462,15 +470,16 @@ int rb9704_signal(k_timeout_t timeout)
int rb9704_info(struct rb9704_info *out, k_timeout_t timeout)
{
bool abandoned;
int rc = take_slot(timeout);
if (rc != 0) {
return rc;
}
req.op = OP_INFO;
rc = submit(timeout, false);
if (rc == -ETIMEDOUT) {
return rc;
rc = submit(timeout, &abandoned);
if (abandoned) {
return -ETIMEDOUT;
}
if (rc == 0) {
*out = req.info;
@@ -481,6 +490,7 @@ int rb9704_info(struct rb9704_info *out, k_timeout_t timeout)
int rb9704_send(uint16_t topic, const void *data, size_t len, k_timeout_t timeout)
{
bool abandoned;
int rc;
if (topic < RB9704_TOPIC_MIN || data == NULL || len == 0 || len > sizeof(mo_buf)) {
@@ -494,10 +504,11 @@ int rb9704_send(uint16_t topic, const void *data, size_t len, k_timeout_t timeou
req.topic = topic;
req.len = len;
memcpy(mo_buf, data, len);
rc = submit(timeout, true);
if (rc != -EINPROGRESS) {
k_sem_give(&rb9704_slot);
rc = submit(timeout, &abandoned);
if (abandoned) {
return -EINPROGRESS;
}
k_sem_give(&rb9704_slot);
return rc;
}