/jetson_nano_setup

Comprehensive step-by-step instructions on how to set up the Jetson Nano

Primary LanguageShell

What You Need:

  1. DC 5V/4A Barrel Jack Power Adapter* - Makersupplies
  2. HDMI Monitor
  3. Wireless Keyboard and Mouse*
  4. USB-A to micro-usb adapter with dataline
  5. Jumpers - aliexpress
  6. Wireless network adapter, M2(see below) or USB(not recommended*)

You can also get these additional hardware for a higher quality-of-life (QOL) development experience:

  1. M2 slot Wireless Adapter - Makersupplies

*If using the 4A DC jack, the USB wireless adapter and bluetooth wireless transceivers tend to suffer interference from the adjacent power jack related to grounding issues. Related symptoms: keyboard/mouse stutter and network loss.

Flashing the SD Card

  1. Download the Nvidia SDK Manager onto a Debian machine (Ubuntu Desktop 16.04 and 18.04 on x64 system ) or emulator. Download link here

  2. Run the SDK Manager, choose the right platforms, as seen below and proceed to the next step:

    SDK Setup Remember to choose NVIDIA Jetson Nano (Developer Kit Version) and not Jetson Nano (Production version)

  3. Select Jetson OS and Jetson SDK Components and the downloads will commence (will take some time). Continue to the next step.

    SDK Setup

  4. These steps are tricky. You can follow along with the instructions shown but there are some gotchas. First, you can only use 'Manual Mode' because automatic doesn't work with a SD card that isn't already flashed with the OS. So go ahead and select Manual Mode. I'll go step-by-step from here.

    SDK Setup

    Remember to choose NVIDIA Jetson Nano (Developer Kit Version) and not Jetson Nano (Production version)

  5. First unpower the device by removing the DC jack. Remove all peripherals if you haven't done so already

    SDK Setup

  6. Next, attach a jumper to the J48 pin. This changes the power draw from micro-usb to the barrel jack.

    J48

  7. Then, attach the jumper to the J40 pins as pictured (second row from the camera slot).

    J40

    This boots the Nano is USB recovery mode. If you are not sure, you can always flip the board around to check the labels and look for RST(pictured below)

    Labels

  8. Now, connect the USB-A to micro-usb adapter from the Nano to your x86 host machine.

    Micro-usb

Also connect your mouse/keyboard wireless transceiver and HDMI display adapter.

![Micro-usb](SDK-Step4-done.jpg)
  1. Finally connect the DC barrel jack and power on! A green light should appear and the end result should look something like this:

    Done // TODO: Better photo needed here

  2. The SDK Manager should automatically start flashing the SD card. Meanwhile you can remove the J40 jumper(pictured black)

    Jumpers

  3. When the progress bar hits about 42%. A prompt should appear asking to complete the Configuration Wizard.

    Step 5

    Now switch to the Nano display and a GUI should appear. Complete the configuration steps until the wizard is completed. Switch over to the x86 Host Machine once you have set your username and password and key this into the SDK Manager (and ignore the IP address)

  4. The SDK Manager will now proceed to install the additional SDK Components, so just wait until its completed.

Setting Static IP

Setting Up SSH Access

On your local x86 machine:

  • ssh-copy-id -i ~/.ssh/id_rsa <nano-ip>
  • Key in your nano's password and the ssh keys will be added to ~/.ssh/known_hosts
  • Try: ssh -X username@<nano-ip> and you should now have passwordless login

On your Nano:

  • You might have to change some sshd settings in sudo vim /etc/ssh/sshd_config

Setting up VS Code Remote Development on the Nano

This is absolutely useful if you wish to run the nano headless and modify on the nano directly

Start an elevated session

  • sudo -s

Install the community repo key

  • apt-key adv --keyserver keyserver.ubuntu.com - --recv-keys 0CC3FD642696BFC8

