Files
thebearsandClaude Opus 5.5 07da135257 Add the vendor firmware: stock flash dump, update file, both unpacked
vendor/ holds the camera's 16 MB NOR dump (backup-ssc377d-nor16m.bin), the
vendor update V3.6.1.3, and their unpacked trees, which the RE tools and
notes read. verify.py now defaults to vendor/flash_dump_ssc377d, and the
docs point at vendor/ instead of folders beside the checkout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EfVNki7giKruPunvux6dDA
2026-10-29 14:23:37 -04:00

15 KiB

OpenIPC on the AnjoyVision MC-L18D (SSC377D + GC5603)

Sources analysed: backup-ssc377d-nor16m.bin (full 16 MB NOR dump, extracted to vendor/flash_dump_ssc377d/) and the vendor update r1885__firmware_MCL18D_...bin (extracted to vendor/firmware_MCL18D_V3.6.1.3/). Both carry the same kernel and the same GC5603 driver; the rootfs in the flash dump is an older app build.

Layout of this folder

Path What it is
firmware/ OpenIPC/firmware at tag latest (7d213e9), branch mcl18d-port, changes uncommitted
sensors/ OpenIPC/sensors, branch gc5603-infinity6c, new sigmastar/infinity6c/sensor_gc5603_mipi.c
linux-infinity6c/ OpenIPC/linux sigmastar-infinity6c, branch mcl18d, new MC-L18D device tree
ipctool/ OpenIPC/ipctool, reference only (it already detects GC5603)
images/ built firmware: openipc.ssc377d-nor-lite.tgz, uImage.ssc377d, rootfs.squashfs.ssc377d
gc5603-difftest/ emulator harness comparing the vendor and rebuilt GC5603 modules
AF-BOARD-PROTOCOL.md, af-board-re/ the lens (AF/zoom) board protocol, and the emulator checks behind it
TECH-SPEC.md technical specification: interfaces, configs, protocols, algorithms, verification matrix
LEARNING-GUIDE.md the whole port explained: sources for every fact, every change, tests, mistakes

Build: make BOARD=ssc377d_mcl18d in firmware/ on Ubuntu 24.04. This Arch host cannot build Buildroot 2024.02's host-tar, so the build was run in a container (Ubuntu 24.04 plus build-essential, bc, bison, flex, cpio, rsync, unzip, wget, python3, cmake, u-boot-tools, and bsdextrautils for the kernel's padmux check):

docker run --rm --user $(id -u):$(id -g) -e HOME=$O/home -e BR2_DL_DIR=$O/dl -e PWD=$F \
  -v $F:$F -v $O:$O -w $F openipc-builder:24.04 make BOARD=ssc377d_mcl18d TARGET=$O/output

with F the firmware/ path and O=~/.cache/openipc-mcl18d.

Changes in firmware/

File Change
br-ext-chip-sigmastar/configs/ssc377d_mcl18d_defconfig ssc377d_lite plus: board kernel config and patch dir, 16 MB flash, SNS_MODEL=gc5603, board package
br-ext-chip-sigmastar/board/infinity6c/infinity6c-ssc027a-mcl18d.config ssc027a kernel config with CONFIG_SS_DTB_NAME="infinity6c-ssc027a-s01a-mcl18d"
br-ext-chip-sigmastar/board/infinity6c/mcl18d/linux/0001-...patch adds the MC-L18D device tree (from linux-infinity6c/)
general/package/sigmastar-osdrv-sensors/0001-...gc5603-driver.patch adds the GC5603 driver (from sensors/)
general/package/sigmastar-osdrv-infinity6c/files/script/load_sigmastar gc5603) case arm
general/package/sigmastar-osdrv-infinity6c/files/sensor/configs/gc5603.bin IQ file: the flash dump's /config/iqfile/gc4023_day.bin
general/package/anjvision-mcl18d/ customizer.sh (majestic pin map, ONVIF setup), muxes.sh (boot GPIO levels), mcl18d-io (reset button, alarm in), pelco-ptz (C, built from src/), mcl18d-af (autofocus), onvif.conf, pelco-ptz.conf, onvif-passwd
general/package/onvif-simple-server/03-ptz-absolute-relative-zoom-fixes.patch upstream fixes for absolute/relative moves (see PTZ below)
general/package/Config.in, .github/scripts/ci-matrix.py registration

