Add Config -> Sync net time manual trigger

The reflashed image starts chronyd at ~27 s, before NetworkManager installs
a usable resolv.conf, so pool.ntp.org stays unresolved and minpoll 12 would
wait up to 4096 s. Wi-Fi came up at ~30 s but the clock was only stepped at
~112 s, when usb0 emitted another dispatcher event.

- Config -> Sync net time in the built-in dmenu Config menu runs
  bananarchy-sync-net-time.sh, forces a burst via bananarchy-time-sync.sh
  sync and shows a desktop notification with the UTC date or a failure.
- New sync mode reports success/failure and exit status; resolved() now
  requires at least one known source, DNS waits run before the flock, and
  network-up/force/sync get 8 retries so a slow boot retry cannot swallow
  network-up events.
- Rebuilt dmenu.so from src/sxmo-dmenu/dmenu.c into prebuilt/ and overlay/;
  apply-bananarchy-overlay.sh keeps the wrapper root-owned and executable;
  check-rebuild.sh guards the menu entry, wrapper and sync mode.
- Rebuilt and verified images/bananarchy-nokia-argon.img (all new files
  byte-identical to overlay, boot.img unchanged, 27 initramfs modules).

Live verification on the reflashed phone: helper sync as the X session user
prints "Network time synced: 2026-11-07 20:17:43 UTC", the wrapper posts a
notification, a DNS-down sync fails clearly after 16 s, restoring DNS syncs
again, and the rebuilt dmenu daemon was reloaded with the new Config item.
This commit is contained in:
Luxferre committed 2026-11-07 22:22:02 +02:00
1 parent 9ac39ce6bf
commit 85c6a7b886
12 files changed
+177 -16

No files matched your search

