Docs: install guide and image audit
GUIDE.md: step-by-step for others (compatibility check, backup, build, four install methods, settings, recording, Wi-Fi, updates, restore, troubleshooting). IMAGE_CONTENTS.md: partition-by-partition audit of what the build changes and where every input comes from. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
No files matched your search
@@ -0,0 +1,386 @@
|
|||||||
|
# Guide: local RTSP firmware for AK3918AV130 / SC3332 Tuya cameras
|
||||||
|
|
||||||
|
This turns a cheap Tuya "2K" Wi-Fi camera into a **local-only** camera: no cloud and no app.
|
||||||
|
You get a password-protected RTSP stream at the sensor's full 2304×1296, continuous and
|
||||||
|
motion recording to the SD card, SSH access,
|
||||||
|
Wi-Fi settings you can change without reflashing, and firmware updates over Wi-Fi or from an
|
||||||
|
SD card.
|
||||||
|
|
||||||
|
You may not have to open the camera at all: a stock camera can be installed from the SD card
|
||||||
|
alone (§5a). Otherwise you open it **once**, for the first install. After that, every update and
|
||||||
|
recovery happens over Wi-Fi or the SD card slot.
|
||||||
|
|
||||||
|
> **Status:** RTSP, Wi-Fi, SSH and repartitioning are confirmed on hardware. Full resolution
|
||||||
|
> (24 MB ION heap), RTSP auth, over-the-air updates, the SD updater, `wifi-set`/`wifi.txt` and
|
||||||
|
> SD recording are built but not yet confirmed on a device. The recorder's file writing,
|
||||||
|
> rotation, size limits and motion pre-roll were checked in a host simulation (all output
|
||||||
|
> decodes with ffmpeg). Motion detection itself only runs on the camera. Report back if you try them.
|
||||||
|
> What's in the image, file by file: [IMAGE_CONTENTS.md](IMAGE_CONTENTS.md).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 0. Does this apply to my camera?
|
||||||
|
|
||||||
|
All of the following must be true. Check them in the serial boot log (§2):
|
||||||
|
|
||||||
|
| Check | Expected |
|
||||||
|
|---|---|
|
||||||
|
| U-Boot banner | `U-Boot 2019.10.0-V4.0.27`, `Model: EVB_CBD_AK3918AV130` |
|
||||||
|
| Flash | `SF: Detected ZB25VQ64 … total 8 MiB` |
|
||||||
|
| RAM | `DRAM: 64 MiB` |
|
||||||
|
| Kernel | `Linux version 4.4.302-cip94` |
|
||||||
|
| Sensor | `sc3332 Probed success` |
|
||||||
|
| Wi-Fi | ATBM6x6x (USB) |
|
||||||
|
|
||||||
|
A different sensor, flash size or kernel means **stop**. The modules and libraries won't
|
||||||
|
match.
|
||||||
|
|
||||||
|
## 1. What you need
|
||||||
|
|
||||||
|
- A Linux PC with `squashfs-tools`, `mtd-utils`, `device-tree-compiler` (`fdtput`/`fdtdump`),
|
||||||
|
`openssl`, `python3`. Add `flashrom` if you use a programmer.
|
||||||
|
- A **3.3 V USB-serial adapter** (no 5 V!), connected to the board's TX/RX/GND pads at 115200 8N1.
|
||||||
|
Needed for the first install.
|
||||||
|
- *Optional:* a CH341A programmer with a SOIC-8 clip, for the easiest backup and restore.
|
||||||
|
- A microSD card, **FAT32**.
|
||||||
|
- This repository (the `toolkit/` directory).
|
||||||
|
|
||||||
|
## 2. Open it, connect serial, stop U-Boot
|
||||||
|
|
||||||
|
1. Open the case and find the UART pads (usually labelled TX/RX/GND near the SoC).
|
||||||
|
Connect adapter RX→board TX and TX→board RX, plus GND. **Don't connect VCC.**
|
||||||
|
2. `picocom -b 115200 /dev/ttyUSB0` (or screen or minicom), then power the camera.
|
||||||
|
3. Press **Ctrl+C** repeatedly while it boots until you get the `=>` prompt.
|
||||||
|
4. Run `printenv` and save the output. You'll want your original `mtdparts` and `bootcmd`.
|
||||||
|
|
||||||
|
## 3. Back up your flash (mandatory)
|
||||||
|
|
||||||
|
Your backup is the only way back to stock, and the build uses **your own** device-specific
|
||||||
|
partitions (Tuya keys, MAC address). Never use someone else's dump.
|
||||||
|
|
||||||
|
**With a programmer** (camera unpowered, clip on the flash chip):
|
||||||
|
```sh
|
||||||
|
flashrom -p ch341a_spi -r dump1.bin
|
||||||
|
flashrom -p ch341a_spi -r dump2.bin
|
||||||
|
cmp dump1.bin dump2.bin && cp dump1.bin camera_flash.bin # the two reads must be identical
|
||||||
|
```
|
||||||
|
|
||||||
|
**Without a programmer:** boot to a root shell over serial (README.md §2: `init=/bin/sh`
|
||||||
|
plus the mounts shown there), then copy every partition to the SD card:
|
||||||
|
```sh
|
||||||
|
insmod /usr/modules/mmc_core.ko; insmod /usr/modules/mmc_block.ko; insmod /usr/modules/ak_mci.ko
|
||||||
|
mount -t vfat /dev/mmcblk0p1 /mnt || mount -t vfat /dev/mmcblk0 /mnt
|
||||||
|
for i in 0 1 2 3 4 5 6 7; do cat /dev/mtd$i > /mnt/mtd$i.bin; done; sync; umount /mnt
|
||||||
|
```
|
||||||
|
On the PC, join them in order: `cat mtd0.bin mtd1.bin … mtd7.bin > camera_flash.bin`.
|
||||||
|
The result must be exactly 8388608 bytes.
|
||||||
|
|
||||||
|
Keep `camera_flash.bin` somewhere safe.
|
||||||
|
|
||||||
|
## 4. Build your image
|
||||||
|
|
||||||
|
```sh
|
||||||
|
cd toolkit
|
||||||
|
./fetch-deps.sh # once: SDK libs, OpenIPC modules, toolchains
|
||||||
|
./build-deps.sh # once: mtdflash, dropbear, RTSP server (from source)
|
||||||
|
./split.sh ../camera_flash.bin parts/stock # carve your dump into partitions
|
||||||
|
|
||||||
|
WIFI_SSID='YourNetwork' WIFI_PSK='YourWifiPassword' \
|
||||||
|
ROOT_PW='choose-a-root-password' RTSP_PASS='choose-a-stream-password' \
|
||||||
|
./variants/rtsp.sh
|
||||||
|
```
|
||||||
|
- Output, collected in `sdcard/` next to `toolkit/` (`STAGE_DIR=` to change). Every build
|
||||||
|
refreshes all of them:
|
||||||
|
- `full.bin`: the whole 8 MiB chip
|
||||||
|
- `app.bin`, `dtb.bin`, `data.bin`, `env.bin`, `MD5SUMS`: single partitions
|
||||||
|
- `sd-install-backup/`, `sd-install-direct/`: SD-card-only installs for stock cameras (§5a)
|
||||||
|
- `full.bin` already has the right U-Boot settings (partition layout + SD-update `bootcmd`)
|
||||||
|
baked in, so flashing it whole needs no typing at the U-Boot prompt.
|
||||||
|
- To leave Wi-Fi out of the image and set it from the SD card instead, use `WIFI_SSID=`
|
||||||
|
(empty) and see §7.
|
||||||
|
- All build settings are listed in IMAGE_CONTENTS.md §8. Almost all of them can be changed
|
||||||
|
later over SSH with `camcfg` (§6b), without rebuilding.
|
||||||
|
- **These files contain your passwords and your camera's keys. Don't share them.**
|
||||||
|
|
||||||
|
## 5. First install
|
||||||
|
|
||||||
|
Pick one. All of them end in the same firmware and layout.
|
||||||
|
|
||||||
|
| Method | Needs | Writes | Backup of the original | Section |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| Programmer | CH341A + clip | whole chip (`full.bin`) | your own dump (§3) | §5 |
|
||||||
|
| Serial + SD | UART adapter, SD card | DTB, APP, DATA + U-Boot settings typed by hand | your own dump (§3) | §5 |
|
||||||
|
| **SD only, with backup** | SD card | U-Boot writes an installer, which dumps the full 8 MiB to the card, then installs | **full 8 MiB, made automatically** | §5a |
|
||||||
|
| **SD only, direct** | SD card | U-Boot writes APP+DATA itself; first boot writes DTB + settings | everything except the original APP | §5a |
|
||||||
|
|
||||||
|
**Already installed?** Use updates (§8), never an install method again: they reset DATA.
|
||||||
|
|
||||||
|
**With a programmer** it's one command, with no serial and no U-Boot typing:
|
||||||
|
```sh
|
||||||
|
flashrom -p ch341a_spi -w sdcard/full.bin
|
||||||
|
```
|
||||||
|
`full.bin` also resets DATA to empty. That doesn't matter on a first install, but don't use it
|
||||||
|
later just to update: your `camcfg` settings and SSH host keys live there. Use §8 instead.
|
||||||
|
|
||||||
|
**Without a programmer:** copy `app.bin`, `data.bin` and `dtb.bin` from `sdcard/` to the root of
|
||||||
|
the FAT32 card. Insert it, power on, stop at `=>` (Ctrl+C), then:
|
||||||
|
|
||||||
|
```
|
||||||
|
mmc dev 0
|
||||||
|
fatls mmc 0
|
||||||
|
sf probe 0
|
||||||
|
|
||||||
|
fatload mmc 0 ${loadaddr} dtb.bin
|
||||||
|
sf erase 0x34000 0x10000
|
||||||
|
sf write ${loadaddr} 0x34000 ${filesize}
|
||||||
|
|
||||||
|
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}
|
||||||
|
|
||||||
|
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)'
|
||||||
|
setenv sdscript version
|
||||||
|
setenv bootcmd 'mmc dev 0; mw.b ${loadaddr} 0 0x1000; fatload mmc 0 ${loadaddr} camupdate.env; env import -t ${loadaddr} 0x1000; run sdscript; setenv sdscript version; run boot_normal'
|
||||||
|
saveenv
|
||||||
|
reset
|
||||||
|
```
|
||||||
|
Notes:
|
||||||
|
- If `fatls mmc 0` shows nothing, the card has a partition table. Use `mmc 0:1` everywhere.
|
||||||
|
- The new `bootcmd` checks the SD card for an update file before every boot. That's what
|
||||||
|
makes recovery possible later without serial (§8). With no card, or no file, it just boots.
|
||||||
|
- Writing only DTB, APP and DATA never touches U-Boot, so U-Boot always stays reachable.
|
||||||
|
|
||||||
|
**Check it worked:** watch the serial log. The camera should join Wi-Fi and print its IP.
|
||||||
|
You can also get a shell on the serial console and run `cat /tmp/local_bootstrap.log`.
|
||||||
|
You can close the case now.
|
||||||
|
|
||||||
|
## 5a. Install with only an SD card (stock camera, no opening, no serial)
|
||||||
|
|
||||||
|
The stock U-Boot has a hidden factory-recovery feature. At every power-on it looks for
|
||||||
|
`ht_recover_fw.conf` on a **FAT32** SD card. If the file is valid and its build id is new, it
|
||||||
|
writes the firmware next to it into flash, then boots. The build makes two ready-to-copy sets:
|
||||||
|
|
||||||
|
| | `sd-install-backup/` (recommended) | `sd-install-direct/` |
|
||||||
|
|---|---|---|
|
||||||
|
| U-Boot writes | a temporary installer rootfs (1 MiB) | the final APP + DATA (5 MiB) |
|
||||||
|
| Then | the installer, with the original APP still intact, **dumps all 8 MiB to the card**, then writes APP+DATA, DTB, the stock rootfs and the U-Boot settings, and reboots | the new firmware's first boot backs up the rest, writes DTB + U-Boot settings, and reboots |
|
||||||
|
| Backup on the card | `original-backup/full.bin`: the **complete chip**; restore stock with `flashrom -w full.bin` | partitions except APP (the Tuya firmware is gone) |
|
||||||
|
| Most of the work done by | Linux (our installer) | U-Boot itself (fewest steps outside U-Boot) |
|
||||||
|
|
||||||
|
**Steps (both):**
|
||||||
|
1. Format a microSD card as **FAT32**. Copy the **contents** of the chosen folder to its root.
|
||||||
|
For the backup variant that's `ht_recover_fw.conf`, `root.sqsh4` and the `camerarev/` folder;
|
||||||
|
for direct, `ht_recover_fw.conf` and `usr.sqsh4`. Card size: at least 64 MB (the backup
|
||||||
|
needs 8 MiB). Optional: add a `wifi.txt` (§7).
|
||||||
|
2. Insert it into the powered-off camera and power on. **Wait about 5 minutes** without
|
||||||
|
cutting power. The camera reboots by itself when done.
|
||||||
|
3. Find it in your router's DHCP list and continue with §6. Keep the card's
|
||||||
|
`original-backup/` folder somewhere safe: it has your camera's keys.
|
||||||
|
|
||||||
|
**What to expect in detail (backup variant):** about 20 s of U-Boot writing, then the installer:
|
||||||
|
- **backup:** about 30 s; writes `original-backup/` with MD5SUMS and a README
|
||||||
|
- **check:** verifies `camerarev/MD5SUMS` and copies everything to RAM
|
||||||
|
- **write:** about 2 minutes of flash writes, then a reboot
|
||||||
|
|
||||||
|
The log is in `camerarev-install.log` on the card. If anything is wrong (card not FAT32, a corrupt
|
||||||
|
file), it stops **before writing anything** and the camera stays stock. Fix the card and
|
||||||
|
power-cycle to retry.
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
- **Power loss:** at any point before the very last step (the U-Boot settings), the next
|
||||||
|
power-on simply runs the install again. An existing backup is kept, never overwritten.
|
||||||
|
- **Leaving the card in is harmless:** the install saves its build id, so U-Boot skips it from
|
||||||
|
then on.
|
||||||
|
- **Don't reuse an install set:** don't put a newer `sd-install-*` set on an installed camera.
|
||||||
|
It would reinstall and **reset DATA**. For updates use §8.
|
||||||
|
- **Which dump the build needs:** a dump of this camera model (§3–§4): yours, or one you
|
||||||
|
trust from an identical camera.
|
||||||
|
- Neither variant ever writes U-Boot, the kernel or CONFIG, so your device keys stay.
|
||||||
|
- The U-Boot settings come from the dump the build used (its unused MAC address included).
|
||||||
|
- The backup variant writes back the stock rootfs from that dump. Its `README.txt` says
|
||||||
|
whether your U-Boot and kernel are identical to that dump, which tells you the rootfs in
|
||||||
|
`full.bin` matches yours too.
|
||||||
|
- **Check the model first:** see §0. Without serial you can't see the boot log, so you're
|
||||||
|
relying on the camera being the same model and firmware as the dump.
|
||||||
|
|
||||||
|
## 6. Using the camera
|
||||||
|
|
||||||
|
| What | How |
|
||||||
|
|---|---|
|
||||||
|
| Main stream (2304×1296) | `rtsp://admin:<RTSP_PASS>@<camera-ip>/vs0` |
|
||||||
|
| Substream (640×360) | `rtsp://admin:<RTSP_PASS>@<camera-ip>/vs1` |
|
||||||
|
| Shell | `ssh root@<camera-ip>` (password `ROOT_PW`) |
|
||||||
|
| Change any setting | `camcfg` (§6b) |
|
||||||
|
| Status at a glance | `camcfg status` |
|
||||||
|
| Change root password | `camcfg password` (or `passwd`) |
|
||||||
|
| Restart the stream | `camcfg apply`, or `killall ak_rtsp_server_sample` (it restarts in 5 s) |
|
||||||
|
| Edit any other read-only file permanently | `rw /path/to/file`, then edit it, then `reboot` |
|
||||||
|
| Logs | `/tmp/local_bootstrap.log`, `/tmp/rtsp.log` |
|
||||||
|
|
||||||
|
VLC, ffmpeg, Frigate, Home Assistant, Blue Iris and similar tools all work with these URLs.
|
||||||
|
Find the IP in your router's DHCP list.
|
||||||
|
|
||||||
|
## 6b. Settings: `camcfg`
|
||||||
|
|
||||||
|
`camcfg` changes every setting over SSH: streams, login, recording, time and Wi-Fi. It checks
|
||||||
|
every value before saving, applies the change (the stream restarts in about 5–10 s), and keeps
|
||||||
|
ONVIF in sync. Your changes are stored **separately** from the firmware defaults
|
||||||
|
(`/data/camcfg.conf`), so they survive reboots **and firmware updates**, and new defaults from an
|
||||||
|
update still apply to everything you didn't change.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
camcfg show # everything; * marks what you changed
|
||||||
|
camcfg show record # one section
|
||||||
|
camcfg get main.bitrate
|
||||||
|
camcfg set main.bitrate=6000 # several at once is fine:
|
||||||
|
camcfg set main.codec=h265 main.bitrate=4500 main.resolution=2304x1296
|
||||||
|
camcfg set rtsp.password=NewStreamPass
|
||||||
|
camcfg set record.continuous_percent=60 record.motion_percent=35
|
||||||
|
camcfg set system.timezone=CET-1CEST,M3.5.0,M10.5.0/3
|
||||||
|
camcfg unset main.bitrate # back to the firmware default
|
||||||
|
camcfg reset # drop all your changes
|
||||||
|
camcfg keys # every key and its allowed values
|
||||||
|
camcfg export # your changes as text (no password)
|
||||||
|
camcfg wifi "Network" "Password" now # = wifi-set (§7)
|
||||||
|
camcfg status # IP, Wi-Fi signal, stream, recorder, SD usage
|
||||||
|
```
|
||||||
|
Add `-n` after the command (`camcfg set -n …`) to save without restarting the stream.
|
||||||
|
If any value is invalid, nothing is saved.
|
||||||
|
|
||||||
|
To copy settings to another camera:
|
||||||
|
`ssh root@cam1 camcfg export | grep -v '^#' | xargs ssh root@cam2 camcfg set`.
|
||||||
|
|
||||||
|
| Key | Values | Default |
|
||||||
|
|---|---|---|
|
||||||
|
| `main.codec` / `sub.codec` | `h264`, `h265` (both supported by the hardware; check your player handles H.265) | h264 |
|
||||||
|
| `main.resolution` / `sub.resolution` | `WxH`, multiples of 8, max 2304x1296 / 1280x720 | 2304x1296 / 640x360 |
|
||||||
|
| `main.bitrate` / `sub.bitrate` | kbps, 256–16000 / 64–4000 | 8000 / 400 |
|
||||||
|
| `main.fps` / `sub.fps` | 1–25 (the stock ISP tuning caps it at 15) | 15 |
|
||||||
|
| `main.level` / `sub.level` | encoder level 10–62 (50 = 5.0) | 50 / 30 |
|
||||||
|
| `rtsp.user`, `rtsp.password` | stream and ONVIF login; empty user = no authentication | admin / root password at build |
|
||||||
|
| `rtsp.port` | 1–65535 | 554 |
|
||||||
|
| `audio.code_type`, `audio.sample_rate` | `aac`/`g711a`/`g711u`, `8000`/`16000` | aac, 16000 |
|
||||||
|
| `record.*` | all recording keys from §6a | see §6a |
|
||||||
|
| `system.timezone` | POSIX TZ: `UTC0`, `CET-1CEST,M3.5.0,M10.5.0/3`, `EST5EDT,M3.2.0,M11.1.0`, … | UTC0 |
|
||||||
|
| `system.ntp` | NTP server | pool.ntp.org |
|
||||||
|
|
||||||
|
`main.*` is short for `video0.*` and `sub.*` for `video1.*`; `bitrate`, `codec`, `level` are
|
||||||
|
short for `target_kbps`, `code_type`, `enc_level`. The full names work too
|
||||||
|
(`camcfg set video0.target_kbps=6000`).
|
||||||
|
|
||||||
|
Rough guide for the main stream: H.264 6–8 Mbps, or H.265 4–5 Mbps, for good detail.
|
||||||
|
Each viewer uses that much Wi-Fi.
|
||||||
|
|
||||||
|
## 6a. Recording to the SD card
|
||||||
|
|
||||||
|
With a FAT32 or exFAT card inserted, the camera records by default in two loops that share
|
||||||
|
the card:
|
||||||
|
|
||||||
|
| Folder | What | Default share of the card |
|
||||||
|
|---|---|---|
|
||||||
|
| `rec/continuous/YYYYMMDD/HHMMSS.ts` | everything, 1-minute files; oldest deleted when full | 70% |
|
||||||
|
| `rec/motion/YYYYMMDD/HHMMSS.ts` | motion clips, starting 5 s before the motion and ending 10 s after it | 25% |
|
||||||
|
|
||||||
|
At least 200 MB always stays free. Files are MPEG-TS: VLC plays them directly, and
|
||||||
|
`ffmpeg -i x.ts -c copy x.mp4` converts one without re-encoding. Copy them off with
|
||||||
|
`scp root@<ip>:/mnt/sd/rec/motion/…` or by reading the card on a PC.
|
||||||
|
|
||||||
|
**Settings:** `camcfg set record.KEY=VALUE`, e.g.
|
||||||
|
`camcfg set record.mode=motion record.motion_sensitivity=70` (§6b).
|
||||||
|
|
||||||
|
| Key (`record.…`) | Meaning |
|
||||||
|
|---|---|
|
||||||
|
| `mode` | `off`, `continuous`, `motion` or `both` |
|
||||||
|
| `stream` | `0` main (2304×1296, ~3.6 GB/hour at 8 Mbps H.264, ~2 GB/hour at 4.5 Mbps H.265), `1` substream (much smaller) |
|
||||||
|
| `continuous_percent`, `motion_percent` | **the split**: share of the card each loop may use |
|
||||||
|
| `continuous_max_mb`, `motion_max_mb` | fixed sizes instead (if > 0 they override the percent) |
|
||||||
|
| `continuous_path`, `motion_path` | where each loop writes. For two real partitions, create a 2nd partition on the card (mounted at `/mnt/sd2`) and set `motion_path = /mnt/sd2/motion` |
|
||||||
|
| `min_free_mb` | free space always kept |
|
||||||
|
| `segment_seconds` | length of continuous files |
|
||||||
|
| `motion_pre_seconds`, `motion_post_seconds`, `motion_clip_max_seconds` | how much before and after the motion each clip covers, and maximum clip length |
|
||||||
|
| `motion_sensitivity` | 0–100 (higher = more sensitive) |
|
||||||
|
| `motion_threshold`, `motion_min_cells`, `motion_trigger_frames` | fine tuning: per-cell level, how many of the 32×24 grid cells must move, for how many checks in a row (10 checks per second) |
|
||||||
|
| `motion_debug` | `1` logs the motion level every second in `/tmp/rtsp.log`, for tuning |
|
||||||
|
| `motion_hook` | a script called with `start`/`stop` on motion (default `/data/motion_hook.sh`, if it exists). Use it for MQTT or a webhook |
|
||||||
|
|
||||||
|
The current motion state is also in `/tmp/motion` (`1 <time>` or `0 <time>`).
|
||||||
|
Build-time defaults: `REC_MODE`, `REC_STREAM`, `REC_CONT_PERCENT`, `REC_MOTION_PERCENT`.
|
||||||
|
|
||||||
|
**Clock:** recordings are named by date and time. The camera syncs time with NTP
|
||||||
|
(`camcfg set system.ntp=…`, default `pool.ntp.org`). The timezone is UTC unless you set it with
|
||||||
|
`camcfg set system.timezone=CET-1CEST,M3.5.0,M10.5.0/3`, or build with `TIMEZONE=…`.
|
||||||
|
|
||||||
|
Not recorded yet: audio.
|
||||||
|
|
||||||
|
## 7. Change Wi-Fi without reflashing
|
||||||
|
|
||||||
|
**Over SSH** (while the camera is still online):
|
||||||
|
```sh
|
||||||
|
wifi-set "NewNetwork" "NewPassword" # used from the next boot
|
||||||
|
wifi-set "NewNetwork" "NewPassword" now # switch now (your SSH session will drop)
|
||||||
|
wifi-set --show # what's configured / connected
|
||||||
|
```
|
||||||
|
If the new network doesn't connect within about 40 s, the camera switches back to the
|
||||||
|
previous one. At boot it tries the new network, then the previous one, then the network
|
||||||
|
built into the image.
|
||||||
|
|
||||||
|
**From the SD card** (camera offline, new router, or no Wi-Fi was built in): create a file
|
||||||
|
`wifi.txt` on the card:
|
||||||
|
```
|
||||||
|
SSID=NewNetwork
|
||||||
|
PASSWORD=NewPassword
|
||||||
|
```
|
||||||
|
Insert the card and power-cycle. The camera saves the network, **deletes `wifi.txt`** (so the
|
||||||
|
password doesn't stay on the card) and leaves a `wifi.txt.applied` note.
|
||||||
|
|
||||||
|
## 8. Updating firmware (no serial)
|
||||||
|
|
||||||
|
**Over Wi-Fi** (normal case): rebuild (§4), then from `toolkit/`:
|
||||||
|
```sh
|
||||||
|
./ota.sh <camera-ip> parts/rtsp/app.bin # add parts/rtsp/dtb.bin etc. if changed
|
||||||
|
```
|
||||||
|
It uploads to the camera's RAM, checks the md5, and writes with read-back verification of
|
||||||
|
every block. Then it reboots. It only writes blocks that changed, and it refuses to touch
|
||||||
|
U-Boot.
|
||||||
|
|
||||||
|
**From the SD card** (if Linux no longer boots, e.g. after a bad APP):
|
||||||
|
```sh
|
||||||
|
./make-sd-update.sh /path/to/mounted/sdcard parts/rtsp/app.bin parts/rtsp/dtb.bin
|
||||||
|
```
|
||||||
|
Insert the card and power on. U-Boot flashes the images before Linux starts. After a good
|
||||||
|
boot, Linux renames `camupdate.env` to `camupdate.done` so the update doesn't run again.
|
||||||
|
The first install (§5) must have set the new `bootcmd`.
|
||||||
|
|
||||||
|
## 9. Restore stock
|
||||||
|
|
||||||
|
- **Programmer:** `flashrom -p ch341a_spi -w camera_flash.bin`
|
||||||
|
- **Serial + SD:** copy your `camera_flash.bin` to the card. At `=>`:
|
||||||
|
`mmc dev 0; fatload mmc 0 ${loadaddr} camera_flash.bin; sf probe 0; sf erase 0 0x800000; sf write ${loadaddr} 0 0x800000; reset`.
|
||||||
|
This rewrites U-Boot too, so don't cut power during it.
|
||||||
|
|
||||||
|
## 10. Troubleshooting
|
||||||
|
|
||||||
|
| Symptom | Cause / fix |
|
||||||
|
|---|---|
|
||||||
|
| `Venc [0] Create DMA Pool failed` in `/tmp/rtsp.log` | The DTB with the 24 MB heap isn't flashed. Flash `dtb.bin`, or lower `[video0]` to 1920×1080 |
|
||||||
|
| `venc_adaper_ioctl … not found` | The stock venc module is loaded; APP from this build is missing |
|
||||||
|
| `wlan0` missing | Wi-Fi modules failed to load (check `/tmp/local_bootstrap.log`) |
|
||||||
|
| Camera never joins Wi-Fi | Use SD `wifi.txt` (§7). 2.4 GHz only; password must be 8–63 characters |
|
||||||
|
| Stream asks for a password you don't know | `camcfg set rtsp.password=…` over SSH (or rebuild with `RTSP_PASS`) |
|
||||||
|
| Frame rate stuck at 15 | The stock ISP tuning caps it (IMAGE_CONTENTS.md §7) |
|
||||||
|
| Nothing recorded | Card must be FAT32/exFAT. `grep record /tmp/rtsp.log`. The recorder refuses to write anywhere that isn't the card |
|
||||||
|
| Too many or too few motion clips | `camcfg set record.motion_debug=1`, watch the levels with `tail -f /tmp/rtsp.log`, then adjust `record.motion_sensitivity` or `record.motion_threshold`/`record.motion_min_cells` (and set `motion_debug=0` again) |
|
||||||
|
| `SD too slow: queue full` in the log | Use a faster card (U1/V10 or better), or record the substream |
|
||||||
|
| Recording times are wrong | No NTP yet (no internet?), or set the timezone (§6a) |
|
||||||
|
| SSH unreachable and Wi-Fi fine | Serial shell → `cat /tmp/local_bootstrap.log`; or SD update (§8) |
|
||||||
|
| Bad settings, stream won't start | `camcfg reset` (or `camcfg unset KEY`); check `/tmp/rtsp.log` |
|
||||||
|
| Boot loops after an update | SD update with known-good images (§8); last resort: serial + §5 |
|
||||||
|
|
||||||
|
## Credits
|
||||||
|
|
||||||
|
The Anyka SDK runtime and RTSP sample come from the public `Link-WQS/ANYKA_130L_SDK`. The
|
||||||
|
venc kernel modules come from OpenIPC `anyka-osdrv`. Bootlin toolchains; dropbear.
|
||||||
@@ -0,0 +1,265 @@
|
|||||||
|
# What the RTSP image contains: partition-by-partition audit
|
||||||
|
|
||||||
|
This lists everything `toolkit/variants/rtsp.sh` puts into `out/camera_flash_rtsp.bin`:
|
||||||
|
what was kept from stock, what was removed or added, where each added file comes from,
|
||||||
|
and how the camera boots. It was checked against the build output (stock APP compared with
|
||||||
|
the built APP, and every other partition `cmp`'d against stock).
|
||||||
|
|
||||||
|
> **Status:** the RTSP stream, Wi-Fi, SSH and repartitioning are confirmed working on hardware.
|
||||||
|
> These features are built but **not yet tested on the device**: 2304×1296 with the 24 MB
|
||||||
|
> ION heap, RTSP Digest auth, `fwupdate`/`ota.sh`, the U-Boot SD updater, `wifi-set`,
|
||||||
|
> `wifi.txt` and SD recording. The recorder's muxer, rotation, size limits and pre-roll were
|
||||||
|
> verified in a host simulation.
|
||||||
|
|
||||||
|
## 1. Partition map (8 MiB SPI-NOR, ZB25VQ64)
|
||||||
|
|
||||||
|
| Partition | Offset | Size | Contents | vs. stock |
|
||||||
|
|---|---|---|---|---|
|
||||||
|
| UBOOT | 0x000000 | 200K | U-Boot 2019.10 (Anyka V4.0.27) | **identical** |
|
||||||
|
| ENV | 0x032000 | 4K | U-Boot environment | **4 variables changed** in the full image: `mtdparts` (this layout), `bootcmd` (SD updater), `sdscript`, `ht_fw_version` (build id, see SD-only install). Everything else, e.g. `ethaddr`, is kept from your dump. Partition flashing never writes ENV; there you set the same values by hand once |
|
||||||
|
| ENVBK | 0x033000 | 4K | vendor env backup | same as ENV |
|
||||||
|
| DTB | 0x034000 | 64K | device tree | **modified**: ION heap 18 MB → 24 MB (see §3) |
|
||||||
|
| KERNEL | 0x044000 | 1536K | Linux 4.4.302-cip94 uImage | **identical** |
|
||||||
|
| ROOTFS | 0x1c4000 | 1008K | squashfs `/` (busybox, uClibc-ng 1.0.31, init scripts) | **identical** |
|
||||||
|
| CONFIG | 0x2c0000 | 256K | jffs2 `/etc/config` (per-device data, see §5) | **identical** |
|
||||||
|
| APP | 0x300000 | 2944K (stock: 13312K) | squashfs `/usr` | **rebuilt** (see §4) |
|
||||||
|
| DATA | 0x5e0000 | 2176K | jffs2 `/data`, **new** | new, empty on first flash |
|
||||||
|
|
||||||
|
The DTB has no partition table. The kernel gets the layout from U-Boot's `mtdparts`
|
||||||
|
variable, which is why moving to this layout is a single `setenv mtdparts … ; saveenv`.
|
||||||
|
|
||||||
|
**The rootfs is not modified at all.** Every change is in APP, which `/etc/init.d/rc.local`
|
||||||
|
runs through `/usr/sbin/main.sh`, plus the DTB, four U-Boot variables and the new DATA
|
||||||
|
partition. The env is rewritten by `toolkit/env-patch.py`: it parses the stock env, sets the
|
||||||
|
variables, and recomputes the CRC32.
|
||||||
|
|
||||||
|
**Build outputs** (staged in `sdcard/` on every build): `full.bin` = the whole chip
|
||||||
|
(`out/camera_flash_rtsp.bin`), plus `app.bin`, `dtb.bin`, `data.bin`, `env.bin`,
|
||||||
|
`sd-install-backup/` and `sd-install-direct/` (SD-only installs for stock cameras) and `MD5SUMS`.
|
||||||
|
Writing `full.bin` resets DATA (camcfg settings, SSH host keys, overlay). Restoring the
|
||||||
|
original dump therefore restores the camera completely.
|
||||||
|
|
||||||
|
## 2. Boot flow
|
||||||
|
|
||||||
|
```
|
||||||
|
U-Boot bootcmd
|
||||||
|
├─ (if you set it up) SD card: camupdate.env → `sf update` the listed images
|
||||||
|
└─ boot_normal: kernel + DTB, root=/dev/mtdblock5 (squashfs)
|
||||||
|
rootfs /etc/init.d/rcS → rc.local
|
||||||
|
├─ mounts /usr (APP squashfs), /etc/config (CONFIG jffs2)
|
||||||
|
└─ /usr/sbin/main.sh (stock script; one line changed)
|
||||||
|
├─ syslogd/klogd, RTC, i2c, PWM, ADC, PCM, keys, ION, LEDs
|
||||||
|
├─ mmc + exfat modules, sensor + ISP + venc modules (sensor_driver.sh)
|
||||||
|
└─ /usr/sbin/local_bootstrap.sh & (replaces `service.sh start`, the Tuya launcher)
|
||||||
|
1. mount DATA → /data, bind-mount everything under /data/overlay over / (`rw` helper)
|
||||||
|
2. root shell on the serial console (ttySAK0)
|
||||||
|
3. SD card → /mnt/sd; camupdate.env → camupdate.done; wifi.txt → wifi-set
|
||||||
|
3b. optional 2nd SD partition → /mnt/sd2
|
||||||
|
4. USB host + cfg80211 + ATBM6x6x Wi-Fi → wifi-connect (with fallback chain)
|
||||||
|
4b. TZ from /data/timezone or /usr/local/timezone; ntpd (pool.ntp.org or /data/ntp_server)
|
||||||
|
5. /etc/config/shadow from /usr/local/root.hash (first boot only)
|
||||||
|
6. dropbear SSH :22 (host keys in /data/dropbear)
|
||||||
|
6b. `camcfg boot`: /etc/config/rtsp.ini = /usr/local/rtsp.ini + /data/camcfg.conf overrides
|
||||||
|
7. RTSP server :554 + SD recorder (same process), supervised (restarted if it exits;
|
||||||
|
the timezone is re-read on each start)
|
||||||
|
8. ONVIF, only if binaries exist in /data/onvif
|
||||||
|
```
|
||||||
|
Log: `/tmp/local_bootstrap.log`. RTSP log: `/tmp/rtsp.log` (previous run in `/tmp/rtsp.log.1`).
|
||||||
|
|
||||||
|
## 3. DTB change
|
||||||
|
|
||||||
|
| Node | Stock | Built |
|
||||||
|
|---|---|---|
|
||||||
|
| `/reserved-memory/dma_reserved@0x81400000` `reg`/`size` | 0x1200000 (18 MB) | 0x1800000 (24 MB) |
|
||||||
|
| `/ion/dma_reserved_heap` `size` | 0x1200000 | 0x1800000 |
|
||||||
|
|
||||||
|
- **Why:** at 2304×1296 the capture buffers (2×4.5 MB + 2×0.35 MB) plus the encoder pool
|
||||||
|
(5.8 MB) don't fit in 18 MB. The Tuya app got by because it shared buffers between capture
|
||||||
|
and the encoder; the SDK sample doesn't.
|
||||||
|
- **Cost:** Linux has about 35 MB instead of 41 MB of the 64 MB RAM.
|
||||||
|
- **Patch method:** values are changed in place with `fdtput`, so the blob size stays exactly
|
||||||
|
0xe351. That matters because U-Boot reads a fixed `dtb_size=e351`. The blob is then re-padded
|
||||||
|
with 0xFF to 64K.
|
||||||
|
- **Build setting:** `ION_MB=` (18 = stock).
|
||||||
|
|
||||||
|
## 4. APP (`/usr`): exactly what changed
|
||||||
|
|
||||||
|
### Removed (≈ 6.8 MB)
|
||||||
|
| File | Why |
|
||||||
|
|---|---|
|
||||||
|
| `bin/anyka_ipc` (5.8 MB) | Tuya cloud and video app |
|
||||||
|
| `bin/msgserver`, `bin/cmdserver`, `bin/system_upgrade` | Tuya IPC and OTA daemons |
|
||||||
|
| `local/model_0x0A000000_V1.1.0.bin` (432K) | NPU human-detection model, used only by anyka_ipc |
|
||||||
|
| `local/ak_font_16.bin` (260K) | OSD font, unused (needed to make APP fit) |
|
||||||
|
| `share/*.mp3` (25 files) | Tuya voice prompts |
|
||||||
|
|
||||||
|
### Modified
|
||||||
|
| File | Change |
|
||||||
|
|---|---|
|
||||||
|
| `sbin/main.sh` | `service.sh start &` → `/usr/sbin/local_bootstrap.sh &` |
|
||||||
|
| `modules/ak_venc_adapter.ko` | stock V2.0.13 → V2.0.16 (OpenIPC anyka-osdrv; same vermagic `4.4.302-cip94 mod_unload ARMv5`). The stock one lacks an ioctl that `libmpi_venc` V3.0.02 needs |
|
||||||
|
| `modules/ak_venc_bridge.ko` | → 2.0.08 (OpenIPC anyka-osdrv), paired with the above |
|
||||||
|
|
||||||
|
### Added
|
||||||
|
| Path (on camera) | What | Source / how it's built |
|
||||||
|
|---|---|---|
|
||||||
|
| `/usr/lib/lib{plat_*,mpi_venc,mpi_aenc,app_its,app_video,rtsp_server,ak*}.so` (23 libs) | Anyka media SDK runtime | prebuilt, from public `Link-WQS/ANYKA_130L_SDK` `platform/lib` |
|
||||||
|
| `/usr/bin/ak_rtsp_server_sample` | RTSP server, `/vs0` main and `/vs1` sub | **rebuilt from SDK source** (`toolkit/src/rtsp_sample`), patched to read `[auth]` and `[server]` from the ini, plus the **SD recorder** (`ak_record.c`, see below) and a per-stream `enc_level` key. The main ring buffer is 2 → 4 MB for 8 Mbps. Built with Bootlin armv5 uClibc 2018.11 (uClibc-ng 1.0.30, older than the camera's 1.0.31, so ABI-safe); its strings match the prebuilt binary exactly except for one log line. `PREBUILT_RTSP=1` uses the original binary |
|
||||||
|
| `/usr/local/firstboot/` | `env.bin`, `envbk.bin`, `dtb.bin`, `version`: applied on the first boot after a **direct** SD-only install | build |
|
||||||
|
| `/usr/local/timezone` | POSIX TZ string (`TIMEZONE=`, default `UTC0`) | generated |
|
||||||
|
| `/usr/local/rtsp.ini` | stream settings: 2304×1296 at 15 fps, 8 Mbps H.264, `enc_level` 50 (level 5.0; the sample hardcoded 30); sub 640×360 at 15 fps; `[auth]` admin/`ROOT_PW` | generated from the SDK ini |
|
||||||
|
| `/usr/sbin/dropbearmulti` + `dropbear`, `dropbearkey`, `scp` links | SSH server | dropbear 2026.94, static musl, Bootlin armv5 musl 2026.08 |
|
||||||
|
| `/usr/sbin/mtdflash` | verified flash writer: per 4K block, skip if identical, else erase, write and read back (3 tries); size-checks every image before writing; refuses UBOOT/ENV without `-f` | `toolkit/src/mtdflash.c`, static musl |
|
||||||
|
| `/usr/sbin/fwupdate` | maps file names to partitions, runs mtdflash from `/tmp`, stops RTSP and ONVIF, reboots | `toolkit/blobs/fwupdate/` |
|
||||||
|
| `/usr/sbin/wifi-set`, `wifi-mkconf`, `wifi-connect` | change Wi-Fi at runtime; fallback chain | `toolkit/blobs/wifi/` |
|
||||||
|
| `/usr/sbin/camcfg` | settings CLI: validates values, stores only overrides in `/data/camcfg.conf`, merges them over `/usr/local/rtsp.ini` into `/etc/config/rtsp.ini`, writes `/data/onvif.conf` (synced size and login), `/data/timezone`, `/data/ntp_server`; restarts the stream | `toolkit/blobs/camcfg/` (tested with busybox sh/awk on the host) |
|
||||||
|
| `/usr/local/wpa_default.conf` | build-time default network (SSID hex-encoded) | from `WIFI_SSID`/`WIFI_PSK`; omitted if `WIFI_SSID=` |
|
||||||
|
| `/usr/local/root.hash` | MD5-crypt hash of `ROOT_PW` | `openssl passwd -1` |
|
||||||
|
| `/usr/sbin/local_bootstrap.sh` | boot script (§2) | generated by rtsp.sh |
|
||||||
|
| `/usr/sbin/rw` | `rw /path/file`: makes a read-only file editable and persistent through `/data/overlay` | generated |
|
||||||
|
| `/usr/local/onvif/{onvif.conf,start_onvif.sh}` | ONVIF scaffolding; resolution and login filled in at build time | `toolkit/blobs/onvif/` |
|
||||||
|
|
||||||
|
Kept from stock and used: busybox applets (`/usr/bin`, `/usr/sbin` links into `/bin/busybox`),
|
||||||
|
`wpa_supplicant`/`wpa_cli`, `wifi_driver.sh`, `sensor_driver.sh`, ISP tuning
|
||||||
|
`/usr/local/isp_sc3332.conf`, all other kernel modules.
|
||||||
|
|
||||||
|
### The SD recorder (`toolkit/src/rtsp_sample/ak_record.c`)
|
||||||
|
Runs inside the RTSP server process as three threads:
|
||||||
|
- **reader:** registers as one more reader on the encoder's ring buffer (like an RTSP
|
||||||
|
client), copies frames into a RAM queue (`queue_max_kb`, default 4 MB). It never waits on
|
||||||
|
the SD card, so streaming is unaffected. If the card is too slow it drops frames until the
|
||||||
|
next keyframe.
|
||||||
|
- **writer:** writes its own MPEG-TS muxer output (PAT/PMT, H.264 or HEVC PES with PTS and
|
||||||
|
PCR). Continuous files rotate on the first keyframe after `segment_seconds`. Motion clips
|
||||||
|
start with an in-RAM pre-roll that always begins on a keyframe. After each file it deletes
|
||||||
|
the oldest files until the folder is under its quota (`*_percent` of its filesystem or
|
||||||
|
`*_max_mb`) and the card keeps `min_free_mb` free. It writes only to a real disk
|
||||||
|
filesystem, never `/`, tmpfs or jffs2, so a missing card doesn't fill RAM.
|
||||||
|
- **motion:** polls `ak_vpss_md_get_stat()` (hardware 3DNR motion statistics, 32×24 grid) at
|
||||||
|
10 Hz. A cell counts as moving if it's above `motion_threshold` (by default derived from
|
||||||
|
`motion_sensitivity`, using the SDK's filter range). Motion fires when `motion_min_cells`
|
||||||
|
cells move for `motion_trigger_frames` checks in a row. It writes `/tmp/motion` and runs
|
||||||
|
`motion_hook start|stop`.
|
||||||
|
|
||||||
|
Video only: audio isn't recorded.
|
||||||
|
|
||||||
|
### SD-card-only install (stock U-Boot `ht_recover_fw.conf`)
|
||||||
|
Reverse-engineered from stock U-Boot (loaded at 0x80dffa00; Thumb code around 0x80e01ffc).
|
||||||
|
It runs at **every boot** before autoboot:
|
||||||
|
1. `fs_set_blk_dev("mmc", "0", FAT)`, then read the first 80 bytes of `ht_recover_fw.conf`
|
||||||
|
to 0x82000000.
|
||||||
|
2. Header: `char magic[8]` = `"HT_FW"`, `u32 type`, `u32 kernel_size`, `u32 rootfs_size`,
|
||||||
|
`u32 usrfs_size`, `u32 check_bundle`, `char bundle[36]`, `char version[16]` (little-endian).
|
||||||
|
3. If `check_bundle` ≠ 0, env `ht_fw_bundle` must equal `bundle`. If env `ht_fw_version`
|
||||||
|
equals `version`, nothing happens ("version is the same"). Stock env has no `ht_fw_version`.
|
||||||
|
4. The decimal digits of `type` select the files: units `uImage` → 0x44000–0x1c3fff, tens
|
||||||
|
`root.sqsh4` → 0x1c4000–0x2bffff, hundreds `usr.sqsh4` → 0x300000–0x7fffff. Each file is
|
||||||
|
read whole and must be exactly the size given in the header. The whole region is erased,
|
||||||
|
then the file is written.
|
||||||
|
5. After `usr.sqsh4`: `setenv ht_fw_version <version>; saveenv`, then a normal boot.
|
||||||
|
|
||||||
|
The build id (`FWVER`, default `cr<date>`) goes into every header as `version` and into the
|
||||||
|
image's env as `ht_fw_version`, so a camera never re-applies its own install.
|
||||||
|
|
||||||
|
**`sd-install-backup/` (type 10, rootfs region):**
|
||||||
|
- U-Boot writes `root.sqsh4`. That's the stock rootfs from the build's dump, with
|
||||||
|
`/etc/init.d/camerarev-install.sh` added. `rc.local` runs it instead of `main.sh`, and
|
||||||
|
doesn't mount CONFIG, so the backup stays pristine.
|
||||||
|
- U-Boot only saves `ht_fw_version` after a `usr.sqsh4` write. So with type 10, U-Boot keeps
|
||||||
|
re-writing the installer at every power-on until the installer itself writes the final env.
|
||||||
|
That is what makes every step before it restartable.
|
||||||
|
- The installer (`toolkit/blobs/sdinstall/camerarev-install.sh`), with the stock layout still
|
||||||
|
active:
|
||||||
|
1. Loads the mmc drivers from the still-original APP and mounts the card.
|
||||||
|
2. Unless the card already has a backup: reads every MTD to `original-backup/`.
|
||||||
|
`full.bin` = UBOOT…APP concatenated (8 MiB). The ROOTFS region is taken from
|
||||||
|
`camerarev/rootfs.bin` (the dump's stock rootfs), because the region now holds the
|
||||||
|
installer, which is kept as `ROOTFS.installer.bin`. UBOOT and KERNEL are compared with
|
||||||
|
`camerarev/ref.md5`, and the result goes into `README.txt`.
|
||||||
|
3. `md5sum -c camerarev/MD5SUMS`, then copies the files to RAM and checks them again.
|
||||||
|
4. `mtdflash -f -r APP usr.sqsh4 DTB dtb.bin ROOTFS rootfs.bin ENVBK envbk.bin ENV env.bin`:
|
||||||
|
ENV goes last, then a reboot.
|
||||||
|
|
||||||
|
A host simulation built fake MTDs from a real dump, with the ROOTFS region replaced by the
|
||||||
|
installer, and ran the script under busybox. The resulting `full.bin` was **byte-identical
|
||||||
|
to the original dump**. Reruns kept the backup, and a corrupted file aborted the install
|
||||||
|
before any write.
|
||||||
|
|
||||||
|
**`sd-install-direct/` (type 100, APP region):** U-Boot writes `usr.sqsh4` (APP padded to
|
||||||
|
0x2e0000 + empty DATA = exactly the 5 MiB region). APP carries
|
||||||
|
`/usr/local/firstboot/{env,envbk,dtb}.bin`. On a boot where `/proc/mtd` has no `DATA`
|
||||||
|
partition (still the stock layout), the boot script:
|
||||||
|
1. backs up every partition except APP to `SD:/original-backup/`
|
||||||
|
2. writes DTB, ENVBK and ENV with `mtdflash -f -r` and reboots
|
||||||
|
|
||||||
|
Cameras installed any other way already have DATA, so this never runs on them.
|
||||||
|
|
||||||
|
### Where third-party inputs come from (none are in the git repo)
|
||||||
|
| Input | Source (pinned commit, checked against `toolkit/deps.sha256`) | Fetched by |
|
||||||
|
|---|---|---|
|
||||||
|
| 23 SDK `.so`, `ak_rtsp_server_sample`, `rtsp.ini`, RTSP sample sources + 48 headers | `Link-WQS/ANYKA_130L_SDK` @ `3480d02` | `fetch-deps.sh` |
|
||||||
|
| `ak_venc_adapter.ko`, `ak_venc_bridge.ko` | `OpenIPC/firmware` @ `9e6a052` `general/package/anyka-osdrv-ak3918av130/files/kmod` | `fetch-deps.sh` |
|
||||||
|
| armv5 musl 2026.08-1, armv5 uClibc 2018.11-1 toolchains | toolchains.bootlin.com | `fetch-deps.sh` |
|
||||||
|
| dropbear 2026.94 source | matt.ucc.asn.au/dropbear | `build-deps.sh` |
|
||||||
|
| stock APP / rootfs trees (`src/app`, `src/rootfs`) | **your dump** | `extract-src.sh` (called by the variants) |
|
||||||
|
|
||||||
|
Built from source by `build-deps.sh`: `mtdflash` (`src/mtdflash.c`), `dropbearmulti`, and the
|
||||||
|
RTSP server (upstream sample + `patches/rtsp_sample.patch` + `src/rtsp_sample/ak_record.c`).
|
||||||
|
|
||||||
|
## 5. Per-device data: don't share built images
|
||||||
|
|
||||||
|
These partitions are copied **from your own dump** and are unique to each camera:
|
||||||
|
|
||||||
|
- **CONFIG** contains `tuya_user.db`, `tuya_enckey.db`, `_ht_encrypt.bin` and
|
||||||
|
`_ht_encrypt_bak.bin` (the device's Tuya identity and keys), plus `_ht_hw_settings.ini`,
|
||||||
|
`_ht_sw_settings.ini` and a `passwd`. After first boot it also holds `/etc/config/shadow`
|
||||||
|
(your root hash).
|
||||||
|
- **ENV** contains `ethaddr` (MAC address) and, after setup, your `mtdparts`/`bootcmd`.
|
||||||
|
- **APP** contains your Wi-Fi password (`wpa_default.conf`), your root password hash, and
|
||||||
|
your RTSP/ONVIF password **in plain text** (`rtsp.ini`, `onvif.conf`).
|
||||||
|
|
||||||
|
So `out/camera_flash_rtsp.bin` and `parts/rtsp/app.bin` are **private**. Don't publish them,
|
||||||
|
and don't flash one camera's full image onto another. Everyone builds from their own dump
|
||||||
|
(see [GUIDE.md](GUIDE.md)). The partition-level flash method (APP, DTB, DATA only) never
|
||||||
|
touches CONFIG, ENV or UBOOT.
|
||||||
|
|
||||||
|
## 6. Security posture
|
||||||
|
|
||||||
|
| Item | State |
|
||||||
|
|---|---|
|
||||||
|
| Tuya cloud | gone (no binaries, nothing contacts it) |
|
||||||
|
| SSH | dropbear :22, root password login (default `anyka`; change it with `passwd`) |
|
||||||
|
| Telnet | not started |
|
||||||
|
| RTSP | Digest auth, default `admin` / root password; set with `RTSP_USER`/`RTSP_PASS` or edit `[auth]` |
|
||||||
|
| ONVIF | not shipped; when added it uses the same user and password |
|
||||||
|
| Serial console | **unauthenticated root shell**, kept on purpose as the recovery path. Needs physical access (case open) |
|
||||||
|
| U-Boot | Ctrl+C prompt open; with the SD updater set up, anyone with the card slot can reflash. That's the price of no-serial recovery |
|
||||||
|
|
||||||
|
## 7. Known gaps and limits
|
||||||
|
|
||||||
|
- **Frame rate:** the stock ISP tuning caps it at 15 fps (`frame_rate=15` in
|
||||||
|
`isp_sc3332.conf`). The sensor can do 25. Raising it means editing that binary config.
|
||||||
|
- **Clock:** busybox `ntpd` syncs the time at boot and the RTC is written a minute later.
|
||||||
|
Without internet, the time comes from the RTC, which may be wrong.
|
||||||
|
- **No hardware watchdog** is fed (the Tuya app did that). Not needed so far.
|
||||||
|
- **ONVIF:** busybox on this rootfs has **no `httpd`**, so `start_onvif.sh` expects one at
|
||||||
|
`/data/onvif/httpd` (for example a static busybox), in addition to the onvif_simple_server
|
||||||
|
binaries.
|
||||||
|
- **Space:** APP is 2848K of 2944K. New features should go on `/data` (≈2 MB) or the SD card.
|
||||||
|
- **Vendor recovery paths don't work** and aren't used: rootfs `system_recover.sh` only runs
|
||||||
|
when APP is missing, but the SD drivers it needs are in APP. U-Boot's
|
||||||
|
`ht_recover_fw.conf` has an undocumented format.
|
||||||
|
|
||||||
|
## 8. Build settings (environment variables for `variants/rtsp.sh`)
|
||||||
|
|
||||||
|
| Var | Default | Effect |
|
||||||
|
|---|---|---|
|
||||||
|
| `WIFI_SSID`, `WIFI_PSK` | **required** | baked default network; `WIFI_SSID=` (empty) = none, configure through SD `wifi.txt` |
|
||||||
|
| `ROOT_PW` | `anyka` | root password (SSH and serial `passwd`) |
|
||||||
|
| `RTSP_USER`, `RTSP_PASS` | `admin`, `$ROOT_PW` | RTSP and ONVIF login; `RTSP_USER=` disables auth |
|
||||||
|
| `MAIN_W`, `MAIN_H`, `MAIN_FPS`, `MAIN_KBPS`, `MAIN_CODEC` | 2304, 1296, 15, 8000, h.264 | main stream; `h.265` is supported by the encoder, driver and RTSP library |
|
||||||
|
| `ION_MB` | 24 | video memory reserved in the DTB |
|
||||||
|
| `PREBUILT_RTSP` | 0 | 1 = original SDK binary (no auth, **no recording**) |
|
||||||
|
| `REC_MODE`, `REC_STREAM` | both, 0 | recording mode, recorded stream |
|
||||||
|
| `REC_CONT_PERCENT`, `REC_MOTION_PERCENT` | 70, 25 | how the card is split (all `[record]` keys: GUIDE.md §6a) |
|
||||||
|
| `TIMEZONE` | `UTC0` | POSIX TZ string |
|
||||||
Reference in New Issue
Block a user