kernel headers are outdated in jetson tx2

on my custom built kernel , im not able to load my driver

insmod mydriver.ko
error : coud not load : invalid exe format

that means the kernel headers (source code) is old one & present booted kernel is different.

i followed this link for building kernel

one thing i observed is :- in kernel build steps, we are copying same kernel header to newly built image which is wrong because of which exe format error we are getting.

please tell me how to create proper kernel headers for which kernel source the image is built

If you are building on another architecture, e.g., if you are building arm64/aarch64/ARMv8-a from a desktop PC (amd64/x86_64), then you have to cross compile. Native compiling builds for the wrong architecture and won’t work on the Jetson. The documents which come with the particular L4T release (see “head -n 1 /etc/nv_tegra_release”, then log in at and click the link a second time since redirect doesn’t work) will show the cross compile steps in the kernel customization section.

If you would rather compile natively on the Jetson, then see this:

Beware though that you have to adjust for your L4T release version…the URL is probably using a different version than what you are using, e.g., you might use “./ -k tegra-l4t-r32.2.0” if you are at R32.2.0. “” is used for downloading not only the source which is within the kernel tree, but also some source related to the board support package which is “out of tree”. The “” script creates a “sources/” subdirectory, and within that the actual kernel source is the “sources/kernel/kernel-4.9/” (or kernel-4.4 in older releases) content.

NOTE: downloads the valid source regardless of whether you are on a host PC cross compiling or doing native compile from the TX2.