Issue building kernel module and getting Linux headers

I have some new questions:

One of our customer is trying to build a wifi driver kernel module (GitHub - aircrack-ng/rtl8812au: RTL8812AU/21AU and RTL8814AU driver with monitor mode and frame injection) which our team uses on other platforms. In order to build this with dkms they need the kernel build/source directory for the linux headers.

There are two locations for this source code on the machine (linux kernel 4.9.140)

Internally links build/source to /usr/src/linux-headers-4.9.140-tegra-ubuntu18.04_aarch64/kernel-4.9/ which doesn’t contain a configuration from make in include/config

Internally links build/source to /home/donmichael/nx/source/Linux_for_Tegra/source/public/kernel/kernel-4.9 which doesn’t exist
The linux kernel headers cannot be installed for the correct kernel version (apt install linux-headers-4.9.140) since this doesn’t exist in the default apt repos for this machine. unfortunately we missed to add export LOCALVERSION=-tegra variable while building BSP from source.

In both cases of telling dkms where the linux headers are something breaks related to missing files or an incorrectly configured source directory.
Is there a way to access the kernel build/source for this custom l4t kernel to obtain the configured linux headers? Is there some other way you would guide me to run dkms to get this critical kernel module?

We use L4T 32.4.3 to build custom BSP.

Is there a way to get the linux headers in a state where I can build with dkms without reflashing the board? want to build this kernel module: GitHub - aircrack-ng/rtl8812au: RTL8812AU/21AU and RTL8814AU driver with monitor mode and frame injection ?

Also I get below 3 kernels:

$ cat /etc/nv_tegra_release

R32 (release), REVISION: 4.3, GCID: 21589087, BOARD: t186ref, EABI: aarch64, DATE: Fri Jun 26 04:34:27 UTC 2020

which is linux kernel 4.9.140. I downloaded the corresponding BSP from NVidia. I tried some hacks like copying the include/config to the root filesystem but this didn’t work. It looks like there are three kernels:

$ ls -l /lib/modules
drwxr-xr-x 2 root root 4096 Sep 14 16:38 4.15.0-156-generic/ (from apt)
drwxr-xr-x 4 root root 4096 Sep 22 14:10 4.9.140/ (refers to a build which doesn’t exist: /home/buildmachine/nx/source/Linux_for_Tegra/source/public/kernel/kernel-4.9)
drwxr-xr-x 3 root root 4096 Jul 8 2020 4.9.140-tegra/ (appears to be valid but not configured) this path is the path of our build machine.

I tried some more hacks including symlinking the build/source in 4.9.140 to 4.9.140-tegra but that didn’t work either.

You might find this thread useful: