Skip to content

ak3918ev200: video on OpenIPC conventions -- kernel at the bottom, osmem split, ak-cam, sensor tunings in /etc/sensor - #2796

Merged
dimerr merged 5 commits into
masterfrom
ak3918ev200-sc1345
Nov 8, 2026
Merged

dimerr merged 5 commits into
masterfrom
ak3918ev200-sc1345

Conversation

@dimerr

@dimerr dimerr commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

AK3918EV200 (ak3918ev200_lite) gives no video:

  • Sensor not supported. The Gwell camera's SmartSens SC1345 had no driver.
  • Capture path unusable. The soc_camera host the board built (VIDEO_AK) cannot capture with this kernel: it wants /dev/isp_char open, and that refuses to open until the ISP is prepared, which only the ak-cam bridge does.
  • Memory layout. With ak-cam, the first capture hard-locked the board. The 24 MiB video pool was a CMA region inside Linux's 40 MiB.

This PR moves the EV200 to OpenIPC conventions:

Needs OpenIPC/linux#186 merged first. Without its memory change, any capture with ak-cam locks the board up.

Hardware tested on

ak3918ev200, Gwell camera (SC1345 sensor, XM25QH64A, Wi-Fi only), flashed with sysupgrade --archive.

  • On hardware: the first three commits — kernel at 0x80008000, memory split, ak-cam, SC1345 and its tuning, load_anyka.
  • Built and booted under qemu-hisilicon ak3918ev200 only: the last two commits (six more sensors and the tuning renames). Each tuning was checked against the kernel's validator, its driver's sensor ID and the frame rates the driver accepts. None of those sensors was available.

Evidence

Before:

aksensor 0-0037: Sensor ID error
ak_camera 20000000.isp: sensor init failed: -19
Memory: 10980K/40960K available (... 24576K cma-reserved)
# with VIDEO_AK_CAM but the old pool: v4l2-ctl -d1 --stream-mmap -> board hard-locked, needed a power cycle

After. The migration from an old environment, as seen under qemu-hisilicon with this camera's own U-Boot and environment:

rmem: no DRAM above mem=, no video memory          # osmem=64M
anyka: osmem 40M of 64M, video 24M; rebooting

On the camera after the same migration (fw_printenv: osmem=40M, totalmem=64M):

Kernel command line: mem=40M console=ttySAK0,115200 ...
rmem: 24 MiB at 0x82800000 for video
Memory: 35608K/40960K available (... 0K cma-reserved)
ak-venc 20020000.video-encoder-m2m: encoder pool at 0x82800000, 24576 KiB (rmem)
ak-cam 20000000.isp: capture pool at 0x82800000, 24576 KiB (rmem)
aksensor 0-0037: sensor id 0x1345
ak-cam 20000000.isp: ISP tuning /etc/sensor/sc1345.conf, 2 styles
$ v4l2-ctl -d1 --stream-mmap --stream-count=10 --stream-to=/tmp/main.yuv
-rw------- 1 root root 13824000 /tmp/main.yuv     # 10 x 1280x720 YU12, correct picture, 15 fps

Image size: uImage 1618 KB / 2048, rootfs 4896 KB / 5120.

ci-matrix.py --self-test and STRICT=1 test_shell_parse.sh pass. With the index diff, the selector builds the seven Anyka boards plus the smoke set.

Scope

  • No kernel patches under general/package/all-patches/linux/ (those go to OpenIPC/linux)
  • No files specific to a single retail camera model (those go to OpenIPC/builder)
  • No probing or bring-up tooling (that goes to OpenIPC/ipctool)
  • Nothing under general/overlay/ or in a shared load_<vendor> script hardcodes a value specific to my board
  • Package sources come from an OpenIPC repository, and any version bump keeps at least the specificity of the pin it replaces (a new package should pin a full 40-character SHA)
  • No LD_PRELOAD, and no binaries that cannot be rebuilt from source
  • New code is selected by a defconfig, so CI actually builds it

