Or you can use source_sync.sh in L4T that will clone the public Nvidia repositories for you. Unfortunately that script is currently broken but you can fix it:
It is a “make” target. “make modules_prepare”. You’d need to know that your config is valid prior to this. I always start with putting the decompressed version of “/proc/config.gz” in the kernel top level directory and editing CONFIG_LOCALVERSION. Other than that it becomes fairly standard for a kernel build (add whatever cross compile arguments you need if not doing native compile).
but how to build the kernel at the target device natively after I downloaded and unpacked the sources to ‘kernel/kernel-4.9/’.
Could you extend on that?
As I understand, first it needs to copy and unpack /proc/config.gz to ‘the kernel top level folder’.
But what edition of CONFIG_LOCALVERSION may be required?
Thanks.
I installed “gcc-6” since the 6.4 version was specified in docs:
sudo apt-get install gcc-6
EDIT: I forgot to mention, before building the kernel, I run this:
export CC=/usr/bin/gcc-6
…which causes the 6.4 version of gcc to be used.
I didn’t do just the modules_prepare, but after having my source it goes something like this (you will have to create and set permissions for user ubuntu or nvidia since I don’t compile as root):
sudo nvpmodel -m 0
# Unpack in "/usr/local/src/kernel_tree/", owned and writeable by user "ubuntu".
export SRC=/usr/local/src/kernel_tree/kernel/kernel-4.9
export STAGE=/usr/local/src/build
export TEGRA_KERNEL_OUT=${STAGE}/kernel
export TEGRA_MODULES_OUT=${STAGE}/modules
rm -Rf ${STAGE:-/usr/local/src/build}/*
mkdir ${STAGE:-/usr/local/src/build}/kernel
mkdir ${STAGE:-/usr/local/src/build}/modules
mkdir ${STAGE:-/usr/local/src/build}/firmware
cp /proc/config.gz ${STAGE:-/usr/local/src/build}/
gunzip ${STAGE:-/usr/local/src/build}/config.gz
mv ${STAGE:-/usr/local/src/build}/config ${STAGE:-/usr/local/src/build}/config-$(uname -r)
# Edit CONFIG_LOCALVERSION for the "uname -r" suffix.
cd $SRC
make O=$TEGRA_KERNEL_OUT nconfig
make -j8 O=$TEGRA_KERNEL_OUT Image
make -j8 O=$TEGRA_KERNEL_OUT modules
make O=$TEGRA_KERNEL_OUT modules_install INSTALL_MOD_PATH=$TEGRA_MODULES_OUT
make O=$TEGRA_KERNEL_OUT firmware_install INSTALL_FW_PATH=$TEGRA_FIRMWARE_OUT
In theory (I didn’t test) you could run “make O=$TEGRA_KERNEL_OUT modules_prepare” instead of “Image”.
@linuxdev, thank you for sharing.
I am looking to get v4l2loopback module to function somehow.
At TX2 I could get that with module_prepare, or with a provided by other folk .ko file.
I added one “EDIT” to that post…I had forgot to mention that installing gcc-6 doesn’t cause it to be used. It also has to be exported as “CC=/usr/bin/gcc-6”.
In any case, try building the whole kernel just as a debug step if modules_prepare won’t do the trick.
make
Building v4l2-loopback driver...
make -C /lib/modules/`uname -r`/build M=/home/nvidia/Downloads/public_sources/kernel/kernel-4.9/v4l2loopback/v4l2loopback modules
make[1]: *** /lib/modules/4.9.108/build: No such file or directory. Stop.
Makefile:42: recipe for target 'v4l2loopback.ko' failed
make: *** [v4l2loopback.ko] Error 2
sudo apt-get install v4l2loopback-utils
[sudo] password for nvidia:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
liblockfile-bin liblockfile1 lockfile-progs
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
dkms libv4l2rds0 linux-headers-4.15.0-36 linux-headers-4.15.0-36-generic
linux-headers-generic v4l-utils v4l2loopback-dkms
Suggested packages:
menu
The following NEW packages will be installed:
dkms libv4l2rds0 linux-headers-4.15.0-36 linux-headers-4.15.0-36-generic
linux-headers-generic v4l-utils v4l2loopback-dkms v4l2loopback-utils
0 upgraded, 8 newly installed, 0 to remove and 199 not upgraded.
Need to get 12.2 MB of archives.
After this operation, 87.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 dkms all 2.3-3ubuntu9.2 [68.0 kB]
Get:2 http://ports.ubuntu.com/ubuntu-ports bionic/main arm64 libv4l2rds0 arm64 1.14.2-1 [14.8 kB]
Get:3 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 linux-headers-4.15.0-36 all 4.15.0-36.39 [11.0 MB]
Get:4 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 linux-headers-4.15.0-36-generic arm64 4.15.0-36.39 [744 kB]
Get:5 http://ports.ubuntu.com/ubuntu-ports bionic-updates/main arm64 linux-headers-generic arm64 4.15.0.36.38 [2,376 B]
Get:6 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 v4l-utils arm64 1.14.2-1 [384 kB]
Get:7 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 v4l2loopback-dkms all 0.10.0-1ubuntu1 [23.1 kB]
Get:8 http://ports.ubuntu.com/ubuntu-ports bionic/universe arm64 v4l2loopback-utils arm64 0.10.0-1ubuntu1 [8,544 B]
Fetched 12.2 MB in 8s (1,537 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package dkms.
(Reading database ... 113142 files and directories currently installed.)
Preparing to unpack .../0-dkms_2.3-3ubuntu9.2_all.deb ...
Unpacking dkms (2.3-3ubuntu9.2) ...
Selecting previously unselected package libv4l2rds0:arm64.
Preparing to unpack .../1-libv4l2rds0_1.14.2-1_arm64.deb ...
Unpacking libv4l2rds0:arm64 (1.14.2-1) ...
Selecting previously unselected package linux-headers-4.15.0-36.
Preparing to unpack .../2-linux-headers-4.15.0-36_4.15.0-36.39_all.deb ...
Unpacking linux-headers-4.15.0-36 (4.15.0-36.39) ...
Selecting previously unselected package linux-headers-4.15.0-36-generic.
Preparing to unpack .../3-linux-headers-4.15.0-36-generic_4.15.0-36.39_arm64.deb ...
Unpacking linux-headers-4.15.0-36-generic (4.15.0-36.39) ...
Selecting previously unselected package linux-headers-generic.
Preparing to unpack .../4-linux-headers-generic_4.15.0.36.38_arm64.deb ...
Unpacking linux-headers-generic (4.15.0.36.38) ...
Selecting previously unselected package v4l-utils.
Preparing to unpack .../5-v4l-utils_1.14.2-1_arm64.deb ...
Unpacking v4l-utils (1.14.2-1) ...
Selecting previously unselected package v4l2loopback-dkms.
Preparing to unpack .../6-v4l2loopback-dkms_0.10.0-1ubuntu1_all.deb ...
Unpacking v4l2loopback-dkms (0.10.0-1ubuntu1) ...
Selecting previously unselected package v4l2loopback-utils:arm64.
Preparing to unpack .../7-v4l2loopback-utils_0.10.0-1ubuntu1_arm64.deb ...
Unpacking v4l2loopback-utils:arm64 (0.10.0-1ubuntu1) ...
Setting up libv4l2rds0:arm64 (1.14.2-1) ...
Setting up v4l-utils (1.14.2-1) ...
Setting up dkms (2.3-3ubuntu9.2) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for man-db (2.8.3-2) ...
Setting up v4l2loopback-utils:arm64 (0.10.0-1ubuntu1) ...
Setting up linux-headers-4.15.0-36 (4.15.0-36.39) ...
Setting up linux-headers-4.15.0-36-generic (4.15.0-36.39) ...
Setting up v4l2loopback-dkms (0.10.0-1ubuntu1) ...
Loading new v4l2loopback-0.10.0 DKMS files...
It is likely that 4.9.108 belongs to a chroot's host
Building for 4.15.0-36-generic and 4.9.108-tegra
Building initial module for 4.15.0-36-generic
Done.
v4l2loopback:
Running module version sanity check.
- Original module
- No original module exists within this kernel
- Installation
- Installing to /lib/modules/4.15.0-36-generic/updates/dkms/
depmod...
DKMS: install completed.
Building initial module for 4.9.108-tegra
ERROR (dkms apport): kernel package linux-headers-4.9.108-tegra is not supported
Error! Bad return status for module build on kernel: 4.9.108-tegra (aarch64)
Consult /var/lib/dkms/v4l2loopback/0.10.0/build/make.log for more information.
Setting up linux-headers-generic (4.15.0.36.38)