Skip to content

Commit 7497c01

Browse files
Update Builder
1 parent a3f377c commit 7497c01

18 files changed

+550
-288
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Issue report
3+
about: Create a report to help us improve
4+
title: "[BUG]"
5+
labels: bug
6+
assignees: ''
7+
8+
---
9+
10+
**Describe the issue**
11+
Please describe the issue
12+
13+
**Which version of Ubuntu on the Host machine**
14+
Ubuntu version:
15+
16+
**What version of L4T/JetPack**
17+
L4T/JetPack version:
18+
19+
**Which Jetson**
20+
Jetson:
21+
22+
**To Reproduce**
23+
Steps to reproduce the behavior:
24+
For example, what command line did you run?
25+
26+
**Expected behavior**
27+
A clear and concise description of what you expected to happen.
28+
29+
**Additional context**
30+
Add any other context about the problem here.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 JetsonHacksNano
3+
Copyright (c) 2016-2021 Jetsonhacks
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 60 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,86 +1,90 @@
1-
# buildKernelAndModules
2-
Build the Linux Kernel and Modules on board the NVIDIA Jetson Nano Developer Kit
1+
## jetson-linux-build
2+
Tools to build the Linux kernel and modules on board Jetson Developer Kits
33

4-
These scripts are for JetPack 4.3, L4T 32.3.1
4+
This is a tool for meant for intermediate+ users. Please read this entire document before proceeding.
55

6-
Scripts to help build the 4.9.140 kernel and modules onboard the Jetson Nano Developer Kit Previous versions may be available in releases.
6+
This repository contains convenience scripts to:
7+
* Download Kernel and Module sources (**B**oard **S**upport **P**ackage - **BSP**)
8+
* Edit the kernel configuration
9+
* Build the kernel image
10+
* Build all of the kernel modules
11+
* Copy the Kernel Image to the /boot directory - This may not supported for newer versions of L4T - see below _**copyImage.sh deprecation (mostly)**_
12+
* An example to build a single kernel module (most useful)
713

8-
<em><strong>Note:</strong> The kernel source version must match the version of firmware flashed on the Jetson. For example, the source for the 4.9.140 kernel here is matched with L4T 32.3.1. This kernel compiled using this source tree may not work with newer versions or older versions of L4T</em>
14+
## Scripts
915

10-
As of this writing, the "official" way to build the Jetson Nano kernel is to use a cross compiler on a Linux PC. This is an alternative which builds the kernel onboard the Jetson itself. These scripts will download the kernel source to the Jetson Nano, and then compile the kernel and selected modules. The newly compiled kernel can then be installed. We recommend a SD card size of 32GB, 64GB preferred.
16+
### getKernelSources.sh
1117

12-
The scripts should be run directly after flashing the Jetson, or copying the SD card image from a host PC. There are several scripts:
18+
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**
1319

14-
<strong>getKernelSources.sh</strong>
20+
### makeKernel.sh
1521

16-
Downloads the kernel sources for L4T from the NVIDIA website, decompresses them and opens a graphical editor on the .config file. Note that this also sets the .config file to the current system, and also sets the local version to the current local version, i.e., -tegra
22+
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.
1723

24+
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.
1825

19-
<strong>makeKernel.sh</strong>
26+
### makeModules.sh
2027

21-
Compiles the kernel using make. The script commands make the kernel Image file. Installing the Image file on to the system is a separate step. Note that the make is limited to the Image and modules.
28+
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.
2229

23-
The other parts of the kernel build, such as building the device tree, require that the result be 'signed' and flashed from the the NVIDIA tools on a host PC.
30+
### copyImage.sh
2431

25-
<strong>makeModules.sh</strong>
32+
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.
2633

27-
Compiles the modules using make and then installs them.
28-
29-
<strong>copyImage.sh</strong>
34+
You will want to make a copy of the original Image before the copy, something like:
35+
```
36+
$ cp /boot/Image $INSTALL_DIR/Image.orig
37+
$ ./copyImage.sh
38+
$ echo "New Image created and placed in /boot"
39+
```
40+
### editConfig.sh
41+
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.
3042

31-
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.
43+
### removeAllKernelSources.sh
3244

33-
You will want to make a copy of the original Image before the copy, something like:
45+
Removes all of the kernel sources and compressed source files. You may want to make a backup of the files before deletion.
3446

35-
$ cp /boot/Image $INSTALL_DIR/Image.orig<br>
36-
$ ./copyImage.sh<br>
37-
$ echo "New Image created and placed in /boot"<br>
47+
### Example - build-module.sh
48+
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**_
49+
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**
3850

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

40-
<strong>editConfig.sh</strong>
41-
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.
4253

43-
<strong>removeAllKernelSources.sh</strong>
44-
Removes all of the kernel sources and compressed source files. You may want to make a backup of the files before deletion.
54+
## Background Notes
55+
Over the years, we have been maintaining several different repositories here and on https://github.com/jetsonhacksnano to build the Linux kernel and modules for the various NVIDIA Jetson models:
4556

46-
<h2>Notes:</h2>
47-
<h3>Make sure to update the micro SD card</h3>
57+
* Jetson Nano
58+
* Jetson Nano 2GB
59+
* Jetson TX1
60+
* Jetson TX2
61+
* Jetson AGX Xavier
62+
* Jetson Xavier NX
4863

49-
The copyImage.sh script copies the Image to the current device. If you are building the kernel on an external device, for example a USB drive, you will probably want to copy the Image file over to the micro SD card in the micro SD's /boot directory.
50-
Special thanks to Raffaello Bonghi (https://github.com/rbonghi) for jetson_easy scripts.
51-
Special thanks to Shreeyak (https://github.com/Shreeyak) for discussing alternatives to get source directly from NVIDIA git repositories.
52-
Special thanks to Dustin Franklin (https://github.com/dusty-nv/) for how to correctly determine the correct L4T version. (https://github.com/dusty-nv/jetson-inference/blob/7e81381a96c1ac5f57f1728afbfdec7f1bfeffc2/tools/install-pytorch.sh#L296)
64+
The main difficulty of this approach is that there are several different repositories to maintain across NVIDIA L4T releases.
5365

54-
Sometimes it is useful to log the builds:
66+
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.
5567

56-
$ command 2>&1 | tee log.txt
68+
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.
5769

58-
so you can go back and catch errors.
70+
### copyImage.sh deprecation (mostly)
71+
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.
5972

60-
<h4>Intended Use</h4>
61-
The intended use of this repository is to help automate building known configurations of the kernel and build modules. You should use the kernel-4.9/scripts/config script to set the kernel configuration that you desire. See the 'rootOnUSB' repository on the JetsonHacksNano Github account for an example.
73+
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.
6274

63-
### Release Notes
64-
<b>December, 2019</b>
65-
* vL4T32.3.1
66-
* L4T 32.3.1 (JetPack 4.3)
67-
* Minor version update
75+
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.
6876

69-
<b>November, 2019</b>
70-
* vL4T32.2.3
71-
* L4T 32.2.3 (JetPack 4.2.2)
72-
* Minor version update
77+
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.
7378

74-
<b>October, 2019</b>
75-
* vL4T32.2.1
76-
* L4T 32.2.1 (JetPack 4.2.1)
77-
* Better release version parsing
79+
### So what good are these scripts?
80+
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.
7881

79-
<b>July, 2019</b>
80-
* vL4T32.2
81-
* L4T 32.2 (JetPack 4.2.1)
82+
## Release Notes
8283

83-
<b>June, 2019</b>
84-
* vL4T32.1
85-
* L4T 32.1 (JetPack 4.2)
86-
* Initial Release
84+
### September, 2021
85+
* Initial Release
86+
* Unification of build methods across Jetson platform
87+
* Jetson Nano, Nano 2GB, TX1, TX2, AGX Xavier, Xavier NX
88+
* Associative lookup of BSP source code via L4T Release name
89+
* L4T Releases 32.4.2 through 32.6.1
90+
* Tested on Jetson Nano, Jetson Xavier NX

copyImage.sh

Lines changed: 4 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,10 @@
11
#!/bin/bash
2-
# Copy the kernel image to /boot for NVIDIA Jetson Nano Developer Kit, L4T
3-
# Copyright (c) 2016-19 Jetsonhacks
2+
# Copy the kernel image on NVIDIA Jetson Developer Kit
3+
# Copyright (c) 2016-21 Jetsonhacks
44
# MIT License
55

6-
SOURCE_TARGET="/usr/src"
7-
BOOT_TARGET="/boot/"
8-
KERNEL_RELEASE="4.9"
9-
10-
function usage
11-
{
12-
echo "usage: ./makeKernel.sh [[-d directory ] | [-h]]"
13-
echo "-d | --directory Directory path to parent of kernel"
14-
echo "-b | --boot Directory path to boot"
15-
echo "-h | --help This message"
16-
}
17-
18-
# Iterate through command line inputs
19-
while [ "$1" != "" ]; do
20-
case $1 in
21-
-d | --directory ) shift
22-
SOURCE_TARGET=$1
23-
;;
24-
-b | --boot ) shift
25-
BOOT_TARGET=$1
26-
;;
27-
-h | --help ) usage
28-
exit
29-
;;
30-
* ) usage
31-
exit 1
32-
esac
33-
shift
34-
done
35-
36-
LAST="${SOURCE_TARGET: -1}"
37-
if [ $LAST != '/' ] ; then
38-
SOURCE_TARGET="$SOURCE_TARGET""/"
39-
fi
40-
LAST="${BOOT_TARGET: -1}"
41-
if [ $LAST != '/' ] ; then
42-
BOOT_TARGET="$BOOT_TARGET""/"
43-
fi
44-
6+
SOURCE_TARGET="/usr/src/"
7+
KERNEL_RELEASE=$( uname -r | cut -d. -f1-2) # e.g. 4.9
458
export SOURCE_TARGET
46-
export BOOT_TARGET
479
export KERNEL_RELEASE
48-
49-
# E Option carries over environment variables
5010
sudo -E ./scripts/copyImage.sh

