# After modifying the kernel config and using the new kernel image, I can not use kernel modules which is compiled on the machine

**URL:** <https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682>\
**Category:** Jetson AGX Orin\
**Tags:** kernel\
**Created:** [June 26, 2024, 5:54am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682 "2024-06-26T05:54:55Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![user148386](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@user148386](https://forums.developer.nvidia.com/u/user148386)\
**Post date:** [June 26, 2024, 5:54am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/1 "2024-06-26T05:54:55Z")

</div>

$ sudo insmod ./test.ko  
insmod: ERROR: could not insert module test.ko: Invalid module format

Should I modify the header files of Linux?  
How to export Linux header files from kernel source code? such as/usr/src/Linux headers 5.10.104 tegra ubuntu20.04-arch64

---

<div class="post-metadata">

**Author:** ![DaveYYY](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/daveyyy/32/233244_2.png) [@DaveYYY](https://forums.developer.nvidia.com/u/DaveYYY)\
**Post date:** [June 26, 2024, 6:11am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/3 "2024-06-26T06:11:35Z")

</div>

Better share how you build the kernel.

---

<div class="post-metadata">

**Author:** ![user148386](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@user148386](https://forums.developer.nvidia.com/u/user148386)\
**Post date:** [June 26, 2024, 6:20am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/4 "2024-06-26T06:20:53Z")

</div>

1. create .config  
make ARCH=arm64 LOCALVERSION=“-tegra” O=$BUILD\_KERNEL\_OUT $KERNEL\_DEFCONFIG\_NAME

2. build kernel  
make ARCH=arm64 LOCALVERSION=“-tegra” O=$BUILD\_KERNEL\_OUT

---

<div class="post-metadata">

**Author:** ![DaveYYY](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/daveyyy/32/233244_2.png) [@DaveYYY](https://forums.developer.nvidia.com/u/DaveYYY)\
**Post date:** [June 26, 2024, 6:24am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/5 "2024-06-26T06:24:02Z")

</div>

I need the complete steps and what scripts you use.  
Is it JetPack 5 or JetPack 6?

> [@user148386](#):
>
> $ sudo insmod ./test.ko  
> insmod: ERROR: could not insert module test.ko: Invalid module format

Put the result of modinfo here.

---

<div class="post-metadata">

**Author:** ![user148386](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@user148386](https://forums.developer.nvidia.com/u/user148386)\
**Post date:** [June 26, 2024, 6:33am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/6 "2024-06-26T06:33:13Z")

</div>

Jetpack 5.1.1

1. create .config and add some configuration  
make ARCH=arm64 LOCALVERSION=“-tegra” O=$BUILD\_KERNEL\_OUT $KERNEL\_DEFCONFIG\_NAME

2. compile kernel  
make ARCH=arm64 LOCALVERSION=“-tegra” O=$BUILD\_KERNEL\_OUT

3. replace Image  
cp $BUILD\_KERNEL\_OUT/arch/arm64/boot/Image /boot/Image

4. compile test module  
cd /home/user/test/ && make

5. install ko  
$ sudo insmod ./test.ko  
insmod: ERROR: could not insert module ./test.ko: Invalid module format

$ modinfo ./test.ko  
filename: /home/dev/test/./test.ko  
license: GPL  
depends:  
name: test  
vermagic: 5.10.104-tegra SMP preempt mod\_unload modversions aarch64  
parm: debug: debug level (int)

---

<div class="post-metadata">

**Author:** ![DaveYYY](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/daveyyy/32/233244_2.png) [@DaveYYY](https://forums.developer.nvidia.com/u/DaveYYY)\
**Post date:** [June 26, 2024, 6:37am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/7 "2024-06-26T06:37:38Z")

</div>

How is the Makefile for your own module written?  
Do you have any issues loading other modules that are packed into the BSP?

---

<div class="post-metadata">

**Author:** ![user148386](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@user148386](https://forums.developer.nvidia.com/u/user148386)\
**Post date:** [June 26, 2024, 6:47am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/8 "2024-06-26T06:47:41Z")

</div>

Before replacement, this test kernel module is normal.

MONITOR\_EXTRA\_CFLAGS := -DMODULE  
ARCH := $(shell uname -i)  
ifneq ($(findstring aarch64,$(ARCH)),)  
MONITOR\_EXTRA\_CFLAGS += -DTARGET\_ARM64  
endif  
ifneq ($(KERNELRELEASE),)  
CFLAGS\_cpusocket\_unbalance.o = -I$(src)  
obj-m := test.o  
else  
KERNELDIR ?= /lib/modules/$(shell uname -r)/build  
PWD := $(shell pwd)  
default:  
$(MAKE) CFLAGS\_MODULE=“$(MONITOR\_EXTRA\_CFLAGS)” -C $(KERNELDIR) M=$(PWD) modules  
endif  
clean:  
rm -f core \*.o \*.a \*.s _.ko ._.cmd \*.mod \*.mod.c modules.order Module.symvers

---

<div class="post-metadata">

**Author:** ![DaveYYY](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/daveyyy/32/233244_2.png) [@DaveYYY](https://forums.developer.nvidia.com/u/DaveYYY)\
**Post date:** [June 26, 2024, 6:51am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/9 "2024-06-26T06:51:38Z")

</div>

> [@user148386](#):
>
> KERNELDIR ?= /lib/modules/$(shell uname -r)/build

Is this folder still linked to the kernel header source?

---

<div class="post-metadata">

**Author:** ![user148386](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@user148386](https://forums.developer.nvidia.com/u/user148386)\
**Post date:** [June 26, 2024, 6:53am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/10 "2024-06-26T06:53:07Z")

</div>

Yes, this folder is linked to /usr/src/linux-headers-5.10.104-tegra-ubuntu20.04\_aarch64/kernel-5.10/

So how can I export the new kernel header source?

---

<div class="post-metadata">

**Author:** ![DaveYYY](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/daveyyy/32/233244_2.png) [@DaveYYY](https://forums.developer.nvidia.com/u/DaveYYY)\
**Post date:** [June 26, 2024, 6:58am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/11 "2024-06-26T06:58:03Z")

</div>

Did you reboot the device after installing new kernels?  
Your module is now built against the new kernel, but if you don’t reboot, it is still the old kernel that currently runs on the device, which is imcompatible with your module.

---

<div class="post-metadata">

**Author:** ![user148386](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@user148386](https://forums.developer.nvidia.com/u/user148386)\
**Post date:** [June 26, 2024, 7:00am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/12 "2024-06-26T07:00:00Z")

</div>

I have already rebooted the machine and the kernel is the latest

---

<div class="post-metadata">

**Author:** ![DaveYYY](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/daveyyy/32/233244_2.png) [@DaveYYY](https://forums.developer.nvidia.com/u/DaveYYY)\
**Post date:** [June 26, 2024, 8:17am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/13 "2024-06-26T08:17:54Z")

</div>

Then does builiding the module after you reboot with the new kernel make any difference?  
Or are you able to do similar things on x86 PC?

---

<div class="post-metadata">

**Author:** ![user148386](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@user148386](https://forums.developer.nvidia.com/u/user148386)\
**Post date:** [June 26, 2024, 8:22am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/14 "2024-06-26T08:22:42Z")

</div>

yes, I build the module with the new kernel, but it does not work normally.  
In x86 machine, I usually replace new kernel header source after updating the new kernel. But I don’t know how to export header files in the Orin kernel code.

---

<div class="post-metadata">

**Author:** ![DaveYYY](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/daveyyy/32/233244_2.png) [@DaveYYY](https://forums.developer.nvidia.com/u/DaveYYY)\
**Post date:** [June 26, 2024, 8:24am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/15 "2024-06-26T08:24:45Z")

</div>

Can you check this?

> <https://unix.stackexchange.com/questions/270123/how-to-create-usr-src-linux-headers-version-files>

---

<div class="post-metadata">

**Author:** ![user148386](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@user148386](https://forums.developer.nvidia.com/u/user148386)\
**Post date:** [June 26, 2024, 9:29am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/16 "2024-06-26T09:29:41Z")

</div>

This method can not work, do you know how the tar package kernel\_headers.tbz2 generate?

[https://docs.nvidia.com/jetson/archives/r34.1/DeveloperGuide/text/SD/Kernel/KernelCustomization.html#:~:text=/Linux\_for\_Tegra/kernel/-,kernel\_headers.tbz2,-Where%20is%20a](https://docs.nvidia.com/jetson/archives/r34.1/DeveloperGuide/text/SD/Kernel/KernelCustomization.html#:~:text=/Linux_for_Tegra/kernel/-,kernel_headers.tbz2,-Where%20is%20a)

---

<div class="post-metadata">

**Author:** ![DaveYYY](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/daveyyy/32/233244_2.png) [@DaveYYY](https://forums.developer.nvidia.com/u/DaveYYY)\
**Post date:** [June 27, 2024, 1:24am UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/17 "2024-06-27T01:24:48Z")

</div>

What do you mean with `cannot work`?  
Kernel source header is a general Linux thing, and not specific to NVIDIA/Jetson.

---

<div class="post-metadata">

**Author:** ![linuxdev](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/linuxdev/32/10243_2.png) [@linuxdev](https://forums.developer.nvidia.com/u/linuxdev)\
**Post date:** [June 27, 2024, 5:51pm UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/18 "2024-06-27T17:51:49Z")

</div>

Tip: You can unpack the full kernel source at the correct location for headers if you don’t have a “headers specific” package. For example, if you go here:  
`cd /lib/modules/$(uname -r)`

And then check:  
`ls -ld build`

You might find the location is:  
`/usr/src/linux-headers-$(uname -r)/`

You could unpack the kernel source you used at that latter location. This contains more source than needed, but it also includes the headers. Sometimes you’d need to configure it, but most of the time not.

(the `uname -r` is from the Jetson, not the host PC)

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/system/32/68080_2.png) [@system](https://forums.developer.nvidia.com/u/system)\
**Post date:** [July 11, 2024, 5:52pm UTC](https://forums.developer.nvidia.com/t/after-modifying-the-kernel-config-and-using-the-new-kernel-image-i-can-not-use-kernel-modules-which-is-compiled-on-the-machine/297682/19 "2024-07-11T17:52:09Z")

</div>

Closed on July 11, 2024, 5:52pm UTC

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