Skip to content

kernel: bring up hi3516cv6xx (V5 — Hi3516CV610/CV608)#202

Merged
widgetii merged 3 commits into
mainfrom
hi3516cv6xx-port
Jun 4, 2026
Merged

kernel: bring up hi3516cv6xx (V5 — Hi3516CV610/CV608)#202
widgetii merged 3 commits into
mainfrom
hi3516cv6xx-port

Conversation

@widgetii
Copy link
Copy Markdown
Member

@widgetii widgetii commented Jun 4, 2026

Summary

Adds a new CHIPARCH=hi3516cv6xx arm to the openhisilicon kernel-module dispatch, covering the V5 generation of HiSilicon vision SoCs — Hi3516CV610 and Hi3516CV608.

42 open_*.ko modules build clean against openipc/linux 5.10.221 (ARMv7 Cortex-A7, musl) and load successfully on a real CV610 demo board:

  • full MPP image + encode + audio + AI pipeline up
  • /proc/umap/ exposes 27 chardevs (sys, vb, vi, isp, vpss, venc, h264e/h265e/jpege/svac3e, ive, svp_npu, aiisp, audio aio/ai/ao/aenc/adec/acodec, mipi_rx, pm, …)
  • sensor I2C/SPI probe path reaches the bus (/dev/i2c-{0,1,2}, /dev/ot_mipi_rx)
  • zero depmod warnings, zero unresolved symbols

Pattern

Mirrors hi3516cv500 with two structural differences inherent to V5:

  • open_mmz ships as a separate module — V4 folded MMZ into open_osal
  • every blob's init wrapper is shipped as source by the vendor SDK (Hi3516CV610_SDK_V1.0.2.0/.../out/init/src/*_init.c), so no init source had to be hand-written for the 30 blob-backed modules; only the closed MPP/codec payloads need blob-linking

Source patches against vendor code

