Xavier Kernel (Solved)

How can I recompile the Kernel on the Xavier? I’m trying to rebuild it to support my wireless wifi dongle because at the moment I have a flashed Jetson but I can’t properly connect to the internet. (I don’t have Ethernet in the room I am in, and I will need to be able to transport the jetson with me.)

I have not yet attempted to build the kernel for Xavier, but for native compile the instructions should be the same as for a TX2 (though you’d need to download source through some mechanism other than source_sync.sh). Try this as a starting point:
[url]https://devtalk.nvidia.com/default/topic/1038175/jetson-tx2/tx2i-wifi-support/post/5274619/#5274619[/url]

For fastest build you might want to run “sudo nvpmodel -m 0” first, and then “sudo ~ubuntu/tegra_clocks.sh”.

I’m compiling it on my PC and then flashing it. Go on GitHub and search Jetson Xavier and you can find a really useful script to allow you to do kernel or full flashes. I’ll take a look at the link hopefully it works, none of my USB wifi devices so far work, all show up as USB-0. Maybe I’m missing the broadcom module.

You may need to adjust, but basically the steps are the same on cross-compile…except for naming the right cross-tools and locations via environment variables and/or options. An example would go something like this on a PC host, though you will need to adjust for your case:

# Assumes that the named directories exist at some point. Complete removal and
# recreation sometimes works better than a "make mrproper". Be very careful to not "rm -Rf"
# to an environment variable name which is not set to a temp location.
# This happens to be one of my cross compilers. Name your version, not mine.
<u><b>export CROSS_COMPILE</b></u>=/usr/local/gcc-linaro-6.1-2016.07/bin/aarch64-linux-gnu-
<u><b>export ARCH=arm64</b></u>
# "kernel-4.4" is from the source_sync.sh of a TX1/TX2...adjust for where your Xavier kernel is.
export SRC=/usr/local/src/sources/kernel/kernel-4.4
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
# This must be copied from the Xavier to the PC host. Command is only for example.
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 the "config-$(uname -r)" to set CONFIG_LOCALVERSION.
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

Note the “CROSS_COMPILE” and “ARCH” lines…these are environment variables which the kernel build will understand. This is what differs on a cross-compile versus a regular compile.

I recommend making the entire kernel and all modules without change to first see if things are correct and building without error. You could add the module you are interested in during the “make nconfig” step. “nconfig” may require “sudo apt-get install libncurses5-dev”.

I’ve attempted to flash the kernel with the required drivers to have wifi working, but so far nothing works. I’m trying to use a Atheros based wifi adapter from ThinkPenguin.com (TPE-N150USB).
Penguin Wireless N USB Adapter for GNU / Linux (TPE-N150USB) | ThinkPenguin.com

But this issue persists with all the wifi dongles I attempt to use, TP-LINK and other.
Otherwise flashing the kernel is fairly easy. Someone created a great tool:

I don’t know for the particular hardware, but many WiFi adapters require extra firmware (the firmware is loaded into the hardware…the driver won’t work in those cases if the hardware doesn’t have the firmware). Someone else may know more about whether this card requires firmware.

Hello linuxdev,
Thank you for sharing guide on how to cross complile Xavier kernel on linux host, But after carefully following your instructions I’m having ARM DMA allocator error and couldn’t find out solution for the same anywhere else.

CC      arch/arm64/net/bpf_jit_comp.o
/home/amey/Documents/public_sources/kernel/kernel-4.9/arch/arm64/mm/dma-mapping.c:1526:2: error: #error ARM Coherent DMA allocator does not (yet) support huge TLB
 #error ARM Coherent DMA allocator does not (yet) support huge TLB
  ^

Can you help me in getting out of this error?

So for some reason I try to compile the Kernel using

so I can enable ath9k_htc, but when I try to build the kernel I get the following errors for cfg802.11

