I don’t see the underscore ‘_’ between “modules” and “prepare”. If this is copy and paste then I’m thinking it is missing in the actual command. Should be “modules_prepare” instead of “modules prepare”.
However, there are other possible errors even if the “modules_prepare” is correct. Typically what I’ve done is to copy the “source_sync.sh” from the host PC to the Jetson at “/usr/src”, run something like this to get full source:
./source_sync.sh -k tegra-l4t-r32.1
Now you will have “/usr/src/sources/kernel/kernel-4.9”. Copy the “/proc/config.gz” there, gunzip it, rename as “.config”, set CONFIG_LOCALVERSION=“-tegra” (or whatever your current “uname -r” suffix is), and then update the symbolic link in “/lib/modules/$(uname -r)/”:
cd /lib/modules/$(uname -r)
rm build
ln -s /usr/src/sources/kernel/kernel-4.9 build
cd /usr/src/sources/kernel/kernel-4.9 build
sudo make modules_prepare
At this point you will have a guaranteed full source with any relative paths going outside of the tree also being there. If you want to switch back to the default headers just point the sym link back to the original headers directory.
Sorry to raise this topic again, but I was facing the same issue during building v4l2loopback dkms package, and it didn’t worked without make modules_prepare. Maybe I’m doing something wrong?..
First, if I just tried to build the module, I got the following in logs:
make[1]: Entering directory '/usr/src/linux-headers-4.9.140'
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.
So, I tried to do “make modules_prepare”, and found same errors (can’t open file “drivers/net/ethernet/nvidia/eqos/Kconfig”) etc.
The fastest way to “solve” this was to just comment out missing files in Kconfig.
After that dkms autoinstall executed correctly, but still I think it’s a workaround, not a solution, because I need to modify kernel sources by myself.
Wherever your config is being searched for I recommend you copy the “/proc/config.gz” there, gunzip it, rename it as “.config”, and then edit the CONFIG_LOCALVERSION to:
CONFIG_LOCALVERSION="-tegra"
(the string would change if your “uname -r” had a suffix other than “-tegra”)
I remember trying CONFIG_LOCALVERSION=“-tegra” in .config file under linux headers directory, but it produced no effect. I guess, this setting is needed only to find folder with kernel sources?
Also I checked 1058526 and 1044016 topics, but those are apparently about different issues, because my error is
can't open file "drivers/net/ethernet/nvidia/eqos/Kconfig"
I’m building v4l2loopback-dkms v0.12.3-1, but the same happens for the default one (0.10).
Conclusion
The root of the problem is kernel sources. It doesn’t matter what module I try to build.
Currently I’m building with kernel got from nvidia downloads for r32.2.
Before, if I remember correctly, I tried source_sync.sh, but with the same result.
This issue won’t reproduce, if you already have prepared kernel. So it needs cleaning before:
cd <kernel source root>
make mrproper
cat /proc/config.gz | gunzip > .config
This is the issue, and requires a bit of explanation:
can't open file "drivers/net/ethernet/nvidia/eqos/Kconfig"
Normally, if you get your kernel source code from some of the more common places, you get only the kernel source. However, there are certain config items which can refer to out of tree content relative to the regular kernel sources. The directory “drivers/net/ethernet/nvidia/eqos/Kconfig” can only be accessed through a relative path to source code outside of the regular kernel source.
If you were to download the kernel source via “source_sync.sh” (in the “Linux_for_Tegra/” directory), then you would get this excerpt of subdirectory structure:
The “sources/kernel/kernel-4.9/” is the base kernel source. The path you need is in “sources/kernel/nvidia/”, and that directory is missing for your case. Earlier there is a suggestion of how to download via source_sync.sh, and this will download the out of tree content. The tag to use depends on release, but the example from earlier is this:
./source_sync.sh -k tegra-l4t-r32.1
I think for R32.3.1 it would be:
./source_sync.sh -k tegra-l4t-r32.3-1
When you have the full source it will probably work. If you cut out features referring to the out of tree content, then it would also work, but then you wouldn’t have the features anymore.
Indeed the error was due to missing nvidia folder. I thought it’s unnecessary, but apparently I was wrong.
There’s a line in Makefile, which probably explains why:
KERNEL_OVERLAYS += $(CURDIR)/../nvidia
So, the correct steps are:
./source_sync.sh -k tegra-l4t-r32.3-1 # should be replaced by installed version
sudo ln -sfn $(pwd)/sources/kernel/kernel-4.9/ /lib/modules/4.9.140/build
cd sources/kernel/kernel-4.9/
cat /proc/config.gz | gunzip > .config
make modules_prepare
sudo apt install --reinstall v4l2loopback-dkms # or any other module
Version can be found with
head -n 1 /etc/nv_tegra_release
source_sync.sh can be found somewhere in the download folder of sdkmanager. Not sure if there’s a better way to acquire it…
“source_sync.sh” is part of the “driver package”, and the driver package can be downloaded separately. SDKM is just a convenience front end and the actual flash is through that package after SDKM performance the download and unpack.