More Fall Cleaning, 2021

Fall cleaning continues here at JetsonHacks. The last week here we’ve been doing some deep cleaning, working on the operating system level repositories.

Updating Repositories

One area that has changed quite a bit over the last few iterations of the Jetson L4T releases is the way that a developer can interact with the Linux kernel and modules. Previously, it was possible to work directly with most of the lower level system directly on the device. NVIDIA recommended working with these system level changes in a cross development environment hosted on a PC running Ubuntu.

As Linus Torvald diplomatically points out: “Cross-development is pointless and stupid when the alternative is to just develop and deploy on the same platform. Yes, you can do it, but you generally would like to avoid it if at all possible.” There are opposing views, of course.

I personally subscribe to that philosophy for simple development. However, note that when you are building new hardware (and you are serious about doing so) you need to have as much compute power as possible if you intend to advance the state of the art. You ain’t building next generation supercomputers with your desktop PC.

Also, it makes sense to train complex machine learning models on high-end GPUs, or in the cloud. Once you have a trained model, you can deploy it on a Jetson. You are only going to live so long, you don’t have time to wait days/weeks/months to train a model on a Jetson. However, things like device drivers, changing the device tree, and hacking the kernel? To me, that should happen on device.

One of the main reasons on device OS hacking on device has become difficult is the emphasis on security in the last several iterations of L4T on the Jetson. There have been several features introduced at the OS level to facilitate better security.

First, the kernel images may be signed. For example, the Jetson Xaviers have their kernel PKC Signed and has SBK encryption. Depending on the architecture of the specific Jetson, the kernel may be placed in QSPI-NOR flash memory onboard the Jetson module (Jetson Nano, Nano 2GB, and Xavier NX). Or it may be placed in the APP partition of the rootfs. Second, there may be multiple rootfs partitions to help facilitate Over The Air (OTA) updates. The device tree binaries may be also signed.

jetson-linux-build

With all of that said, the Jetson Hacks versions “Build Kernel and Modules” were all in various states of disrepair. With each release of L4T came a little more cruft. There are a surprisingly large number of these repositories:

On JetsonHacks Github repository:

On JetsonHacksNano repository (Jetson Nano, and Nano 2GB):

Inside Baseball

For the most part, the only difference between the code on each one of these repositories is where we retrieve the source code for the kernel and modules from the NVIDIA L4T archive. These URLs are based on the L4T release version. In fact, there are two branches of code for each release. One is for what is know as code name T210 (Jetson TX1, Jetson Nano, Jetson Nano 2GB). The other branch is code name T186 (Jetson TX2, Jetson AGX Xavier, Jetson Xavier NX).

If only there was a way to consolidate a way to get the kernel sources …

In the jetson-linux-build repository in the JetsonHacks Gitub account there is a file named getKernelSources.sh. If you look at the script that it calls, getKernelSources.sh, you will see a nearly magical dictionary that corresponds to the source URL given a L4T release number. Some people call it an “associative array”, us computer sciency people call it a hash table. There’s a lot of fancy code in there which grabs the correct source for the machine on which you are running.

There’s also an example in the repository on how to build a kernel module. In this case, a module to connect a Logitech F710 game controller. It’s still possible to build modules onboard the device.

As for the kernel image, it’s much more nuanced. To be honest, I’m a little confused as to what can and can’t be done on the device right now as far as the kernel image goes.

The above mentioned repositories are still in place, but note that if they haven’t been already, they will be switching over to the jetson-linux-build codewise.

Logitech F710 module

The logitech-f710-module has been updated on JetsonHacks, JetsonHacksNano, and RACECARJ Github repositories. These modules cover L4T 32.4.3 through L4T 32.6.1. See the releases for the appropriate release for your needs.

Conclusion

It takes some time to work on these cleanup efforts. Cleanup this time took a couple of weeks. Hopefully you will find it useful, and you can use this work as is or modify it to suit your needs.

2 Comments

Leave a Reply