NvSIPL example unable to restart (switch states)

Please provide the following info:
Hardware Platform: DRIVE AGX Xavier™ Developer Kit
Software Version: DRIVE Software 10
Host Machine Version: native Ubuntu 18.04
SDK Manager Version: 1.0.1.5538

Hi all,

We’ve been working with nvmedia for a while (IPP) and now we are integrating NvSIPL into our application, we found a problem while trying to change states in the NvSIPL framework, basically we cannot apply start->stop->start states without errors and this also happens on the NvSIPL example application.

We are using this example application and this fails in the start->stop->start sequence
https://docs.nvidia.com/drive/drive_os_5.1.6.1L/nvvib_docs/index.html#page/DRIVE_OS_Linux_SDK_Development_Guide/NvMedia/nvmedia_nvsipl_camera.html#wwpID0E0IC0HA

We used this command to run the example on a single port:

./nvsipl_camera -c IMX390_CPHY_x2 --showfps --link-enable-masks “0x0000 0x0000 0x0001 0x0000” --disableISP1Output -v 3

The regular sequence: init->setup->start->(process buffers here)->stop->deinit works as expected but we modified the example to change from Start to Stop and then Start to “resume” the internal pipelines operation and process buffers again but the second start fails, the sequence is as follows: init->setup->start->(process buffers here)->stop->start(fails here)->(process buffers)->stop->deinit.

This is a simplified output log for this case:

nvmedia isc: GetCameraPowerControlLevel: 936: Camera power control library: NVCCP
MAX96712: Revision 2 detected
MAX9295: Revision 8 detected!
Sensor IMX390 Rev 0 RGGB detected!
[InitializeIspConfigData:337] No Camera Specific Configuration found:                     Using default settings, Image quality is not supported!
Output	FPS
Sensor8_Out1	25.9965
Output	FPS
Sensor8_Out1	29.9962
Output	FPS
Sensor8_Out1	29.9971
Output	FPS
Sensor8_Out1	29.9965
Output	FPS
Sensor8_Out1	29.9976
Output	FPS
Sensor8_Out1	29.9973
Output	FPS
Sensor8_Out1	29.9976
Output	FPS
Sensor8_Out1	29.9973
Output	FPS
Sensor8_Out1	29.9975
Output	FPS
Sensor8_Out1	29.9974
libnvsipl.so: CNvMCamera.cpp: 231: Start: CNvMCamera has not been init.
nvsipl_camera: ERROR: Master start failed. status: 127

So, since the second start indicates “CNvMCamera has not been init” We configured again everything (SetPlatform, ApplyMask,SetOutputs…) replicating the same code used in the first run and the the new error indicates “Invalid argument”. log below:

nvmedia isc: GetCameraPowerControlLevel: 936: Camera power control library: NVCCP
MAX96712: Revision 2 detected
MAX9295: Revision 8 detected!
Sensor IMX390 Rev 0 RGGB detected!
[InitializeIspConfigData:337] No Camera Specific Configuration found:                     Using default settings, Image quality is not supported!
Output	FPS
Sensor8_Out1	25.9973
Output	FPS
Sensor8_Out1	29.9971
Output	FPS
Sensor8_Out1	29.9969
Output	FPS
Sensor8_Out1	29.997
Output	FPS
Sensor8_Out1	29.997
Output	FPS
Sensor8_Out1	29.9972
Output	FPS
Sensor8_Out1	29.997
Output	FPS
Sensor8_Out1	29.9972
Output	FPS
Sensor8_Out1	29.9971
Output	FPS
Sensor8_Out1	29.9969
iscDevCreate: Failed - add isc dev driver /dev/isc-dev.1.63 - Invalid argument
NvMediaISCDeviceCreate: Cannot create isc dev
libnvsipl_devblk.so: CNvMDevice.cpp: 72: CreateISCDevice: NvMediaISCDeviceCreate in CNvMSensor::Init failed!
libnvsipl_devblk.so: CNvMMAX96712CameraModule.cpp: 343: CreateISCDevice: Serializer CreateISCDevice failed! with error: 7f
libnvsipl_devblk.so: CNvMDeviceBlock.cpp: 158: Init: Module CreateISCDevice failed! with error: 7f
libnvsipl.so: CNvMDeviceBlockMgr.hpp: 90: ThreadFunc: ThreadCreate failed. (7f)
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 83: Init: Failed to initialize device block:0
libnvsipl.so: CNvMCamera.cpp: 169: Init: CNvMCamera::Init failed! with error: 7f
nvsipl_camera: ERROR: Master initialization failed. status: 127

libnvsipl_devblk.so: CNvMDeviceBlock.cpp: 226: Stop: CNvMDeviceBlock has not been started
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 132: Stop: Deviceblock fails to stop
libnvsipl.so: CNvMCamera.cpp: 259: Stop: m_upDeviceBlockMgr fails to stop

So, it seems that NvSIPL doesn’t support Start->Stop->Start states, Can you check if this is possible?

If state changes are possible, could you please clarify how to handle these cases? we have tried several ways and we got the same error, even after applying a deinit and creating the variables and configurations again.

We also added verbose mode to get more information about the issue, this log belong to the first Init->Start->Stop->Deinit:

./nvsipl_camera -c IMX390_CPHY_x2 --showfps --link-enable-masks “0x0000 0x0000 0x0001 0x0000” --disableISP1Output -v 3
nvsipl_camera: Setting up signal handler

nvsipl_camera: Getting platform configuration for IMX390_CPHY_x2

nvsipl_camera: Setting link masks

nvsipl_camera: Creating camera master

nvsipl_camera: Setting up master