Three small, scoped patches:

  1. kernel/compat/kernel_compat.hdma-contiguous.h gate switched to __has_include because the openipc/linux cv6xx kernel branch backports the upstream-5.16 merge of dma-contiguous.h into dma-map-ops.h onto 5.10.221, so the version-code-based gate misfires.

  2. kernel/osal/hi3516cv6xx/mmz/cma_allocator.c

    • pte_fn_t signature drift: 4-arg vendor (pte_t*, struct page*, addr, data) → upstream 3-arg (pte_t*, addr, data)
    • bsp_flush_tlb_kernel_range → public flush_tlb_kernel_range (the bsp_ wrapper lives in a vendor BSP we don't ship)
    • apply_to_page_range(&init_mm, …) gated behind CONFIG_CMA because init_mm is not EXPORT_SYMBOL'd and V5 boards default to CONFIG_CMA=n with mmz_allocator=ot at boot
  3. kernel/pwm/hi3516cv6xx/pwm.c and kernel/piris/hi3516cv6xx/piris.c — force #undef IOMEM before redefining as __iomem. arch/arm/include/asm/io.h already provides IOMEM(x) as a function-like macro that collides with the vendor's object-like usage. Both files' #ifndef IOMEM guard sees the function-like macro and skips, leaving IOMEM as an undefined token at the use site.

Vendor blobs

The 30 closed-source .o payloads under kernel/obj/hi3516cv6xx/ are extracted from out/obj/mod_*.o in the Hi3516CV610_SDK_V1.0.2.0 release. Force-added because the repo .gitignore otherwise excludes *.o (same pattern as the cv500 / ev200 obj trees).

CI status

hi3516cv6xx is intentionally not in .github/workflows/build.yml's Build SDK matrix in this PR. The reason: the CI's "Build OpenHisilicon" step depends on firmware's hisilicon-opensdk.mk knowing how to dispatch CHIPARCH=hi3516cv6xx, and OpenIPC/firmware:master doesn't yet have that wiring (PR #2167 added the cv6xx board package but with prebuilt vendor .ko, not opensdk). Until the firmware companion PR lands (defconfig flip + opensdk.mk SoC arm + osdrv .mk strip + load_hisilicon rewrite), any matrix entry for hi3516cv6xx here would fail at the firmware checkout step and gate the PR.

CI matrix entry will land in the firmware companion PR cycle once both repos can dispatch cv6xx natively. The build itself has been validated locally (see "Test plan" below) using the firmware-side companion changes via BR2_PACKAGE_HISILICON_OPENSDK_OVERRIDE_SRCDIR.

Deferred follow-ups (not blocking)

  • open_cipher, open_km, open_otp, open_hardware_cryptodev — vendor ships these only as full closed .ko (not separate mod_*.o); need a separate objcopy-extraction step
  • open_es8388, open_sample_ist, open_spi_st7789 — extdrv audio codec / sample peripherals not used by the standard load_hisilicon chain

Hardware validation

Hi3516CV610 demo board (sc4336p sensor):

load mmz ....OK!
load base.ko ....OK!     <-- the boot-hang point before this PR
... 33 more "load X.ko ....OK!" lines ...
load sensor_i2c.ko ....OK!
load sensor_spi.ko ....OK!
ot_wtdg init ok.

$ lsmod | wc -l
43
$ ls /proc/umap | wc -l
27
$ ls /dev/i2c-* /dev/ot_*
/dev/i2c-0 /dev/i2c-1 /dev/i2c-2 /dev/ot_proc /dev/ot_lsadc /dev/ot_mipi_rx

Test plan

  • Build clean (make BOARD=hi3516cv6xx_lite br-hisilicon-opensdk with firmware-side BR2_PACKAGE_HISILICON_OPENSDK_OVERRIDE_SRCDIR pointing at this PR's tree)
  • Zero depmod warnings on install
  • All 42 .ko files install to /lib/modules/5.10.221/extra/
  • Modules load on real CV610 hardware via insmod with full paths
  • Modules load on real CV610 hardware via modprobe (with buildroot-generated modules.dep)
  • Full load_hisilicon -a -sensor0 sc4336p -sensor1 sc4336p chain completes
  • CI matrix entry — adds in firmware companion PR cycle (see "CI status" above)
  • End-to-end sysupgrade + cold boot — requires firmware companion PR with HISILICON_OPENSDK_VERSION bumped and PR #2170's CONFIG_IO_STRICT_DEVMEM=n
  • majestic RTSP smoke test once sysupgrade lands

closes #180

widgetii and others added 3 commits June 4, 2026 21:55
Adds a CHIPARCH=hi3516cv6xx arm to the module dispatch, covering the
V5 generation of HiSilicon vision SoCs (Hi3516CV610 + Hi3516CV608).

42 open_*.ko modules build clean against openipc/linux 5.10.221 (ARMv7
Cortex-A7, musl) and validated by loading on a CV610 demo board: full
MPP image + encode + audio + AI pipeline up, /proc/umap exposes 27
chardevs, sensor I2C/SPI probe path reaches the bus.

Pattern mirrors hi3516cv500 with two structural differences inherent
to V5:

* open_mmz ships as a separate module (V4 folded MMZ into open_osal)
* every blob's init wrapper is shipped as source by the vendor SDK,
  so no init source needed to be hand-written; only the closed
  MPP/codec payloads need blob-linking

Three small source patches were required against vendor source:

1. kernel/compat/kernel_compat.h — dma-contiguous.h gate switched
   to __has_include because the openipc/linux hi3516cv6xx branch
   backports the upstream-5.16 merge of dma-contiguous.h into
   dma-map-ops.h onto 5.10.221.

2. kernel/osal/hi3516cv6xx/mmz/cma_allocator.c — pte_fn_t signature
   drift (4-arg vendor vs upstream 3-arg), bsp_flush_tlb_kernel_range
   replaced with the public flush_tlb_kernel_range, and the
   apply_to_page_range/init_mm reference gated behind CONFIG_CMA
   (init_mm is not EXPORT_SYMBOL'd and the V5 board builds with
   CONFIG_CMA=n by default; the OT allocator is the boot-time path).

3. kernel/pwm/hi3516cv6xx/pwm.c and kernel/piris/hi3516cv6xx/piris.c
   — force-undef IOMEM before redefining as __iomem, because
   arch/arm/include/asm/io.h ships IOMEM(x) as a function-like macro
   that collides with the vendor's object-like usage.

The 30 vendor closed-source blobs under kernel/obj/hi3516cv6xx/ are
extracted from out/obj/mod_*.o in the Hi3516CV610_SDK_V1.0.2.0 release
and force-added because the repo .gitignore otherwise excludes *.o.

Modules not yet covered (deferred to follow-up):

* open_cipher, open_km, open_otp, open_hardware_cryptodev — vendor
  ships these only as full closed .ko (no separate mod_*.o); need a
  separate extraction step.
* open_es8388, open_sample_ist, open_spi_st7789 — extdrv audio codec
  / sample peripherals, not needed for the standard pipeline.

closes #180

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds the V5 family row to the supported-hardware table, the 5.10.221
vendor-kernel row to the supported-kernels table, and a hi3516cv6xx.kbuild
entry in the repository-structure tree.

SoC family column points at hi3516cv610 (the headline chip in the V5
generation) per the table's existing convention of using a real chip ID,
while CHIPARCH stays as the hi3516cv6xx umbrella label that covers both
hi3516cv610 and the smaller hi3516cv608 in a single build target.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two-part follow-up to the cv6xx kernel-module bring-up:

1. Sensor drivers: port the 6 sensors shipped in
   Hi3516CV610_SDK_V1.0.2.0 from mpp/cbb/isp/user/sensor/hi3516cv610/
   into libraries/sensor/hi3516cv6xx/:

   * GalaxyCore GC4023
   * OmniVision OS04D10
   * SmartSens SC431HAI / SC4336P / SC450AI / SC500AI

   Each sensor builds libsns_<sensor>.{so,a} via a Makefile mirroring
   the hi3516cv500 pattern: -I to kernel/include/hi3516cv6xx/ for the
   ot_*.h vendor headers staged in the earlier commit, plus
   libraries/isp/include/hi3516cv6xx/{,3a,ext_inc}/ for the userspace
   ot_mpi_* / ot_common_* headers staged here from the vendor SDK's
   mpp/cbb/isp/include/, mpp/cbb/isp/user/3a/include/, and
   mpp/cbb/isp/ext_inc/.

   The shared sensor_common.c lives in libraries/sensor/hi3516cv6xx/
   common/ and is pulled into each sensor's link target.

   libraries/Makefile gains an ifeq($(CHIPARCH),hi3516cv6xx) arm that
   filters SUBDIRS to ./sensor/hi3516cv6xx/% and excludes ./common/
   (no Makefile of its own).

   Cross-compile-verified with the openipc arm-musleabi-gcc 13.3
   toolchain. Each .so links only against libc.so (no vendor
   dependencies) and exports the openhisilicon sensor ABI
   (cis_register_callback / cis_i2c_init / cis_read_reg /
   cis_write_reg / cis_init_attr / cis_wdr_range_check / cis_delay_ms).

2. README consistency sweep for V5 / CV6xx. The earlier commit only
   touched the SoC-family table, the kernel-version table, and the
   repo-structure tree. This commit completes coverage:

   * V5 row in the "How it evolved across generations" table (CV610,
     Cortex-A7, OSAL+MMZ split, raw .o + vendor init wrappers).
   * Strategy A list extended with CV6xx, plus a note about the
     vendor SDK shipping init wrappers as source.
   * Build example: make BOARD=hi3516cv6xx_lite br-hisilicon-opensdk.
   * Module load order: V5 = sys_config -> osal -> mmz (separate) ->
     base -> vb -> vca -> sys -> everything else.
   * V5 column added to the "Kernel modules" matrix; 14 rows added
     for V5-specific modules (vb, vca, vpp, svac3e, chnl, svp_npu,
     aiisp, piris, adc, spi_dma_transfer, user, user_proc, uvc,
     devstat).
   * Restored open_vo V4=blank — the previous commit's V5-column
     extension accidentally flipped it to V4=x; V4 EV200 has no
     video-output module.
   * CV6xx column added to the sensor matrix with the 6 V5 sensors
     marked; "V5 sensors not yet ported" note removed.
   * adc/, piris/, spi_dma_transfer/, user/ now listed in the
     repo-structure tree.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@widgetii widgetii merged commit b1c4dae into main Jun 4, 2026
34 checks passed
@widgetii widgetii deleted the hi3516cv6xx-port branch June 4, 2026 19:38
@anatol
Copy link
Copy Markdown

anatol commented Jun 4, 2026

Fantastic! Thank you very much for your work.

I see that a lot of *.o binaries has been merged. So I wondering what is the current policy and plans related to it. Do you plan eventually reimplement/recover it to a proper *.c linux driver?

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.

Add support for Hi3516CV608 / Hi3516CV610

2 participants