feat(firmware): relay-proxy PoC — NodeMCU as a Dingtian DT-R004 + cloud proxy/watchdog

A NodeMCU v3 (ESP8266) that speaks the Dingtian wire contract (binary UDP 60000 with
relay_pw, string UDP 60001, config CGI incl. the setconfig gotcha, userset.cgi, Digest
input push) so the booth's existing driver needs no change, plus a heartbeat/command/
watchdog path to an ephemeral cloud stand-in (poc/cloud-standin.mjs). Verified at park-lab:
the booth's assign flow configured it like real hardware and a button press reached the
booth (401→Digest→200) and the cloud with the booth's status. Watchdog probes /health and
power-cycles the PC via a spare relay with backoff. IO behind one interface for the ESP32/
Dingtian port.

wiki: relay-proxy-firmware page; esp32-flashability-test runbook (esptool lock test);
dingtian-relay "can we flash our own firmware" (vendor locks the standard SKU);
site-device-installation: booth ufw must allow device-net → 3000 (push targets PORT, not
Caddy's 80); open-questions: cloud takeover vs signed ledger (parked).

.gitignore: firmware venv/.pio/secrets.h.
This commit is contained in:
2026-10-22 12:08:20 +02:00
parent e842f036e2
commit c08e232339
19 changed files with 1162 additions and 1 deletions
+101
View File
@@ -0,0 +1,101 @@
---
type: concept
tags: [parking, hardware, runbook, esp32, dingtian]
sources: []
updated: 2026-10-22
---
# Runbook — Is this ESP32 board flashable? (Dingtian DT-R0xx lock test)
A bench test that answers one question in a few minutes: **is the ESP32 on this [[dingtian-relay]]
locked (standard SKU) or open (Development Board Version)?** Run it before ordering more units or
planning any custom-firmware work (see [[dingtian-relay]] "Can we flash our own firmware?").
The test is read-only. Nothing is written to the chip, no eFuse is burned, and the stock firmware
boots normally afterwards.
## What "locked" means on an ESP32
The vendor burns one-time eFuse bits at the factory; they can never be cleared. Any one of these
blocks custom firmware:
| eFuse | Effect | How the test shows it |
| --- | --- | --- |
| `DISABLE_DL_ENCRYPT` / `DISABLE_DL_DECRYPT` / UART download disabled | ROM bootloader refuses serial flashing | `esptool chip_id` never connects |
| `FLASH_CRYPT_CNT` (flash encryption) | flash contents unreadable/unwritable from outside | `espefuse summary` shows it odd/enabled |
| `ABS_DONE_0` / `ABS_DONE_1` (secure boot) | ROM only runs a vendor-signed bootloader | `espefuse summary` shows it set |
The 74HC595 / 74HC165 shift registers on the board are **not** a blocker; community firmware drives
them already.
## Equipment
- USB-to-UART adapter, **3.3 V logic** (CP2102 / CH340 / FT232). Set its jumper to 3.3 V.
- Dupont leads. Do **not** connect the 12 V supply; the adapter's 3.3 V powers the ESP32 for this test.
- A PC with Python: `pip install esptool` (gives both `esptool.py` and `espefuse.py`).
## Wiring (DT-R0xx programming header)
| Adapter | Board |
| --- | --- |
| GND | GND |
| 3V3 | 3V3 |
| TXD | RXD (ESP32 GPIO3) |
| RXD | TXD (ESP32 GPIO1) |
| DTR | NRST (optional; lets esptool reset the board itself) |
Header labelling varies by revision; confirm against the silkscreen. GPIO1/3 are also the board's
Modbus UART, so expect the stock firmware to chatter on them when it boots.
## Procedure
1. Wire as above, adapter unplugged.
2. **Hold the board's boot switch** while plugging the adapter into USB. Keep holding ~1 s, release.
(Without DTR wired, this is the only way into download mode.)
3. Identify the port: `COMx` on Windows, `/dev/ttyUSB0` on Linux. On WSL, pass the device through
or run from Windows.
4. Run:
```
esptool.py --port COM5 --baud 115200 chip_id
```
5. If it connects, read the eFuses:
```
espefuse.py --port COM5 summary
```
## Reading the result
**Open (Development SKU):**
```
Chip is ESP32-D0WD-V3 (revision v3.x)
Features: WiFi, BT, Dual Core, 240MHz, ...
Chip ID: 0x...
```
and in the summary `FLASH_CRYPT_CNT = 0`, `ABS_DONE_0 = False`, `ABS_DONE_1 = False`,
`DISABLE_DL_* = False`. Custom firmware (ESPHome `dtr0xx_io`, Tasmota, ESP-IDF) is possible.
**Locked (Standard SKU), either of:**
- `A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header`
after the boot-switch step was done correctly → UART download is disabled.
- It connects but the summary shows flash encryption and/or secure boot enabled → you can reach the
ROM but cannot run your own image. Treat as locked.
**Inconclusive:** garbled output or "Connecting....." forever on the *first* try is usually a wiring
or boot-mode slip (TX/RX swapped, 5 V jumper, switch released too early). Retry twice before calling
it locked. One forum report of exactly this symptom was never resolved.
## Record the outcome
Add a line to the "Status" list on [[dingtian-relay]] with the unit's serial, SKU, firmware version
and the verdict, and a `## [date] query` entry in `log.md`. A locked verdict closes the custom-firmware
question for that unit; the only route is ordering the Development Board Version
([[esp32-custom-controller]] remains deferred, [[open-questions]] #6).
## Related
- [[dingtian-relay]] — hardening gaps that custom firmware would close.
- [[esp32-custom-controller]] — the prevention-grade device this would approximate.
- [[site-device-installation]] — field runbook; this test is a bench task, not a site task.