Platform: ddpx-a
Platform configuration: IMX390_CPHY_x2
Platform configuration description: IMX390 module in 2 lane CPHY mode

CSI Port: 6
I2C Device 1
Deserializer Name:MAX96712
Description: Maxim 96712 Aggregator
I2C Address: 0x29
CameraModule on link 0
Name: IMX390
Description: Sony IMX390 module - 120-deg FOV, MIPI-IMX390, MAX9295
Serializer Name: MAX9295
Address: 0x62
Sensor Name: IMX390
ID: 8
Address: 0x1a

libnvsipl.so: CNvMCamera.cpp: 42: SetPlatformCfg: Copy platform configure information
libnvsipl.so: CNvMCamera.cpp: 45: SetPlatformCfg: Create device block control
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 27: SetConfig: Create device block
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 36: SetConfig: Create device block
nvsipl_camera: Setting up consumer descriptor for output: 1 of sensor 8

nvsipl_camera: Initializing master interface

libnvsipl.so: CNvMCamera.cpp: 166: Init: Initializing device blocks
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 68: Init: Creating worker thread for block:0
libnvsipl.so: CNvMThreadingClasses.cpp: 125: ThreadCreate: Waiting for thread to be created
libnvsipl.so: CNvMThreadingClasses.cpp: 293: m_FuncStatic: Thread created.
libnvsipl.so: CNvMThreadingClasses.cpp: 300: m_Func: Notifying the creator.
libnvsipl.so: CNvMThreadingClasses.cpp: 132: ThreadCreate: Thread DEVBLK_INIT_0 started
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 75: Init: Created worker thread for block:0
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 80: Init: Getting result from worker thread for block:0
libnvsipl.so: CNvMThreadingClasses.cpp: 151: ThreadQuit: Waiting for thread DELK_INIT_0
libnvsipl.so: CNvMThreadingClasses.cpp: 151: ThreadQuit: Waiting for thread DEVBLK_INIT_0 to end
libnvsipl.so: CNvMThreadingClasses.cpp: 343: m_Func: Initializing thread DEVBLK_INIT_0
libnvsipl.so: CNvMThreadingClasses.cpp: 350: m_Func: Thread DEVBLK_INIT_0 running
nvmedia isc: GetCameraPowerControlLevel: 936: Camera power control library: NVCCP
libnvsipl_devblk.so: CNvMI2CAddrMgr.cpp: 74: GenerateI2CAddr: Generated I2C address 0x63 for native I2C address 0x62
libnvsipl_devblk.so: CNvMI2CAddrMgr.cpp: 74: GenerateI2CAddr: Generated I2C address 0x1b for native I2C address 0x1a
libnvsipl_devblk.so: CNvMMax96712.cpp: 138: Init: Check deserializer is present
MAX96712: Revision 2 detected
libnvsipl_devblk.so: CNvMMax96712.cpp: 142: Init: Set deserializer defaults
libnvsipl_devblk.so: CNvMMax96712.cpp: 147: Init: Get deserializer revision
libnvsipl_devblk.so: CNvMMax96712.cpp: 156: Init: Set MIPI output mode
libnvsipl_devblk.so: CNvMI2CAddrMgr.cpp: 50: RegisterNativeI2CAddr: Native I2C address already registered
libnvsipl_devblk.so: CNvMI2CAddrMgr.cpp: 50: RegisterNativeI2CAddr: Native I2C address already registered
libnvsipl_devblk.so: CNvMMax96712.cpp: 191: EnableLinks: Enabling links
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 153: Init: Initializing link 0
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 64: DumpLinkParams: Link parameters
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 65: DumpLinkParams: Link Index: 0
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 66: DumpLinkParams: Broadcast serializer addr: 0x62
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 67: DumpLinkParams: Serializer addr: 0x63
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 70: DumpLinkParams:
Broadcast sensor addr: 0x1a
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 71: DumpLinkParams: Sensor addr: 0x1b
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 72: DumpLinkParams: VCID: 0
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 73: DumpLinkParams: Embedded data type: true
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 74: DumpLinkParams: Trigger mode sync: true
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 75: DumpLinkParams: Frame rate: 30.00 fps
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 86: DumpLinkParams: Simulator mode: 0
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 87: DumpLinkParams: Slave mode: 0
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 189: Init: Check config link lock
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 196: Init: Setup address translations
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 96: SetupAddressTranslations: Check broadcast serializer is present
MAX9295: Revision 8 detected!
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 106: SetupAddressTranslations: Translate image sensor device addr 1b to 1a
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 127: SetupAddressTranslations: Set unique address
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 203: Init: Release sensor reset
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 226: Init: ISC_WRITE_PARAM_CMD_MAX9295_SET_FSYNC_GPIO
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 247: Init: ISC_WRITE_PARAM_CMD_MAX9295_CONFIG_PHY
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 272: Init: ISC_WRITE_PARAM_CMD_MAX9295_CONFIG_VIDEO_PIPELINES
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 294: Init: Initializing link 0
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 303: Init: Set Fsync
libnvsipl_devblk.so: CNvMTransportLink_Max96712_9295.cpp: 310: Init: Set FSYNC mode
libnvsipl_devblk.so: CNvMMAX96712_9295_IMX390.cpp: 90: InitModule: Check SENSOR is present
Sensor IMX390 Rev 0 RGGB detected!
libnvsipl_devblk.so: CNvMMAX96712_9295_IMX390.cpp: 102: InitModule: Set defaults in CNvMSensor::Init
libnvsipl_devblk.so: CNvMMax96712.cpp: 191: EnableLinks: Enabling links
libnvsipl_devblk.so: CNvMMax96712.cpp: 258: CheckLinkLock: Check config link lock
libnvsipl_devblk.so: CNvMMax96712.cpp: 191: EnableLinks: Enabling links
libnvsipl.so: CNvMThreadingClasses.cpp: 363: m_Func: Finishing thread DEVBLK_INIT_0
libnvsipl.so: CNvMThreadingClasses.cpp: 369: m_Func: Thread exiting
libnvsipl.so: CNvMThreadingClasses.cpp: 153: ThreadQuit: Thread DEVBLK_INIT_0 ended
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 86: Init: Got result from worker thread for block:0
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 96: Init: Creating Error monitor thread for block:0
libnvsipl.so: CNvMThreadingClasses.cpp: 125: ThreadCreate: Waiting for thread to be created
libnvsipl.so: CNvMThreadingClasses.cpp: 293: m_FuncStatic: Thread created.
libnvsipl.so: CNvMThreadingClasses.cpp: 300: m_Func: Notifying the creator.
libnvsipl.so: CNvMThreadingClasses.cpp: 337: m_Func: Setting thread name. DEVBLK_MON_0
libnvsipl.so: CNvMThreadingClasses.cpp: 343: m_Func: Initializing thread DEVBLK_MON_0
libnvsipl.so: CNvMThreadingClasses.cpp: 350: m_Func: Thread DEVBLK_MON_0 running
libnvsipl.so: CNvMThreadingClasses.cpp: 132: ThreadCreate: Thread DEVBLK_MON_0 started
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 102: Init: Created Error Monitor for block:0
libnvsipl.so: CNvMCamera.cpp: 204: Init: Initializing pipeline manager
libnvsipl.so: CNvMIppPipelineMgr.cpp: 66: Init: Creating 1 pipelines for block:0
libnvsipl.so: CNvMIppPipelineMgr.cpp: 104: Init: sensorHandle:0x7fa0001670
libnvsipl.so: CNvMIppPipelineMgr.cpp: 106: Init: Creating pipeline for first link
libnvsipl.so: CNvMIppPipeline.cpp: 273: Create: Creating Raw pipelines in CNvMIppPipeline::Create
libnvsipl.so: CNvMIppCompISP.cpp: 95: SetImagePoolAttributes: Set surf alloc attr. for out 0 type:5 value:1
[InitializeIspConfigData:337] No Camera Specific Configuration found: Using default settings, Image quality is not supported!
libnvsipl.so: CNvMThreadingClasses.cpp: 125: ThreadCreate: Waiting for thread to be created
libnvsipl.so: CNvMThreadingClasses.cpp: 293: m_FuncStatic: Thread created.
libnvsipl.so: CNvMThreadingClasses.cpp: 300: m_Func: Notifying the creator.
libnvsipl.so: CNvMThreadingClasses.cpp: 132: ThreadCreate: Thread SIPL_ISP0_8 started
libnvsipl.so: CNvMIppPipeline.cpp: 405: BuildPipeline: Attach ICP with ISP comp
libnvsipl.so: CNvMIppPipeline.cpp: 417: BuildPipeline: Attach ISP with ALG comp
libnvsipl.so: CNvMIppPipeline.cpp: 423: BuildPipeline: Attach ALG with ISC comp
libnvsipl.so: CNvMIppPipeline.cpp: 429: BuildPipeline: Attach ISP with ISP output1
libnvsipl.so: CNvMIppPipeline.cpp: 429: BuildPipeline: Attach ISP with ISP output1

