Build new camera sensor kernel module - symbols missing

Hi,
I followed this section to build the new kernel module:
https://docs.nvidia.com/jetson/archives/r35.3.1/DeveloperGuide/text/SD/Kernel/KernelCustomization.html#to-prepare-a-kernel-source-tree-that-is-not-built
and this:
https://docs.nvidia.com/jetson/archives/r35.3.1/DeveloperGuide/text/SD/Kernel/KernelCustomization.html#to-build-external-kernel-modules

1.I build it on the target (Orin nx devkit)
2. I downloaded the L4T sources into the target. I work with these sources (including kernel sources)
3. I wrote the kernel module
4. Execute:

cd $L4T/source/public/kernel/kernel-5.10/:
$ make tegra_defconfig
$ make ARCH=arm64 O=$L4T/source/public/kernel/kernel-5.10/ -j2 modules_prepare
$ cd $L4T/source/public/kernel/nvidia/drivers/media/i2c
$ make ARCH=arm64 -C $L4T/source/public/kernel/kernel-5.10/ M=(pwd)
$ ${TOOLCHAIN}strip --strip-unneeded $KERNEL_MODULE_PATH

When I insmod the new module it says:
no symbol version for module_layout
module verification failed: signature and/or required key missing - tainting kernel

Could you build reference sensor driver like nv_imx219/nv_imx477 to check if the same error while probe?

BTW, I also build the module by cross compile on host PC.

Thanks

is it possible to build it on host without building the whole kernel each time?

Can you share how you build the specific module on the host without building the kernel from scratch each time? Iā€™m having trouble doing that based on the existing dev-guide instructions (JP 5.1.3)

@ShaneCCC
I built on the host. I get the following errors:

No change to .config

CALL scripts/atomic/check-atomics.sh
CALL scripts/checksyscalls.sh
make: Entering directory ā€˜/media/bsp/Projects/Workspace_5_1_3/Linux_for_Tegra/source/public/kernel/kernel-5.10ā€™
CC [M] /media/bsp/Projects/Workspace_5_1_3/Linux_for_Tegra/source/public/kernel/nvidia/drivers/media/i2c/des960.o
WARNING: Symbol version dump ā€œModule.symversā€ is missing.
Modules may not have dependencies or modversions.
MODPOST /media/bsp/Projects/Workspace_5_1_3/Linux_for_Tegra/source/public/kernel/nvidia/drivers/media/i2c/Module.symvers
WARNING: modpost: Symbol info of vmlinux is missing. Unresolved symbol check will be entirely skipped.
CC [M] /media/bsp/Projects/Workspace_5_1_3/Linux_for_Tegra/source/public/kernel/nvidia/drivers/media/i2c/des960.mod.o
LD [M] /media/bsp/Projects/Workspace_5_1_3/Linux_for_Tegra/source/public/kernel/nvidia/drivers/media/i2c/des960.ko
make: Leaving directory ā€˜/media/bsp/Projects/Workspace_5_1_3/Linux_for_Tegra/source/public/kernel/kernel-5.10ā€™

So during the build I already get these errors

Do you follow the document to build the source?

./nvbuild.sh -o $PWD/kernel_out

https://docs.nvidia.com/jetson/archives/r35.5.0/DeveloperGuide/SD/Kernel/KernelCustomization.html

Hi @ShaneCCC ,
I donā€™t want to build the kernel each time I build the kernel module.
I tried a little bit more and succefully built the module on the host and loaded it on the target without receving the errors mentioned before:

no symbol version for module_layout
module verification failed: signature and/or required key missing - tainting kernel

Now I have another problem. For some reason my driverā€™s probe function isnā€™t execuing.
I used proper compatible fields in both my device tree and the kernel module

from my kernel module:

static const struct i2c_device_id ds960_id =
{
{ā€œdes960ā€, 0},
{}
};

static const struct of_device_id ds960_of_match =
{
{.compatible = ā€œnvidia,des960ā€,},
{},
};