drivers/built-in.o: In function `cancel_ro_ch_handler':
t19x-nvlink-endpt-minion.c:(.text+0x5f56c0): undefined reference to `cfg80211_remain_on_channel_expired'
drivers/built-in.o: In function `rtw_handle_tkip_mic_err':
t19x-nvlink-endpt-minion.c:(.text+0x62381c): undefined reference to `cfg80211_michael_mic_failure'
drivers/built-in.o: In function `cfg80211_rtw_mgmt_tx':
t19x-nvlink-endpt-minion.c:(.text+0x626054): undefined reference to `ieee80211_frequency_to_channel'
t19x-nvlink-endpt-minion.c:(.text+0x626084): undefined reference to `cfg80211_mgmt_tx_status'
drivers/built-in.o: In function `cfg80211_rtw_remain_on_channel':
t19x-nvlink-endpt-minion.c:(.text+0x6265bc): undefined reference to `ieee80211_frequency_to_channel'
t19x-nvlink-endpt-minion.c:(.text+0x626a5c): undefined reference to `cfg80211_ready_on_channel'
drivers/built-in.o: In function `rtw_cfg80211_inform_bss':
t19x-nvlink-endpt-minion.c:(.text+0x62a114): undefined reference to `__ieee80211_get_channel'
t19x-nvlink-endpt-minion.c:(.text+0x62a1f8): undefined reference to `cfg80211_inform_bss_frame_data'
t19x-nvlink-endpt-minion.c:(.text+0x62a20c): undefined reference to `cfg80211_put_bss'
drivers/built-in.o: In function `rtw_cfg80211_check_bss':
t19x-nvlink-endpt-minion.c:(.text+0x62a2e0): undefined reference to `__ieee80211_get_channel'
t19x-nvlink-endpt-minion.c:(.text+0x62a318): undefined reference to `cfg80211_get_bss'
t19x-nvlink-endpt-minion.c:(.text+0x62a32c): undefined reference to `cfg80211_put_bss'
drivers/built-in.o: In function `rtw_cfg80211_ibss_indicate_connect':
t19x-nvlink-endpt-minion.c:(.text+0x62a434): undefined reference to `__ieee80211_get_channel'
t19x-nvlink-endpt-minion.c:(.text+0x62a44c): undefined reference to `cfg80211_ibss_joined'
drivers/built-in.o: In function `rtw_cfg80211_indicate_connect':
t19x-nvlink-endpt-minion.c:(.text+0x62a668): undefined reference to `__ieee80211_get_channel'
t19x-nvlink-endpt-minion.c:(.text+0x62a6b4): undefined reference to `cfg80211_roamed'
t19x-nvlink-endpt-minion.c:(.text+0x62a854): undefined reference to `cfg80211_connect_bss'
drivers/built-in.o: In function `rtw_cfg80211_indicate_disconnect':
t19x-nvlink-endpt-minion.c:(.text+0x62a948): undefined reference to `cfg80211_connect_bss'
t19x-nvlink-endpt-minion.c:(.text+0x62aa84): undefined reference to `cfg80211_disconnected'
drivers/built-in.o: In function `rtw_cfg80211_indicate_scan_done':
t19x-nvlink-endpt-minion.c:(.text+0x62ab38): undefined reference to `cfg80211_scan_done'
drivers/built-in.o: In function `rtw_cfg80211_unlink_bss':
t19x-nvlink-endpt-minion.c:(.text+0x62ac90): undefined reference to `cfg80211_get_bss'
t19x-nvlink-endpt-minion.c:(.text+0x62aca4): undefined reference to `cfg80211_unlink_bss'
t19x-nvlink-endpt-minion.c:(.text+0x62acc4): undefined reference to `cfg80211_put_bss'
drivers/built-in.o: In function `cfg80211_rtw_scan':
t19x-nvlink-endpt-minion.c:(.text+0x62b0f0): undefined reference to `cfg80211_scan_done'
drivers/built-in.o: In function `rtw_cfg80211_indicate_sta_assoc':
t19x-nvlink-endpt-minion.c:(.text+0x62b834): undefined reference to `cfg80211_new_sta'
drivers/built-in.o: In function `rtw_cfg80211_indicate_sta_disassoc':
t19x-nvlink-endpt-minion.c:(.text+0x62b8b0): undefined reference to `cfg80211_del_sta_sinfo'
drivers/built-in.o: In function `rtw_cfg80211_rx_probe_request':
t19x-nvlink-endpt-minion.c:(.text+0x62bab0): undefined reference to `cfg80211_rx_mgmt'
drivers/built-in.o: In function `rtw_cfg80211_rx_action_p2p':
t19x-nvlink-endpt-minion.c:(.text+0x62bb6c): undefined reference to `cfg80211_rx_mgmt'
drivers/built-in.o: In function `rtw_cfg80211_rx_p2p_action_public':
t19x-nvlink-endpt-minion.c:(.text+0x62bcd8): undefined reference to `cfg80211_rx_mgmt'
drivers/built-in.o: In function `rtw_cfg80211_rx_action':
t19x-nvlink-endpt-minion.c:(.text+0x62be80): undefined reference to `cfg80211_rx_mgmt'
drivers/built-in.o: In function `rtw_pd_iface_free':
t19x-nvlink-endpt-minion.c:(.text+0x62c9f4): undefined reference to `cfg80211_unregister_wdev'
t19x-nvlink-endpt-minion.c:(.text+0x62ca84): undefined reference to `cfg80211_unregister_wdev'
drivers/built-in.o: In function `rtw_wiphy_alloc':
t19x-nvlink-endpt-minion.c:(.text+0x62cfa4): undefined reference to `wiphy_new_nm'
drivers/built-in.o: In function `rtw_wiphy_free':
t19x-nvlink-endpt-minion.c:(.text+0x62d088): undefined reference to `wiphy_free'
drivers/built-in.o: In function `rtw_wiphy_register':
t19x-nvlink-endpt-minion.c:(.text+0x62d0f8): undefined reference to `wiphy_register'
drivers/built-in.o: In function `rtw_wiphy_unregister':
t19x-nvlink-endpt-minion.c:(.text+0x62d170): undefined reference to `wiphy_unregister'
drivers/built-in.o: In function `rtw_cfgvendor_send_cmd_reply':
t19x-nvlink-endpt-minion.c:(.text+0x62d700): undefined reference to `__cfg80211_alloc_reply_skb'
t19x-nvlink-endpt-minion.c:(.text+0x62d71c): undefined reference to `cfg80211_vendor_cmd_reply'
drivers/built-in.o: In function `rtw_cfg80211_vendor_event_alloc':
t19x-nvlink-endpt-minion.c:(.text+0x62d86c): undefined reference to `__cfg80211_alloc_event_skb'
drivers/built-in.o: In function `rtw_cfgvendor_send_async_event':
t19x-nvlink-endpt-minion.c:(.text+0x62d900): undefined reference to `__cfg80211_send_event_skb'
drivers/built-in.o: In function `rtw_cfgvendor_get_feature_set_matrix':
t19x-nvlink-endpt-minion.c:(.text+0x62db3c): undefined reference to `__cfg80211_alloc_reply_skb'
t19x-nvlink-endpt-minion.c:(.text+0x62dbac): undefined reference to `cfg80211_vendor_cmd_reply'
drivers/built-in.o: In function `_rtw_reg_apply_flags':
t19x-nvlink-endpt-minion.c:(.text+0x62de38): undefined reference to `__ieee80211_get_channel'
drivers/built-in.o: In function `_rtw_regd_init_wiphy':
t19x-nvlink-endpt-minion.c:(.text+0x62e064): undefined reference to `wiphy_apply_custom_regulatory'
/home/raf/Downloads/sources/kernel/kernel/kernel-4.9/Makefile:1006: recipe for target 'vmlinux' failed
make[1]: *** [vmlinux] Error 1
make[1]: Leaving directory '/home/raf/Downloads/out/KERNEL'
Makefile:170: recipe for target 'sub-make' failed
make: *** [sub-make] Error 2
make: Leaving directory '/home/raf/Downloads/sources/kernel/kernel/kernel-4.9'
Done

SOLVED
When building the Kernel, although its the lazy way, if you set your kernel configs in the kmenu to y and not m it will work, that being said you need to set the cfg80211 to Y instead of M and for the device drivers/Wireless Lan, you have to set your required USB driver to Y instead of M as well. I attempted to compile a module with it but it never seemed to work.

So if you use a dongle and instead of the device automatically being setup on the Jetson X, if it is set as USB0 then you need to recompile the kernel with the required drivers and make sure cfg80211 is enabled.

Thanks to user Jtagxhub for making this repo to easily do flashing for the Jetson Xavier on Jetpack 4.1

I will try to start setting up my bug fix scripts at my repo here: GitHub - Rafcin/XavierToolkit: Scripts to help setup the Jetson Xavier faster and solve any existing bugs that don't get patched by Nvidia.