libnvsipl.so: CNvMThreadingClasses.cpp: 343: m_Func: Initializing thread SIPL_ISP0_8
libnvsipl.so: CNvMThreadingClasses.cpp: 350: m_Func: Thread SIPL_ISP0_8 running
libnvsipl.so: CNvMThreadingClasses.cpp: 358: m_Func: Thread SIPL_ISP0_8 going to sleep
nvsipl_camera: Creating consumers

nvsipl_camera: Creating consumer Sensor8_Out1

nvsipl_camera: Creating INvSIPLClient

libnvsipl.so: CNvMClient.cpp: 24: Init: CNvMClient::Init
nvsipl_camera: Starting master

libnvsipl.so: CNvMIppPipelineMgr.cpp: 294: Start: Start pipeline id = 8
libnvsipl.so: CNvMIppPostImage.cpp: 95: Start: Pipeline index 8 thread name SIPL_ISP0_8
libnvsipl.so: CNvMThreadingClasses.cpp: 360: m_Func: Thread SIPL_ISP0_8 woke up
Output FPS
Sensor8_Out1 25.9972
Output FPS
Sensor8_Out1 29.9968
Output FPS
Sensor8_Out1 29.9969
Output FPS
Sensor8_Out1 29.9968
Output FPS
Sensor8_Out1 29.996
Output FPS
Sensor8_Out1 29.9967
Output FPS
Sensor8_Out1 29.9971
Output FPS
Sensor8_Out1 29.9967
Output FPS
Sensor8_Out1 29.9967
Output FPS
Sensor8_Out1 29.9968
nvsipl_camera: Stopping master

libnvsipl.so: CNvMIppPipelineMgr.cpp: 311: Stop: Stop pipeline id = 8
libnvsipl.so: CNvMThreadingClasses.cpp: 151: ThreadQuit: Waiting for thread SIPL_ISP0_8 to end
libnvsipl.so: CNvMThreadingClasses.cpp: 363: m_Func: Finishing thread SIPL_ISP0_8
libnvsipl.so: CNvMThreadingClasses.cpp: 369: m_Func: Thread exiting
libnvsipl.so: CNvMThreadingClasses.cpp: 153: ThreadQuit: Thread SIPL_ISP0_8 ended
libnvsipl.so: CNvMIppPostImage.cpp: 107: Stop: Pipeline index 8 thread name SIPL_ISP0_8
nvsipl_camera: De-initializing consumer Sensor8_Out1

