variants/rtsp.sh assembles the complete firmware: DTB with a 24 MB ION heap for 2304x1296, Tuya-free APP with the SDK runtime, rebuilt RTSP server, dropbear, OTA, Wi-Fi and camcfg tools, DATA partition, patched env, and stages full.bin, partitions and both SD install sets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
199 lines
8.0 KiB
Markdown
199 lines
8.0 KiB
Markdown
# Build & Install
|
|
|
|
End-to-end: build a firmware image with the toolkit, flash it, repartition, and (for the
|
|
RTSP build) add the ONVIF binaries. For background/why, see `README.md`, `RTSP.md`, `OPENIPC.md`.
|
|
|
|
> **Always keep `camera_flash.bin` (your original dump).** It's your restore image.
|
|
|
|
---
|
|
|
|
## 0. Prerequisites (build host, Linux)
|
|
|
|
```sh
|
|
sudo apt install squashfs-tools mtd-utils flashrom # mksquashfs, mkfs.jffs2, flashrom
|
|
```
|
|
Plus your SPI programmer (e.g. CH341A) wired to the ZB25VQ64 chip, or serial/U-Boot access.
|
|
|
|
Everything below runs from the `toolkit/` directory:
|
|
```sh
|
|
cd toolkit
|
|
./fetch-deps.sh && ./build-deps.sh # third-party inputs + our tools (once)
|
|
./split.sh ../camera_flash.bin parts/stock # your dump -> partitions
|
|
```
|
|
|
|
---
|
|
|
|
## 1. Pick an image and build it
|
|
|
|
All three keep stock U-Boot/kernel and give a root shell (telnet :23 + serial). They differ
|
|
in what else they do:
|
|
|
|
| Image | What it is | Layout |
|
|
|---|---|---|
|
|
| `camera_flash_telnet.bin` | Tuya intact-ish, adds telnet+wifi+overlay | stock (no repartition) |
|
|
| `camera_flash_local.bin` | **Tuya removed** + 2.9M writable DATA | repartitioned |
|
|
| `camera_flash_rtsp.bin` | Tuya removed + **RTSP server** (+ONVIF scaffold) + DATA | repartitioned |
|
|
|
|
Build (bake in your Wi-Fi so it auto-joins):
|
|
```sh
|
|
WIFI_SSID='MyNet' WIFI_PSK='MyPass' ./variants/telnet.sh # -> out/camera_flash_telnet.bin
|
|
WIFI_SSID='MyNet' WIFI_PSK='MyPass' ./variants/local.sh # -> out/camera_flash_local.bin
|
|
WIFI_SSID='MyNet' WIFI_PSK='MyPass' ./variants/rtsp.sh # -> out/camera_flash_rtsp.bin
|
|
```
|
|
`WIFI_SSID` is required (`WIFI_SSID=` = no built-in network). On the rtsp image you change
|
|
Wi-Fi later with `wifi-set`/`camcfg wifi`, or a `wifi.txt` on the SD card (GUIDE.md §7).
|
|
|
|
Rebuild the stock image unchanged (sanity check — reproduces your dump byte-for-byte):
|
|
```sh
|
|
./build-image.sh parts/stock out/stock_rebuilt.bin
|
|
```
|
|
|
|
---
|
|
|
|
## 2. Flash
|
|
|
|
### A. SPI programmer (recommended)
|
|
Chip powered by the programmer, board off, clip on the ZB25VQ64:
|
|
```sh
|
|
flashrom -p ch341a_spi -w out/camera_flash_rtsp.bin # pick your image
|
|
# restore anytime:
|
|
flashrom -p ch341a_spi -w ../camera_flash.bin
|
|
```
|
|
(Adjust `-p` for your programmer. The whole chip is written; only the changed partitions differ.)
|
|
|
|
### B. SD card + U-Boot (no programmer, recommended if no programmer)
|
|
Your U-Boot has `mmc`/`fatload`/`sf`, so it can read the image off a FAT SD card and write it
|
|
to SPI-NOR. Flash **only the changed partitions** (APP + DATA) — this never touches
|
|
U-Boot/env/kernel/rootfs, so it can't brick the bootloader.
|
|
|
|
1. **Prepare the card:** format a (micro)SD as **FAT32**, and copy the staged files from
|
|
`sdcard/` to its root:
|
|
```
|
|
app.bin (the new APP squashfs)
|
|
data.bin (the empty writable DATA)
|
|
```
|
|
2. **At the `=>` prompt** (Ctrl+C at power-on), insert the card and run:
|
|
```
|
|
mmc dev 0
|
|
fatls mmc 0 # confirm app.bin / data.bin are listed
|
|
sf probe
|
|
|
|
fatload mmc 0 ${loadaddr} app.bin
|
|
sf erase 0x300000 0x2e0000
|
|
sf write ${loadaddr} 0x300000 ${filesize}
|
|
|
|
fatload mmc 0 ${loadaddr} data.bin
|
|
sf erase 0x5e0000 0x220000
|
|
sf write ${loadaddr} 0x5e0000 ${filesize}
|
|
```
|
|
Then do the repartition in step 3 (`setenv mtdparts … ; saveenv ; reset`).
|
|
- `${loadaddr}` is `0x80008000` (already in env). `${filesize}` is set by each `fatload`
|
|
(you should see `2822144` then `2228224` — matching the table above).
|
|
- `mmc dev` takes only the device number — `mmc dev 0`, **not** `mmc dev 0 1` (the second
|
|
arg is an eMMC hw-partition that SD doesn't have, and errors).
|
|
- A FAT-formatted SD is usually a "superfloppy" (no MBR), so address it as **`mmc 0`**
|
|
with no `:part`. If yours has a partition table, use `mmc 0:1`.
|
|
- For the **telnet** image (stock layout) the single changed partition is APP at
|
|
`0x300000`, slot `0x500000` — `sf erase 0x300000 0x500000` then write `app.bin`; no repartition.
|
|
|
|
**Full-chip from SD (optional, riskier):** `fatload mmc 0:1 ${loadaddr} full.bin; sf probe; sf erase 0 0x800000; sf write ${loadaddr} 0 0x800000` — this also rewrites U-Boot/env, so a bad write/power loss can brick it. Prefer the partition method above.
|
|
|
|
### C. Serial / U-Boot — write a partition via Y-modem (no SD, no programmer)
|
|
At the `=>` prompt (≈8 min for a ~2.7 MB APP at 115200). Send the part file from your terminal:
|
|
```
|
|
loady 0x80008000 # then send toolkit/parts/rtsp/app.bin (Y-modem)
|
|
sf probe
|
|
sf erase 0x300000 0x2e0000
|
|
sf write 0x80008000 0x300000 ${filesize}
|
|
reset
|
|
```
|
|
Repeat for `data.bin` at its offset. (U-Boot TFTP needs an Ethernet PHY — this is a Wi-Fi
|
|
model, so use SD, Y-modem, or the programmer.)
|
|
|
|
---
|
|
|
|
## 3. One-time repartition (only for `local` / `rtsp` images)
|
|
|
|
The DTB has no partition table — the kernel gets partitions from the U-Boot `mtdparts` env.
|
|
After flashing a repartitioned image, break to `=>` and run **once**, then `reset`:
|
|
|
|
**local image:**
|
|
```
|
|
setenv mtdparts 'mtdparts=spi-nor:200k@0x0(UBOOT),4k@0x32000(ENV),4k@0x33000(ENVBK),64k@0x34000(DTB),1536k@0x44000(KERNEL),1008k@0x1c4000(ROOTFS),256k@0x2c0000(CONFIG),2176k@0x300000(APP),2944k@0x520000(DATA)'
|
|
saveenv
|
|
reset
|
|
```
|
|
**rtsp image:**
|
|
```
|
|
setenv mtdparts 'mtdparts=spi-nor:200k@0x0(UBOOT),4k@0x32000(ENV),4k@0x33000(ENVBK),64k@0x34000(DTB),1536k@0x44000(KERNEL),1008k@0x1c4000(ROOTFS),256k@0x2c0000(CONFIG),2944k@0x300000(APP),2176k@0x5e0000(DATA)'
|
|
saveenv
|
|
reset
|
|
```
|
|
`boot_normal` rebuilds `bootargs` from `${mtdparts}` every boot, so that's all it takes.
|
|
DATA then appears as `mtd8` (`/dev/mtdblock8`). Reversible: `setenv` it back, or restore the dump.
|
|
(The `telnet` image uses the stock layout — skip this step.)
|
|
|
|
---
|
|
|
|
## 4. First boot / get in
|
|
|
|
- The camera joins your Wi-Fi and starts **telnet** (passwordless root) on port 23, plus a
|
|
root shell on the serial console.
|
|
```sh
|
|
telnet <camera-ip>
|
|
cat /tmp/local_bootstrap.log # wifi/overlay/service startup
|
|
```
|
|
- Make any file editable+persistent: `rw /path/to/file` (backed by DATA/overlay).
|
|
- ⚠️ No watchdog is petted (Tuya service removed). If the board resets ~1 min into boot, add
|
|
`[ -e /dev/watchdog ] && watchdog -t 5 /dev/watchdog` early in `local_bootstrap.sh` and rebuild.
|
|
|
|
---
|
|
|
|
## 5. RTSP (rtsp image only)
|
|
|
|
Starts automatically. H.264, port 554:
|
|
```
|
|
rtsp://<camera-ip>/vs0 # main 1920x1080
|
|
rtsp://<camera-ip>/vs1 # sub 640x360
|
|
```
|
|
View: `ffplay rtsp://<camera-ip>/vs0`. Check `cat /tmp/rtsp.log` if no stream.
|
|
**Status: assembled from the public Anyka SDK, ABI-matched, not yet hardware-tested** — see
|
|
`RTSP.md` for validation (venc/lib version match, ISP config).
|
|
|
|
---
|
|
|
|
## 6. ONVIF (rtsp image only) — build + install the two binaries
|
|
|
|
Config + web/discovery wiring + autostart are already baked in; you supply the binaries.
|
|
|
|
**Build** (static, so libc doesn't matter):
|
|
```sh
|
|
git clone https://github.com/roleoroleo/onvif_simple_server && cd onvif_simple_server
|
|
export CC=<arm-cross>-gcc # OpenIPC arm-openipc-linux-musleabi-gcc, or the Anyka toolchain
|
|
make -f Makefile.static CC=$CC HAVE_MBEDTLS=y \
|
|
INCLUDE="-I<deps>/include" LIBS_O="-L<deps>/lib -lmbedcrypto -ljson-c -lz -lpthread -lrt"
|
|
# outputs: onvif_simple_server wsd_simple_server onvif_notify_server
|
|
```
|
|
(Or lift prebuilt ARM `onvif_simple_server`/`wsd_simple_server` from an OpenIPC/thingino rootfs.)
|
|
|
|
**Install** on the camera (over telnet):
|
|
```sh
|
|
mkdir -p /data/onvif/wsd_files
|
|
# copy from your build host into /data/onvif/ :
|
|
# onvif_simple_server wsd_simple_server wsd_files/* (+ any *_service_files)
|
|
chmod +x /data/onvif/onvif_simple_server /data/onvif/wsd_simple_server
|
|
sh /usr/local/onvif/start_onvif.sh # or reboot — it auto-starts when binaries exist
|
|
```
|
|
ONVIF is then discoverable at `http://<ip>:8080/cgi-bin/device_service`; add it in
|
|
Frigate / Home Assistant / ONVIF Device Manager. Details and gotchas: `RTSP.md`.
|
|
|
|
---
|
|
|
|
## 7. Recovery
|
|
|
|
```sh
|
|
flashrom -p ch341a_spi -w ../camera_flash.bin
|
|
```
|
|
As long as UBOOT/ENV are intact you also have the `=>` prompt on serial to re-flash via
|
|
Y-modem (step 2B). This is why the images never touch UBOOT/ENV/DTB/kernel.
|