Enable Kernel modules without going through complete Kernel recompile


I need new kernel modules that are missing in my current installed one.
Is it necessary to entirely recompile the kernel ?

Thank you

So long as all the kernel configuration matches what is required to support the moduel, no, you don’t need to rebuild the kernel.

Some tips…

If you kernel is the default, then you could start with the config target “tegra_defconfig”. If the kernel is not the default, then you could start with a copy of “/proc/config.gz” (this is not a real file, it is in RAM, and is the kernel itself pretending to be a file; the content is the existing configuration).

None of those methods will correctly set up one parameter, CONFIG_LOCALVERSION. When you run the command “uname -r”, the prefix is the kernel source release, and the suffix is CONFIG_LOCALVERSION. The default is:

As a contrived example, if the kernel is version 5.15.0, and if CONFIG_LOCALVERSION is “-tegra”, then “uname -r” will respond with “5.15.0-tegra”. When that kernel looks for modules to load, it will look in subdirectories of:
/lib/modules/$(uname -r)/kernel
(the specific subdirectory matches the subdirectory where the compiled module is found in the kernel source)

So for example, you could do this (there are modifications to build in a clean directory, which I recommend, but I am not showing those; assumes you are in the top of the kernel source, and compiling natively on the Jetson):

  • cp /proc/config.gz .
  • gunzip config.gz
  • mv config .config
  • Use something like “make menuconfig” or “make nconfig” to set CONFIG_LOCALVERSION to “-tegra”. I happen to know that this particular symbol has no dependencies, so you could actually edit the .config directly…but be very very careful about doing this with anything you don’t know the dependencies on.
  • Propagate the configuration:
    make modules_prepare
  • make modules

One could substitute, if a default kernel, “make tegra_defconfig” for the part where I copied config.gz, but you would still need to set CONFIG_LOCALVERSION.

If you are only adding modules, then this should always work. If you are changing a feature which is integrated into the kernel Image itself, then likely you need a new CONFIG_LOCALVERSION and an entirely new kernel and all modules.

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