nvsipl_camera: De-initilaizing master

libnvsipl.so: CNvMCamera.cpp: 284: Deinit: Deinit deviceblock in CNvMCamera::Deinit()
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 145: Deinit: Deinit deviceblock
libnvsipl.so: CNvMDeviceBlockMgr.hpp: 136: ThreadFunc: Monitor thread exiting
libnvsipl.so: CNvMThreadingClasses.cpp: 358: m_Func: Thread DEVBLK_MON_0 going to sleep
libnvsipl.so: CNvMThreadingClasses.cpp: 151: ThreadQuit: Waiting for thread DEVBLK_MON_0 to end
libnvsipl.so: CNvMThreadingClasses.cpp: 360: m_Func: Thread DEVBLK_MON_0 woke up
libnvsipl.so: CNvMThreadingClasses.cpp: 363: m_Func: Finishing thread DEVBLK_MON_0
libnvsipl.so: CNvMThreadingClasses.cpp: 369: m_Func: Thread exiting
libnvsipl.so: CNvMThreadingClasses.cpp: 153: ThreadQuit: Thread DEVBLK_MON_0 ended
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 158: Deinit: Deinit platform configure info
libnvsipl.so: CNvMCamera.cpp: 292: Deinit: Deinit pipeline manager in CNvMCamera::Deinit()

Master is null here, then we restarted again the configuration, this is the log of the second Init->Start (this time we tried to configure everything again):

nvsipl_camera: Setting verbosity level: 3

nvsipl_camera: Getting platform configuration for IMX390_CPHY_x2

nvsipl_camera: Setting link masks

nvsipl_camera: Creating camera master

nvsipl_camera: Setting up master

Platform: ddpx-a
Platform configuration: IMX390_CPHY_x2
Platform configuration description: IMX390 module in 2 lane CPHY mode

CSI Port: 6
I2C Device 1
Deserializer Name:MAX96712
Description: Maxim 96712 Aggregator
I2C Address: 0x29
CameraModule on link 0
Name: IMX390
Description: Sony IMX390 module - 120-deg FOV, MIPI-IMX390, MAX9295
Serializer Name: MAX9295
Address: 0x62
Sensor Name: IMX390
ID: 8
Address: 0x1a

libnvsipl.so: CNvMCamera.cpp: 42: SetPlatformCfg: Copy platform configure information
libnvsipl.so: CNvMCamera.cpp: 45: SetPlatformCfg: Create device block control
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 27: SetConfig: Create device block
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 36: SetConfig: Create device block
nvsipl_camera: Setting up consumer descriptor for output: 1 of sensor 8

nvsipl_camera: Initializing master interface

libnvsipl.so: CNvMCamera.cpp: 166: Init: Initializing device blocks
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 68: Init: Creating worker thread for block:0
libnvsipl.so: CNvMThreadingClasses.cpp: 125: ThreadCreate: Waiting for thread to be created
libnvsipl.so: CNvMThreadingClasses.cpp: 293: m_FuncStatic: Thread created.
libnvsipl.so: CNvMThreadingClasses.cpp: 300: m_Func: Notifying the creator.
libnvsipl.so: CNvMThreadingClasses.cpp: 132: ThreadCreate: Thread DEVBLK_INIT_0 started
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 75: Init: Created worker thread for block:0
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 80: Init: Getting result from worker thread for bllibnvsipl.so: CNvMThreadingClasses.cpp: 343: m_Func: Initializing thread DEVBLK_INIT_0
ock:0
libnvsipl.so: CNvMThreadingClasses.cpp: 151: ThreadQuit: Waiting for thread DEVBLK_INIT_0 to end
libnvsipl.so: CNvMThreadingClasses.cpp: 151: ThreadQuit: Waiting for thread DEVBLK_INITlibnvsipl.so: CNvMThreadingClasses.cpp: 350: m_Func: Thread DEVBLK_INIT_0 running
libnvsipl_devblk.so: CNvMI2CAddrMgr.cpp: 74: GenerateI2CAddr: Generated I2C address 0x63 for native I2C address 0x62
iscDevCreate: Failed - add isc dev driver /dev/isc-dev.1.63 - Invalid argument
NvMediaISCDeviceCreate: Cannot create isc dev
libnvsipl_devblk.so: CNvMDevice.cpp: 72: CreateISCDevice: NvMediaISCDeviceCreate in CNvMSensor::Init failed!
libnvsipl_devblk.so: CNvMMAX96712CameraModule.cpp: 343: CreateISCDevice: Serializer CreateISCDevice failed! with error: 7f
libnvsipl_devblk.so: CNvMDeviceBlock.cpp: 158: Init: Module CreateISCDevice failed! with error: 7f
libnvsipl.so: CNvMDeviceBlockMgr.hpp: 90: ThreadFunc: ThreadCreate failed. (7f)
libnvsipl.so: CNvMThreadingClasses.cpp: 363: m_Func: Finishing thread DEVBLK_INIT_0
libnvsipl.so: CNvMThreadingClasses.cpp: 369: m_Func: Thread exiting
libnvsipl.so: CNvMThreadingClasses.cpp: 153: ThreadQuit: Thread DEVBLK_INIT_0 ended
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 83: Init: Failed to initialize device block:0
libnvsipl.so: CNvMCamera.cpp: 169: Init: CNvMCamera::Init failed! with error: 7f
nvsipl_camera: ERROR: Master initialization failed. status: 127