Kernel changes carried over

The vendor kernel is SigmaStar's SSC027A-S01A reference build. Against OpenIPC's SSC027A device tree, the board-level differences are:

  • Pad mux: PAD_PWM0 is PWM0 (white lamp), PAD_SPI0_CZ is PWM4 (IR lamp), PAD_PWM1 is the Ethernet LED, PAD_FUART_RX/TX are the 2-wire FUART for the zoom/PTZ board. OpenIPC's default puts I2C0 on the PWM pads.
  • SD card at 20 MHz with drive strength 0 (OpenIPC default 48 MHz, drive 1).

The compiled padmux table matches the vendor's entry for entry. Pad numbering is identical between the two kernels.

Not carried over, on purpose:

  • The vendor's built-in /dev/irled driver. It pulses the IR-cut pins and reads the CDS pin; majestic does both from customizer.sh's pin map.
  • Core voltage: OpenIPC's reference tree switches 900/1000 mV on PAD_PM_GPIO4 (GPIO 30) by CPU frequency. The vendor has no regulator node and its media_server holds GPIO 30 low. OpenIPC's behaviour is the reference design's.

GC5603 driver

Rebuilt in C from the vendor's gc5603_MIPI_1125.ko: 2960x1666@30, 2-lane MIPI, 27 MHz MCLK, I2C 0x62, BG Bayer, 10-bit. The vendor module cannot be loaded as-is: its ms_cus_sensor has no SPI fields, which OpenIPC's has (spi_cfg, 12 bytes, and spi_bus, 4), so everything past the I2C bus pointer sits 16 bytes off. After sat_mingain, OpenIPC also has CurTotalVertLine and bChangeVTS (8 bytes with padding) where the vendor has nothing, so every callback pointer sits 24 bytes off.

Verification without hardware: both modules run in an ARM emulator against the same fake sensor (scratchpad/difftest/). 76,011 checks over init, ID, gain, exposure, FPS, orientation and the temperature black-level logic: zero mismatches. Four injected bugs were each caught (82 to 928 mismatches).

Deliberate difference: orientation. The vendor driver maps "no mirror/flip" to 0x022c=3 and its app inverts mirror and flip for this board, so the picture is upright at the sensor's native readout. Here "no mirror/flip" is native readout.

Pin map

Resource Pad Use majestic / script
GPIO 11 SPI0_DI IR-cut, opens filter (night) nightMode.irCutPin1
GPIO 80 SAR_GPIO1 IR-cut, closes filter (day) nightMode.irCutPin2
GPIO 23 PM_IRIN light board's day/night output: 1 day, 0 night nightMode.lightSensorPin, lightMonitor true
PWM4 / GPIO 9 SPI0_CZ IR lamp; driven as a GPIO, high at night nightMode.backlightPin 9 (irLightPwmChannel 4 kept)
PWM0 PWM0 white lamp nightMode.whiteLightPwmChannel
GPIO 12 SPI0_DO speaker amp enable audio.speakerPin
GPIO 10 SPI0_CK red/blue light IO, driven 1 at boot muxes.sh
GPIO 61 SR_IO01 warning-light output, active low; 1 (off) at boot muxes.sh
GPIO 60 SR_IO00 reset button, hold 5 s = factory reset mcl18d-io
GPIO 44 FUART_CTS alarm input, logged, runs /etc/mcl18d/alarm-in mcl18d-io
GPIO 45 FUART_RTS SD card power device tree
GPIO 22 PM_SD_CDZ SD card detect device tree
pad 48 GPIO2 audio amp (kernel amp-pad) device tree

Build result

  • uImage 1991 of 2048 KB, rootfs 5264 of 8192 KB (16 MB NOR layout).
  • The kernel's own SigmaStar checks passed: "The configuration of GPIO & PADMUX is correct!" and "PUSE check PASS!".
  • The DTB embedded in the uImage carries the MC-L18D pad mux and SD settings.
  • The rootfs has sensor_gc5603_mipi.ko, /etc/sensors/gc5603.bin, the gc5603) loader arm, customizer.sh, muxes.sh, S94mcl18d, mcl18d-io.
  • The shipped sensor_gc5603_mipi.ko passes the vendor comparison (0 of 76,011).
  • ci-matrix.py --self-test passes with the board and package registered.