static struct i2c_driver ds960_i2c_driver = {
.driver = {
.name = ā€œdes960ā€,
.owner = THIS_MODULE,
.of_match_table = of_match_ptr(ds960_of_match),
},
.probe = ds960_probe,
.remove = ds960_remove,
.id_table = ds960_id,
};

MODULE_DEVICE_TABLE(of, ds960_of_match);

MODULE_DEVICE_TABLE(i2c, ds960_id);

module_i2c_driver(ds960_i2c_driver);

From my device tree:

des960_a@3d {
compatible = ā€œnvidia,des960ā€;
status = ā€œokayā€
.
.
.
}

In addition, I executed

ls /sys/bus/platform/devices

and didnā€™t see a file with ā€œdes960ā€ on its name.

the target final device tree is:
my_tree.txt (409.4 KB)

Looks like your cam_i2cmux lose some context.
Have reference to below.

cam_i2cmux {
26 		compatible = "i2c-mux-gpio";
27 		#address-cells = <1>;
28 		#size-cells = <0>;
29 		mux-gpios = <&tegra_aon_gpio CAM_I2C_MUX GPIO_ACTIVE_HIGH>;
30 		i2c-parent = <&cam_i2c>;
31 		i2c@0 {

@ShaneCCC

Thank you for your answer!

I modified the device tree from scratch according to the imx219 example.

When I load my kernel module the target gets stuck and I have to reset it.
I guess its some kind of a good sign since I probably touch something there.

my i2cdetect output:
terminal.log (1.7 KB)

my device tree:
orin_nx.txt (410.7 KB)

my kernel module source:
des960.txt (25.6 KB)

  1. There are several device tree (property-value) pairs that I took ā€œas isā€ from the imx219 example since I donā€™t know what are the correct values for now and I just want to make sure that my probe function is working and identifying my de-serializer properly.

Can it be the reason for getting stuck?

  1. My driver is not complete. I took it from reference driver as well. I just want to make sure my probe function works and that I can see its prints.

As I said, this is my first time writing a kernel module, modifying device tree and working with cameras.
Thank you very much for your help. I think Iā€™m close to the solution.

I would suspect it could be the des960 driver cause the problem.
Whatā€™s the kernel log while load the driver.

I canā€™t read the kernel log since as I execute:

insmod des960.ko

the target freeze. I canā€™t execute dmesg.

From my understanding the only function executed while inserting the module is the probe function. You can see that in my probe function I commented any regs read/write operations for testing purposes but it still freezes.

Check the log from UART.

Hi @ShaneCCC ,
The probe function works but I have a problem when using v4l2-ctl to stream the /dev/video0.

This is the log:

[16:12:25:797] [ 4721.719323] bwmgr API not supportedāāŠ

[16:12:25:806] [ 4724.320283] tegra-camrtc-capture-vi tegra-capture-vi: uncorr_err: request timed out after 2500 msāāŠ

[16:12:25:815] [ 4724.333045] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: attempting to reset the capture channelāāŠ

[16:12:25:825] [ 4724.343625] (NULL device *): vi_capture_control_message: NULL VI channel receivedāāŠ

[16:12:25:835] [ 4724.351455] t194-nvcsi 13e40000.host1x:nvcsi@15a00000: csi5_stream_close: Error in closing stream_id=1, csi_port=1āāŠ

[16:12:25:845] [ 4724.362142] (NULL device *): vi_capture_control_message: NULL VI channel receivedāāŠ

[16:12:25:853] [ 4724.370036] t194-nvcsi 13e40000.host1x:nvcsi@15a00000: csi5_stream_open: VI channel not found for stream- 1 vc- 0āāŠ

[16:12:25:863] [ 4724.380987] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: successfully reset the capture channelāāŠ

[16:12:28:618] [ 4727.136213] tegra-camrtc-capture-vi tegra-capture-vi: uncorr_err: request timed out after 2500 msāāŠ

[16:12:28:628] [ 4727.145374] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: attempting to reset the capture channelāāŠ

[16:12:28:637] [ 4727.155312] (NULL device *): vi_capture_control_message: NULL VI channel receivedāāŠ

[16:12:28:646] [ 4727.163112] t194-nvcsi 13e40000.host1x:nvcsi@15a00000: csi5_stream_close: Error in closing stream_id=1, csi_port=1āāŠ

[16:12:28:658] [ 4727.174084] (NULL device *): vi_capture_control_message: NULL VI channel receivedāāŠ

[16:12:28:665] [ 4727.181919] t194-nvcsi 13e40000.host1x:nvcsi@15a00000: csi5_stream_open: VI channel not found for stream- 1 vc- 0āāŠ

[16:12:28:678] [ 4727.196226] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: successfully reset the capture channelāāŠ

[16:12:31:434] [ 4729.952176] tegra-camrtc-capture-vi tegra-capture-vi: uncorr_err: request timed out after 2500 msāāŠ

[16:12:31:444] [ 4729.961356] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: attempting to reset the capture channelāāŠ

[16:12:31:454] [ 4729.971797] (NULL device *): vi_capture_control_message: NULL VI channel receivedāāŠ

[16:12:31:463] [ 4729.979660] t194-nvcsi 13e40000.host1x:nvcsi@15a00000: csi5_stream_close: Error in closing stream_id=1, csi_port=1āāŠ

[16:12:31:475] [ 4729.991188] (NULL device *): vi_capture_control_message: NULL VI channel receivedāāŠ

[16:12:31:482] [ 4729.999003] t194-nvcsi 13e40000.host1x:nvcsi@15a00000: csi5_stream_open: VI channel not found for stream- 1 vc- 0āāŠ

[16:12:31:494] [ 4730.010021] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: successfully reset the capture channelāāŠ

[16:12:34:250] [ 4732.768098] tegra-camrtc-capture-vi tegra-capture-vi: uncorr_err: request timed out after 2500 msāāŠ

[16:12:34:260] [ 4732.777349] tegra-camrtc-capture-vi tegra-capture-vi: err_rec: attempting to reset the capture channelāāŠ

[16:12:34:273] [ 4732.787005] (NULL device *): vi_capture_control_message: NULL VI channel receivedāāŠ

[16:12:34:279] [ 4732.794774] t194-nvcsi 13e40000.host1x:nvcsi@15a00000: csi5_stream_close: Error in closing stream_id=1, csi_port=1āāŠ

[16:12:34:291] [ 4732.805555] (NULL device *): vi_capture_control_message: NULL VI channel receivedāāŠ

[16:12:35:306] [ 4733.824090] tegra194-vi5 13e40000.host1x:vi0@15c00000: capture control message timed outāāŠ

[16:12:35:317] [ 4733.832459] tegra194-vi5 13e40000.host1x:vi0@15c00000: vi_capture_control_send_message: failed to send IVC control messageāāŠ

[16:12:36:330] [ 4734.848020] tegra194-vi5 13e40000.host1x:vi0@15c00000: capture control message timed outāāŠ

[16:12:36:337] [ 4734.856447] tegra-camrtc-capture-vi tegra-capture-vi: vi capture setup failedāāŠ

[16:12:36:345] [ 4734.863834] tegra-camrtc-capture-vi tegra-capture-vi: fatal: error recovery failedāāŠ

Hi @ShaneCCC ,
I played a little with both the driver and device tree.

  1. I fail in 2 out of 45 tests of the v4l2 compliance tests.
  2. Iā€™m able to record video but not playing it with gstreamer. I read its a problem with the AB24 format. Is there other solution?
    V4l2-ctl stream-mmap works but gstreamer does not

Thanks

  1. Suppose the failed of compliance can ignore.
  2. What do you mean for "ā€™m able to record video but not playing it with gstreamer. "?

I execute:

v4l2-ctl --set-fmt-video=width=640,height=480 --stream-mmap --set-ctrl=sensor_mode=0 --stream-count=100 -d /dev/video0

without problems. No errors in dmesg.

If I want to display the video with gstreamer is not working. I get exactly the same error as here:

I didnā€™t understand how to solve this issue or the verify the video is valid.

Whatā€™s the output format?

v4l2-ctl --list-formats-ext

Whatā€™s the gstreamer command and failed message?

Hi @ShaneCCC ,
This is the output:

gstreamer.log (2.7 KB)

full :
usits@ubuntu:~/Desktop$ gst-inspect-1.0 v4l2src

Factory Details:
Rank primary (256)
Long-name Video (video4linux2) Source
Klass Source/Video
Description Reads frames from a Video4Linux2 device
Author Edgard Lima edgard.lima@gmail.com, Stefan Kost ensonic@users.sf.net

Plugin Details:
Name video4linux2
Description elements for Video 4 Linux
Filename /usr/lib/aarch64-linux-gnu/gstreamer-1.0/libgstvideo4linux2.so
Version 1.16.3
License LGPL
Source module gst-plugins-good
Source release date 2020-10-21
Binary package GStreamer Good Plugins (Ubuntu)
Origin URL https://launchpad.net/distros/ubuntu/+source/gst-plugins-good1.0

GObject
Ā±ā€”GInitiallyUnowned
Ā±ā€”GstObject
Ā±ā€”GstElement
Ā±ā€”GstBaseSrc
Ā±ā€”GstPushSrc
Ā±ā€”GstV4l2Src

Implemented Interfaces:
GstURIHandler
GstTuner
GstColorBalance
GstVideoOrientation

Pad Templates:
SRC template: ā€˜srcā€™
Availability: Always
Capabilities:
image/jpeg
video/mpeg
mpegversion: 4
systemstream: false
video/mpeg
mpegversion: { (int)1, (int)2 }
video/mpegts
systemstream: true
video/x-bayer
format: { (string)bggr, (string)gbrg, (string)grbg, (string)rggb }
width: [ 1, 32768 ]
height: [ 1, 32768 ]
framerate: [ 0/1, 2147483647/1 ]
video/x-dv
systemstream: true
video/x-fwht
video/x-h263
variant: itu
video/x-h264
stream-format: { (string)byte-stream, (string)avc }
alignment: au
video/x-h265
stream-format: byte-stream
alignment: au
video/x-pwc1
width: [ 1, 32768 ]
height: [ 1, 32768 ]
framerate: [ 0/1, 2147483647/1 ]
video/x-pwc2
width: [ 1, 32768 ]
height: [ 1, 32768 ]
framerate: [ 0/1, 2147483647/1 ]
video/x-raw
format: { (string)RGB16, (string)BGR, (string)RGB, (string)GRAY8, (string)GRAY16_LE, (string)GRAY16_BE, (string)YVU9, (string)YV12, (string)YUY2, (string)YVYU, (string)UYVY, (string)Y42B, (string)Y41B, (string)YUV9, (string)NV12_64Z32, (string)NV24, (string)NV61, (string)NV16, (string)NV21, (string)NV12, (string)I420, (string)BGRA, (string)BGRx, (string)ARGB, (string)xRGB, (string)BGR15, (string)RGB15 }
width: [ 1, 32768 ]
height: [ 1, 32768 ]
framerate: [ 0/1, 2147483647/1 ]
video/x-sonix
width: [ 1, 32768 ]
height: [ 1, 32768 ]
framerate: [ 0/1, 2147483647/1 ]
video/x-vp8
video/x-vp9
video/x-wmv
wmvversion: 3
format: WVC1

Element has no clocking capabilities.

URI handling capabilities:
Element can act as source.
Supported URI protocols:
v4l2

Pads:
SRC: ā€˜srcā€™
Pad Template: ā€˜srcā€™

Element Properties:
blocksize : Size in bytes to read per buffer (-1 = default)
flags: readable, writable
Unsigned Integer. Range: 0 - 4294967295 Default: 4096
brightness : Picture brightness, or more precisely, the black level
flags: readable, writable, controllable
Integer. Range: -2147483648 - 2147483647 Default: 0
contrast : Picture contrast or luma gain
flags: readable, writable, controllable
Integer. Range: -2147483648 - 2147483647 Default: 0
device : Device location
flags: readable, writable
String. Default: ā€œ/dev/video0ā€
device-fd : File descriptor of the device
flags: readable
Integer. Range: -1 - 2147483647 Default: -1
device-name : Name of the device
flags: readable
String. Default: null
do-timestamp : Apply current stream time to buffers
flags: readable, writable
Boolean. Default: false
extra-controls : Extra v4l2 controls (CIDs) for the device
flags: readable, writable
Boxed pointer of type ā€œGstStructureā€
flags : Device type flags
flags: readable
Flags ā€œGstV4l2DeviceTypeFlagsā€ Default: 0x00000000, ā€œ(none)ā€
(0x00000001): capture - Device supports video capture
(0x00000002): output - Device supports video playback
(0x00000004): overlay - Device supports video overlay
(0x00000010): vbi-capture - Device supports the VBI capture
(0x00000020): vbi-output - Device supports the VBI output
(0x00010000): tuner - Device has a tuner or modulator
(0x00020000): audio - Device has audio inputs or outputs
force-aspect-ratio : When enabled, the pixel aspect ratio will be enforced
flags: readable, writable
Boolean. Default: true
hue : Hue or color balance
flags: readable, writable, controllable
Integer. Range: -2147483648 - 2147483647 Default: 0
io-mode : I/O mode
flags: readable, writable
Enum ā€œGstV4l2IOModeā€ Default: 0, ā€œautoā€
(0): auto - GST_V4L2_IO_AUTO
(1): rw - GST_V4L2_IO_RW
(2): mmap - GST_V4L2_IO_MMAP
(3): userptr - GST_V4L2_IO_USERPTR
(4): dmabuf - GST_V4L2_IO_DMABUF
(5): dmabuf-import - GST_V4L2_IO_DMABUF_IMPORT
name : The name of the object
flags: readable, writable
String. Default: ā€œv4l2src0ā€
norm : video standard
flags: readable, writable
Enum ā€œV4L2_TV_normsā€ Default: 0, ā€œnoneā€
(0): none - none
(45056): NTSC - NTSC
(4096): NTSC-M - NTSC-M
(8192): NTSC-M-JP - NTSC-M-JP
(32768): NTSC-M-KR - NTSC-M-KR
(16384): NTSC-443 - NTSC-443
(255): PAL - PAL
(7): PAL-BG - PAL-BG
(1): PAL-B - PAL-B
(2): PAL-B1 - PAL-B1
(4): PAL-G - PAL-G
(8): PAL-H - PAL-H
(16): PAL-I - PAL-I
(224): PAL-DK - PAL-DK
(32): PAL-D - PAL-D
(64): PAL-D1 - PAL-D1
(128): PAL-K - PAL-K
(256): PAL-M - PAL-M
(512): PAL-N - PAL-N
(1024): PAL-Nc - PAL-Nc
(2048): PAL-60 - PAL-60
(16711680): SECAM - SECAM
(65536): SECAM-B - SECAM-B
(262144): SECAM-G - SECAM-G
(524288): SECAM-H - SECAM-H
(3276800): SECAM-DK - SECAM-DK
(131072): SECAM-D - SECAM-D
(1048576): SECAM-K - SECAM-K
(2097152): SECAM-K1 - SECAM-K1
(4194304): SECAM-L - SECAM-L
(8388608): SECAM-Lc - SECAM-Lc
num-buffers : Number of buffers to output before sending EOS (-1 = unlimited)
flags: readable, writable
Integer. Range: -1 - 2147483647 Default: -1
parent : The parent of the object
flags: readable, writable
Object of type ā€œGstObjectā€
pixel-aspect-ratio : Overwrite the pixel aspect ratio of the device
flags: readable, writable
String. Default: null
saturation : Picture color saturation or chroma gain
flags: readable, writable, controllable
Integer. Range: -2147483648 - 2147483647 Default: 0
typefind : Run typefind before negotiating (deprecated, non-functional)
flags: readable, writable, deprecated
Boolean. Default: false

Element Signals:
ā€œprepare-formatā€ : void user_function (GstElement* object,
gint arg0,
GstCaps* arg1,
gpointer user_data);

Whatā€™s the sensor output format? RGB888?