libnvsipl_devblk.so: CNvMDeviceBlock.cpp: 226: Stop: CNvMDeviceBlock has not been started
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 132: Stop: Deviceblock fails to stop
libnvsipl.so: CNvMCamera.cpp: 259: Stop: m_upDeviceBlockMgr fails to stop
libnvsipl.so: CNvMCamera.cpp: 284: Deinit: Deinit deviceblock in CNvMCamera::Deinit()
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 145: Deinit: Deinit deviceblock
libnvsipl.so: CNvMDeviceBlockMgr.cpp: 158: Deinit: Deinit platform configure info
libnvsipl.so: CNvMCamera.cpp: 292: Deinit: Deinit pipeline manager in CNvMCamera::Deinit()

This there is the error “Invalid argument”, we used the same platform and mask in the configuration but we are unable to resume the camera operation. Just in case, on the example we removed the code that used the composite, we only need to get buffers from the NvSIPL framework.

From our tests, it seems that NvSIPL doesn’t support state changes or something else is missing in the example, any ideas about the issue would help us to overcome this problem. This is currently blocking us on the application.

Thanks,
Greivin F.

Dear @greivin.fallas,
Could you share simple repro code snippet?

Hi @SivaRamaKrishnaNV,

Sure, here is the modified code that I used in the main:

/**
 * @file
 * <b>NvSIPL Camera sample application. </b>
 *
 * @b Description: This application demonstrates the usage of NvSIPL APIs to,
 *  1. Select a pre-defined platform configuration using Query APIs.
 *  2. Create and configure camera pipelines using Camera APIs.
 *  3. Create an NvSIPL client to consume images using NvSIPL Client APIs.
 *  4. Implement callbacks to receive and process the outputs a pipeline using Client APIs.
 */

/* STL Headers */
#include <unistd.h>
#include <cstring>
#include <iostream>
#include <csignal>
#include <thread>
#include <chrono>
#include <ctime>
#include <atomic>
#include <pthread.h>

/* NvSIPL Headers */
#include "NvSIPLVersion.hpp" // Version
#include "NvSIPLTrace.hpp" // Trace
#include "NvSIPLCommon.hpp" // Common
#include "NvSIPLQuery.hpp" // Query
#include "NvSIPLCamera.hpp" // Camera
#include "NvSIPLPipelineMgr.hpp" // Pipeline manager
#include "NvSIPLClient.hpp" // Client

#include "CNvSIPLMaster.hpp"
#include "CFileReader.hpp"
#include "CFileWriter.hpp"
#include "CNvSIPLConsumer.hpp"
#include "CCmdLineParser.hpp"
#include "CComposite.hpp"
#include "CUtils.hpp"

/* Quit flag. */
std::atomic<bool> bQuit;

/** Signal handler.*/
static void SigHandler(int signum)
{
    LOG_WARN("Received signal: %u. Quitting\n", signum);
    signal(SIGINT, SIG_IGN);
    signal(SIGTERM, SIG_IGN);
    signal(SIGQUIT, SIG_IGN);
    signal(SIGHUP, SIG_IGN);

    bQuit = true;

    signal(SIGINT, SIG_DFL);
    signal(SIGTERM, SIG_DFL);
    signal(SIGQUIT, SIG_DFL);
    signal(SIGHUP, SIG_DFL);
}

/** Sets up signal handler.*/
static void SigSetup(void)
{
    struct sigaction action { };
    action.sa_handler = SigHandler;

    sigaction(SIGINT, &action, NULL);
    sigaction(SIGTERM, &action, NULL);
    sigaction(SIGQUIT, &action, NULL);
    sigaction(SIGHUP, &action, NULL);
}

