Skip to content

Build the Linux Kernel and Modules on board the NVIDIA Jetson Nano Developer Kit

License

Notifications You must be signed in to change notification settings

stanciuadrian/buildKernelAndModules

 
 

Repository files navigation

buildKernelAndModules

Tools to build the Linux kernel and modules on board Jetson Developer Kits

This tool is meant for intermediate+ users. Please read this entire document before proceeding.

Supports L4T Releases 32.4.2 through 32.6.1

This repository contains convenience scripts to:

  • Download Kernel and Module sources (Board Support Package - BSP)
  • Edit the kernel configuration
  • Build the kernel image
  • Build all of the kernel modules
  • Copy the Kernel Image to the /boot directory - This may not supported for newer versions of L4T - see below copyImage.sh deprecation (mostly)
  • An example to build a single kernel module (most useful)

Scripts

getKernelSources.sh

Downloads the kernel sources for L4T from the NVIDIA website and decompresses them into /usr/src/ . Note that this also sets the .config file to that of the current system, and sets the LOCALVERSION to the current local version, i.e., -tegra

makeKernel.sh

Please read the notes below about installing the kernel using copyImage.sh. Compiles the kernel using make. The script commands builds the kernel Image file. Installing the Image file on to the system is a separate step.

This and other parts of the kernel build, such as building the device tree, may require that the result be 'signed' and flashed from the the NVIDIA tools on a host PC.

makeModules.sh

Compiles all of the the modules on the system using make and then installs them. You more than likely not want to do this. Instead, look at the script build-module.sh in the example directory for an outline on how to build a single module.

copyImage.sh

Please read the notes below under Background Notes about installing the kernel image. This script copies the Image file created by compiling the kernel to the /boot directory. Note that while developing you will want to be more conservative than this: You will probably want to copy the new kernel Image to a different name in the boot directory, and modify /boot/extlinux/extlinux.conf to have entry points at the old image, or the new image. This way, if things go sideways you can still boot the machine using the serial console.

You will want to make a copy of the original Image before the copy, something like:

$ cp /boot/Image $INSTALL_DIR/Image.orig
$ ./copyImage.sh
$ echo "New Image created and placed in /boot"

You may need to modify the /boot/extlinux/extlinux.conf to reflect the changes.

editConfig.sh

Edit the .config file located in /usr/src/kernel/kernel-4.9 This file must be present (from the getKernelSources.sh script) before launching the file. Note that if you change the local version, you will need to make both the kernel and modules and install them.

removeAllKernelSources.sh

Removes all of the kernel sources and compressed source files. You may want to make a backup of the files before deletion.

Example - build-module.sh

The most likely use for these scripts is to build kernel module(s). In the example folder, there is a script named build-module.sh You should open the script, read through it, and modify to meet your needs. The script builds a module for the Logitech F710 game controller. The module name is hid-logitech.ko

You will need to know the module flag to use this method, in this case it is: LOGITECH_FF

Background Notes

Over the years, we have been maintaining several different repositories here and on https://github.com/jetsonhacks to build the Linux kernel and modules for the various NVIDIA Jetson models:

  • Jetson Nano
  • Jetson Nano 2GB
  • Jetson TX1
  • Jetson TX2
  • Jetson AGX Xavier
  • Jetson Xavier NX

The main difficulty of this approach is that there are several different repositories to maintain across NVIDIA L4T releases.

There are two different versions of BSP source code for each NVIDIA L4T release. One version is for the Jetson Nano, Nano 2GB and TX1 named T210. The other version is for the Jetson TX2, AGX Xavier, and Xavier NX named T186. The only difference in building the kernel from machine to machine is where to download the BSP sources from for a given release. The idea of this repository is to place these URLs into an associative array to lookup given the L4T release version.

The other procedures have remained the same over the years, except for placing items in the /boot directory. The placement of the Linux kernel image, device tree and extlinux.conf may be different based on the Jetson model and L4T release.

copyImage.sh deprecation (mostly)

There has been an architectural shift on different Jetson models to provide better security. These changes are implemented differently on each model, depending on hardware capabilities and bootloaders of the Jetson module in question. Several system files, such as but not limited to the Linux kernel and device tree, may now be signed.

For example, on the Jetson Xaviers the kernel is PKC Signed and has SBK encryption in the newer releases. Currently, the NVIDIA approved application to sign these files is an x86 app running on the host machine.

Additionally, there are Jetsons which place the /boot folder into the onboard QSPI-NOR flash memory to be read at boot time, rather than reading it from the APP partition. Consequently the developer needs to know where/how to place a newly created kernel and support code.

The copyImage.sh script may be helpful depending on the Jetson model and L4T release it is being used with. However, on some releases or Jetson models it may not work, or give a false sense of hope of actually doing something.

So what good are these scripts?

One thing that the scripts are useful for is building external kernel modules. People can build the modules on the device without having to go through the steps of setting up a development environment on the host, building the module, and transferring it to the Jetson. Instead, build the module on the Jetson and then install it.

Release Notes

September, 2021

  • v1.0
  • Initial Release - Build 32.4.2 through 32.6.1
  • Unification of build methods across Jetson platform
    • Jetson Nano, Nano 2GB, TX1, TX2, AGX Xavier, Xavier NX
  • Associative lookup of BSP source code via L4T Release name
  • L4T Releases 32.4.2 through 32.6.1
  • Tested on Jetson Nano, Jetson Xavier NX

December, 2019

  • vL4T32.3.1
  • L4T 32.3.1 (JetPack 4.3)
  • Minor version update

November, 2019

  • vL4T32.2.3
  • L4T 32.2.3 (JetPack 4.2.2)
  • Minor version update

October, 2019

  • vL4T32.2.1
  • L4T 32.2.1 (JetPack 4.2.1)
  • Better release version parsing

July, 2019

  • vL4T32.2
  • L4T 32.2 (JetPack 4.2.1)

June, 2019

  • vL4T32.1
  • L4T 32.1 (JetPack 4.2)
  • Initial Release

Special thanks to Raffaello Bonghi (https://github.com/rbonghi) for jetson_easy scripts.

Special thanks to Shreeyak (https://github.com/Shreeyak) for discussing alternatives to get source directly from NVIDIA git repositories.

About

Build the Linux Kernel and Modules on board the NVIDIA Jetson Nano Developer Kit

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Shell 100.0%