Skip to content

Lidar Mapping (PoC) »

Notes for Jetson Nano

Tips, hints, and tricks when working on Jetson Nano

Last update: 2022-06-29

Check log#

Get system log:


Log file:

cat /var/log/syslog

List of built-in modules#

cat /lib/modules/$(uname -r)/modules.builtin | grep spi

Build kernel and modules#

This is a method to build Kernel image and modules directly on the Jetson board.

Firstly, clone build scripts:

git clone && \
cd jetson-linux-build

Download kernel source. The script will automatically detect the kernel version.


Kernel modules can be configured using KConfig Menu:


Example of reviewing SPI driver for Tegra114.

  1. Browse to Device DriversSPI support and check detail of NVIDIA Tegra114 SPI Controller by pressing H:

    .config - Linux/arm64 4.9.140 Kernel Configuration
    > Device Drivers > SPI support ------------
    ------NVIDIA Tegra114 SPI Controller------- CONFIG_SPI_TEGRA114:                                                              Symbol: SPI_TEGRA114 [=y]                Type  : tristate                         Prompt: NVIDIA Tegra114 SPI Controller     Location:                                  -> Device Drivers                          -> SPI support (SPI [=y])            Defined at drivers/spi/Kconfig:626       Depends on:...

    This driver uses the symbol SPI_TEGRA114 which is defined at drivers/spi/Kconfig:626.

  2. Check the Makefile in /usr/src/kernel/$(uname -r)/drivers/spi/Makefile:

    obj-$(CONFIG_SPI_MASTER)        += spi.o
    obj-$(CONFIG_SPI_SPIDEV)        += spidev.o
    obj-$(CONFIG_SPI_LOOPBACK_TEST) += spi-loopback-test.o
    obj-$(CONFIG_SPI_TEGRA114)      += spi-tegra114.o

    Trace to .config file in the kernel folder /usr/src/kernel/$(uname -r). Read more at Makefile.


    The CONFIG_SPI_TEGRA114=y means spi_tegra114 is a platform driver, not a module, therefore it needs to rebuild kernel image to include change in that driver.

  3. Edit the source code or apply a patch

  4. Rebuild kernel image


    It takes about an hour at the first time.

  5. Replace BOOT image at line LINUX /boot/Image by editing the boot file:

    cat /boot/extlinux/extlinux.conf

    Should back up the kernel image first.


Find in file#

grep --include=\*.{c,h} -rnw '.' -e "SPI_MODE_1"

Check shared libraries#

ld -lrf24 --verbose

Wrap C lib to C++ lib#

Add wrapper to the header file

#ifdef __cplusplus
extern "C" {

... header content here...

#ifdef __cplusplus

Device Tree Compile#


dtc -I dtb -O dts <input.dtb> -o <output.dts>

Edit .dts file, and then recompile:

dtc -I dts -O dtb <input.dts> -o <output.dtb>

Replace FDT file at line FDT /boot/xxx.dtb by editing the boot file cat /boot/extlinux/extlinux.conf. Should back up the kernel image first.

Fix USB Partition#

USB with wrong partition table can not be read. Erase the entire partition table is needed.

sudo dd if=/dev/zero of=/dev/sda bs=512 count=1

Then use fdisk to create GPT partition table and add new partition.

sudo fdisk /dev/sdx

The format the partition:

sudo mkfs.ext4 /dev/sdxy

Visual Studio Code#

Visual Studio Code is far better than Sublime Text. Here is a method to install it automatically:

wget -qO- \
    | gpg --dearmor \
    > \
&& \
sudo install -o root -g root -m 644 \ \
    /etc/apt/trusted.gpg.d/ \
&& \
rm -f \
&& \
sudo sh -c \
    'echo "\
        deb [signed-by=/etc/apt/trusted.gpg.d/] \ stable main\
    " \
    > /etc/apt/sources.list.d/vscode.list' \
&& \
sudo apt install -y apt-transport-https \
&& \
sudo apt update \
&& \
sudo apt install -y code


  • Sublime Text key map
  • C/C++


    "configurations": [
            "browse": {
                "databaseFilename": "",
                "limitSymbolsToIncludedHeaders": true
            "includePath": [
            "name": "ROS",
            "configurationProvider": "ms-vscode.cmake-tools"
    "version": 4

Submodule in Git#

Add a new module:

git submodule add <remote_url>

Initialize submodule:

git submodule init

Download submodule after initializing:

git submodule update

Remove a module:

git submodule deinit <submodule_name>

Clone and download all submodules:

git clone --recursive <repo_url>