int main(int argc, char *argv[])
{
    bQuit = false;

    // INvSIPLQuery
    auto pQuery = INvSIPLQuery::GetInstance();
    CHK_PTR_AND_RETURN(pQuery, "INvSIPLQuery::GetInstance");

    auto status = pQuery->ParseDatabase();
    CHK_STATUS_AND_RETURN(status, "INvSIPLQuery::ParseDatabase");

    LOG_INFO("Parsing command line arguments\n");
    CCmdLineParser cmdline;
    auto ret = cmdline.Parse(argc, argv);
    if (ret != 0) {
        return -1;
    }

    // Set verbosity level in libnvsiple
    LOG_INFO("Setting verbosity level: %u\n", cmdline.verbosity);
    INvSIPLTrace::GetInstance()->SetLevel((INvSIPLTrace::TraceLevel)cmdline.verbosity);
    CLogger::GetInstance().SetLogLevel((CLogger::LogLevel) cmdline.verbosity);

    LOG_INFO("Setting up signal handler\n");
    SigSetup();

    if (cmdline.sTestConfigFile != "") {
        status = pQuery->ParseJsonFile(cmdline.sTestConfigFile);
        CHK_STATUS_AND_RETURN(status, "INvSIPLQuery::ParseJsonFile");
    }

    LOG_INFO("Getting platform configuration for %s\n", cmdline.sConfigName.c_str());
    PlatformCfg oPlatformCfg;
    status = pQuery->GetPlatformCfg(cmdline.sConfigName, oPlatformCfg);
    CHK_STATUS_AND_RETURN(status, "INvSIPLQuery::GetPlatformCfg");

    // Check if file mode or slave mode is enabled.
    // If so we need to modify device block info.
    for (auto d = 0u; d != oPlatformCfg.numDeviceBlocks; d++ ) {
        if (cmdline.sInputRawFile != "") {
            oPlatformCfg.deviceBlockList[d].isSimulatorModeEnabled = true;
        } else if (cmdline.bEnableSlave) {
            oPlatformCfg.deviceBlockList[d].isSlaveModeEnabled = true;
        }
    }

    // Apply mask
    if (cmdline.vMasks.size() != 0) {
        LOG_INFO("Setting link masks\n");
        status = pQuery->ApplyMask(oPlatformCfg, cmdline.vMasks);
        CHK_STATUS_AND_RETURN(status, "INvSIPLQuery::ApplyMask");
    }

    LOG_INFO("Creating camera master\n");
    auto upMaster = unique_ptr<CNvSIPLMaster>(new CNvSIPLMaster());
    CHK_PTR_AND_RETURN(upMaster, "Camera Master creation");

    LOG_INFO("Setting up master\n");
    status = upMaster->Setup(&oPlatformCfg);
    CHK_STATUS_AND_RETURN(status, "Master setup");

    // Enable following outputs for all sensors
    std::vector<INvSIPLClient::ConsumerDesc::OutputType> eOutputList;
    if (!cmdline.bDisableRaw) {
        eOutputList.push_back(INvSIPLClient::ConsumerDesc::OutputType::ICP);
    }

    if (!cmdline.bDisableISP0) {
        eOutputList.push_back(INvSIPLClient::ConsumerDesc::OutputType::ISP0);
    }

    // Decide the ISP output image attributes.
    NvSIPLImageAttr ispOutImgAttr{};
    NVM_SURF_FMT_DEFINE_ATTR(surfFormatAttrs);
    NVM_SURF_FMT_SET_ATTR_YUV(surfFormatAttrs, YUV, 420, SEMI_PLANAR, UINT, 8, BL);
    ispOutImgAttr.surfaceType = NvMediaSurfaceFormatGetType(surfFormatAttrs, NVM_SURF_FMT_ATTR_MAX);

    // Set NVM_SURF_ATTR_ALLOC_ISOCHRONOUS for using the ISP outputs with IDP
    ispOutImgAttr.surfaceAllocAttr.push_back({NVM_SURF_ATTR_ALLOC_TYPE, NVM_SURF_ATTR_ALLOC_ISOCHRONOUS});

    for (auto d = 0u; d != oPlatformCfg.numDeviceBlocks; d++ ) {
        auto db = oPlatformCfg.deviceBlockList[d];
        for (auto m = 0u; m != db.numCameraModules; m++) {
            auto module = db.cameraModuleInfoList[m];
            for (auto s = 0u; s!= module.numSensors; s++) {
                auto sensor = module.sensorInfoList[s];
                uint32_t uSensor = sensor.id;

                // For each output
                for (INvSIPLClient::ConsumerDesc::OutputType eOutput : eOutputList) {
                    if (db.isSimulatorModeEnabled and (eOutput == INvSIPLClient::ConsumerDesc::OutputType::ICP)) {
                        continue;
                    }

                    if (eOutput != INvSIPLClient::ConsumerDesc::OutputType::ICP) {
                        // Set output image attributes.
                        status = upMaster->SetImagePoolAttributes(uSensor, eOutput, 4, ispOutImgAttr);
                        if (status != NVSIPL_STATUS_OK) {
                            LOG_ERR("SetImagePoolAttributes failed for ISP output of sensor: %u\n", uSensor);
                            return -1;
                        }
                    }

                    LOG_INFO("Setting up consumer descriptor for output: %u of sensor %u\n", int(eOutput), uSensor);
                    vector<INvSIPLClient::ConsumerDesc> voConsDesc;

                    // Create descriptor for NvMediaImage consumer
                    INvSIPLClient::ConsumerDesc oConDesc { };
                    oConDesc.sName = "Sensor" + to_string(uSensor) + "_Out" + to_string(int(eOutput));
                    oConDesc.uSensorIndex = uSensor;
                    oConDesc.eOutputType = eOutput;
                    voConsDesc.push_back(oConDesc);

                    // Set output descriptors
                    status = upMaster->SetOutputs(voConsDesc);
                    CHK_STATUS_AND_RETURN(status, "Master SetOutputs");
                } // output
            } // sensor
        } // module
    } // deviceblock

    LOG_INFO("Initializing master interface\n");
    status = upMaster->Init();
    CHK_STATUS_AND_RETURN(status, "Master initialization");

     LOG_INFO("Creating consumers\n");
    vector<unique_ptr<CNvSIPLConsumer>> vupConsumers;
    // for each sensor
    for (auto d = 0u; d != oPlatformCfg.numDeviceBlocks; d++ ) {
        auto db = oPlatformCfg.deviceBlockList[d];
        for (auto m = 0u; m != db.numCameraModules; m++) {
            auto module = db.cameraModuleInfoList[m];
            for (auto s = 0u; s!= module.numSensors; s++) {
                auto sensor = module.sensorInfoList[s];
                uint32_t uSensor = sensor.id;
                // for each output
                for (INvSIPLClient::ConsumerDesc::OutputType eOutput : eOutputList) {
                    if (db.isSimulatorModeEnabled and (eOutput == INvSIPLClient::ConsumerDesc::OutputType::ICP)) {
                        continue;
                    }
                    // Create NvMediaImage consumer
                    string sName = "Sensor" + to_string(uSensor) + "_Out" + to_string(int(eOutput));
                    LOG_INFO("Creating consumer %s\n", sName.c_str());

                    auto pClientDesc = upMaster->GetClientDesc(uSensor, eOutput);
                    if (pClientDesc == nullptr) {
                        LOG_ERR("GetClientDesc failed for output:%u of sensor:%u\n", eOutput, uSensor);
                        return -1;
                    }

                    // Create NvSIPL consumer using client descriptor
                    auto upCons = unique_ptr<CNvSIPLConsumer>(new CNvSIPLConsumer());
                    if (upCons == nullptr) {
                        LOG_ERR("Failed to create NvSIPLConsumer for output:%u of sensor:%u\n", eOutput, uSensor);
                        return -1;
                    }

                    status = upCons->Init(pClientDesc, nullptr, -1, cmdline.sPrefix);
                    if (status != NVSIPL_STATUS_OK) {
                        LOG_ERR("Failed to initialize consumer for output:%u of sensor:%u\n", eOutput, uSensor);
                        return -1;
                    }

                    if (cmdline.bShowMetadata) {
                        upCons->EnableMetadataLogging();
                    }

                    vupConsumers.push_back(move(upCons));
                } // output
            } // sensor
        } // module
    } // device block

    LOG_INFO("Starting master\n");
    status = upMaster->Start();
    CHK_STATUS_AND_RETURN(status, "Master start");

    // Wait for quit
    while (!bQuit) {
        // Wait for a second
        auto oStartTime = chrono::steady_clock::now();
        std::this_thread::sleep_for(std::chrono::seconds(1));

        if (cmdline.uRunDurationSec != -1) {
            cmdline.uRunDurationSec--;
            if (cmdline.uRunDurationSec == 0) {
                bQuit = true;
            }
        }

        // Log FPS
        if (cmdline.bShowFPS) {
            auto uTimeElapsedMs = chrono::duration<double, std::milli> (chrono::steady_clock::now() - oStartTime).count();
            cout << "Output\tFPS\n";
            for (auto &cons : vupConsumers) {
                auto fps = (cons->m_uFrameCount*1000.0)/(uTimeElapsedMs);
                cout << cons->m_pDesc->oConsDesc.sName << "\t" << fps << endl;
                cons->m_uFrameCount = 0;
            }
        }
    }

    if (upMaster != nullptr) {
        LOG_INFO("Stopping master\n");
        status = upMaster->Stop();
        if (status != NVSIPL_STATUS_OK) {
            LOG_ERR("Failed to Stop master %u\n", status);
        }
    }

    for (auto &cons : vupConsumers) {
        LOG_INFO("De-initializing consumer %s\n", cons->m_pDesc->oConsDesc.sName.c_str());
        cons->Deinit();
	cons.reset();
    }

    if (upMaster != nullptr) {
        LOG_INFO("De-initilaizing master\n");
        upMaster->Deinit();
	upMaster.reset();
    }

    if (upMaster == nullptr) {
        LOG_INFO("MASTER NULL\n");
    }

    auto oStartTimee = chrono::steady_clock::now();
    std::this_thread::sleep_for(std::chrono::seconds(2));
    

    cout << "--restart everything--" << endl;
    
    pQuery = INvSIPLQuery::GetInstance();
    CHK_PTR_AND_RETURN(pQuery, "INvSIPLQuery::GetInstance");

    status = pQuery->ParseDatabase();
    CHK_STATUS_AND_RETURN(status, "INvSIPLQuery::ParseDatabase");

    // Set verbosity level in libnvsiple
    LOG_INFO("Setting verbosity level: %u\n", cmdline.verbosity);
    INvSIPLTrace::GetInstance()->SetLevel((INvSIPLTrace::TraceLevel)cmdline.verbosity);
    CLogger::GetInstance().SetLogLevel((CLogger::LogLevel) cmdline.verbosity);


    LOG_INFO("Getting platform configuration for %s\n", cmdline.sConfigName.c_str());
    PlatformCfg oPlatformCfg2;
    status = pQuery->GetPlatformCfg(cmdline.sConfigName, oPlatformCfg2);
    CHK_STATUS_AND_RETURN(status, "INvSIPLQuery::GetPlatformCfg");

    // Apply mask
    if (cmdline.vMasks.size() != 0) {
        LOG_INFO("Setting link masks\n");
        status = pQuery->ApplyMask(oPlatformCfg2, cmdline.vMasks);
        CHK_STATUS_AND_RETURN(status, "INvSIPLQuery::ApplyMask");
    }

    LOG_INFO("Creating camera master\n");
    auto upMaster2 = unique_ptr<CNvSIPLMaster>(new CNvSIPLMaster());
    CHK_PTR_AND_RETURN(upMaster2, "Camera Master creation");

    LOG_INFO("Setting up master\n");
    status = upMaster2->Setup(&oPlatformCfg2);
    CHK_STATUS_AND_RETURN(status, "Master setup");

    for (auto d = 0u; d != oPlatformCfg2.numDeviceBlocks; d++ ) {
        auto db = oPlatformCfg2.deviceBlockList[d];
        for (auto m = 0u; m != db.numCameraModules; m++) {
            auto module = db.cameraModuleInfoList[m];
            for (auto s = 0u; s!= module.numSensors; s++) {
                auto sensor = module.sensorInfoList[s];
                uint32_t uSensor = sensor.id;

                // For each output
                for (INvSIPLClient::ConsumerDesc::OutputType eOutput : eOutputList) {
                    if (db.isSimulatorModeEnabled and (eOutput == INvSIPLClient::ConsumerDesc::OutputType::ICP)) {
                        continue;
                    }

                    if (eOutput != INvSIPLClient::ConsumerDesc::OutputType::ICP) {
                        // Set output image attributes.
                        status = upMaster2->SetImagePoolAttributes(uSensor, eOutput, 4, ispOutImgAttr);
                        if (status != NVSIPL_STATUS_OK) {
                            LOG_ERR("SetImagePoolAttributes failed for ISP output of sensor: %u\n", uSensor);
                            return -1;
                        }
                    }

                    LOG_INFO("Setting up consumer descriptor for output: %u of sensor %u\n", int(eOutput), uSensor);
                    vector<INvSIPLClient::ConsumerDesc> voConsDesc;

                    // Create descriptor for NvMediaImage consumer
                    INvSIPLClient::ConsumerDesc oConDesc { };
                    oConDesc.sName = "Sensor" + to_string(uSensor) + "_Out" + to_string(int(eOutput));
                    oConDesc.uSensorIndex = uSensor;
                    oConDesc.eOutputType = eOutput;
                    voConsDesc.push_back(oConDesc);

                    // Set output descriptors
                    status = upMaster2->SetOutputs(voConsDesc);
                    CHK_STATUS_AND_RETURN(status, "Master SetOutputs");
                } // output
            } // sensor
        } // module
    } // deviceblock

    LOG_INFO("Initializing master interface\n");
    status = upMaster2->Init();
    CHK_STATUS_AND_RETURN(status, "Master initialization");

     LOG_INFO("Creating consumers\n");
    vupConsumers.clear();
    // for each sensor
    for (auto d = 0u; d != oPlatformCfg2.numDeviceBlocks; d++ ) {
        auto db = oPlatformCfg2.deviceBlockList[d];
        for (auto m = 0u; m != db.numCameraModules; m++) {
            auto module = db.cameraModuleInfoList[m];
            for (auto s = 0u; s!= module.numSensors; s++) {
                auto sensor = module.sensorInfoList[s];
                uint32_t uSensor = sensor.id;
                // for each output
                for (INvSIPLClient::ConsumerDesc::OutputType eOutput : eOutputList) {
                    if (db.isSimulatorModeEnabled and (eOutput == INvSIPLClient::ConsumerDesc::OutputType::ICP)) {
                        continue;
                    }
                    // Create NvMediaImage consumer
                    string sName = "Sensor" + to_string(uSensor) + "_Out" + to_string(int(eOutput));
                    LOG_INFO("Creating consumer %s\n", sName.c_str());

                    auto pClientDesc = upMaster2->GetClientDesc(uSensor, eOutput);
                    if (pClientDesc == nullptr) {
                        LOG_ERR("GetClientDesc failed for output:%u of sensor:%u\n", eOutput, uSensor);
                        return -1;
                    }

                    // Create NvSIPL consumer using client descriptor
                    auto upCons = unique_ptr<CNvSIPLConsumer>(new CNvSIPLConsumer());
                    if (upCons == nullptr) {
                        LOG_ERR("Failed to create NvSIPLConsumer for output:%u of sensor:%u\n", eOutput, uSensor);
                        return -1;
                    }

                    status = upCons->Init(pClientDesc, nullptr, -1, cmdline.sPrefix);
                    if (status != NVSIPL_STATUS_OK) {
                        LOG_ERR("Failed to initialize consumer for output:%u of sensor:%u\n", eOutput, uSensor);
                        return -1;
                    }

                    if (cmdline.bShowMetadata) {
                        upCons->EnableMetadataLogging();
                    }

                    vupConsumers.push_back(move(upCons));
                } // output
            } // sensor
        } // module
    } // device block

    LOG_INFO("Starting master\n");
    status = upMaster2->Start();
    CHK_STATUS_AND_RETURN(status, "Master start");

    // Wait for quit
    while (!bQuit) {
        // Wait for a second
        auto oStartTime = chrono::steady_clock::now();
        std::this_thread::sleep_for(std::chrono::seconds(1));

        if (cmdline.uRunDurationSec != -1) {
            cmdline.uRunDurationSec--;
            if (cmdline.uRunDurationSec == 0) {
                bQuit = true;
            }
        }

        // Log FPS
        if (cmdline.bShowFPS) {
            auto uTimeElapsedMs = chrono::duration<double, std::milli> (chrono::steady_clock::now() - oStartTime).count();
            cout << "Output\tFPS\n";
            for (auto &cons : vupConsumers) {
                auto fps = (cons->m_uFrameCount*1000.0)/(uTimeElapsedMs);
                cout << cons->m_pDesc->oConsDesc.sName << "\t" << fps << endl;
                cons->m_uFrameCount = 0;
            }
        }
    }

    if (upMaster2 != nullptr) {
        LOG_INFO("Stopping master\n");
        status = upMaster2->Stop();
        if (status != NVSIPL_STATUS_OK) {
            LOG_ERR("Failed to Stop master %u\n", status);
        }
    }

    for (auto &cons : vupConsumers) {
        LOG_INFO("De-initializing consumer %s\n", cons->m_pDesc->oConsDesc.sName.c_str());
        cons->Deinit();
    }

    if (upMaster2 != nullptr) {
        LOG_INFO("De-initilaizing master\n");
        upMaster2->Deinit();
    }

    return 0;
}

Dear @greivin.fallas,
Please confirm if camera model is Sony IMX390? Which port camera is connected?

Hi @SivaRamaKrishnaNV,

Yes, sensor is Sony IMX390, I tested on 4 ports (1 camera per port).

Thanks.

Dear @greivin.fallas,
Ok. Could you share dmseg log when you hit issue. I am checking internally and get back to you.

Dear @greivin.fallas,
Can you provide any update here?

Hi @SivaRamaKrishnaNV,

This is the dmesg log when the issue happens:

[1051818.253086] scare-pigeon 13e10000.host1x:vi-thi@15f00000: nvhost_syncpt_get_cv_dev_address_table: failed to fetch_cv_dev_info
[1051818.271294] scare-pigeon 14b00000.isp-thi: nvhost_syncpt_get_cv_dev_address_table: failed to fetch_cv_dev_info
[1051818.286725] [RCE] vi5_hwinit: firmware CL2018101701 protocol version 2.2
[1051830.739546] i2c i2c-7: Failed to register i2c client isc-dev at 0x63 (-16)
[1051830.742468] isc-mgr.7.g isc-mgr.7.g: __isc_create_dev cannot allocate client: isc-dev.7.63 bus 7, 63