Run the installation script

  • . <( wget -O - https://code.headmelted.com/installers/apt.sh ) Then reboot or exit the sudo shell
  • sudo reboot or exit

Disable Lock Screen

  • Run gsettings set org.gnome.desktop.screensaver lock-enabled false

Enable auto-login

  • Even though the auto-login is enabled on the GUI settings. It needs a retoggle to work. Run sudo vim /etc/gdm3/custom.conf and make sure the AutomaticLoginEnable flag is True and uncommented, as follows.

    [daemon]
    AutomaticLoginEnable=True
    AutomaticLogin=user
    

    or if you are lazy:

    sudo sed -i '/AutomaticLoginEnable*/s/^#//; s/False/True/' /etc/gdm3/custom.conf && sed -i '/AutomaticLogin=*/s/^#//' /etc/gdm3/custom.conf
    

Resize Partitions

Start an elevated session

  • sudo -s Run resize script
  • curl -s https://raw.githubusercontent.com/lackdaz/jetson_nano_setup/master/scripts/resize.sh | sh Then reboot
  • sudo reboot

Create Swap File

The default nano swapfile is 2GB. You can see this by running: zramctl

You will notice that there are four entries (one for each CPU of the Jetson Nano) /dev/zram0 - /dev/zram3. Each entry has an allocated amount of swap memory associated with it, by default 494.6M, for a total of around 2GB. This is half the size of the main memory. You will find this to be adequate for most tasks, but not for dockerised applications. To increase the swapfile size, we are going to use the Jetson Nano convenice script:

  • git clone https://github.com/JetsonHacksNano/resizeSwapMemory utilities && cd utilities
  • Then to increase to 8gb: ./setSwapMemorySize.sh -g 8
  • Reboot for the changes to take effect: sudo reboot
  • Finally check the new swap file size by running zramctl again. You should now see 4x2GB(8GB)

Git

  • $ git config --global user.name "user"
  • $ git config --global user.email "user@gmail.com"
  • git config credential.helper store or git config --global credential.helper store (global)
  • git push in the github repositories you want your credentials saved

Git Submodules

  • Run: git clone https://github.com/lackdaz/wallaby.git --recursive

A Better Git log/tree (Optional)

Installing Yarn (Optional)

Required for node package management

Upgrading Docker to 19.03

  • To upgrade docker: curl -sSL https://get.docker.com/ | sh
  • To install docker-compose:
    • sudo apt-get update
    • sudo apt-get install -y python-pip python-dev libffi-dev libssl-dev libxml2-dev libxslt1-dev libjpeg8-dev zlib1g-dev
    • sudo pip install docker-compose=="1.25.5" (latest) Fix user permissions
  • sudo groupadd docker
  • sudo usermod -aG docker $(whoami)
  • sudo service docker start Checking versions
  • To check docker version: sudo docker version
  • To check compose version: sudo docker-compose version

Setting HDMI has default audio output (Optional)

It's always nice to hear a little audio

  • Just add pactl set-default-sink 0 to ~/.bashrc or run this convenience script:
curl -s https://raw.githubusercontent.com/lackdaz/jetson_nano_setup/master/scripts/set_hdmi_audio.sh | sh

Disable Monitor Sleep

  • Run: gsettings set org.gnome.desktop.session idle-delay 0

Install exFAT

Silly proprietary Microsoft software

  • Run: sudo apt-get install -y exfat-fuse exfat-utils

JTOP

Resource Diagnostics Tools

  • Install: sudo -H pip install -U jetson-stats
  • Run: sudo jtop
  • Run: sudo systemctl enable jetson_performance.service

Playing Videos

GNOME Videos seems to be one of the few plug-and-play options that work on the arm64:

  • Install: sudo apt-get install totem libtotem0
  • Run: totem <path-to-video> Alternatively, you can use the native plug-and-play gstreamer player:
  • Run gst-play-1.0 file:///home/seth/<path-to-video> or, for more advanced video/audio pipeline building:
  • Run: gst-launch-1.0 uridecodebin uri=file:///home/seth/<path-to-video> ! nvoverlaysink or run a movie at 10x without subtitles
  • Run: gst-launch-1.0 filesrc location=~/Videos/Westworld.S03E07.Passed.Pawn.1080p.AMZN.WEB-DL.DDP5.1.H.264-NTb.mkv ! queue ! decodebin3 name=d d.video_0 ! nvvidconv interpolation-method=3 flip-method=0 ! 'video/x-raw(memory:NVMM), format=(string)I420' ! videoconvert ! videorate rate=10.0 ! nvoverlaysink d. ! queue ! audioconvert ! speed speed=10.0 ! alsasink -e Utils
  • If using webcam, you'll need: sudo apt install v4l-utils and then run: v4l2-ctl -d /dev/video1

Rysnc

  • Run: rsync -azP -e 'ssh -p 3091' --delete ~/Videos seth@158.140.136.216:~

Locate

Search filename on your terminal, e.g. locate deepstream | grep samples

  • Run: sudo apt-get install -y libopenblas-base mlocate && sudo updatedb (it takes some time to update the database)

Passwordless Shutdown/Reboot

  • Elevate user session as root: sudo su
  • Run: echo "<user> ALL=NOPASSWD: /sbin/shutdown" >> /etc/sudoers.d/nano_shutdown, where is defined, e.g. foo ALL=NOPASSWD: /sbin/shutdown
  • Test it out: sudo reboot now

Git-LFS

  • Run: sudo apt-get install git-lfs

Disable System Error Reporting

  • Run sudo vim /etc/default/apport

Install htop

A more verbose top

  • Run sudo apt-get install htop and run htop