Using MIPI to transfer RAW image data

For a project we are using the MIPI CSI to transfer data (not camera data) from an FPGA to the jetson. In between the FPGA and the MIPI interface is a toshiba tc358748 to convert the parallel data to MIPI.

The data is not video data, but the dynamics of the data are the same (24 bits, frames, lines and colums). The idea is to transfer the data as RGB888 or as RAW data into the jetson.

The driver we build to control the tc358748 is based on the imx185 and the ov5693 example driver, combined with the documentation (Sensor Driver Programming Guide).

So far so good, we currently have a driver that loads and registers itself properly in the camera platform.

But as soon as we start streaming, we get a segmentation fault from the nvcamera-daemon:

[11004.523888] nvcamera-daemon[726]: unhandled level 2 translation fault (11) at 0x00000000, esr 0x92000006
[11004.536014] pgd = ffffffc1d7c4e000
[11004.542048] [00000000] *pgd=0000000261912003, *pud=0000000261912003, *pmd=0000000000000000
[11004.553141]
[11004.557368] CPU: 0 PID: 726 Comm: nvcamera-daemon Not tainted 4.4.38 #127
[11004.567033] Hardware name: quill (DT)
[11004.573564] task: ffffffc070286800 ti: ffffffc07793c000 task.ti: ffffffc07793c000
[11004.584032] PC is at 0x403038
[11004.589975] LR is at 0x403034
[11004.595912] pc : [<0000000000403038>] lr : [<0000000000403034>] pstate: 60000000
[11004.606423] sp : 0000007f8775c280
[11004.612835] x29: 0000007f877609c0 x28: 0000000000000000
[11004.621353] x27: 0000000000000001 x26: 0000007f877602f0
[11004.629849] x25: 0000000000404000 x24: 0000000000000334
[11004.638420] x23: 0000007f8775e2f0 x22: 0000007f8775d2f0
[11004.647013] x21: 0000007f8775e234 x20: 0000007f8775c300
[11004.655524] x19: 0000007f8775e920 x18: 0000000000000001
[11004.664140] x17: 00000000000002d6 x16: 00000000000002d6
[11004.672593] x15: 0000007f877611d0 x14: 0000007f877618c0
[11004.681063] x13: 0000007f88e48030 x12: 0000000000000000
[11004.689382] x11: 0000000000000001 x10: 0000000000000000
[11004.697557] x9 : 0000007f88f1e000 x8 : 0000000000000001
[11004.705710] x7 : 0000000000000001 x6 : 0000000000000001
[11004.713864] x5 : 0000000000000000 x4 : 0000000000000000
[11004.721982] x3 : 0000000000000001 x2 : 0000007f80000d70
[11004.730111] x1 : 0000000000000001 x0 : 0000000000000000
[11004.738248]
[11004.742476] Library at 0x403038: 0x400000 /usr/sbin/nvcamera-daemon
[11004.751572] Library at 0x403034: 0x400000 /usr/sbin/nvcamera-daemon
[11004.760632] vdso base = 0x7f8990d000
[11004.767082] audit: type=1701 audit(1546521140.260:4): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=726 comm="nvcamera-daemon" exe="/usr/sbin/nvcamera-daemon" sig=11
Segmentation fault (core dumped)

To start the stream, we use gst-launch:

