Jetson AGX Xavier - Kernel modules compiling issue

I am trying to toggle the gpio pin 22. I wrote a kernel driver for this and I wrote a makefile.While I try to build, I am facing the following error.
make ARCH=arm64 -C /lib/modules/5.10.104-tegra/build M=/home/mcw/xavier modules
make[1]: Entering directory ‘/usr/src/linux-headers-5.10.104-tegra-ubuntu20.04_aarch64/kernel-5.10’

ERROR: Kernel configuration is invalid.
include/generated/autoconf.h or include/config/auto.conf are missing.
Run ‘make oldconfig && make prepare’ on kernel src to fix it.

make[1]: *** [Makefile:750: include/config/auto.conf] Error 1
make[1]: Leaving directory ‘/usr/src/linux-headers-5.10.104-tegra-ubuntu20.04_aarch64/kernel-5.10’
make: *** [Makefile:8: default] Error 2

gpio_toggle_xavier.txt (1.3 KB)
Makefile.txt (254 Bytes)

When I try to install headers, I get the following error
E: Unable to locate package linux-headers-5.10.104-tegra
E: Couldn’t find any package by glob ‘linux-headers-5.10.104-tegra’
E: Couldn’t find any package by regex ‘linux-headers-5.10.104-tegra’

Please guide on this

Hi @swedhar10

I think you are not pointing the right Linux kernel directory to allow you proceed with the build successfully.

Is you project/repo accessible to public ? if so, share the link, I can take a look.


Hi ilies,
Thanks for the immediate reply.

This is the path I am mentioning for the kernel directory, I think It might be correct.
uname -r → 5.10.104-tegra
Is my makefile is correct? Or what I need to do?
And sorry its not accessible to public.
If you need any further information on my process, please let me know I will tell.


Do you have a .config file to build kernel module?
The error message shows ‘make oldconfig && make prepare’ to fix this.

Hi Hiker,
/usr/src/linux-headers-5.10.104-tegra-ubuntu20.04_aarch64/kernel-5.10# ls
arch .config drivers include Kbuild kernel-int-overlays.txt Makefile net security usr
block .config.old fs init Kconfig kernel-overlays.txt mm samples sound virt
certs crypto .gitignore ipc kernel lib Module.symvers scripts tools

See, in the above kernel directory , it has the .config file.
And when I try to run the “make oldconfig && make prepare”
in the kernel directory it throws error like,
make oldconfig
make: *** No rule to make target ‘oldconfig’. Stop.

Did you refer this guide?

Yes, I have visited this site.
But I have a doubt on that. Is that we need to follow all the steps below the preparing to build external kernel modules title?

It isn’t in general.
As I remember, I could find everything what I need on the NVIDIA’s Online jetson documents site, kernel build, kernel module build.
I recommend you following the guides from the bottom line.

Ok Hiker, I will try it out and let you know if I face any errors.

Thanks and Regards,

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