Skip to content

Add camhi (Hi3516CV610 / Hichip PIHC) target#44

Open
josephnef wants to merge 1 commit into
mainfrom
camhi-hi3516cv610
Open

Add camhi (Hi3516CV610 / Hichip PIHC) target#44
josephnef wants to merge 1 commit into
mainfrom
camhi-hi3516cv610

Conversation

@josephnef

Copy link
Copy Markdown
Collaborator

What

Adds a coupler build target for CamHi-app cameras on the Hisilicon Hi3516CV610 SoC. These ship firmware in a proprietary "PIHC" container that the vendor's admin upgrade.cgi endpoint accepts; this PR builds an OpenIPC .pkg in that container so the camera flashes itself to OpenIPC via its own web upgrade.

The format and partition map were reverse-engineered from the vendor ipc_server binary and one live reference device (MPP HI3516CV610_MPP_V1.0.1.0 B040).

⚠️ Status: UNTESTED ON HARDWARE

The container format is verified by reverse engineering and the builder is unit-tested, but no end-to-end conversion flash has been performed. The README marks the target (Untested!). Do not flash a unit you cannot recover over UART/TFTP.

How it works

  • pihc_pack.py — PIHC container builder: 512-byte header (PIHC magic, type 4098, six component lengths, six MD5(component||"IPCAM") integrity strings), concatenated components, PK-signature mangle on the zip slot. The Hichip block cipher on the zip component is not AES and is left unreversed; the empty-zip path stays under the cipher's 1024-byte threshold so it's never needed.
  • uboot_env.py — pure-Python mkenvimage fallback so the build runs without u-boot-tools.
  • _camhi2oipc.sh — wraps an OpenIPC hi3516cv6xx release into a .pkg. Builds a u-boot env that switches init=/bin/shinit=/init and relabels the trailing partition to rootfs_data for OpenIPC's overlay; omits boot.img to preserve the vendor u-boot (keeps TFTP recovery); aborts if the rootfs overflows the 3456K partition.
  • camhi.ymlworkflow_dispatch build; self-tests the packer then builds one generic image (sensor left to OpenIPC autodetect / fw_setenv).
  • tests.yml — runs the unit + e2e tests on push/pull_request.

Tests

  • tests/test_pihc_pack.py — 19 unit tests mirroring the vendor's header validator (sub_36A70).
  • tests/test_build_e2e.sh — end-to-end build against a synthetic release tarball, validating the produced .pkg (magic, type, component layout, all MD5+IPCAM checksums, and the init=/init + rootfs_data env changes).

Both are wired into CI via tests.yml.

Verified vs open

.github/workflows/camhi-NOTES.md documents the split. Verified: partition geometry (/proc/mtd, /proc/cmdline), PIHC format, the MD5-only integrity scheme, the upload→stage→flash path. Open: that it actually boots OpenIPC, flash_upg.sh exact mapping, overlay adoption, whether the ultimate rootfs fits 3456K, and the image sensor.

Adds a coupler build target for CamHi-app cameras on the Hisilicon
Hi3516CV610 SoC, which ship firmware in the proprietary "PIHC" container
accepted by the vendor's admin upgrade.cgi endpoint.

Reverse-engineered from the vendor ipc_server binary and one live reference
device (MPP HI3516CV610_MPP_V1.0.1.0 B040):

- pihc_pack.py: PIHC container builder. 512-byte header (PIHC magic, type
  4098, six component lengths, six MD5(component||"IPCAM") integrity
  strings), concatenated components, PK-signature mangle on the zip slot.
  The Hichip block cipher on the zip component is NOT AES and is left
  unreversed; the empty-zip path stays under the cipher's 1024-byte
  threshold so it is never needed.
- uboot_env.py: pure-Python mkenvimage fallback (CRC32 + KEY=VALUE env).
- _camhi2oipc.sh: wraps an OpenIPC hi3516cv6xx release into a .pkg. Builds
  a u-boot env that switches init=/bin/sh -> init=/init and relabels the
  trailing partition to rootfs_data for OpenIPC's overlay; omits boot.img to
  preserve vendor u-boot (keeps TFTP recovery); aborts if the rootfs exceeds
  the 3456K partition.
- camhi.yml: workflow that self-tests the packer then builds one generic
  image (sensor left to OpenIPC autodetect / fw_setenv).
- tests/test_pihc_pack.py: 19 unit tests mirroring the vendor's header
  validator (sub_36A70).
- tests/test_build_e2e.sh: end-to-end build smoke test against a synthetic
  release tarball, validating the produced .pkg.
- tests.yml: runs both test suites on push/pull_request.
- camhi-NOTES.md: verified facts (partition geometry, flash path) vs the
  open questions.

STATUS: UNTESTED ON HARDWARE. The format and partition map are verified by
reverse engineering, the packer is unit-tested, but no end-to-end conversion
flash has been performed. README marks the target (Untested!). No sensor or
root password is asserted — neither was verified on the reference unit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant