The Jetson board is often used for autonomous driving applications, many of which require hard realtime determinism. The Jetson source code even includes realtime patches from the PREEMPT_RT kernel community. So why no one at Nvidia has documented how to use them is beyond me. Here’s the walk-through:
Step 1: Install Jetpack SDK on Host Machine
You’ll need a host machine running Ubuntu (tested on 18.04) to compile your kernel and flash your Jetson board. You can find the link to Jetpack here. Install it, run it, and you should see this screen:
Select your hardware, and the version of Jetpack you want to use. They will have the developer preview, 4.4 selected by default, but I recommend using 4.3. Click Next
On this screen, you’ll install the host components (I’ve already installed them in the screenshot). Deselect the Jetson OS, as we’ll be installing our own custom image with a realtime kernel. Also deselect Jetson SDK components as those will be installed later. Press continue and go grab coffee while CUDA, OpenCV, Visionworks, and the like are installed on your host machine.
cd /usr/include sudo ln -s opencv4/opencv2/ opencv
Exit when finished.
Step 2: Make your own Kernel
Now create a folder in your home directory to store your kernel source and auxillary goodies.
Clone the jetson-agx-build repo into it.
git clone https://github.com/jtagxhub/jetpack-agx-build.git build
This provides useful scripts to build your own kernel and flash it onto the Jetson. It downloads a lot of the same things the SDK Manager does; but also downloads the Jetson source code, complete with realtime kernel patches.
To set up the repo, run
It’ll prompt you for your target board, your release, your user and password for your board, and your device IP. Answers should be the following:
- Probably Xavier or TX2, but put whatever you’re using
- 4.3, if you heeded my recommendations above
- The username and password you plan on using when you install Ubuntu on your Jetson
- 192.168.55.1, this is the IP address the Jetson assigns to itself in the Ethernet-over-USB mini-network
Finish setup with:
nvidia directory will resemble the structure seen in the build/README.md. You’re ready to edit kernel code.
This is the source for your kernel. It includes patches for realtime functionality. Apply these with:
Your kernel is now realtime! Do some quick config and build it
kdefconfig kmenuconfig # You don't HAVE to change anything ksavedefconfig kbuild -a
Go grab coffee.
Step 3: Flash your Jetson
Unplug your Jetson and replug it in. The only things connected should be power, a keyboard, an HDMI monitor, and a USB connecting it to your host machine. Mouse is optional. Do not connect ethernet.
Enter recovery mode by holding down the Recovery switch (location varies by board) and then holding down the Power button. Release both after a couple seconds. Also plug in a monitor now.
Back on your host, run:
It’ll prompt you for a conf file. If you’re using an AGX, it’s probably not the 8GB one, fyi. Go get coffee again. If this process isn’t done in 10 minutes, something went wrong.
Step 4: Install Ubuntu
The guaranteed way you know your flash works is the that the Jetson will power up, and you’ll see an install screen on its monitor. Connect a keyboard and do all the things.
When it prompts you for username and password, be sure to use the same ones you specified in step 2 after running envsetup.sh.
When installation is complete, and your Jetson restarted, login and run
uname -a to see what kernel you have. If it has
PREEMPT RT in it, congratulations! Your Jetson is running a fully preemptive realtime kernel!
Step 5: Install SDK components on Jetson
, bring up the SDK Manger again. Select all the same things on Step 1 (be careful not to accidentally select 4.4) and press continue.
This time, only leave Jetson OS unchecked, since we already flashed it. Take note of the Target HW Image Folder. Notice how I made mine a subfolder of the same nvidia directory we used before.
Press continue and take a quick potty break on account of the three coffee breaks you had during this tutorial.
When this is done, there will be CUDA and Visionworks demos installed on your Jetson. JetsonHacks has a YouTube video exploring these. Check that out if you want, but if not, you’re finished!
If you’re digging into jetson-agx-build’s scripts and you’d rather use a git repo instead of a tarball, the link is:
Their opensource graphics driver is
And you can find code for related projects here