Unticked, deliberately:

  • No binaries. The files/sensor/*.conf tunings are vendor data: ISP tables and sensor register lists from the stock firmware of AK3918EV200 cameras (and one from the AnyCloud39EV300 SDK). On this ISP the sensor's init list lives in the tuning, so no driver can start its sensor without one. They are converted by files/sensor/convert-3.004.py (header fields only), and the .mk lists where each came from.
  • Package sources. The package has no *_SITE; it installs files from this tree.

There is no LD_PRELOAD.

…plit

The AK3918EV200 drivers are built into the kernel; what the family
needs from a package is the sensors' ISP tuning and a bootloader
environment the kernel can take its memory split from.

files/sensor/<sensor>.conf is installed into /etc/sensor, where the
kernel's ISP driver reads the tuning of the sensor it detected by the
name ipctool gives it. sc1345.conf (SmartSens SC1345, DVP) is
isp_sc1345_dvp.conf from the stock firmware of a Gwell AK3918EV200
camera, converted from the vendor's "3.004" layout to the "3.05_032401"
one the kernel validates with files/sensor/convert-3.004.py; only header
fields change, no tuning value.

load_anyka: Linux gets osmem (mem=${osmem}) and video the rest of
totalmem. An environment with osmem equal to totalmem leaves no video
memory, so load_anyka -i lowers osmem by the 24 MiB the vendor firmware
gives video, once, and reboots.
The kernel now starts at 0x80000000 (load address 0x80008000) and takes
its video memory as totalmem - osmem, like the other SoCs, instead of a
device tree pool below a kernel at 0x81800000.

The soc_camera host (VIDEO_AK) cannot capture with this kernel: it asks
for /dev/isp_char to be open first, and that refuses to open until the
ISP is prepared, which only the ak-cam bridge does. Build ak-cam and
its sensor subdev instead, add the SC1345 driver, and install
anyka-osdrv-ak3918ev200 for the sensor tuning and the osmem split.

Needs the OpenIPC/linux anyka-ak3918ev300 changes that take video
memory from mem= and the tuning from /etc/sensor, and the SC1345 driver.
…r tunings

Build the six sensor drivers the vendor's AK3918EV200 firmware supports
and the kernel now has, and ship ISP tunings for them and for the
SC1235 and SC1245 the kernel already drove: nine files in /etc/sensor,
each the newest generic vendor tuning for that sensor in the layout the
EV200 ISP reads, converted by convert-3.004.py. The .mk lists where
each came from.

uImage 1618 KB of 2048, rootfs 4896 KB of 5120. Boots on qemu-hisilicon
ak3918ev200; none of the new sensors has been run on hardware.
The kernel looks a tuning up by the name the sensor driver registers,
which is now the one `ipcinfo -s` prints. Four files carried the
vendor's name for a chip ipctool knows by another:

  gc1024.conf -> gc1004.conf    ID 0x1004
  h62.conf    -> jxh62.conf     ID 0xa062
  sc1245.conf -> sc2145h.conf   ID 0x1245
  sc2232.conf -> sc2235p.conf   ID 0x2232

Contents unchanged. Needs the OpenIPC/linux change that registers the
drivers under these names.
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Enable AK3918EV200 video capture with reserved memory and sensor tunings

✨ Enhancement 🐞 Bug fix ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Move the EV200 kernel to the bottom of DRAM and reserve remaining memory for video.
Diagram

graph TD
  Env[("U-Boot environment")] --> Script["load_anyka migration"] --> Kernel["Kernel memory split"] --> Pool[("Video pool")] --> Cam["ak-cam bridge"] --> Sensor["Detected sensor"] --> Tuning["ISP tuning file"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Keep a device-tree video pool
  • ➕ Avoids migrating bootloader environment values on deployed devices.
  • ➖ Retains the layout associated with capture lockups and diverges from the proposed kernel memory convention.

Recommendation: Use the proposed osmem-based split and ak-cam bridge, conditional on merging the referenced OpenIPC/linux memory change first. Keeping the old pool would avoid migration but would not address the reported capture lockup; sensor support beyond SC1345 still needs hardware validation.

Files changed (16) +181 / -4

Enhancement (11) +118 / -0
anyka-osdrv-ak3918ev200.mkInstall and document EV200 sensor tunings +50/-0

Install and document EV200 sensor tunings

• Installs nine locally supplied tuning files into /etc/sensor and load_anyka into /usr/bin. Documents each tuning's vendor filename and provenance.

general/package/anyka-osdrv-ak3918ev200/anyka-osdrv-ak3918ev200.mk

convert-3.004.pyConvert vendor ISP tuning layout +68/-0

Convert vendor ISP tuning layout

• Validates module and sensor-register blocks, normalizes style lengths using style zero's register list, and writes headers accepted by the kernel's tuning validator.

general/package/anyka-osdrv-ak3918ev200/files/sensor/convert-3.004.py

gc1004.confAdd GC1004 ISP tuning +0/-0

Add GC1004 ISP tuning

• Supplies tuning for the GC1004, identified as GC1024 in the vendor source, under its detected sensor name.

general/package/anyka-osdrv-ak3918ev200/files/sensor/gc1004.conf

gc1034.confAdd GC1034 ISP tuning +0/-0

Add GC1034 ISP tuning

• Supplies a converted vendor tuning file for GC1034 capture.

general/package/anyka-osdrv-ak3918ev200/files/sensor/gc1034.conf

jxh62.confAdd JX-H62 ISP tuning +0/-0

Add JX-H62 ISP tuning

• Supplies a converted H62 tuning from the AnyCloud39EV300 SDK, named for the detected JX-H62 sensor.

general/package/anyka-osdrv-ak3918ev200/files/sensor/jxh62.conf

sc1135.confAdd SC1135 ISP tuning +0/-0

Add SC1135 ISP tuning

• Supplies a converted vendor tuning file for SC1135 capture.

general/package/anyka-osdrv-ak3918ev200/files/sensor/sc1135.conf

sc1145.confAdd SC1145 ISP tuning +0/-0

Add SC1145 ISP tuning

• Supplies a converted vendor tuning file for SC1145 capture.

general/package/anyka-osdrv-ak3918ev200/files/sensor/sc1145.conf

sc1235.confAdd SC1235 ISP tuning +0/-0

Add SC1235 ISP tuning

• Supplies a converted vendor tuning file for the already-configured SC1235 sensor.

general/package/anyka-osdrv-ak3918ev200/files/sensor/sc1235.conf

sc1345.confAdd SC1345 ISP tuning +0/-0

Add SC1345 ISP tuning

• Supplies the converted Gwell camera tuning for SC1345, the sensor used in the reported hardware capture test.

general/package/anyka-osdrv-ak3918ev200/files/sensor/sc1345.conf

sc2145h.confAdd SC2145H ISP tuning +0/-0

Add SC2145H ISP tuning

• Supplies a converted vendor tuning originally named for SC1245, installed under the detected SC2145H name.

general/package/anyka-osdrv-ak3918ev200/files/sensor/sc2145h.conf

sc2235p.confAdd SC2235P ISP tuning +0/-0

Add SC2235P ISP tuning

• Supplies a converted vendor tuning originally named SC2232, installed under the detected SC2235P name.

general/package/anyka-osdrv-ak3918ev200/files/sensor/sc2235p.conf

Bug fix (1) +37 / -0
load_anykaMigrate legacy boot environments to a video-memory split +37/-0

Migrate legacy boot environments to a video-memory split

• On -i, checks totalmem and osmem, lowers osmem when less than 24 MiB would remain for video, and reboots after a successful environment update.

general/package/anyka-osdrv-ak3918ev200/files/script/load_anyka

Other (4) +26 / -4
ak3918ev200.generic.configConfigure bottom-of-DRAM memory and ak-cam capture +12/-3

Configure bottom-of-DRAM memory and ak-cam capture

• Sets the physical offset to 0x80000000 and enables reserved memory. Replaces the VIDEO_AK capture host with ak-cam and enables additional sensor drivers.

br-ext-chip-anyka/board/ak3918ev300/ak3918ev200.generic.config

ak3918ev200_lite_defconfigRelocate the kernel image and select EV200 support files +2/-1

Relocate the kernel image and select EV200 support files

• Changes the uImage load address to 0x80008000 and includes the new sensor-tuning package in the lite image.

br-ext-chip-anyka/configs/ak3918ev200_lite_defconfig

Config.inExpose the EV200 support package +1/-0

Expose the EV200 support package

• Adds the new package to the general Buildroot package menu.

general/package/Config.in

Config.inDefine the EV200 support package option +11/-0

Define the EV200 support package option

• Declares a kernel-dependent package for ISP tunings and the boot-environment migration script; its drivers remain built into the kernel.

general/package/anyka-osdrv-ak3918ev200/Config.in

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (2) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Shipped tunings not regenerated by build 📘 Rule violation ⚙ Maintainability
Description
The nine files/sensor/*.conf tunings are vendor binaries whose headers convert-3.004.py
rewrites, but the install rule copies the committed files without regenerating them from source
inputs in the tree. A later change to a tuning can silently diverge from what is shipped, and a
reader cannot rebuild the files for another kernel or check their values against a datasheet.
Code

general/package/anyka-osdrv-ak3918ev200/anyka-osdrv-ak3918ev200.mk[R18-23]

+# Every file is a vendor tuning from the stock firmware of an AK3918EV200
+# camera, converted from the vendor's "3.0xx" layout to the "3.05_032401"
+# one the kernel validates with files/sensor/convert-3.004.py. The
+# conversion changes header fields only (version string, style count and
+# style size) and gives each style style 0's sensor register list, the
+# only one the kernel writes; no tuning value is changed.
Evidence
The .mk comment identifies the shipped tunings as vendor files from camera stock firmware, and the
PR description likewise calls them vendor data; the diff shows the .conf files as binary content.
The committed converter only rewrites fields in those inputs, while the .mk installs the committed
outputs without running it, so neither the converter nor the package build supplies a buildable
source for the tunings. This is the binary-origin and buildable-source concern identified by rules 6
and 21.

Rule 6: No binaries without a buildable source
general/package/anyka-osdrv-ak3918ev200/files/sensor/convert-3.004.py[1-3]
general/package/anyka-osdrv-ak3918ev200/anyka-osdrv-ak3918ev200.mk[18-23]
CLAUDE.md: Do Not Add Binaries or Extracted Code Without Buildable Source: CLAUDE.md: Do Not Add Binaries or Extracted Code Without Buildable Source: CLAUDE.md: Do Not Add Binaries or Extracted Code Without Buildable Source: CLAUDE.md: Do Not Add Binaries or Extracted Code Without Buildable Source: CLAUDE.md: Do Not Add Binaries or Extracted Code Without Buildable Source: CLAUDE.md: Do Not Add Binaries or Extracted Code Without Buildable Source: CLAUDE.md: Do Not Add Binaries or Extracted Code Without Buildable Source: CLAUDE.md: Do Not Add Binaries or Extracted Code Without Buildable Source
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The package installs committed binary ISP tunings extracted from vendor firmware. Their source inputs are absent from the tree, and the build does not regenerate the converted files.
## Fix Focus Areas
- general/package/anyka-osdrv-ak3918ev200/anyka-osdrv-ak3918ev200.mk[11-48]
- general/package/anyka-osdrv-ak3918ev200/files/sensor/convert-3.004.py[1-68]
## Recommended Fix
For each tuning, identify and include the vendor source tuning or point to the SDK release or source tree that generates it, then update the `.mk` to run the converter into `$(@D)` before installation. Document the exact vendor inputs and converter version in the `.mk` and a README, with a checksum for each shipped `.conf`, so the outputs can be reproduced and audited. Remove any file and its `.mk` entry if its source cannot be established; tunings that cannot be sourced should instead be handled in a separate PR documenting their origin and limited to sensors tested on hardware.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Unverified sensor tables ship to cameras 📘 Rule violation ≡ Correctness
Description
The AK3918EV200 config enables six sensor drivers and ships ISP register lists copied from vendor
firmware images; convert-3.004.py copies style 0’s list into every style without a documented
datasheet reference or register-delta analysis. GC1024, GC1034, H62, SC1135, SC1145 and SC2232 have
not run on hardware, so a board using any of them would be the first to exercise those register
sequences and camera paths beyond validator checks and a qemu boot.
Code

general/package/anyka-osdrv-ak3918ev200/anyka-osdrv-ak3918ev200.mk[R25-34]

+#   gc1004.conf  isp_gc1024.conf      v3.000      AK3918EV200 camera
+#   gc1034.conf  isp_gc1034_0.conf    v3.001      V380E2 camera
+#   jxh62.conf   isp_h62.conf         v3.004      AnyCloud39EV300 SDK
+#                (UVC_check_sensor; a webcam tuning, the only H62 one)
+#   sc1135.conf  isp_sc1135_0.conf    v3.015      V380E2 camera
+#   sc1145.conf  isp_sc1145.conf      v3.006      AK3918EV200 camera
+#   sc1235.conf  isp_sc1235.conf      v3.012      AK3918EV200 camera
+#   sc1345.conf  isp_sc1345_dvp.conf  v3.004      Gwell camera
+#   sc2145h.conf isp_sc1245.conf      v3.011      AK3918EV200 camera
+#   sc2235p.conf isp_sc2232.conf      v3.000      V380E2 camera
Evidence
The kernel config enables the six named sensor drivers, while the package source table attributes
their tunings to stock camera firmware images. The converter propagates style 0’s register list to
every style without a datasheet reference or register-delta analysis. The PR description reports
checks against the kernel validator, sensor IDs and frame-rate tables, plus a qemu boot, but no
hardware run for these sensors; those checks do not provide sensor-streaming output.

Rule 3: Hardware evidence is present and honest
general/package/anyka-osdrv-ak3918ev200/anyka-osdrv-ak3918ev200.mk[25-34]
general/package/anyka-osdrv-ak3918ev200/files/sensor/convert-3.004.py[36-62]
br-ext-chip-anyka/board/ak3918ev300/ak3918ev200.generic.config[1471-1474]
Best Practice: Repository guidelines

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Six sensor drivers and their ISP tunings are enabled, but their register lists come from vendor firmware images, the converter reuses style 0’s list for every style, and none of the six sensors has run on hardware. The available validator checks and qemu boot do not establish how they behave on a real camera.
## Fix Focus Areas
- br-ext-chip-anyka/board/ak3918ev300/ak3918ev200.generic.config[1471-1474]
- br-ext-chip-anyka/board/ak3918ev300/ak3918ev200.generic.config[1480-1481]
- br-ext-chip-anyka/board/ak3918ev300/ak3918ev200.generic.config[1484-1485]
- general/package/anyka-osdrv-ak3918ev200/anyka-osdrv-ak3918ev200.mk[25-34]
- general/package/anyka-osdrv-ak3918ev200/files/sensor/convert-3.004.py[12-14]
## Recommended Fix
For each sensor, document in the `.mk` a datasheet or driver reference supporting its register sequence, or identify the specific deltas from shared initialisation and their effect on other boards. Either move the six sensor enables and tunings to a separate PR with hardware sensor-streaming output, or add a real-board `dmesg` log and `v4l2-ctl --stream-mmap` capture for each sensor to this PR’s description. Mark sensors that remain unverified as untested in the Config.in help text; keep the SC1345 commits that the PR description says were run on hardware.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Small video pools prevent capture ✓ Resolved
Description
check_mem accepts every osmem value below totalmem, even when their difference is less than
the 24 MiB video pool this configuration expects. For example, a camera with totalmem=64M and
osmem=60M keeps a 4 MiB video pool because the script returns without adjusting the split.

Grey Divider

Tip of the day
💡 Did you know, you can pick a display mode instead of tweaking every Display option by hand

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

…ideo too little

check_mem only acted when osmem was unset or at least totalmem, so
osmem=60M on a 64M camera kept a 4 MiB video pool, too small to capture.
Bring any split that leaves video less than the vendor's 24 MiB down to
it; a larger pool, chosen on purpose, is left alone.

Raised by the Qodo review of #2796. Dry-run against a stub environment:
64M, 60M and unset become 40M, 40M and 32M stay.
@dimerr

dimerr commented Nov 8, 2026

Copy link
Copy Markdown
Collaborator Author

On the Qodo review:

  1. Small video pools. Fixed in the latest commit. load_anyka now brings down any osmem that leaves video less than 24 MiB, not only one equal to totalmem. A larger pool is left alone.

1 and 2 are the trade-off the description already declares (Scope, unticked box):

  • The .conf files are vendor tuning data. On this ISP the sensor's init list lives in the tuning, so a sensor cannot start without one. Shipping the converted files keeps the build free of vendor originals that are themselves binaries. convert-3.004.py is in the tree so anyone can redo the conversion from a vendor file, and the .mk lists where each came from.
  • The six sensors besides the SC1345 have not run on hardware. That is stated under "Hardware tested on". Their drivers follow the vendor modules that drove these exact register lists, and only the detected sensor's file is ever read, so a board with an SC1345 runs none of them.

@dimerr
dimerr enabled auto-merge (squash) November 8, 2026 07:38
@dimerr
dimerr disabled auto-merge November 8, 2026 12:01
@dimerr
dimerr enabled auto-merge (squash) November 8, 2026 12:01
@dimerr
dimerr marked this pull request as draft November 8, 2026 12:23
auto-merge was automatically disabled November 8, 2026 12:23

Pull request was converted to draft

@dimerr
dimerr marked this pull request as ready for review November 8, 2026 12:23
@dimerr
dimerr enabled auto-merge (squash) November 8, 2026 12:23
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 54a4b91

@dimerr
dimerr merged commit f7a749c into master Nov 8, 2026
85 of 97 checks passed
@dimerr
dimerr deleted the ak3918ev200-sc1345 branch November 8, 2026 15:45
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