How to Set Up the NVIDIA Jetson Nano Developer Kit

In this tutorial, I will show you everything you need to know to get started with the NVIDIA Jetson Nano. The official tutorial is here, but I will run through all the steps below. I recommend you go through these steps slowly. It took me a full day to set up the Jetson Nano, so be patient and enjoy the journey.

You Will Need

This section is the complete list of components you will need for this project (#ad).

Disclosure (#ad): As an Amazon Associate I earn from qualifying purchases.

2021-04-01-102838

Write the Operating System Image to the microSD Card

The first thing we need to do is to prepare the operating system. The Jetson Nano uses a microSD card for storing the operating system.

Grab your SD/Micro SD Card Reader with Standard USB Connector.

Grab your tiny 128GB MicroSD Card, and slide it into the adapter.

2021-04-01-103207

Put the adapter into the SD card reader.

2021-04-01-103357

Plug the SD card reader into your PC. 

Check to see if the SD card reader appears in your lists of disks. Make a note of where this is on your PC. My SD card reader shows up as my F drive.

Download the Jetson Nano Developer Kit SD card image file (often called “JetPack”) to your PC. Mine will save to my Desktop. It is a large file and will take a long time to download. Just go get something to eat and come back when it is finished.

Now, we need to write the image to our microSD card. The instructions will vary depending if you have Windows, Mac OS, or Linux. I have a Windows PC, so here is what I will do next.

Download, install, and launch the SD Memory Card Formatter for Windows.

  • Select the drive where your SD card reader is.
  • Select “Quick format”.
  • Leave “Volume label” blank.
  • Click “Format” to start formatting, and “Yes” on the warning dialog.

Here are the screenshots I took of the process:

1-open-zip-file-click-setupJPG
2-accept-user-agreementJPG
3-click-nextJPG
4-click-installJPG
5-click-finishJPG
6-quick-formatJPG
7-click-yesJPG
8-format-successfulJPG

When you get the notification that the formatting was successfully, close all open windows.

Now download, install, and launch Etcher.

1-download-install-etcherJPG
2-agreeJPG

Click “Flash from file” and choose the zipped Nano Jetson image file you downloaded earlier.

3-flash-from-fileJPG
4-jetson-nano-imageJPG

Insert your microSD card if not already inserted.

Click “Select target” and choose the SD card’s drive. Remember mine is on the F drive.

5-select-targetJPG

Click “Flash!” It will take Etcher a while to write and validate the image, so go do something else and come back.

After Etcher finishes, Windows may let you know it doesn’t know how to read the SD Card. Just click Cancel all those screens and remove the microSD card.

6-weird-pop-upsJPG
Just cancel all of these weird pop ups.

Setup and First Boot

Unfold the paper stand, and place the Nano Jetson inside the developer kit box.

2021-04-01-134219

Set the developer kit on top of the paper stand.

2021-04-01-134321

Insert the microSD card (with system image already written to it) into the slot on the underside of the Jetson Nano module.

2021-04-01-134736

Make sure the jumper is pushed into the J48 Power Select Header pins.

pin-diagram-nano
2021-04-01-135304

Connect the Jetson Nano into your monitor. I am using an HDMI cable to connect my monitor to my Jetson Nano. If you don’t have one, you can buy one off Amazon or any other electronic retailer.

2021-04-01-135628
2021-04-01-135648

Connect the Jetson Nano into your keyboard.

Connect the Jetson Nano into your mouse.

Grab the “Power Supply Applicable for Jetson Nano 5V/4A OD 5.5mm ID 2.1mm”.

Connect the power supply to the 5V/4A Power Jack. The developer kit will power on automatically.

Allow 1 minute for the developer kit to boot.

A green LED next to the Micro-USB connector will light as soon as the developer kit powers on. When you boot the first time, the developer kit will take you through some initial setup, including:

Review and accept NVIDIA Jetson software End User License Agreement.

2021-04-01-140450

Select the system language.

2021-04-01-140517

Select the keyboard layout.

2021-04-01-140537

Select the time zone.

2021-04-01-140553

Create a username, password, and computer name. Be sure to select “Log in automatically.”

Select APP partition size. NVIDIA recommends to use the maximum size.

Here is the screen you should see now.

2021-04-01-140948

Update QSPI process and click Continue.

2021-04-01-141151

Keep the default setting for the Nvpmodel Mode, and click Continue.

2021-04-01-141654

Your Nvidia will automatically reboot to the Ubuntu desktop.

2021-04-01-142023

Click the Terminal icon in the bottom-left.

2021-04-01-142035
2021-04-01-143055

Restart the computer again.

sudo reboot

Set Up WiFi

Grab your WiFi adapter.

2021-04-01-143208

Plug it into one of the USB ports on the Jetson Nano.

To set up WiFi, you can use the following command in a terminal window (sudo nmtui), or follow the steps below.

Click the settings (gear) icon in the upper right corner of the desktop.

Click System Settings in the drop down menu.

Click the Network dialog in the dialog box.

Set up the network connection.

Reboot the computer.

sudo reboot

Your computer might pop up a Software Updater dialog. You can click Install Now.

Right click on the Desktop.

Open the Terminal.

Check if your WiFi setup is fine.

ping google.com
2021-04-01-144224

Turn off the power save mode to get stability.

sudo iw dev wlan0 set power_save off
sudo reboot

Run Updates

Let’s update our package list and upgrade the software on the system.

Open the terminal, and type:

sudo apt-get update
sudo apt-get upgrade

Type Y and press Enter to upgrade everything.

Reboot the computer.

sudo reboot

Collect Information About Your Jetson Nano

Open a terminal window, and type the following command.

hostname -I

Make a note of your internal IP address.

Change the Power Supply Settings

If you are using the 5V/4A power supply like I am, open your terminal window, and type:

sudo nvpmodel -q

If you see the following, you are good to go.

NV Power Mode: MAXN

Otherwise, type the following command:

sudo nvpmodel -m 0 

This command will give you high power performance. If you want to change it to low performance because you are using microUSB to power the Jetson Nano, here is the command:

sudo nvpmodel -m 1

Create a Swap File

Some of the applications I will use on my Jetson Nano require a lot of memory. To keep the Nano from crashing, we need to create a swap file.

See if your Nano already has swap space.

free -h


If you don’t have swap space, add a 4GB swap file.

sudo fallocate -l 4G /var/swapfile
sudo chmod 600 /var/swapfile
sudo mkswap /var/swapfile
sudo swapon /var/swapfile
sudo bash -c 'echo "/var/swapfile swap swap defaults 0 0" >> /etc/fstab'

Reboot your Nano.

sudo reboot

Once the Nano is done rebooting, see if you have swap space.

free -h

Connect to Your NVIDIA Jetson Nano Remotely From Your PC

Now I will show you everything you need to know to connect to your NVIDIA Jetson Nano desktop remotely from your own PC (on the same WiFi network) using an application called VNC Viewer.

Save RAM By Using the LXDE Desktop

First, let’s free up some RAM to keep our Nano from crashing.

Type the following command. Your computer will then reboot to a login screen.

$DESKTOP_SESSION

On the login screen, click the gear icon next to “Sign In”.

2021-04-01-160057

Scroll down, and select LXDE.

Type your password, and click Sign In.

LXDE is now your desktop environment.

2021-04-01-160200

Reboot.

sudo reboot

Open a terminal window in your Nano, and type the following command to see what desktop environment you’re using.

echo $XDG_CURRENT_DESKTOP
2021-04-01-160617

See how much free memory you have.

free
2021-04-01-160656

Now open a terminal window, and change the display manager from gdm3 (GNOME display manager) to lightdm.

sudo dpkg-reconfigure lightdm

You will see a window pop up.

Press Enter.

Next, select lightdm, and press Enter.

2021-04-01-160836

Reboot your computer.

sudo reboot

Open a new terminal window, and type:

free
2021-04-01-161051

You can see that we now have less memory used.

Set Up the VNC Server

Now we need to set up the VNC server

First, enable the VNC server to start each time you log in. Open a new terminal window, and type:

mkdir -p ~/.config/autostart
cp /usr/share/applications/vino-server.desktop ~/.config/autostart/.

Now, we need to configure the VNC server.

gsettings set org.gnome.Vino prompt-enabled false
gsettings set org.gnome.Vino require-encryption false

Set a password for the VNC server. Make sure you remember it.

# Replace thepassword with your desired password

gsettings set org.gnome.Vino authentication-methods "['vnc']"
gsettings set org.gnome.Vino vnc-password $(echo -n 'thepassword'|base64)

Shutdown your Jetson Nano.

sudo shutdown -h now

Once the Jetson Nano is OFF, unplug the 5V/4A power source.

Unplug your mouse, keyboard, and monitor from the Jetson Nano. 

Plug the 5V/4A power source back into the Jetson Nano.

Install a Remote Desktop Software

Option 1 (Slowest): VNC Viewer on Your PC

To install VNC Viewer, I will follow these instructions that cover Windows, MacOs, and Linux.

If you’re using Windows, go to your PC, and download and install VNC Viewer.

Launch the VNC viewer and type in the IP address of your Jetson Nano. You can also go to File -> New Connection

If you have configured the VNC server for authentication, provide the VNC password.

1-vnc-viewer-setupJPG

The remote desktop connection lag might be very strong.You change the desktop resolution by clicking in the bottom-left and going to Preference -> Monitor settings.

I’m not a huge fan of the remote desktop for the Jetson Nano. Raspberry Pi is far superior. Hopefully the guys at NVIDIA fix that in the future by building in WiFi to their boards.

Now, power OFF your Jetson Nano.

sudo shutdown -h now

Remove the power supply, and then plug it back in.

Option 2 (Fastest): Install NoMachine on Your PC

VNC Viewer was too slow for me on Windows, so I installed NoMachine. I will follow these instructions and these instructions.

Go to the NoMachine website and download the DEB package for ARMv8.

This folder will go to your Downloads folder. Move to that folder via the terminal.

cd Downloads

Install NoMachine with the ‘dpkg’ command. For example if you downloaded package ‘nomachine_7.4.1_1_arm64.deb’:

sudo dpkg -i nomachine_7.4.1_1_arm64.deb

Now click on the start menu in the bottom-left. Select NoMachine. NoMachine might be under the “Internet” option.

Make a note of the URL you can use to connect to your Jetson Nano.

Restart your Jetson Nano.

sudo shutdown -h now

Unplug the power supply from your Jetson Nano.

Plug the power supply into your Jetson Nano.

Now download the NoMachine software from your own PC (Windows, MacOs, or Linux).

After you have downloaded it, launch the NoMachine application on your PC.

Double click on your Jetson Nano icon (i.e. Ubuntu 18.04).

connect_no_machineJPG

Click Yes.

Type in the username and password for the Jetson Nano machine.

Click through the prompts, and you will see your Desktop appear.

2-connect-to-no-machine-from-windowsJPG

Now, power OFF your Jetson Nano.

sudo shutdown -h now

Remove the power supply, and then plug it back in.

Install Putty (Optional)

Putty is a program that will enable us to connect to the Jetson Nano’s terminal only. 

Go to putty.org and download the installer for your machine. I am using a 64-bit Windows computer so that is what I will select.

Follow the instructions to download Putty. Once you’ve finished, open up Putty. If you’re using Windows, you can usually find it in the Start Menu.

putty

The first thing you will do is type in the IP address of your Jetson Nano.

Select the SSH radio button.

Click the Open button.

If you get a popup window, click “Yes” and then you will go to a black terminal window.

Type in the username and password of your Jetson Nano. 

That’s it. You’re logged in to your Jetson Nano via the command line interface.

You are now good to go.

Next Steps

A lot of Jetson Nano projects involve heavy computation (e.g. deep learning and robotics), which can make the board heat up pretty quickly. I recommend buying and setting up your Jetson Nano with a cooling fan and case.

Whew! That was a lot of work setting up the NVIDIA Jetson Nano. 

That’s it. Keep building!

How to Add an External C++ Library to Your Project

Libraries in C++ are collections of code that someone else wrote. They prevent you from having to reinvent the wheel when you need to implement some desired functionality. You can think of libraries as a plugin or add-on that gives you more functionality.

For example, I wanted to write a program that is able to multiply two matrices together. Instead of writing the code from scratch, I searched the web for a linear algebra library in C++ that contained functionality for multiplying matrices. I found the library named “Eigen.” I added the library to my project in the CodeLite IDE, and I was ready to go.

Without further ado, here is the step-by-step process for adding an external C++ library to your project using the CodeLite IDE and Visual Studio IDE.

Note that this process will be different if you are using another IDE for C++, but the two basic steps are the same for all IDEs:

  1. Add the path for the header files
  2. Add the path for the actual code (i.e. the library)

How to Add an External C++ Library to Your Project Using the CodeLite IDE

Step 1: Go to the website of the library.
For example, for the linear algebra library, Eigen, you go to this page: Eigen Main Page

Step 2: Download the zip file that contains all the code.

Step 3: Unzip the zip file to your computer.

Step 4: Open CodeLite (i.e. your IDE)

Step 5: Open a new Project

Step 6: Right click on project name and click on Settings

Step 7: Click the Compiler tab and add the Include Paths:
e.g. the folder that contains the folder named ‘Eigen’…C:\XYZ\eigen-eigen-21301928\
This is where the compiler can find the .h (i.e. header) files

Step 8: Click Linker and add the Libraries Search Path
e.g. C:\XYZ\eigen-eigen-21301928\
The path above needs to be the location where the linker can find the libraries (usually suffixed with .a, .dll, .lib, .so)

  • Static Libraries are – XYZ.lib for Windows, UNIX/Linux/Max – libXYZ.a
  • Dynamic Libraries are – XYZ.dll for Windows, Unix/Linux/Mac – libXYZ.so

Step 9: Go to main.cc (i.e. your source code file…could also be main.cpp) and add the preprocessor directives at the top of the source file. You can use this code to test that everything is setup properly.

#include <iostream>
#include <Eigen/Dense>

using Eigen::MatrixXd;

int main()
{
  MatrixXd m(2,2);
  m(0,0) = 3;
  m(1,0) = 2.5;
  m(0,1) = -1;
  m(1,1) = m(1,0) + m(0,1);
  std::cout << m << std::endl;
}

Step 10: That’s it. You are ready to rock and roll!

How to Add an External C++ Library to Your Project Using the Visual Studio IDE

Step 1: Go to the website of the library.
For example, for the linear algebra library, Eigen, you go to this page: Eigen Main Page

Step 2: Download the zip file that contains all the code.

1-zip_fileJPG

Step 3: Unzip the zip file to your computer.

2-unzipJPG

Step 4: Move the folder to some directory on your computer.

I’ll move it to the C:\libraries directory. At this stage, Eigen is along the following path for me:

C:\libraries\eigen-3.3.7\eigen-3.3.7\Eigen

3-directoryJPG

Step 5: Open Visual Studio.

Step 6: Create a new C++ project.

Step 7: Write the following code into a new Source file.

I’ll name this file main.cpp.

#include <iostream>
#include <Eigen/Dense>
 
using Eigen::MatrixXd;
 
int main()
{
  MatrixXd m(2,2);
  m(0,0) = 3;
  m(1,0) = 2.5;
  m(0,1) = -1;
  m(1,1) = m(1,0) + m(0,1);
  std::cout << m << std::endl;
}

Step 8: Click on the Project tab at the top and go to Additional Include Directories.

Project -> Properties -> C/C++ -> General (you can find it by expanding the little triangle next to C/C++) -> Additional Include Directories

4-additional-includeJPG

Step 9: Click the blank next to “Additional Include Directories”.
A small triangle dropdown should appear.

Step 10: Click <…Edit>.

Step 11: Click the Add New Line icon.

5-add-new-lineJPG

Step 12: Add the path to the folder containing Eigen

If you click the blank, an icon with three periods “…” should appear. Click that icon and add the path to the folder that contains Eigen.

In my case, the path is:

C:\libraries\eigen-3.3.7\eigen-3.3.7\

because the actual Eigen library is this folder:

C:\libraries\eigen-3.3.7\eigen-3.3.7\Eigen

Step 13: Click OK.

6-after-includeJPG

Step 14: Click Apply and then OK.

7-apply-then-okJPG

Step 15: Go to main.cpp (or whatever the name of the source code you wrote earlier is).

8-write-the-codeJPG

Step 16: Compile and Run the Code.

To compile the code, go to Build -> Build Solution.

Then to run the code, go to Debug -> Start Without Debugging.

Here is the output you should see:

9-outputJPG

That’s it! You’re all good to go.

How to Install and Launch ROS2 Using Docker

In this tutorial, we will install and launch ROS2 using Docker within Ubuntu Linux 20.04. To test our installation, we will launch and run the popular Turtlebot3 software program.

What is Docker?

You can think of a Docker container on your PC as a computer inside your computer.

Docker is a service that provides portable stand-alone containers that come bundled with pre-installed software packages. These containers  make your life easier because they come with the right software versions and dependencies for whatever application you are trying to run.

Docker makes a lot more sense when you actually use it, so let’s get started.

Install Docker

Go to this link to download the appropriate Docker for your system.

Install Docker on your computer. Since I’m using Ubuntu 20.04 in Virtual Box on a Windows 10 machine, I’ll follow the Ubuntu instructions for “Install using the repository.”

If you’re using a Mac or Windows, follow those instructions. I actually find it easier to use Ubuntu, so if you’re using Windows, I highly suggest you do this tutorial first to get Ubuntu up and running, and then come back to this page.

Pull and Start the Docker Container With ROS2

Open a new terminal window, and create a new folder.

mkdir new_folder

Let’s pull a docker container. This one below comes with ROS2 already installed. This docker container comes from this GitHub repository.

sudo docker pull /tiryoh/ros2-desktop-vnc:foxy

Now we need to start the docker container and mount the folder on it (the command below is all a single command).

sudo docker run -it -p 6080:80 -v /new_folder --name ros2_new_folder tiryoh/ros2-desktop-vnc:foxy

Note that ros2_new_folder is the name of the container.

Type the following in any browser: http://127.0.0.1:6080/

Here is the screen you should see:

1-screen-you-should-seeJPG

Install TurtleBot3

Click the menu icon in the very bottom left of the container.

Go to System Tools -> LX Terminal.

Download TurtleBot3.

mkdir -p ~/turtlebot3_ws/src
cd ~/turtlebot3_ws
wget https://raw.githubusercontent.com/ROBOTIS-GIT/turtlebot3/ros2/turtlebot3.repos
vcs import src < turtlebot3.repos

Wait a while while TurtleBot3 downloads into the container.

2-wait-a-whileJPG

Compile the source code.

colcon build --symlink-install

Wait for the source code to compile.

3-source-code-compileJPG

Let’s set the environment variables. Type these commands, one right after the other.

echo 'source ~/turtlebot3_ws/install/setup.bash' >> ~/.bashrc
echo 'export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:~/turtlebot3_ws/src/turtlebot3/turtlebot3_simulations/turtlebot3_gazebo/models' >> ~/.bashrc
echo 'export TURTLEBOT3_MODEL=waffle_pi' >> ~/.bashrc
source ~/.bashrc

Launch an Empty World in Gazebo in ROS2

Now we will launch the simulation using the ros2 launch command.

ros2 launch turtlebot3_gazebo empty_world.launch.py

It will take a while to launch the first time, so be patient. You might see a bunch of warning messages, just ignore those.

When everything is done launching, you should see an empty world like this.

4-empty-gazebo-worldJPG

Go back to the terminal window by clicking the icon at the bottom of the screen.

Press CTRL+C to close it out.

For more simulations, check out this link at the TurtleBot3 website.

How to Stop the Docker Container

To stop the Docker container, go back to Ubuntu Linux and open a new terminal window. Type the following code.

sudo docker stop [name_of_container]

For example:

sudo docker stop ros2_new_folder

How to Restart the Docker Container

If you ever want to restart it in the future, you type:

sudo docker stop [name_of_container]

For example:

sudo docker restart ros2_new_folder

Type the following in any browser. http://127.0.0.1:6080/

That’s it.