Load a kernel module prior to the automatically started nv_imx219.ko

Hi ,
On the Jetson AGX Orin platform, I have successfully installed the IMX219 driver and can see the image output. Now, I need to do something: execute another serdes module before nv_imx219.ko is executed. However, after the system boot, I see that nv_imx219 has been automatically executed. May I know where is this action performed in which file? I need to execute the serdes module before it

Thanks in advance.

What’s the BSP version?

cat /etc/nv_tegra_release

Here is the BSP version info:

#R36 (release), REVISION: 4.0, GCID: 37537400, BOARD: generic, EABI: aarch64, DATE: Fri Sep 13 04:36:44 UTC 2024
#KERNEL_VARIANT: oot
TARGET_USERSPACE_LIB_DIR=nvidia
TARGET_USERSPACE_LIB_DIR_PATH=usr/lib/aarch64-linux-gnu/nvidia

Try modify /var/lib/dpkg/info/nvidia-l4t-kernel-oot-modules.list to check.

I can find nv_imx219.ko in this file. However, when I tried to add my serdes.ko to this file, the module is not installed after reboot. I also removed nv_imx219.ko, but that module is still installed after reboot. May I know the possible reasons for this behavior ?

Refer this link which explains how to modify config file so that the different KO modules and there dependencies are handled.

Thanks. However, it seems that approach requires kernel image modifications. My intention is to insert a kernel module without making any changes to the kernel image. Is there a method to acheive it?

Using Make menuconfig etc you can modify and configure modules accordingly…

  1. If you set a module as "CONFIG_…=“m” you want to load independently and not as part of kernel image
  2. If you set it as “CONFIG_…=y”, then it will be part of your kernel image.

refer below link for detailed explanation:

I am still confused. Setting it as "CONFIG_…=“m” wont’ auto insert module. My question is where the kernel insmod it automatically at boot up stage.

Suppose should be this file “/usr/lib/modules/5.15.148-tegra/modules.dep”

If you have a valid module in the correct location, and you have run “sudo depmod -a” to tell the system the module is there, then it should auto load. However, to preload (in the Linux stage once the kernel is loaded) you could add a spec to /etc/modules-load.d/, then it will load regardless of seeing a need. If the module is not valid, then it can never load. If the module is required to mount the actual filesystem (e.g., it is a module needed for an NFS mount or for a filesystem not natively in the kernel), then you have to place this in the initrd. If this is to be part of a boot chain (before the Linux kernel loads), then you have to compile it for that boot chain and adjust the boot chain itself.

If this is a camera driver, then you won’t have any special early load required. If that module is valid, and thus that module can load, then anything requiring that module will result in it loading.

However, let’s talk about how the “need” to load is determined…

Some devices are “plug-n-play”, and others are not. Plug-n-play devices include PCIe and USB devices, and the PCI bus and USB bus can actually query the device to ask what its specs are. The hot plug layer will broadcast what the device is, and drivers known to have that capability will take ownership; the module will auto load.

Other devices are not plug-n-play. Those devices cannot be hot-plug detected, and those devices are incapable of being queried as to what they are and what their requirements are. These devices will have a physical address on a bus, and the module must be told to access that address with the right arguments. At that moment the module will load, and the module will blindly try to access that address. The method for telling the o/s what that address is, along with which driver to use, is via the device tree (which is “firmware”). If your device is not plug-n-play, then if the module is capable of loading, that device tree entry is how you would trigger this.

If you happen to have a module which can be loaded, and you manually load it, then the module will do nothing at all unless it is paired with information on where the non-plug-n-play device is.

1 Like

I put serdes.ko in /usr/lib/modules/5.15.148-tegra/updates/drivers/media/i2c and treid the 2 methods:

  1. modify /usr/lib/modules/5.15.148-tegra/modules.dep

  2. modify /etc/modules-load.d/modules.conf

but still fail to insert the serdes.ko at boot time. May I have your suggestions. Thank you.

Have reference to below link to try.

https://www.cyberciti.biz/faq/linux-how-to-load-a-kernel-module-automatically-at-boot-time/

1 Like

although i still have no idea why the previous steps cannot work, this method can finally work, and it is inserted prior to nv_imx219.ko. Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.