Build Kernel and ttyACM Module – NVIDIA Jetson TX2

In this article, we cover building the kernel and modules for the NVIDIA Jetson TX2. 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.

With the advent of the production version of L4T 28.1 for the NVIDIA Jetson TX2, 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 TX2.

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 TX2 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

The script files to build the kernel on the Jetson TX2 are available on the JetsonHacks Github account in the buildJetsonTX2 repository.

$ git clone https://github.com/jetsonhacks/buildJetsonTX2Kernel.git
$ cd buildJetsonTX2Kernel

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.

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.

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 TX2 with L4T 28.1 using JetPack 3.1.

14 Comments

  1. Thanks for your fast respond to the latest jetpack release.
    I’ve successfully include the CP2102 (Cygnal Integrated Products, Inc. CP210x UART Bridge) driver into kernel and recognized the rplidar as ttyUSB0 device after install the kernel.

  2. I’m having trouble, I get error: ‘ENODEV” undeclared during the
    make -j6 Image command of the makeKernel.sh script.
    Any ideas?

      • Uh, I’m not sure. uname -r gives
        4.4.15-tegra and I just bought the it new about a month ago, so I’m assuming it ships latest and greatest…?
        It is a TX2 running Ubuntu 16.04 with the GUI. How do I check the version of L4T?

        • You are running an earlier version of L4T. These scripts are for L4T 28.1, which is installed when the system is flashed with JetPack 3.1. There is a tagged version in the Github repository for L4T 27.1.
          Note that the firmware that is shipped from the factory is usually just a placeholder when the devices are put into production. NVIDIA recommends flashing the device with the latest version of JetPack to upgrade to the latest and greatest. Thanks for reading!

  3. Hi ,
    I’m working with TX1 and also need to enable ttyACM .
    My TX1 also run with Jetpack 3.1 .
    As I know , the “L4T 28.1” could be use for TX1 & TX2 .
    If I modify the “scripts/getKernelSources.sh” to”sources/kernel_src-tx1.tbz2″
    for Tar Extract , could I Still use your build scripts to re-build Kernel ?

    Thanks

    • It’s pretty close. I’m working on an article now about the process. One of the patches isn’t used on the TX1 (I recall it’s the sound one). The rather sticky part is that there’s no free space left on the device after building the kernel, so after you copy the Image, you will need to make more space. There’s several ways to do that, the easiest is to copy the compressed sources and/or the kernel sources to external media and delete them from the /usr/src directory. Hope this helps.

      • Thanks a lot .

        The free space of TX1 is not problem for me , because I used the 64G SD Card for root directory.

        After modify the ”sources/kernel_src-tx1.tbz2″ for Tar Extract , I could be use your build scripts to re-build kernel successful .

        Because I just need the “cdc-acm.ko” , the local version I still used “-tegra” for make xconfig.

        After append the module name “cdc-acm” to /etc/modules-load.d/modules.conf , It seems work normally with my TX1 now.

Leave a Reply

Your email address will not be published.


*