Repository navigation
hisilicon-opensdk: build sc2315e for hi3516ev200 from source, dropping the binary - #2881
Conversation
…g the binary hisilicon-osdrv-hi3516ev200 carried libsns_sc2315e.so as a binary with no source here. It wrote two words ~490 bytes past its 2156-byte sensor state on every frame-rate set, and musl's allocator could stop the streamer with SIGILL in free() when the pipeline restarted -- reported from the field on hi3516ev200 + SC2315E cameras. Its source is now in openhisilicon (smart_sc2315e, OpenIPC/openhisilicon#306) with the overrun fixed. Bump the opensdk pin to that merge and build the driver for the hi3516ev200 family only: gk7205v200 takes the family's sensor list whole and installs from its own sensor tree, which has no sc2315e. The binary goes, so the two cannot overwrite each other in either install order.
PR Summary by QodoBuild hi3516ev200 SC2315E driver from fixed upstream source
AI Description
Diagram
High-Level Assessment
Files changed (1)
|
Code Review by Qodo
1. Standalone builds lose the sensor driver
|
|
Qodo finding 1 (standalone builds lose the sensor driver): left as is. Every defconfig that enables |
Problem
hi3516ev200-family cameras with an SC2315E sensor can lose the streamer when the video pipeline restarts (a reload with a changed setting): it stops with SIGILL in musl's
free(), freeing the sensor driver's state. Reported from the field to openipc.org's crash collection; whether a given streamer build is hit depends only on heap layout, so it comes and goes with unrelated changes.The cause is
libsns_sc2315e.so, whichhisilicon-osdrv-hi3516ev200carried as a binary with no source here. It allocates a 2156-byteISP_SNS_STATE_Sand, on every frame-rate set, writes two words ~490 bytes past it (pstSnsState[1]..., lines carried over from a disassembly of a vendor build with a larger state struct). Its source is now in openhisilicon (libraries/sensor/hi3516ev200/smart_sc2315e), with the overrun fixed: OpenIPC/openhisilicon#306.This bumps the opensdk pin to that merge (the only change between the two pins), builds the driver for the hi3516ev200 family, and removes the binary so the two cannot overwrite each other in either install order. It is added per family rather than to
HISILICON_OPENSDK_SENSORS_hi3516ev200itself, because gk7205v200 takes that list whole and installs from its own sensor tree, which has no sc2315e.Hardware tested on
hi3516ev200 + SC2315E lab camera, stock OpenIPC lite firmware (
Lite HiSilicon (hi3516ev200), master+8d76d3e), with thelibsns_sc2315e.sotaken from ahi3516ev200_litebuild of this branch (output/target/usr/lib/sensors/) bind-mounted over the installed one. I did not flash a full image from this branch: locally the build stopped atpost-image-split.shon the kernel config (a stale kernel tarball in the download cache I reused), after the rootfs was built.To make the overrun visible regardless of heap layout, the streamer was run with a test-only
LD_PRELOADshim that places any 2156-byte allocation flush against aPROT_NONEpage, and with/proc/sys/kernel/print-fatal-signalsset to 1. Neither is part of this change. The "after" run used a current streamer build (it restarts the pipeline only when a setting changes, sovideo0.fpswas changed before each reload).Evidence
Before (installed binary, md5
c945192b496632a12f5004a3a17f0367), on start:The driver is mapped at
0xb6a8e000(themalloccall returns to+0x161c), so the fault is at+0x1050:str r1, [r3, #2648]withr3the 2156-byte state.After (this branch's build, md5
b5a5b19441aa8f3ef8e86df0a99cc4c1), eight pipeline rebuilds:Sensor timing (
/proc/umap/ispinterrupt gap, 40 ms) and encoder rates match the installed binary's under the same settings; snapshots from both looked the same.Size: the driver built from source is 31320 bytes against the binary's 35360, so the image shrinks by ~4 KB. Local
hi3516ev200_literootfs:Filesystem size 5214.91 Kbytes.Scope
general/package/all-patches/linux/(those go to OpenIPC/linux)general/overlay/or in a sharedload_<vendor>script hardcodes a value specific to my boardLD_PRELOAD, and no binaries that cannot be rebuilt from source