## Summary
Fixes three user-reported M1 defects (root causes pre-diagnosed):
1. **RTC permanently invalid** (`-` on screen, `"utc":""` in JSONL, 228x
`ESP_ERR_INVALID_CRC`):
nothing ever wrote the PCF85063, so after power loss its OS (oscillator
stopped) bit stays set.
- `board_service::set_rtc_time(int64_t)`: gmtime_r -> BCD -> multi-byte
I2C write of registers
0x04-0x0A with seconds bit7=0 (clears OS), then re-read confirms; I2C
access serialized
against `read_rtc` with a FreeRTOS mutex (console/SNTP context safe).
- `time_sync` service: on Wi-Fi CONNECTED starts `esp_netif_sntp`
(ntp.aliyun.com +
pool.ntp.org, `CONFIG_LWIP_SNTP_MAX_SERVERS=2`), and once `time()`
passes 2020-01-01 writes
the RTC once per sync (`rtc synced from sntp`).
- Console: `rtc status` (valid/unix/utc/OS bit), `rtc raw` (0x00-0x0A
hex + decode),
`rtc set YYYY-MM-DD HH:MM:SS` (strptime, UTC, range + calendar
round-trip validation).
2. **KEY feels slow**: display rendering was throttled to 10 s.
`display_service::run` now keeps
the 10 s full-render heartbeat (with memory refresh) but adds a 500 ms
fast path that
re-renders as soon as a signature over volatile fields (key counters,
key_pressed, wifi/storage
state, tf_logging_ok, ap_active, ssid_configured, rtc valid+minute)
changes. KEY counter now
appears within ~0.5-1 s.
3. **Which button?**: README now documents that only KEY (GPIO18) is
monitored; RST reboots and
BOOT (GPIO0) does nothing, plus the `rtc` commands, SNTP behavior, and
the CR1220 coin-cell
note (without a battery every power loss clears the clock again).
## On-device evidence
Single-session serial on /dev/ttyACM0 (see
`.omo/evidence/m1wp/rtc-render-fix-finish-m1-wifi-provisioning.log`):
- Post-flash boot auto-connected Wi-Fi and SNTP-synced the RTC before
the console attached
(pre-manual-set `rtc status` already showed real UTC 2026-08-31
05:17:55, OS bit clear).
- `rtc set 2026-08-31 12:00:00` -> `ESP_OK`; `rtc status` valid and
advancing across polls
(12:14:59 -> 12:15:49); JSONL `utc_valid:true` + non-empty `utc` with 10
s cadence and crc32c.
- Explicit RTS reset round captured live: `frame-time: sntp started
(ntp.aliyun.com,
pool.ntp.org)` and `frame-time: rtc synced from sntp (unix 1788154496)`
7.8 s after reset;
device-vs-host time delta 4 s.
- Pre-fix invalid state (OS bit set -> ESP_ERR_INVALID_CRC) is
documented in the prior soak
evidence (F3 log); the fix clears it on the first SNTP sync.
- KEY latency: no user press within the two assist windows;
console-observer polling at 500 ms
shows counters served immediately from the shared snapshot the display
fast path renders
(CITED: `volatile_signature` + 500 ms check in `display_service.cc`), 10
s heartbeat captured
via memory-metric refresh.
- Regression: `status --json` tf_logging=true, wifi=CONNECTED, selftest
`wifi_config: ok`.
Build 0 warnings; clang-format 18 clean;
pytest/ruff/frame-evidence/frame-doc-links green.
Co-authored-by: ania-lain <[email protected]>
Frame M1 Hardware Firmware
This isolated ESP-IDF application implements the 0.1.0-dev.1 hardware-status vertical slice for
the Waveshare ESP32-S3-RLCD-4.2 N16R8 board. It does not load dynamic plugins.
It checks the ESP32-S3 target, 16 MiB flash, 8 MiB PSRAM, ST7305 display, shared I2C RTC/SHTC3, active-low KEY, SDMMC TF card transitions, Wi-Fi STA configuration with softAP web provisioning, native landscape 400x300 display output, and USB Serial/JTAG console output.
Wi-Fi provisioning persists the last credentials as plaintext JSON at /system/wifi.json on the
internal system_fs partition. This is a user-approved development-board exception (SEC-010,
recorded in _doc/requirements-v4.2.md under M1-007): ESP-IDF v6.0.2 requires Flash Encryption or
an HMAC eFuse key to protect NVS encryption keys, and both provisioning steps are irreversible on
the single development board. Production boards must switch to NVS-encrypted credential storage
before shipping. The password never appears in UART output, logs, or status.
On boot the device auto-connects with the saved credentials. When no valid configuration exists, or
after 5 disconnects without an IP address or 60 seconds without obtaining one, it starts an open
setup hotspot Frame-Setup-XXXX at 192.168.4.1. The portal's network list is populated from a
live scan; hidden networks cannot be typed into the browser form — configure those through the
console with wifi set <ssid> hidden. Holding KEY for 3 seconds or longer also requests the setup
hotspot; such a hold is a portal command and does not count as a button press.
Buttons
The only monitored button is the board's KEY button (GPIO18, active-low): a release under 1
second counts as a short press, 1-3 seconds as a long press, and 3 seconds or more requests the
setup hotspot. Both counters appear on the display and in status. The RST button resets the
board, and BOOT (GPIO0) is not monitored — pressing either does not change any counter.
Real-Time Clock
The PCF85063 RTC shares the I2C bus with the SHTC3. Nothing writes the chip from the factory, so
after a power loss its oscillator-stopped (OS) flag is set and the time reads invalid on the
display (-) and in JSONL ("utc":""). The firmware now provides two time sources:
- SNTP: once the station has an IP address, the firmware starts SNTP against
ntp.aliyun.comandpool.ntp.org, and on the first successful sync writes the UTC time to the RTC (log linertc synced from sntp). SNTP keeps running; periodic re-syncs update the system clock. - Console:
rtc setwrites the chip manually (UTC is assumed).
A CR1220 coin cell on the board keeps the RTC running across power-off. Without a battery (or with an empty one) every boot loses the time and the OS flag returns — install a fresh cell for persistence across power loss.
Build with the exact IDF tag:
. "$IDF_PATH/export.sh"
cmake --preset default --fresh
cmake --build --preset default
The console is available through USB Serial/JTAG at 115200 baud. Useful commands:
status [--json]
rtc status
rtc raw
rtc set YYYY-MM-DD HH:MM:SS
wifi set <ssid> [hidden]
wifi clear
wifi reconnect
wifi status
prov status
prov start
prov scan
storage probe
storage status
selftest
rtc status reports validity, unix time, formatted UTC, and the OS-bit state; rtc raw dumps
PCF85063 registers 0x00-0x0A with a decode; rtc set parses YYYY-MM-DD HH:MM:SS as UTC,
validates the ranges, writes the chip, and re-reads it to confirm.
Do not place real credentials in command transcripts or committed evidence. wifi set asks for the
password after parsing the command so it is not stored in command history; terminal software must
also keep local echo disabled. The password is persisted only inside /system/wifi.json under the
SEC-010 development-board exception and is never echoed back.