editConfig.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/bin/bash
2-
# Edit the kernel configuration for NVIDIA Jetson Nano Developer Kit, L4T
3-
# Copyright (c) 2016-19 Jetsonhacks
2+
# Edit the kernel configuration for NVIDIA Jetson Developer Kit
3+
# Copyright (c) 2016-21 Jetsonhacks
44
# MIT License
55

66
SOURCE_TARGET="/usr/src"
7-
KERNEL_RELEASE="4.9"
7+
KERNEL_RELEASE=$( uname -r | cut -d. -f1-2) # e.g. 4.9
88

99
function usage
1010
{

example/build-module.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
# Example to build Logitech F710 module on NVIDIA Jetson Developer Kit
3+
# Copyright (c) 2016-21 Jetsonhacks
4+
# MIT License
5+
# build the hid-logitech.ko module with Logitech F710 support
6+
# We need the kernel sources installed
7+
8+
SOURCE_TARGET="/usr/src/"
9+
KERNEL_RELEASE=$( uname -r | cut -d. -f1-2)
10+
KERNEL_URI=$SOURCE_TARGET"kernel/kernel-"$KERNEL_RELEASE
11+
if [ ! -d "$KERNEL_URI" ] ; then
12+
echo "Cannot find kernel source in $SOURCE_TARGET."
13+
echo "You will need to install the kernel source before proceeding."
14+
exit 1
15+
fi
16+
17+
cd "$KERNEL_URI"
18+
19+
sudo bash scripts/config --file .config \
20+
--set-val LOGITECH_FF y
21+
sudo make modules_prepare
22+
sudo make drivers/hid/hid-logitech.ko
23+
24+
echo "Build complete."
25+
echo "The module is here: ${KERNEL_URI}/drivers/hid/hid-logitech.ko"
26+
echo "To install the module:"
27+
echo " "
28+
29+
INSTALL_DIRECTORY=/lib/modules/$(uname -r)/kernel/drivers/hid
30+
echo "$ sudo cp -v ${KERNEL_URI}/drivers/hid/hid-logitech.ko $INSTALL_DIRECTORY"
31+
echo "$ sudo depmod -a"
32+
33+
echo ""
34+
echo "You may need to reboot for the changes to take effect."
35+
36+
37+
38+

0 commit comments

Comments
 (0)