errror executing modules prepare

root@jetbot:/usr/src/linux-headers-4.9.140-tegra-ubuntu18.04_aarch64/kernel-4.9# modules prepare
bash: modules: command not found
root@jetbot:/usr/src/linux-headers-4.9.140-tegra-ubuntu18.04_aarch64/kernel-4.9# make modules prepare
scripts/kconfig/conf  --silentoldconfig Kconfig
drivers/net/ethernet/nvidia/Kconfig:30: can't open file "drivers/net/ethernet/nvidia/eqos/Kconfig"
scripts/kconfig/Makefile:37: recipe for target 'silentoldconfig' failed
make[2]: *** [silentoldconfig] Error 1
Makefile:565: recipe for target 'silentoldconfig' failed
make[1]: *** [silentoldconfig] Error 2
make: *** No rule to make target 'include/config/auto.conf', needed by 'include/config/kernel.release'.  Stop.
root@jetbot:/usr/src/linux-headers-4.9.140-tegra-ubuntu18.04_aarch64/kernel-4.9#

Previously the approach worked and I installed v4l2loopback module with it, as far as I remember.

Reference found: https://devtalk.nvidia.com/default/topic/1049606/jetson-nano/compiling-kernel-from-git-failure-s-/

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.

It turned out:
I)

make modules_prepare

is not required anymore to build the v4l2loopback kernel module

II)
neither at last releases the command work on nano nor on xaviers anymore, though, it is not the issue because of I)

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ā€)

From there try the modules_prepare.

You may try this topic for building v4l2loopback.

Thank you for responses!

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:

sources
ā”œā”€ā”€ hardware
ā”‚Ā Ā  ā””ā”€ā”€ nvidia
ā”œā”€ā”€ kernel
ā”‚Ā Ā  ā”œā”€ā”€ kernel-4.9
ā”‚Ā Ā  ā”œā”€ā”€ nvgpu
ā”‚Ā Ā  ā””ā”€ā”€ nvidia
ā””ā”€ā”€ u-boot

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.

2 Likes

Thank you very much, it was super helpful!

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.

1 Like