Note: This article has been superseded. Please see: Build Kernel and Modules – NVIDIA Jetson TX1.
In this article, we cover building the kernel and modules for the NVIDIA Jetson TX1 Development Kit onboard the Jetson itself. We also build the ACM module, which allows the Jetson to communicate with devices that report through ttyACM. Looky here:
Background
Note: This article is for intermediate users. You should be familiar with the purpose of the kernel. You should be able to read shell scripts to understand the steps described.
Note: The kernel source must match the version of L4T that has been flashed onto the Jetson. For example, here we use the kernel source for L4T 28.1 with L4T 28.1. Kernel versions are not compatible across releases.
With the advent of the production version of L4T 28.1 for the NVIDIA Jetson TX1, NVIDIA recommends using a host PC when building a system from source. See the Linux for Tegra R28.1 web page where you can get the required GCC 4.8.5 Tool Chain for 64-bit BSP.
If you are building systems which require a large amount of kernel development, that is a good option. For a person like me, it’s a little overkill. Most of the time I just want to compile an extra driver or three as modules to support some extra hardware with the TX1.
For example, one of the modules that I need is used to support USB ACM devices. Some USB devices report as USB, others report as ACM. Here’s an article explaining the good bits about what that means. Many devices, such as a Hokoyo LIDAR and some Arduinos, report as ACM devices.
Presented here are some scripts which download the kernel source on to the Jetson TX1 itself, modifies the Makefiles so that it will compile onboard the Jetson, and then copies the kernel Image into the boot directory. The video above shows how to select the ACM module and add it to the Image. The options are:
USB Modem (CDC ACM) support
CONFIG_USB_ACM
Installation
Note: A major issue with building the kernel and modules onboard the Jetson TX1 is the amount of space on the eMMC. If you are building the kernel on the eMMC, listen closely. If you flashed the with JetPack 3.1 and installed all of the options, then you probably have ~ 3.9GB free. This is just barely enough to build the system. Moreover, if you attempt to reboot the system after installation, and there is not enough free space left on the eMMC, the system will not boot.
There are several options, such as clearing off space before you start building the kernel. Another option is to build the kernel and then offload the kernel sources and the compressed versions to another device, and then remove them from the eMMC. You have been warned.
The script files to build the kernel on the Jetson TX1 are available on the JetsonHacks Github account in the buildJetsonTX1 repository.
$ git clone https://github.com/jetsonhacks/buildJetsonTX1Kernel.git
$ cd buildJetsonTX1Kernel
There are three main scripts. The first script, getKernelSources.sh gets the kernel sources from the NVIDIA developer website, then unpacks the sources into /usr/src/kernel.
$ ./getKernelSources.sh
After the sources are installed, the script opens an editor on the kernel configuration file. In the video, the local version of the kernel is set. The stock kernel uses -tegra as its local version identifier. Make sure to save the configuration file when done editing. Note that if you want to just compile a module or two for use with a stock kernel, you should set the local version identifier to match.
The second script, makeKernel.sh, fixes up the makefiles so that the source can be compiled on the Jetson, and then builds the kernel and modules specified.
$ ./makeKernel.sh
The modules are then installed in /lib/modules/
The third script, copyImage.sh, copies over the newly built Image and zImage files into the /boot directory.
$ ./copyImage.sh
Once the images have been copied over to the /boot directory, the machine must be restarted for the new kernel to take effect.
Note: The copyImage.sh script copies the Image file to the /boot directory of the current device. If you are using an external device such as a SSD as your root directory and still using the eMMC to boot from, you will need to copy the Image file to the /boot directory of the eMMC, and modify /boot/extlinux/extlinux.conf accordingly.
Spaces!
The kernel and module sources, along with the compressed versions of the source, are located in /usr/src
After building the kernel, you may want to save the sources off-board to save some space (they take up about 3GB) You can also save the boot images and modules for later use, and to flash other Jetsons from the PC host. The kernel sources are in the directory named kernel. The file source_release.tbz2 is the compressed version of the kernel and some other system packages. Then you can remove the directory and file. Remember to use ‘sudo’ as this is part of the system area.
Conclusion
For a lot of use cases, it makes sense to be able to compile the kernel and add modules from the device itself.
Note
The video above was made directly after flashing the Jetson TX1 with L4T 28.1 using JetPack 3.1.
4 Responses
FWIW, I am able to stick much more recent kernels on DebianTX1 IAW the HOWTO at https://wiki.debian.org/InstallingDebianOn/NVIDIA/Jetson-TX1 … I have kernel4.12.0-1-arm64 just from that default buster install but it looks like I can get linux-next on there as well… I wonder what is different?
Sorry, this is the correct one to replace the previous one.
Hi, I have a problem when I do the $ ./copyImage.sh ,it comes with error and said “cannot stat ‘arch/arm64/boot/Image’: No such file or directory”. I have no clue that how I can fix it. Could u give me some suggestions?
“cannot stat” means that it could not find the image file. Which means that the image file did not build correctly in the makeKernel process. Which means that there were error messages printed out during the image file building process. The error messages indicate the issue you encountered when building the image file.
You should check to make sure that the version of L4T that you are building, for example L4T 28.1, matches the version in the GitHub repository that you are building. The current version is L4T 28.1 in the repository. For example if you are building L4T 24.2.1, you must checkout the appropriate tagged version.
Hi.
I am happy to find your nice video!
I want to follow this guide but I do not have enough storage in jetson tx1.( only 800MB )
So, are there any way to avoid this storage problem?
Can I build kernel in the usb memory and extract necessary part from usb?
Thank you.