# GST_DEBUG=3 gst-launch-1.0 nvcamerasrc ! autovideosink
Setting pipeline to PAUSED ...
0:00:00.081145824   645       0x596490 WARN                     omx gstomx.c:2826:plugin_init: Failed to load configuration file: Valid key file could not be found in search dirs (searched in: /home/root/.config:/etc/xdg as per GST_OMX_CONFIG_DIR environment variable, the xdg user config directory (or XDG_CONFIG_HOME) and the system config directory (or XDG_CONFIG_DIRS)
Socket read error. Camera Daemon stopped functioning.....
0:00:00.800932352   645       0x596490 ERROR            nvcamerasrc gstnvcamerasrc.cpp:2448:gst_nvcamera_open:<nvcamerasrc0> REQ_NVCAM_CREATE_SESSION to camera_daemon failed

gst_nvcamera_open() failed ret=0
0:00:00.801118944   645       0x596490 WARN                 basesrc gstbasesrc.c:3345:gst_base_src_start:<nvcamerasrc0> error: Failed to start
0:00:00.801278656   645       0x596490 WARN                 basesrc gstbasesrc.c:3718:gst_base_src_activate_push:<nvcamerasrc0> Failed to start in push mode
0:00:00.801378368   645       0x596490 WARN                GST_PADS gstpad.c:1107:gst_pad_set_active:<nvcamerasrc0:src> Failed to activate pad
ERROR: Pipeline doesn't want to pause.
ERROR: from element /GstPipeline:pipeline0/GstNvCameraSrc:nvcamerasrc0: GStreamer error: state change failed and some element failed to post a proper error message with the reason for the failure.
Additional debug info:
../../../../gstreamer-1.12.2/libs/gst/base/gstbasesrc.c(3345): gst_base_src_start (): /GstPipeline:pipeline0/GstNvCameraSrc:nvcamerasrc0:
Failed to start
Setting pipeline to NULL ...
Freeing pipeline ...

For more debugging, we enabled the extra debugging in the nvcamera-daemon:

# systemctl stop nvcamera-daemon
# export enableCamPclLogs=5
# export enableCamScfLogs=5
# /usr/sbin/nvcamera-daemon &> log
# cat log
Thread 1 getting next capture
Thread 1 is waiting
Thread 2 getting next capture
Thread 2 is waiting
Thread 3 getting next capture
Thread 3 is waiting
Thread 4 getting next capture
Thread 4 is waiting
Thread 5 getting next capture
Thread 5 is waiting
Thread 6 getting next capture
Thread 6 is waiting
Thread 7 getting next capture
Thread 7 is waiting
Thread 8 getting next capture
Thread 8 is waiting
Thread 9 getting next capture
Thread 9 is waiting
Thread 10 getting next capture
Thread 10 is waiting
Thread 11 getting next capture
Thread 11 is waiting
Thread 12 getting next capture
Thread 12 is waiting
Starting services...
Worker thread IspHw statsComplete start
Worker thread IspHw frameComplete start
Worker thread CaptureScheduler checkFramePending start
Worker thread CaptureScheduler frameStart start
Worker thread V4L2CaptureScheduler checkCaptureComplete start
Worker thread V4L2CaptureScheduler issueCaptures start
Worker thread PS handleRequests start
getInstance: s_instance(0x7f80b2dc90)
getInstance: s_instance(0x7f80b2dc90)
subscribe: create SensorType(gyroscope) sensor(0x7f80b2fe10)
subscribe: create SensorType(accelerometer) sensor(0x7f80b35270)
AC plugin not present: dlopen "acplugin.so", acplugin.so: cannot open shared object file: No such file or directory
Services are started
NvPclSetHotplugCallback: ++++++++++++++++++++++
---- Imager: Calibration blob file handling supported in this build ----
NvPclHwGetModuleList: OFParserListModules Succeeded
NvPclHwMatchPartNum: Found calibration Part#:P5V27CCV, P5V27C:"P5V27C"
NvPclHwPrintModuleDefinition -- Name: e3326_front_P5V27C
NvPclHwPrintModuleDefinition -- Position: 0
NvPclHwPrintModuleDefinition -- CalibrationData Found: 1
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].Name: v4l2_sensor
NvPclHwPrintCameraSubModule -- HwCamSubModule[0].DevName: tc358748 2-000e
NvPclHwGetModuleList: OFParserListModules Succeeded
NvPclModuleListInitialize: NvPclModule list[0]: e3326_front_P5V27C position0
NvPclHwScanExternalCameras -- adding video0 to discover list
NvPclHwScanExternalCameras -- adding video0 to discover list
initialize: /dev/video0
queryControls: 10100746 control Exposure
queryControls: 10100747 control Frame Rate
queryControls: 10100836 control Bypass Mode
queryControls: 10100837 control Override Enable
queryControls: 10100838 control Height Align
queryControls: 10100839 control Size Align
queryControls: 10100840 control Write ISP format
queryControls: 10100841 control Sensor Signal Properties
queryControls: 10100842 control Sensor Image Properties
queryControls: 10100843 control Sensor Control Properties
queryControls: 10100844 control Sensor DV Timings
queryControls: 10100866 control Sensor Modes
Ioctl failed: Invalid argument
NvPclHwScanExternalCameras -- adding video0 to discover list
initialize: /dev/video0
queryControls: 10100746 control Exposure
queryControls: 10100747 control Frame Rate
queryControls: 10100836 control Bypass Mode
queryControls: 10100837 control Override Enable
queryControls: 10100838 control Height Align
queryControls: 10100839 control Size Align
queryControls: 10100840 control Write ISP format
queryControls: 10100841 control Sensor Signal Properties
queryControls: 10100842 control Sensor Image Properties
queryControls: 10100843 control Sensor Control Properties
queryControls: 10100844 control Sensor DV Timings
queryControls: 10100866 control Sensor Modes
Ioctl failed: Invalid argument
getHotplugMonitor: Getting hotplug monitor instance
 initializeHotplug++
 hotPlugfunc ++
 addWatch: Watch added wd='1'
