Hi,
I am trying to port a driver for AWR2243 chip. I have it working as expected on Jetson TX2 NX (JetPack 4.6.4) but I have problems on Jetson Orin NX (JP 5.1.3).
Moving to JetPack 6 is not an option at the moment, unless it is the only option.
Driver has been inspired by IMX204 driver.
My first issue was with calling v4l2_async_register_subdev() in the last step of probing.
It caused kernel panic on target startup. I traced the issue to __v4l2_ctrl_handler_setup in v4l2-ctrls.c file.
For some reason “Bypass Mode” control did not have cluster member set and it cause null pointer dereference.
What might be the reason for that?
Then I’ve added a check if cluster pointer is set and if not just to skip the control.
NOTE: I’ve added some debug logs and only “Bypass Mode” has the issue, other controls have cluster member set.
That worked and the driver successfully probed device.
Boot log looks fine:
$ sudo dmesg | grep tegra-c
[ 6.285424] t19x_cache tegra-cache: probed
[ 7.231386] tegra-camrtc-capture-vi tegra-capture-vi: subdev 13e40000.host1x:nvcsi@15a00000- bound
[ 7.240601] tegra-camrtc-capture-vi tegra-capture-vi: subdev 13e40000.host1x:nvcsi@15a00000- bound
[ 7.249821] tegra-camrtc-capture-vi tegra-capture-vi: subdev 13e40000.host1x:nvcsi@15a00000- bound
[ 7.259032] tegra-camrtc-capture-vi tegra-capture-vi: subdev 13e40000.host1x:nvcsi@15a00000- bound
[ 13.609177] tegra-camrtc-capture-vi tegra-capture-vi: subdev awr2243 spi1.0 bound
[ 13.610833] [AWR2243]: get format tegra-camrtc-capture-vi tegra-captu->awr2243 spi1.0 == 0
[ 13.988237] tegra-camrtc-capture-vi tegra-capture-vi: subdev awr2243 spi1.1 bound
[ 13.989229] [AWR2243]: get format tegra-camrtc-capture-vi tegra-captu->awr2243 spi1.1 == 0
[ 13.991542] tegra-camrtc-capture-vi tegra-capture-vi: subdev awr2243 spi1.2 bound
[ 13.993009] [AWR2243]: get format tegra-camrtc-capture-vi tegra-captu->awr2243 spi1.2 == 0
[ 13.994248] tegra-camrtc-capture-vi tegra-capture-vi: subdev awr2243 spi1.3 bound
[ 13.995250] [AWR2243]: get format tegra-camrtc-capture-vi tegra-captu->awr2243 spi1.3 == 0
[ 22.603259] [AWR2243]: input status tegra-camrtc-capture-vi tegra-captu->awr2243 spi1.0
[ 22.608443] [AWR2243]: input status tegra-camrtc-capture-vi tegra-captu->awr2243 spi1.1
[ 22.613283] [AWR2243]: input status tegra-camrtc-capture-vi tegra-captu->awr2243 spi1.2
[ 22.618133] [AWR2243]: input status tegra-camrtc-capture-vi tegra-captu->awr2243 spi1.3
Video devices (/dev/video) are created.
I’ve run media-ctl to verify port binding as suggested in SensorSoftwareDriverProgramming:
$ media-ctl -p
Media controller API version 5.10.192
Media device information
------------------------
driver tegra-camrtc-ca
model NVIDIA Tegra Video Input Device
serial
bus info
hw revision 0x3
driver version 5.10.192
Device topology
- entity 1: 13e40000.host1x:nvcsi@15a00000- (2 pads, 2 links)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev0
pad0: Sink
<- "awr2243 spi1.0":0 [ENABLED]
pad1: Source
-> "vi-output, awr2243 spi1.0":0 [ENABLED]
- entity 4: 13e40000.host1x:nvcsi@15a00000- (2 pads, 2 links)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev1
pad0: Sink
<- "awr2243 spi1.1":0 [ENABLED]
pad1: Source
-> "vi-output, awr2243 spi1.1":0 [ENABLED]
- entity 7: 13e40000.host1x:nvcsi@15a00000- (2 pads, 2 links)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev2
pad0: Sink
<- "awr2243 spi1.2":0 [ENABLED]
pad1: Source
-> "vi-output, awr2243 spi1.2":0 [ENABLED]
- entity 10: 13e40000.host1x:nvcsi@15a00000- (2 pads, 2 links)
type V4L2 subdev subtype Unknown flags 0
device node name /dev/v4l-subdev3
pad0: Sink
<- "awr2243 spi1.3":0 [ENABLED]
pad1: Source
-> "vi-output, awr2243 spi1.3":0 [ENABLED]
- entity 13: awr2243 spi1.0 (1 pad, 1 link)
type V4L2 subdev subtype Sensor flags 0
device node name /dev/v4l-subdev4
pad0: Source
[fmt:SRGGB8_1X8/2048x32 field:none colorspace:srgb]
-> "13e40000.host1x:nvcsi@15a00000-":0 [ENABLED]
- entity 15: vi-output, awr2243 spi1.0 (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video0
pad0: Sink
<- "13e40000.host1x:nvcsi@15a00000-":1 [ENABLED]
- entity 33: awr2243 spi1.1 (1 pad, 1 link)
type V4L2 subdev subtype Sensor flags 0
device node name /dev/v4l-subdev5
pad0: Source
[fmt:SRGGB8_1X8/2048x32 field:none colorspace:srgb]
-> "13e40000.host1x:nvcsi@15a00000-":0 [ENABLED]
- entity 35: vi-output, awr2243 spi1.1 (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video1
pad0: Sink
<- "13e40000.host1x:nvcsi@15a00000-":1 [ENABLED]
- entity 45: awr2243 spi1.2 (1 pad, 1 link)
type V4L2 subdev subtype Sensor flags 0
device node name /dev/v4l-subdev6
pad0: Source
[fmt:SRGGB8_1X8/2048x32 field:none colorspace:srgb]
-> "13e40000.host1x:nvcsi@15a00000-":0 [ENABLED]
- entity 47: vi-output, awr2243 spi1.2 (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video2
pad0: Sink
<- "13e40000.host1x:nvcsi@15a00000-":1 [ENABLED]
- entity 57: awr2243 spi1.3 (1 pad, 1 link)
type V4L2 subdev subtype Sensor flags 0
device node name /dev/v4l-subdev7
pad0: Source
[fmt:SRGGB8_1X8/2048x32 field:none colorspace:srgb]
-> "13e40000.host1x:nvcsi@15a00000-":0 [ENABLED]
- entity 59: vi-output, awr2243 spi1.3 (1 pad, 1 link)
type Node subtype V4L flags 0
device node name /dev/video3
pad0: Sink
<- "13e40000.host1x:nvcsi@15a00000-":1 [ENABLED]
Next problem I have is when running v4l2-complience:
v4l2-compliance
v4l2-compliance SHA: not available, 64 bits
Compliance test for tegra-video device /dev/video0:
Driver Info:
Driver name : tegra-video
Card type : vi-output, awr2243 spi1.0
Bus info : platform:tegra-capture-vi:0
Driver version : 5.10.192
Capabilities : 0x84200001
Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Media Driver Info:
Driver name : tegra-camrtc-ca
Model : NVIDIA Tegra Video Input Device
Serial :
Bus info :
Media version : 5.10.192
Hardware revision: 0x00000003 (3)
Driver version : 5.10.192
Interface Info:
ID : 0x03000011
Type : V4L Video
Entity Info:
ID : 0x0000000f (15)
Name : vi-output, awr2243 spi1.0
Function : V4L2 I/O
Pad 0x01000010 : 0: Sink
Link 0x02000015: from remote pad 0x1000003 of entity '13e40000.host1x:nvcsi@15a00000-': Data, Enabled
Required ioctls:
test MC information (see 'Media Driver Info' above): OK
test VIDIOC_QUERYCAP: OK
Allow for multiple opens:
test second /dev/video0 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported)
test VIDIOC_LOG_STATUS: OK
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls (Input 0):
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
fail: v4l2-test-controls.cpp(663): g_ext_ctrls returned an error (22)
test VIDIOC_G/S/TRY_EXT_CTRLS: FAIL
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 1 Private Controls: 20
Format ioctls (Input 0):
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
fail: v4l2-test-formats.cpp(1280): ret && node->has_frmintervals
test VIDIOC_G/S_PARM: FAIL
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)
Codec ioctls (Input 0):
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls (Input 0):
fail: v4l2-test-buffers.cpp(715): q.create_bufs(node, 1, &fmt) != EINVAL
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: FAIL
test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)
Total for tegra-video device /dev/video0: 45, Succeeded: 42, Failed: 3, Warnings: 0
I don’t care about VIDIOC_G/S_PARM because that one failed on TX2 NX and capturing still worked, but VIDIOC_G/S/TRY_EXT_CTRLS: and especially VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF have to pass.
Output of v4l2-ctl:
v4l2-ctl --all
Driver Info:
Driver name : tegra-video
Card type : vi-output, awr2243 spi1.0
Bus info : platform:tegra-capture-vi:0
Driver version : 5.10.192
Capabilities : 0x84200001
Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Media Driver Info:
Driver name : tegra-camrtc-ca
Model : NVIDIA Tegra Video Input Device
Serial :
Bus info :
Media version : 5.10.192
Hardware revision: 0x00000003 (3)
Driver version : 5.10.192
Interface Info:
ID : 0x03000011
Type : V4L Video
Entity Info:
ID : 0x0000000f (15)
Name : vi-output, awr2243 spi1.0
Function : V4L2 I/O
Pad 0x01000010 : 0: Sink
Link 0x02000015: from remote pad 0x1000003 of entity '13e40000.host1x:nvcsi@15a00000-': Data, Enabled
Priority: 2
Video input : 0 (Camera 0: no power)
Format Video Capture:
Width/Height : 2048/32
Pixel Format : 'RGGB' (8-bit Bayer RGRG/GBGB)
Field : None
Bytes per Line : 2048
Size Image : 65536
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Full Range)
Flags :
Camera Controls
frame_length 0x009a2000 (int) : min=0 max=65535 step=1 default=3665 value=3665 flags=slider
coarse_time 0x009a2001 (int) : min=1 max=65525 step=1 default=3655 value=3655 flags=slider
group_hold 0x009a2003 (intmenu): min=0 max=1 default=0 value=0
0: 0 (0x0)
1: 1 (0x1)
hdr_enable 0x009a2004 (intmenu): min=0 max=1 default=0 value=0
0: 0 (0x0)
1: 1 (0x1)
gain 0x009a2009 (int) : min=256 max=5888 step=1 default=256 value=256 flags=slider
sensor_configuration 0x009a2032 (u32) : min=0 max=4294967295 step=1 default=0 [22] flags=read-only, volatile, has-payload
sensor_mode_i2c_packet 0x009a2033 (u32) : min=0 max=4294967295 step=1 default=0 [1026] flags=read-only, volatile, has-payload
sensor_control_i2c_packet 0x009a2034 (u32) : min=0 max=4294967295 step=1 default=0 [1026] flags=read-only, volatile, has-payload
vi_bypass_mode 0x009a2064 (int) : min=0 max=1 step=1 default=1 value=1 flags=slider
override_enable 0x009a2065 (intmenu): min=0 max=1 default=0 value=0
0: 0 (0x0)
1: 1 (0x1)
height_align 0x009a2066 (int) : min=1 max=16 step=1 default=1 value=1
size_align 0x009a2067 (intmenu): min=0 max=2 default=0 value=0
0: 1 (0x1)
1: 65536 (0x10000)
2: 131072 (0x20000)
write_isp_format 0x009a2068 (int) : min=1 max=1 step=1 default=1 value=1
sensor_signal_properties 0x009a2069 (u32) : min=0 max=4294967295 step=1 default=0 [30][18] flags=read-only, has-payload
sensor_image_properties 0x009a206a (u32) : min=0 max=4294967295 step=1 default=0 [30][16] flags=read-only, has-payload
sensor_control_properties 0x009a206b (u32) : min=0 max=4294967295 step=1 default=0 [30][36] flags=read-only, has-payload
sensor_dv_timings 0x009a206c (u32) : min=0 max=4294967295 step=1 default=0 [30][16] flags=read-only, has-payload
low_latency_mode 0x009a206d (bool) : default=0 value=0
preferred_stride 0x009a206e (int) : min=0 max=65535 step=1 default=0 value=0
sensor_modes 0x009a2082 (int) : min=0 max=30 step=1 default=30 value=26 flags=read-only
When I try to capture with our app I get these errors:
Required memory if buffer gets full: 2013.27 MB
Available memory: 14799.2 MB
Required storage for capture: 2516.58 MB
Available storage: 445887 MB
Device 0 is /dev/awr4
Device 1 is /dev/awr1
Device 2 is /dev/awr3
Device 3 is /dev/awr2
[NOTICE] /home/provizio/development/apt_radar/src/libv4l2cpp/src/V4l2MmapDevice.cpp:49
VIDIOC_REQBUFS: Inappropriate ioctl for device
Device /dev/awr4
[NOTICE] /home/provizio/development/apt_radar/src/libv4l2cpp/src/V4l2MmapDevice.cpp:141
VIDIOC_STREAMOFF: Inappropriate ioctl for device
VIDIOC_REQBUFS: Inappropriate ioctl for device
Device /dev/awr4
[NOTICE] /home/provizio/development/apt_radar/src/libv4l2cpp/src/V4l2MmapDevice.cpp:49
VIDIOC_REQBUFS: Inappropriate ioctl for device
Device /dev/awr1
[NOTICE] /home/provizio/development/apt_radar/src/libv4l2cpp/src/V4l2MmapDevice.cpp:141
VIDIOC_STREAMOFF: Inappropriate ioctl for device
VIDIOC_REQBUFS: Inappropriate ioctl for device
Device /dev/awr1
[NOTICE] /home/provizio/development/apt_radar/src/libv4l2cpp/src/V4l2MmapDevice.cpp:49
VIDIOC_REQBUFS: Inappropriate ioctl for device
Device /dev/awr3
[NOTICE] /home/provizio/development/apt_radar/src/libv4l2cpp/src/V4l2MmapDevice.cpp:141
VIDIOC_STREAMOFF: Inappropriate ioctl for device
VIDIOC_REQBUFS: Inappropriate ioctl for device
Device /dev/awr3
[NOTICE] /home/provizio/development/apt_radar/src/libv4l2cpp/src/V4l2MmapDevice.cpp:49
VIDIOC_REQBUFS: Inappropriate ioctl for device
Device /dev/awr2
[NOTICE] /home/provizio/development/apt_radar/src/libv4l2cpp/src/V4l2MmapDevice.cpp:141
VIDIOC_STREAMOFF: Inappropriate ioctl for device
VIDIOC_REQBUFS: Inappropriate ioctl for device
Device /dev/awr2a v4l2 device == nullptr, can't start
Generating report file...
Exiting...
After that running dmesg I get:
...
[ 18.925272] NVRM: Try unloading the conflicting kernel module (and/or
NVRM: reconfigure your kernel without the conflicting
NVRM: driver(s)), then try loading the NVIDIA kernel module
NVRM: again.
[ 18.925274] NVRM: No NVIDIA devices probed.
[ 19.934961] igb 0001:01:00.0 eth0: igb: eth0 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX/TX
[ 20.258718] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[ 22.926173] [AWR2243]: open
[ 22.926239] [AWR2243]: open
[ 22.926337] [AWR2243]: open
[ 22.926408] [AWR2243]: open
[ 22.929836] [AWR2243]: input status tegra-camrtc-capture-vi tegra-captu->awr2243 spi1.0
[ 22.935119] [AWR2243]: input status tegra-camrtc-capture-vi tegra-captu->awr2243 spi1.1
[ 22.940120] [AWR2243]: input status tegra-camrtc-capture-vi tegra-captu->awr2243 spi1.2
[ 22.945079] [AWR2243]: input status tegra-camrtc-capture-vi tegra-captu->awr2243 spi1.3
What might be the reason for this issue?
Appreciate the help.