+6 -2
View File
@@ -71,8 +71,12 @@ session park on `sxmo_wm.sh display off/on`). Never park a SIM with
`etc/chrony/chrony.conf` (`iburst`, `minpoll 12 maxpoll 16`, `cmdport 0`) plus
`usr/bin/bananarchy-time-sync.sh`, the `bananarchy-time-sync` OpenRC service
and the NetworkManager dispatcher hook, which call `chronyc refresh` / `burst`
over chronyd's root-only Unix socket when a connection comes up; keep
`var/lib/chrony` owned by the `chrony` user. Deep standby is `bananarchy-suspend.sh` / `bananarchy-deep-standby.sh` / `sxmo_autosuspend.sh` / `sxmo_suspend.sh`, gated by `/etc/bananarchy-no-deep-standby` (shipped present = disabled) and inert because `CONFIG_SUSPEND` is off. A full custom module tree rebuild is deliberately **not** planned: this firmware has no PSCI `SYSTEM_SUSPEND`, so `CONFIG_SUSPEND` would only give s2idle (`freeze`), not `mem` / DDR self-refresh, for <1 mA of saving (see `BATTERY-OPTIMIZATION-ANALYSIS.md` §14). Never force `sxmo.noidle`/`sxmo.nosuspend` from the session scripts and never reintroduce the infinite `sxmo_not_suspendable` wakelock. `/etc/bananarchy/` is root-only.
over chronyd's root-only Unix socket when a connection comes up; **Config ->
Sync net time** (`src/sxmo-dmenu/dmenu.c` +
`usr/bin/bananarchy-sync-net-time.sh`) forces the same burst manually and
notifies the user, and the helper's `sync` mode reports the result. Keep DNS
resolution outside the helper's `flock` so a long boot retry cannot swallow
network-up events, and keep `var/lib/chrony` owned by the `chrony` user. Deep standby is `bananarchy-suspend.sh` / `bananarchy-deep-standby.sh` / `sxmo_autosuspend.sh` / `sxmo_suspend.sh`, gated by `/etc/bananarchy-no-deep-standby` (shipped present = disabled) and inert because `CONFIG_SUSPEND` is off. A full custom module tree rebuild is deliberately **not** planned: this firmware has no PSCI `SYSTEM_SUSPEND`, so `CONFIG_SUSPEND` would only give s2idle (`freeze`), not `mem` / DDR self-refresh, for <1 mA of saving (see `BATTERY-OPTIMIZATION-ANALYSIS.md` §14). Never force `sxmo.noidle`/`sxmo.nosuspend` from the session scripts and never reintroduce the infinite `sxmo_not_suspendable` wakelock. `/etc/bananarchy/` is root-only.
- **Image residue**: `rebuild-image.sh` strips `/var/cache/apk`, all `apk.log*` files, and unused gettext locale trees before `mke2fs` and aborts the build if any apk cache/log remains; never add an `apk` call after that guard.
- **No on-device compiler**: `scripts/rootfs-packages.txt` ships no `gcc`/`g++`/`musl-dev`/`make` and no Janet runtime (`janet`, `janet-dev`, `jpm`); cross-compile native code with `scripts/build-*.sh`. On-device development uses the Yabasic FFI SDK (`neoui.yab` / `neonet.yab`), which requires `yabasic`, `libffi`, `libneoui.so`, and `libcurl.so.4` — never remove those. `scripts/check-rebuild.sh` guards both sides.
- **Core tools**: `curl`, `bc`, `ed`, `rlwrap`, `mandoc`, `nano`, `less`, and `frotz` are pinned core tools asserted by `scripts/check-rebuild.sh`. Perl, Lua, optional Tcl extensions, and the `sqlite` CLI are excluded, while `tcl`, `python3`, `bash`, `luajit`, `gawk`, `jq`, `gojq`, and `quickjs` remain as hard runtime dependencies.
+45
View File
@@ -868,3 +868,48 @@ clock from `1970-01-12` to `Sat Nov 7 19:40:25 UTC 2026` within seconds;
time`. No UDP chronyc port was opened. The steady-state poll interval remains
`minpoll 12 maxpoll 16`, so U6's battery saving is preserved; the only extra
traffic is one short burst at boot and on each network transition.
### 16.4 Reflashed boot: why autosync still took 80 s
The image was reflashed and the boot was measured from `/proc/uptime`,
NetworkManager's `timestamps` file, OpenRC's `/run/openrc/started` symlinks,
`chronyc sources` and the helper's `/run/bananarchy-time-sync/last` stamp.
The RTC held `1970-01-12 12:39:26 UTC` (epoch 995966), so all boot file
timestamps are on that fake date and map to uptime by subtracting 995966:
| Uptime | Event |
| --- | --- |
| 0 s | kernel sets the clock from `rtc-pm8xxx` to 1970-01-12 12:39:26 UTC |
| ~27 s | NetworkManager, `chronyd`, `bananarchy-time-sync` started; chronyd resolves the pool before DNS exists, so all 8 sources stay `unknown address` |
| ~30 s | dnsmasq, wlan0 DHCP lease, `resolv.conf`; Wi-Fi `OffOurStreets_` activated (NM timestamp 995997) |
| ~112 s | USB RNDIS (`usb0`) activated (NM timestamp 996078); helper stamp 112; first NTP samples; clock stepped to 2026-11-07 20:04:23 UTC |
So `chronyd` did autostart, but at boot rather than on Wi-Fi: OpenRC `need net`
is satisfied by NetworkManager `provide net` as soon as the daemon starts.
`chronyd` resolves `pool.ntp.org` once, at ~27 s, before dnsmasq is up; with
`minpoll 12` an unresolved pool produces no packets for up to 4096 s. The
network-up hook is meant to fix that, but none of the Wi-Fi dispatcher events
(`up`, `dns-change`, `dhcp4-change`) at ~30 s produced a burst: the boot
helper either held `/run/bananarchy-time-sync/lock` for its whole 60 s
`refresh` retry loop (so `flock -n 9` dropped them) or had already written its
15 s throttle stamp after `resolved()` mistook a zero-source `activity` report
for a resolved pool. The next event was `usb0 up` at ~112 s, which finally ran
the helper and synced the clock. A controlled reproduction
with `nameserver 127.0.0.9` showed chronyd does not re-resolve on its own
(8 unknown sources for 10 s after DNS was restored) while `chronyc refresh`
resolves them within ~4 s.
Fixes, without changing the long steady-state poll interval:
- `wait_chronyd()` and `wait_sources()` now run before the lock is taken; only
the stamp / `online` / `burst` section is serialised, with `flock -w 5`.
A slow boot retry can no longer swallow network-up events.
- `resolved()` requires at least one known source (online, offline or doing a
burst) in addition to `0 sources with unknown address`, so a chronyd that
has not created any pool sources yet cannot cause a no-op burst.
- `network-up` / `force` / `sync` get 8 retries (16 s) instead of 3 (6 s).
- `bananarchy-time-sync.sh sync` waits up to 15 s for `chronyc tracking` to
show a reference ID and prints `Network time synced: <UTC date>` or a clear
failure. **Config -> Sync net time** calls it via
`bananarchy-sync-net-time.sh` and shows a desktop notification, so the user
can always force a sync without a shell.
+34
View File
@@ -9,6 +9,40 @@ Release versions follow the `<year-letter><MM><DD>` format (where `2026` is `a`,
---
## Unreleased — manual network time sync from the Config menu
- **Config -> Sync net time**: a new menu item in the built-in dmenu Config
menu (`src/sxmo-dmenu/dmenu.c`) runs
`/usr/bin/bananarchy-sync-net-time.sh`, which forces an immediate NTP burst
and shows a desktop notification with the result. It is the manual escape
hatch when boot-time autosync is slow, e.g. because Wi-Fi DNS became usable
only after `chronyd` had started with an unresolved NTP pool.
- **`bananarchy-time-sync.sh sync`**: the helper now reports
`Network time synced: <UTC date>` (or a clear failure) and returns a
matching exit status. `resolved()` now requires at least one known source,
so a freshly started chronyd with zero sources cannot be mistaken for a
resolved pool. DNS resolution runs before the `flock` is taken, so the long
boot retry no longer swallows the NetworkManager `up` / `dns-change` events
that arrive while it is waiting; network-up events get 8 retries (16 s).
- **Measured on the reflashed phone**: the kernel set the clock from the RTC
to `1970-01-12 12:39:26 UTC`; NetworkManager, chronyd and the time-sync
service started at ~27 s; Wi-Fi got its DHCP lease and `resolv.conf` at
~30 s; the first NTP samples and the clock step to `2026-11-07 20:04:23
UTC` happened only at ~112 s, when the USB RNDIS connection came up and
emitted another dispatcher event. The Wi-Fi events at ~30 s produced no
burst: the boot helper either held its `flock` for the 60 s DNS retry or had
already written its 15 s throttle stamp after treating a zero-source
`activity` report as a resolved pool.
- Live verification: a simulated DNS-down chronyd start followed by a
concurrent `network-up` trigger now syncs while the boot helper is still
waiting; the menu command was exercised as the X session user and reported
success over the root-only chronyd Unix socket.
- `scripts/check-rebuild.sh` guards the menu entry, the menu wrapper, the
`sync` mode and the overlay ownership/mode fix; `prebuilt/sxmo-x11` and
`overlay/rootfs` dmenu plugin were rebuilt from the C source.
---
## Unreleased — network-up NTP synchronisation
- **Fixed the clock never being set over the network**: `chronyd` resolves
+3
View File
@@ -584,9 +584,12 @@ The **Xlibre** display server (`modesetting_drv.so`) uses **Glamor + DRI3 + GLX
`chronyd` runs from the default runlevel with `pool pool.ntp.org iburst minpoll 12 maxpoll 16`: long polls keep Wi-Fi asleep, while `iburst` sets the clock within seconds whenever the pool resolves. Because NetworkManager installs `resolv.conf` after `chronyd` starts, a `bananarchy-time-sync` OpenRC service and `/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh` re-resolve the pool and request an immediate burst when a connection comes up (`up`, `dhcp4-change`, `dhcp6-change`, `dns-change`, `connectivity-change`, `vpn-up`). The helper uses chronyd's root-only Unix command socket, so `cmdport 0` keeps the UDP command port closed, and it throttles repeats with a monotonic uptime stamp so a decades-long clock step cannot confuse it. `/var/lib/chrony` is owned by the `chrony` user so the driftfile survives reboots.
If the clock is still wrong after a connection comes up, use **Config -> Sync net time**. It runs `bananarchy-sync-net-time.sh`, forces an immediate burst over the same Unix socket, and shows a notification with the synced UTC date or a failure message. This is also handy after a long offline period, when the RTC has fallen back to 1970.
```bash
bananarchy-time-sync.sh status # chronyc tracking + sources (via doas)
bananarchy-time-sync.sh force # re-resolve the pool and burst immediately
bananarchy-time-sync.sh sync # force and print a human-readable result
```
---
+1 -1
View File
@@ -18,7 +18,7 @@
### System and hardware support
- **Mainline Linux 6.12 kernel**: custom patches and out-of-tree drivers for Qualcomm **Adreno 304 (`FD304`, 96 KB GMEM)** 3D GPU acceleration (`drm/msm` + `qcom-iommu`), Qualcomm QDSP6/Q6Voice audio routing, Dual-SIM modem control, the rear 2MP GalaxyCore `GC2395` / `GC2385` / `GC2365` camera (`/dev/video0`), the `SY7807` flashlight LED (`white:torch`), physical keypad/slider events, and clean PM8909 poweroff. The kernel image is built from `config-bananarchy-msm8909.armv7` with the known-good pmaports module ABI, and ships with idle-blanking power management; `BATTERY-OPTIMIZATION-ANALYSIS.md` records the measured idle state and explains why suspend-to-RAM is unavailable on this firmware (PSCI `SYSTEM_SUSPEND` missing) and why a full custom module tree rebuild is not worthwhile. Runtime Wi-Fi listen-interval, modem DRX and DSDS secondary-SIM power policies are configurable in `/etc/bananarchy-power-policy.conf`; see `MANUAL.md`.
- **Alpine Linux Edge base**: full access to the Alpine package ecosystem with `< 95 MB` idle RAM usage on 512 MB devices and full local root access out of the box.
- **Network time synchronisation**: `chronyd` uses `iburst` with long `minpoll 12 maxpoll 16` polls; `bananarchy-time-sync.sh` re-resolves the NTP pool and requests an immediate burst over chronyd's root-only Unix socket when NetworkManager brings a connection up, so the clock is set within seconds of boot or a Wi-Fi reconnect without shortening the battery-friendly steady-state interval. See `MANUAL.md` section 5.7.
- **Network time synchronisation**: `chronyd` uses `iburst` with long `minpoll 12 maxpoll 16` polls; `bananarchy-time-sync.sh` re-resolves the NTP pool and requests an immediate burst over chronyd's root-only Unix socket when NetworkManager brings a connection up, so the clock is set within seconds of boot or a Wi-Fi reconnect without shortening the battery-friendly steady-state interval. **Config -> Sync net time** forces a burst manually and reports the result when autosync is slow. See `MANUAL.md` section 5.7.
- **Pure X11 graphical stack with GPU acceleration**: cross-compiled **Xlibre** (`X11Libre/xserver`) display server offloading 2D/3D screen rendering to the **Adreno 304 GPU** via **Glamor, DRI3, GLX, and Mesa Freedreno (`FD304`, OpenGL 3.1 / OpenGL ES 3.0)** over `panel-mipi-dbi` KMSRO, paired with a customized **Sxmo (`sxmo-de-dwm`)** window manager (`240x320` vertical stack layout, native `ParentRelative` desktop clock and softkey bar without Conky overhead, `< 2 ms` slider/key wake latency, and zero Wayland overhead).
### Keypad-first user experience and native DWM plugins
+23
View File
@@ -0,0 +1,23 @@
#!/bin/sh
# Config -> Sync net time: force an immediate NTP sync and show the outcome.
# Runs as the X session user; bananarchy-time-sync.sh escalates via doas.
set -u
result="$(/usr/bin/bananarchy-time-sync.sh sync 2>&1)"
[ -n "$result" ] || result="No response from chronyd"
case "$result" in
"Network time synced"*)
urgency=normal
;;
*)
urgency=critical
;;
esac
if command -v notify-send >/dev/null 2>&1; then
notify-send --urgency="$urgency" --expire-time=8000 \
"Sync net time" "$result" >/dev/null 2>&1 || true
else
sxmo_notify_user.sh "Sync net time: $result" >/dev/null 2>&1 || true
fi
+49 -13
View File
@@ -23,6 +23,12 @@ LOCK="$RUNDIR/lock"
TRIGGER_MIN=15
REFRESH_MIN=300
WAIT_MAX=30
# NetworkManager emits several up/dns events per connection. DNS resolution
# runs before the lock is taken, so a slow boot retry cannot swallow the
# network-up event that would otherwise sync the clock immediately.
ATTEMPTS=8
BOOT_ATTEMPTS=30
SYNC_WAIT=15
if [ "$(id -u)" != "0" ]; then
exec doas -n "$0" "$@"
@@ -53,9 +59,16 @@ wait_chronyd() {
}
# chronyc activity reports how many configured sources still have no address.
# A freshly started chronyd can also report zero sources of any kind while the
# pool name is unresolved, so require at least one known source as well.
resolved() {
"$CHRONYC" -h "$SOCKET" activity 2>/dev/null |
grep -q '^0 sources with unknown address$'
"$CHRONYC" -h "$SOCKET" activity 2>/dev/null | awk '
/^[0-9]+ sources online$/ { on = $1 }
/^[0-9]+ sources offline$/ { off = $1 }
/^[0-9]+ sources doing burst/ { burst += $1 }
/^[0-9]+ sources with unknown address$/ { unknown = $1 }
END { exit !(unknown + 0 == 0 && on + off + burst + 0 > 0) }
'
}
synced() {
@@ -81,26 +94,26 @@ wait_sources() {
trigger() {
mode="${1:-network-up}"
attempts=3
[ "$mode" = "boot" ] && attempts=30
mkdir -p "$RUNDIR" 2>/dev/null || return 1
# NetworkManager emits several up/dns events per connection; serialise them
# so only one helper refreshes and bursts at a time.
exec 9>"$LOCK" || return 1
flock -n 9 || return 0
attempts="$ATTEMPTS"
[ "$mode" = "boot" ] && attempts="$BOOT_ATTEMPTS"
wait_chronyd || {
log "chronyd command socket not available"
return 1
}
if ! wait_sources "$attempts"; then
log "NTP pool names did not resolve yet"
return 0
return 1
fi
mkdir -p "$RUNDIR" 2>/dev/null || return 1
# Only the stamp/burst section is serialised: NetworkManager emits several
# up/dns events per connection and a long DNS wait must not block them.
exec 9>"$LOCK" || return 1
flock -w 5 9 || return 1
now="$(monotonic)"
last=0
[ -r "$STAMP" ] && last="$(cat "$STAMP" 2>/dev/null || echo 0)"
case "$last" in ''|*[!0-9]*) last=0 ;; esac
if [ "$mode" != "force" ]; then
if [ "$mode" != "force" ] && [ "$mode" != "sync" ]; then
if synced; then
[ "$((now - last))" -lt "$REFRESH_MIN" ] && return 0
else
@@ -109,12 +122,31 @@ trigger() {
fi
printf '%s\n' "$now" > "$STAMP" || return 1
chronyc_cmd online
if ! synced || [ "$mode" = "force" ]; then
if ! synced || [ "$mode" = "force" ] || [ "$mode" = "sync" ]; then
chronyc_cmd burst 2/4 || log "chronyc burst failed"
fi
return 0
}
# Config -> Sync net time: force a burst and report when the clock is set.
sync_now() {
if ! trigger sync; then
echo "Network time unavailable: chronyd or DNS is not ready"
return 1
fi
i=0
while [ "$i" -lt "$SYNC_WAIT" ]; do
if synced; then
printf 'Network time synced: %s\n' "$(date -u '+%Y-%m-%d %H:%M:%S UTC')"
return 0
fi
sleep 1
i=$((i + 1))
done
echo "Network time not confirmed yet; retry when the network is up"
return 1
}
case "${1:-status}" in
boot|network-up)
trigger "$1"
@@ -122,6 +154,10 @@ case "${1:-status}" in
force)
trigger force
;;
sync)
sync_now
exit $?
;;
status)
if [ ! -S "$SOCKET" ]; then
echo "chronyd command socket absent"
@@ -131,7 +167,7 @@ case "${1:-status}" in
"$CHRONYC" -h "$SOCKET" sources
;;
*)
echo "usage: $0 boot|network-up|force|status" >&2
echo "usage: $0 boot|network-up|force|sync|status" >&2
exit 2
;;
esac
Binary file not shown.
Binary file not shown.
+2
View File
@@ -115,11 +115,13 @@ chmod 640 "$TARGET_ROOTFS/etc/doas.d/50-sxmo.conf" 2>/dev/null || true
# driftfile (rebuild-image.sh re-applies this after normalising all UIDs).
chown 0:0 "$TARGET_ROOTFS/etc/chrony/chrony.conf" \
"$TARGET_ROOTFS/usr/bin/bananarchy-time-sync.sh" \
"$TARGET_ROOTFS/usr/bin/bananarchy-sync-net-time.sh" \
"$TARGET_ROOTFS/etc/init.d/bananarchy-time-sync" \
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh" \
2>/dev/null || true
chmod 0644 "$TARGET_ROOTFS/etc/chrony/chrony.conf" 2>/dev/null || true
chmod 0755 "$TARGET_ROOTFS/usr/bin/bananarchy-time-sync.sh" \
"$TARGET_ROOTFS/usr/bin/bananarchy-sync-net-time.sh" \
"$TARGET_ROOTFS/etc/init.d/bananarchy-time-sync" \
"$TARGET_ROOTFS/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh" \
2>/dev/null || true
+10
View File
@@ -182,6 +182,7 @@ fi
echo "[check] Network time synchronisation..."
for f in overlay/rootfs/etc/chrony/chrony.conf \
overlay/rootfs/usr/bin/bananarchy-time-sync.sh \
overlay/rootfs/usr/bin/bananarchy-sync-net-time.sh \
overlay/rootfs/etc/init.d/bananarchy-time-sync \
overlay/rootfs/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh; do
if [ ! -f "$BASE_DIR/$f" ]; then
@@ -189,12 +190,21 @@ for f in overlay/rootfs/etc/chrony/chrony.conf \
fi
done
for f in overlay/rootfs/usr/bin/bananarchy-time-sync.sh \
overlay/rootfs/usr/bin/bananarchy-sync-net-time.sh \
overlay/rootfs/etc/init.d/bananarchy-time-sync \
overlay/rootfs/etc/NetworkManager/dispatcher.d/20-bananarchy-time-sync.sh; do
if [ -f "$BASE_DIR/$f" ] && ! sh -n "$BASE_DIR/$f" 2>/dev/null; then
fail "shell syntax: $f"
fi
done
if ! grep -q 'Sync net time' "$BASE_DIR/src/sxmo-dmenu/dmenu.c" || \
! grep -q 'bananarchy-sync-net-time.sh' "$BASE_DIR/src/sxmo-dmenu/dmenu.c"; then
fail "Config menu no longer offers Sync net time"
fi
if ! grep -q 'sync_now' "$BASE_DIR/overlay/rootfs/usr/bin/bananarchy-time-sync.sh" || \
! grep -q 'bananarchy-sync-net-time.sh' "$BASE_DIR/scripts/apply-bananarchy-overlay.sh"; then
fail "manual network time sync is no longer installed"
fi
if ! grep -q 'iburst' "$BASE_DIR/overlay/rootfs/etc/chrony/chrony.conf" || \
! grep -q 'cmdport 0' "$BASE_DIR/overlay/rootfs/etc/chrony/chrony.conf"; then
fail "chrony.conf must keep iburst and the closed UDP command port"
+4
View File
@@ -2926,6 +2926,10 @@ open_builtin_menu(const char *menu_name, int keep_idx)
snprintf(label, sizeof(label), "%s Change Timezone", ICON_CLK);
add_menu_item(label, "@menu:timezone", 1);
/* Config -> Sync net time: manual fallback when boot-time DNS is late. */
snprintf(label, sizeof(label), "%s Sync net time", ICON_CLK);
add_menu_item(label, "/usr/bin/bananarchy-sync-net-time.sh", 0);
snprintf(label, sizeof(label), "%s Screen blank: %s", ICON_CLK,
idle_blank_label(read_idle_blank_secs()));
add_menu_item(label, "@menu:idle_blank", 1);