CheckProcDTExists: INFO: accessing /proc/device-tree/tegra-virtual-camera-platform/modules; No such file or directory
OFParserGetVirtualDevice: NVIDIA Camera virtual enumerator not found in proc device-tree
setHotplugCallback: Registered new callback client
NvPclSetHotplugCallback: ----------------------
 hotPlugfunc: reading from inotify FD, Thread waiting
NvPclOpen: ++++++++++++++++++++++
NvPclStateControllerOpen: Found GUID 0 match at index[0]
NvPclHwInitializeModule: allocate overrides pathname @ 0x7f80a83e30
NvPclHwInitializeModule: allocate overrides pathname @ 0x7f80abeb20
NvPclHwInitializeModule: allocate overrides pathname @ 0x7f80a942b0
NvPclHwInitializeModule: allocate overrides pathname @ 0x7f80a840a0
NvPclHwInitializeModule: allocate overrides pathname @ 0x7f80a88990
NvPclHwInitializeModule: allocate overrides pathname @ 0x7f80a88900
LoadOverridesFile: looking for override file [/Calib/camera_override.isp] 1/16CheckOverridesPermissions: cannot stat file [/Calib/camera_override.isp]
LoadOverridesFile: looking for override file [/data/nvcam/settings/camera_overrides.isp] 2/16CheckOverridesPermissions: cannot stat file [/data/nvcam/settings/camera_overrides.isp]
LoadOverridesFile: looking for override file [/opt/nvidia/nvcam/settings/camera_overrides.isp] 3/16CheckOverridesPermissions: cannot stat file [/opt/nvidia/nvcam/settings/camera_overrides.isp]
LoadOverridesFile: looking for override file [/var/nvidia/nvcam/settings/camera_overrides.isp] 4/16CheckOverridesPermissions: cannot stat file [/var/nvidia/nvcam/settings/camera_overrides.isp]
LoadOverridesFile: looking for override file [/data/nvcam/camera_overrides.isp] 5/16CheckOverridesPermissions: cannot stat file [/data/nvcam/camera_overrides.isp]
LoadOverridesFile: looking for override file [/data/nvcam/settings/e3326_front_P5V27C.isp] 6/16CheckOverridesPermissions: cannot stat file [/data/nvcam/settings/e3326_front_P5V27C.isp]
LoadOverridesFile: looking for override file [/opt/nvidia/nvcam/settings/e3326_front_P5V27C.isp] 7/16CheckOverridesPermissions: cannot stat file [/opt/nvidia/nvcam/settings/e3326_front_P5V27C.isp]
LoadOverridesFile: looking for override file [/var/nvidia/nvcam/settings/e3326_front_P5V27C.isp] 8/16CheckOverridesPermissions: cannot stat file [/var/nvidia/nvcam/settings/e3326_front_P5V27C.isp]
---- imager: No override file found. ----
Imager: looking for override file [/mnt/factory/camera/factory.bin] 1/16
Imager: looking for override file [/Calib/factory.bin] 2/16
Imager: looking for override file [/Calib/calibration.bin] 3/16
Imager: looking for override file [(null)] 4/16
Imager: looking for override file [(null)] 5/16
Imager: looking for override file [(null)] 6/16
Imager: looking for override file [(null)] 7/16
Imager: looking for override file [(null)] 8/16
Imager: looking for override file [(null)] 9/16
Imager: looking for override file [(null)] 10/16
Imager: looking for override file [(null)] 11/16
Imager: looking for override file [(null)] 12/16
Imager: looking for override file [(null)] 13/16
Imager: looking for override file [(null)] 14/16
Imager: looking for override file [(null)] 15/16
Imager: looking for override file [(null)] 16/16
Imager: looking for override file [/data/nvcam/settings/factory.bin] 1/16
Imager: looking for override file [/data/nvcam/settings/e3326_front_P5V27C.bin] 2/16
Imager: looking for override file [/opt/nvidia/nvcam/settings/e3326_front_P5V27C.bin] 3/16
Imager: looking for override file [/var/nvidia/nvcam/settings/e3326_front_P5V27C.bin] 4/16
Imager: looking for override file [(null)] 5/16
Imager: looking for override file [(null)] 6/16
Imager: looking for override file [(null)] 7/16
Imager: looking for override file [(null)] 8/16
Imager: looking for override file [(null)] 9/16
Imager: looking for override file [(null)] 10/16
Imager: looking for override file [(null)] 11/16
Imager: looking for override file [(null)] 12/16
Imager: looking for override file [(null)] 13/16
Imager: looking for override file [(null)] 14/16
Imager: looking for override file [(null)] 15/16
Imager: looking for override file [(null)] 16/16
NvPclCreateDriver: Found NvPcl Driver Hal dev_name match (v4l2_sensor)
NvPclCreateDriver: Found a Driver name match (v4l2_sensor)
NvPclConnectDrivers: hImager was NULL, creating new imager
NvPclInitializeDrivers: v4l2_sensor ++++++++++++++++++
OFDPropertyGetString: could not read property [devnode-bus]
initialize: tc358748 2-000e
queryControls: 10100746 control Exposure
queryControls: 10100747 control Frame Rate
queryControls: 10100836 control Bypass Mode
queryControls: 10100837 control Override Enable
queryControls: 10100838 control Height Align
queryControls: 10100839 control Size Align
queryControls: 10100840 control Write ISP format
queryControls: 10100841 control Sensor Signal Properties
queryControls: 10100842 control Sensor Image Properties
queryControls: 10100843 control Sensor Control Properties
queryControls: 10100844 control Sensor DV Timings
queryControls: 10100866 control Sensor Modes
Ioctl failed: Invalid argument
OFDPropertyGetString: could not read property [use_decibel_gain]
OFDPropertyGetString: could not read property [use_sensor_mode_id]
OFDPropertyGetString: could not read property [delayed_gain]
OFDPropertyCopyToLong: could not read property [has-eeprom]
Control Fuse ID not found
Control OTP Data not found
Control Group Hold not found
Control Gain not found
Control HDR enable not found
Control Frame Length not found
Control Coarse Time not found
Control Coarse Time Short not found
(NvOdmDevice) Error BadParameter: Control 0 not found (in dvs/git/dirty/git-master_linux/camera-partner/imager/src/V4L2Device.cpp, function findControlById(), line 1854)
(NvOdmDevice) Error BadParameter:  (propagating from dvs/git/dirty/git-master_linux/camera-partner/imager/src/V4L2Device.cpp, function getControlRange(), line 320)
(NvOdmDevice) Error BadParameter:  (propagating from dvs/git/dirty/git-master_linux/camera-partner/imager/src/devices/V4L2SensorViCsi.cpp, function initializeV4L2Items(), line 239)
(NvOdmDevice) Error BadParameter:  (propagating from dvs/git/dirty/git-master_linux/camera-partner/imager/src/devices/V4L2SensorViCsi.cpp, function initialize(), line 113)
NvPclDriverInitializeData: Unable to initialize driver v4l2_sensor
NvPclInitializeDrivers: error: Failed to init camera sub module v4l2_sensor
NvPclStartPlatformDrivers: Failed to start module drivers
NvPclCloseModuleDrivers: deallocate/free overrides pathname @ 0x7f80a840a0
NvPclCloseModuleDrivers: deallocate/free overrides pathname @ 0x7f80a88990
NvPclCloseModuleDrivers: deallocate/free overrides pathname @ 0x7f80a88900
NvPclCloseModuleDrivers: deallocate/free overrides pathname @ 0x7f80a83e30
NvPclCloseModuleDrivers: deallocate/free overrides pathname @ 0x7f80abeb20
NvPclCloseModuleDrivers: deallocate/free overrides pathname @ 0x7f80a942b0
NvPclStateControllerOpen: Failed ImagerGUID 0. (error 0x4)
NvPclStateControllerClose: Module e3326_front_P5V27C closed
NvPclOpen: PCL Open Failed. Error: 0xf
NvPclClose: ++++++++++++++++++++++
NvPclClose: ----------------------
NvPclOpen: ----------------------
SCF: Error BadParameter: Sensor could not be opened. (in src/services/capture/CaptureServiceDeviceSensor.cpp, function getSourceFromGuid(), line 598)
SCF: Error BadParameter:  (propagating from src/services/capture/CaptureService.cpp, function addSourceByGuid(), line 781)
SCF: Error BadParameter:  (propagating from src/api/CameraDriver.cpp, function addSourceByIndex(), line 276)
SCF: Error BadParameter:  (propagating from src/api/CameraDriver.cpp, function getSource(), line 439)