PTZ

The infinity6c majestic build has no PTZ settings, so majestic-af cannot load on this chip. PTZ instead goes through onvif-simple-server on port 85, whose PTZ hooks run pelco-ptz, which drives the lens board and any Pelco-D head on connector D7 (/dev/ttyS2, 57600 baud, address 1 by default; /etc/pelco-ptz.conf). majestic's own ONVIF is switched off on first boot so clients find one camera.

D7 is a 3.3 V UART. An RS-485 Pelco head needs a TTL-to-RS-485 adapter.

The lens board must be kept awake. It, and the pan/tilt it drives, ignore every Pelco-D frame unless autofocus data frames keep arriving, which the vendor firmware streams at frame rate. S94mcl18d runs pelco-ptz keepalive, one frame every 100 ms (keepalive_ms in /etc/pelco-ptz.conf; 0 turns it off). Without it nothing on D7 moves and nothing answers. Details and the measurements are in AF-BOARD-PROTOCOL.md, "What this means for OpenIPC".

ONVIF Pelco-D
ContinuousMove (pan, tilt, zoom, diagonals) movement bits, one combined frame
Set/Goto/RemovePreset, home presets 2..32; preset 1 is home
GetStatus last commanded position: this head answers no position query
AbsoluteMove, RelativeMove not offered: this head ignores set-position (0x4B/0x4D/0x4F)

The head's absolute positions are its presets, which it stores and returns to itself. pelco-ptz abs/rel remain for a head that implements the extended commands; uncomment jump_to_abs/jump_to_rel in /etc/onvif.conf for one.

Coordinates: pan -1..1 is -180..180 degrees, tilt -1..1 is -90..90 degrees (up positive, clamped to tilt_min/tilt_max), zoom 0..1 is wide..tele. Invert pan or tilt in /etc/pelco-ptz.conf for a ceiling mount.

ONVIF login is root with a random password until you run onvif-passwd. Use the camera's root password there: clients reuse the ONVIF credentials for RTSP, which majestic checks against root.

Upstream onvif_simple_server bugs fixed by the package patch: a pan/tilt AbsoluteMove also drove the zoom fully wide; zoom-only absolute and relative moves ran an uninitialised command; an empty RelativeMove was accepted; a missing Zoom space was passed to strcmp; SetPreset scanned %s into an int.

Tests, all host-native, in anjvision-mcl18d/src/:

  • make test: frames and coordinate mapping, byte for byte.
  • make e2e: the real pelco-ptz against a simulated head on a pty, including the focus and iris frames, and keepalive: whole frames at the configured rate, commands arriving intact between them, keepalive_ms=0.
  • make af BUSYBOX=...: mcl18d-af under a host build of the tree's busybox ash, against a simulated lens with backlash, noise and end stops. The cases cover starting on either side of focus, at focus, focus behind the start with snapshots that lag the lens, a refused crop, a wrong login and a featureless picture. The simulated lens moves while a sweep snapshots it. The bar is ending within one approach step of focus (15% in the sim's narrow bell); it passed 5 runs out of 5.
  • tests/onvif_e2e.py: SOAP requests through the patched server into pelco-ptz and the simulated head; 23 checks pass. The unpatched server fails 7 of them.

Lens board: zoom, focus, autofocus

The AF/zoom lens board shares this port. The vendor runs the port at 57600 baud whenever /opt/ch/af.flag exists, as it does on this camera, overriding its own 2400 PTZ setting. So pelco-ptz.conf defaults to 57600, and a pan/tilt head on the same wires has to be set to 57600 as well. The board takes plain Pelco-D for zoom, focus and iris, but only while pelco-ptz keepalive runs (above). An earlier version of this file said "115200 baud, FC 01 protocol"; that was wrong for this camera. See AF-BOARD-PROTOCOL.md.

pelco-ptz move in 0.5; sleep 1; pelco-ptz stop    # zoom
pelco-ptz focus near; usleep 200000; pelco-ptz stop
pelco-ptz iris open; usleep 200000; pelco-ptz stop
mcl18d-af                                         # autofocus once

