Xavier kernel building problem

Hello,
I want to rebuild the module iwlwifi on my Xavier for wifi support. uname -r returned 4.9.140-tegra. I downloaded the source code for linux-4.9.140. I ran the commands below as root:

cd kernelbuild/linux-4.9.140 #directory of the source code
make clean
make proper
cp /lib/modules/4.9.140-tegra/build/Module.symvers ./
zcat /proc/config.gz > .config
vim .config #CONFIG_LOCALVERSION="-tegra"
vim Makefile #EXTRAVERSION = -tegra
make oldconfig
make -j8 modules_prepare
make -j8 modules
cp drivers/net/wireless/intel/iwlwifi/iwlwifi.ko /lib/modules/4.9.140-tegra/kernel/drivers/net/wireless/intel/iwlwifi/iwlwifi.ko
reboot

After rebooting the board, module iwlwifi can’t be loaded correctly, and “dmesg | grep iwl” shows:

iwlwifi: no symbol version for module_layout
iwlwifi: Unknown symbol dma_alloc_from_coherent (err 0)
iwlwifi: Unknown symbol dma_release_from_coherent (err 0)
iwlwifi: Unknown symbol debugfs_create_file (err 0)

I am new to linux, and don’t know how to deal with the problem. Can anyone help me? Thanks a lot.

YuzhiYang,

Could you refer to L4T document -> Kernel customization and check the steps to build kernel modules?

Hi YuzhuYang,
Additionally you may use for reference steps from the example below that shows how to build v4l2loopback.

sudo su
cd /usr/src/linux-headers-4.9.140-tegra-ubuntu18.04_aarch64/kernel-4.9
make modules_prepare
mkdir v4l2loopback
git clone https://github.com/umlaeute/v4l2loopback.git v4l2loopback
cd v4l2loopback
make
make install
apt-get install -y v4l2loopback-dkms v4l2loopback-utils
modprobe v4l2loopback devices=1 video_nr=2 exclusive_caps=1
echo options v4l2loopback devices=1 video_nr=2 exclusive_caps=1 > /etc/modprobe.d/v4l2loopback.conf
echo v4l2loopback > /etc/modules
update-initramfs -u