At this point, we are rather stuck, we can’t figure out what the “Control 0 not found” error means, and if it is even the problem that we’re facing.

Also we are questioning ourselves if the nvcamerasrc is the proper path, or that we should go for the v4l2src to handle RAW/RGB888 data.

Please have implement below CID even a dummy function to try.
Also I think you can use v4l2-ctl to get the data instead of nvcamerasrc.

Control Group Hold not found
Control Gain not found
Control HDR enable not found
Control Frame Length not found
Control Coarse Time not found

I’ve added the Group Hold, Gain, HDR enable. The Frame length and Coarse time are mutually exclusive with the Exposure and Frame Rate, which were already implemented.

It seems that we are making progress, the segfault is not showing anymore. We’ll continue with the implementation.

Btw, does the nvcamerasrc give us some extra advantage compared to v4l2src when we only want to transfer data from the CSI to the memory (no video processing?).

You can have full source control to use v4l2src.

I can’t think of any benefits that nvcamerasrc would provide you for your use case. I’d stick with v4l2.

v4l2-ctl --stream-mmap --stream-to data.out

You might also use --stream-count if you want to capture a few frames for debugging.

hi,everyone
I have the same use-case as @gerard.bos.
A camera was connect to FPGA and with FPGA’s IP core and output RGB888 or RAW data to MIPI interface.How can I get the image data in my program? Can opencv works?

@chay1991
Absolutely not. You need a driver for this FPGA on tegra first.