Repository navigation
T41NQ + OS08C10 PTZ camera: bring-up notes, a JFFS2 erase-size bug, a T41 sensor-flip fix and NNA/NNDMA findings #1734
RATMANrush
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
TL;DR
soc-nnammap patch, a camera profile draft forcameras-exp, Raptor patches, and static-analysis notes on the NNDMA descriptor format (not validated on hardware yet).Hardware
Ingenic T41NQ in a 96-pin package (QFN96), 128 MB RAM as configured, Linux 4.4.94, uClibc. The vendor library reports
CPU: T41-NQ. Built from thingino-firmware master at d796c13.OmniVision OS08C10 (the existing
ingenic-sdkdriver and IQ file work as they are, so no new sensor driver is needed), 16 MiB SPI NOR (markingMD25Q128SIG, a GigaDevice part; the programmer I use has no profile for it, so I use theGD25Q128ESOP8 profile, and on my first camera the kernel and rootfs partitions read back from the running system match the image byte for byte), RTL8733BU Wi-Fi, Ethernet, a vendor pan/tilt motor (motor.ko,/dev/motor), an IR board with 12 IR LEDs switched by its own light sensor (no software control), and a separate white LED.Flash layout: boot 320 KiB, env 64 KiB, backup 64 KiB, kernel 1600 KiB, rootfs 8192 KiB, data 6144 KiB. RAM split used for 4K streaming plus detection:
mem=63M rmem=56M@0x3f00000 nmem=9M@0x7700000(camera-specific).GPIO (read from my integration scripts, may differ on other PCBs): Wi-Fi enable 61, active low; white LED 81, active low; IR-cut 49/50 with a 100 ms pulse; motor module parameters
pan_all=1020 titl_all=240 titl_init=0 spd_self=600 spd_pan=1 spd_titl=1 spd_all=800.1. JFFS2 data partition: wrong erase block size
/proc/mtdreportserasesize 00008000(32 KiB) for allsfc0_norpartitions, butMakefile.utilsrunsmkfs.jffs2 --eraseblock=$(ALIGN_BLOCK)withALIGN_BLOCK := 65536.At mount the kernel prints
and drops every node that crosses a 32 KiB boundary. In my image that was 62 nodes of 4096 bytes, all belonging to one 4.3 MB file in the overlay. The file came out with zeros in those places and a different SHA-256, and the program that loaded it failed. Two cameras flashed with images carrying the same data partition showed the same wrong hash, which is how I confirmed it was not a one-off write error.
As far as I can tell from
Makefile.utils, the data image only contains files when a user overlay is present at build time. That is probably why this has not shown up before: files created at runtime are written by the kernel with the correct geometry.How I checked: I parsed the JFFS2 image (cleanmarkers every 64 KiB, 62 nodes crossing a 32 KiB boundary, none crossing 64 KiB) and matched offsets and lengths with the kernel warnings.
Scanner
Usage:
python3 scan.py data.jffs2 32768on the data partition image. Also in the repository linked above (tools/scan_jffs2.py).Fix: build the data partition with the real erase size (
--eraseblock=32768). The rebuilt image has 0 crossing nodes (192 cleanmarkers), and a freshly flashed camera boots with no warnings and the correct file hash. To check your own device:cat /proc/mtdanddmesg | grep "would run over the end of the erase block".I would prefer to derive the value from the flash definition instead of reusing the 64 KiB alignment constant. I can send a PR if you tell me which way you prefer.
2. T41 flip through raptor-hal
On T41,
hal_isp_set_hflip/vflipset bothattr.sensor_modeandattr.isp_mode[0]to the same value. The driver repliesISP and Sensor are prohibited from using mirr or flip together!!!and the call fails with-4090. Setting onlysensor_modeworks on OS08C10 (the sensor driver implements flip through registers 0x3820/0x3821). With this change flip works at boot, at runtime and from the web UI, and persists inraptor.conf. The change is four removed lines (theattr.isp_mode[0]assignments).3.
soc-nna: T41NQ ORAM windowPatch for
4.4.94/misc/soc-nna/soc_nna_main.c: it accepts an ORAM window at0x12640000(up to0x40000bytes) in the T41 mapping path, keeps the existing0x12620000path for the other variant, and validates the ranges (vm_pgoff,vm_end, wrapped end addresses, alias segments) before installing the first PTE. Module version marker:H20230310-t41nq-mmap1.Where
0x12640000comes from: it is0x12600000 + l2cache_size. On two units of this camera the register at0x12200060reads0x02000830, field [12:10] = 2, and the stock__aie_mmapmaps that field tol2cache_size = 0x40000(1 → 0x20000, 2 → 0x40000, 3 → 0x80000, 4 → 0x100000, 0 → dynamic path). This matches by arithmetic, but I have not traced the base0x12600000back to stock code, and both units are the same model. This was tested only on T41NQ (96-pin). I have not tested every mapping or error path, nor the other T41 variant; if you know how the ORAM window differs between T41 variants, I would like to adapt the patch.4. NNDMA descriptor and doorbell: static-analysis notes
From static disassembly of the stock Venus libraries, cross-checked against two SDK generations. Part of the analysis was done with AI assistance; every claim in the full notes is tagged confirmed / strongly supported / unconfirmed. No DMA kick has been executed on hardware yet, so treat this as documentation to verify, not as a working driver.
0x12508000; descriptor RAM0x12500000, 16 KiB, 2048 descriptors of 8 bytes (LOW32 then HIGH32).0x00/0x04/0x08, WR doorbells at +0x10/0x14. Status is read withrdhwr($8-$10 for RD0-RD2, $11-$12 for WR0-WR1). The wait helpers do not loop; the "done" bit pattern is not known.q = (len >> 6) - 1is either 12 bits in HIGH32 [31:20] (max 256 KiB) or 17 bits split across both words (max 8 MiB); HIGH32 [19:0] = ORAM-side term(l2cache_size - oram_vbase + offset) >> 6; the DDR-side term in LOW32 is never vbase-relative. RD and WR use the same layout.0x80000000 | descriptor_index, with no length term, as used by generated kernels in both SDK generations.nna_dma.hI started from (CNT/LINK/END flag in bits 50-51, flataddr >> 6fields) does not match the stock encoding.Open points: done/busy semantics, whether a compiled-in ORAM offset equals the stock runtime-mmap-based one, and concurrent RD+WR. I plan to propose the full notes to opensensor/thingino-accel.
5. Native PersonDet in Raptor and PTZ tracking
For the tested detector library build only (it should be pinned to the library hash before upstreaming):
Init parameter block, 288 bytes (reconstructed by static analysis of the stock
ipc_server): u3220at0x004, pointer to the model path at0x008, sensitivity (0..6) at0x010, motion-trigger byte at0x018/0x019, detection distance (0..4) at0x01c,20at0x020and0x024, skip-frame count at0x0f8, width/height at0x104/0x108, and0x00900000(9 MiB) at0x11c.Result: count at offset
0; records from0x648, stride0x2c; box at +0x10, class at +0x20, confidence at +0x28. The parser rejects invalid counts, confidences and rectangles; class 0 is the person class in my tests.PTZ through
/dev/motor, requests0xC0046Dxx:00stop,03absolute move (argument{int x; int y;}),04read position,08read busy flag. Tracking centres the detected person (pan step proportional to the error; tilt step and dead zone configurable; axis inversion for mirrored images) and shares a lock with manual control. An experimental "white light on person in the dark" switch is included.Camera profile
I would like to add the camera to
configs/cameras-exp/, with a minimal defconfig modelled onzintronic_ikpw530tv1_t41nq_gc5603_eth+rtl8733buand the GPIO inthingino.jsonas described indocs/hardware/gpio.md. A draft is in the repository linked above. The PTZ part depends on the vendormotor.ko(see below). Which key should the white LED use inthingino.json, and which pin of the IR-cut pair is "day" in your convention?What is tested and what is not
Tested on the development camera: streaming, manual PTZ, PersonDet detections, flip at boot and from the UI, pan tracking direction, RTSP. On a second camera flashed with the final image: boot, correct model hash, no JFFS2 warnings, PersonDet detecting, flip at boot.
Not tested: tracking at 1-4 m, vertical tracking tuning, and the white-light logic on real detections (the brightness check works, but I have not seen it trigger). Measurements from one room with stray light:
ae_luma4-14 in the dark with the IR LEDs, about 55 with the night IR-cut position, 52-59 with the white LED; PersonDet confidence 0.60-0.67 with the night IR-cut position and 0.79-0.89 with the white LED.Not included and licences
No OEM files: not the person-detection model or its library, not the vendor
motor.ko(byte-for-byte the stock module,license=GPL, author HX; I do not have its source, so I will not redistribute it). The model can be taken from your own stock dump. The firmware I inspected has only the default accounts and a non-empty data partition, so it is a reference, not a clean public release.Questions
soc-nnapatch inthingino/ingenic-sdk, Raptor/HAL patches in the Raptor repositories, NNDMA notes in the accel project?All reactions