The focus and iris frames match the vendor's FocusNearAutoOff / FocusFarAutoOff / IrisOpenAutoOff / IrisCloseAutoOff byte for byte. Frames that move only the lens carry a speed in both data bytes, as the vendor sends them.

The board's own autofocus needs a frame of ISP focus statistics for every video frame, and neither majestic's API nor its plugins give them on this SoC (/api/v1/isp/af-zones.json answers "No AF statistics on this camera"); the keep-alive sends constant values, so focus after a zoom is not managed. mcl18d-af focuses from the camera side instead, once, when run.

It drives the focus motor with pelco-ptz and judges sharpness by the size of a full-frame JPEG snapshot (majestic answers ?crop= with 501 here): a sharp picture of the bench was nearly three times the size of a blurred one. The motor is slow (focus lay up to 19 s of motor time away, and the sharp band was some 1.5 s wide), so it first sweeps with the motor running, snapshotting as it goes, until the picture has risen and fallen back (focus passed), turning round if it gets worse from the start. Then it backs off past the best snapshot and steps back in 150 ms steps the same way, stopping on the first worse step, so it never reverses near focus and gear backlash cannot leave it short. On the camera, from either side of focus: 12-27 s, ending at 99.4-99.6% of the best snapshot. It logs AF_START, AF_SWEEP, AF_BACK, AF_STEP, AF_DONE, AF_NO_DETAIL to syslog. It needs majestic's login: by default /etc/onvif.conf's, which onvif-passwd sets to root's; otherwise -u root:PASSWORD. mcl18d-af -h lists -s (step), -b (back-off), -t (sweep limit) and the rest.

On hardware, 2026-10-28/29

Seen on the camera, over serial and the network:

  • Boots the 16 MB layout (mtd3 8192 KB); the sensor runs 2960x1666 and snapshots come out 2960x1664.

  • Pan, tilt and zoom move, from the shell and through ONVIF ContinuousMove and Stop on port 85, with the keep-alive running, after a reboot with nothing run by hand. Presets: set, move away, go to returns to the stored view.

  • The head never answers Pelco-D position queries and ignores set-position, also after "set zero" (0x49).

  • /image.jpg?crop= and ?width= answer 501 on this platform.

  • A still scene's JPEG size holds within 0.1-0.6% between snapshots.

  • The heat sink was loose: the SoC ran at 76 C, the camera reset ("HW Reset" in the boot ROM, also idle in U-Boot), its memory self-test failed, the kernel oopsed on corrupted memory, and frames flared into coloured noise every 5-15 s. With it refitted: 63 C steady, no reset or oops in the 25 minutes before I next rebooted it, and flares only at start-up and about one a minute after.

  • Night mode: with lightMonitor on, majestic follows GPIO 23 (source 1), opens the IR-cut and goes grey at night, and drives GPIO 9 high; checked by inverting the sensor for a moment. GPIO 23 itself read 1 (day) with the room lights on and off, and nothing lit the scene with the IR line high or low, or with PWM4 at 0% or 100%. In the vendor's "Passive" mode, the one this unit shipped in, the board switches its IR LEDs and IRDET from its own photoresistor, so both wait for real darkness at that sensor, or the board is unpowered. Not confirmed either way.

  • Colour flares are still there after the heat sink fix, rarer: a horizontal line below which the frame is random noise, at random rows, mostly within seconds of a large lighting change. Not caused by UART traffic, by the driver's black-level writes, by motors, or by mid-frame writes of the frame length, gain index or analog gain page; the cause is open.

  • set_gpio(12, 0) error at every majestic start: the speaker-enable pin is not taken. Not looked into.

Not yet checked: GPIO 10/61's effect, SD card, audio in and out.

Flashing: the vendor U-Boot (the stock image's) stops on Enter, not Ctrl-C, and only within a very short window at power-on; bootdelay=1 in this tree's environment gives OpenIPC's U-Boot a usable one.

Upstreaming

This is a local port. Per firmware/CLAUDE.md it would be split across OpenIPC/sensors (driver), OpenIPC/linux (device tree) and OpenIPC/builder (the board files). Two pieces would not be accepted as they are: the driver's register tables come from the vendor module, and gc5603.bin is a binary from the factory image.