Configuration of NVidia Jetson TK1

[Last update: 2015, 3rd April]

This is the guide to configurate NVidia Jetson TK1 to properly run all the software needed to control MyzharBot… and other robots, why not? 🙂

“The Grinch” custom kernel to enable WiFi and other features

The Jetson TK1 comes from NVidia Labs with  a version of Ubuntu Linux operating system customized for Tegra processor: Linux for Tegra (L4T).
The current version of L4T is the v21.2.1. The system includes drivers for Tegra TK1, but the kernel does not support WiFi.
Since Jetson TK1 can mount Mini PCIe boards, MyzharBot will be able to perform WiFi and Bluetooth communications thanks to an Intel Dual Band Wireless-AC 7260 PCIe Half Mini Card, Dual Band 2.4GHz (Link).
As told before the “original” kernel that comes with L4T v21.2.1 has not support for WiFi, hence we need to install a custom kernel named “The Grinch” provided by Santyago Jarzebski to enable Wifi.

The instructions to install the custom kernel are available on the NVidia Developer Forum. Since they are updated very often and they are written very well, I chose to not replicate them on this page, but I suggest to you to follow the steps directly by the developer forum page.
Please note that installing “The Grinch” you will lose the full content of the flash of your Jetson TK1, hence please move on an Usb Key, or somewhere else, everything you want to save before proceding.


Before starting

Just to remember this: if you did not changed it, the default user of Nvidia Jetson TK1 is “ubuntu” and the default password is “ubuntu“. So when running “sudo” for the first time rembember that you must enter “ubuntu” as password… unless you changed it.

CUDA Toolkit and OpenCV installation

After the installation of the custom kernel you must install the latest CUDA Toolkit and OpenCV Library:

CUDA Toolkit installation

  1. Download the toolikit Debian package for L4T (i.e. CUDA 6.5 Toolkit for L4T Rel 21.2) from the official site
  2. Install the package:
    sudo dpkg -i cuda-repo-<distro>_<version>_<architecture>.deb
  3. Update the repository:
    sudo apt-get update
  4. Install the toolkit:
    sudo apt-get install cuda-toolkit-6-5
  5. Add the user to the video group:
    sudo usermod -a -G video <username>
  6. Add the CUDA paths to your .bashrc:
    echo "# Add CUDA bin & library paths:" >> ~/.bashrc
    echo "export PATH=/usr/local/cuda/bin:$PATH" >> ~/.bashrc
    echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib:$LD_LIBRARY_PATH" >> ~/.bashrc
    source ~/.bashrc
  7. Verify the installation:
    nvcc -V

You can compile the examples to test the CUDA capabilities… please consider that the compilation of the samples will take a lot of time and it is useful only to satisfy your curiosity:

  1. Go to the samples folder:
    cd /usr/local/cuda/samples
  2. Compile:
    sudo make -j4
  3. After the compilation you will find the examples in the folder: /usr/local/cuda/samples/bin/armv7l/linux/release/gnueabihf

Default OpenCV4Tegra installation

  1. Download the OpenCV4Tegra Debian package (i.e. OpenCV4Tegra for L4T 21.x) from the official site
  2. Install the package:
    sudo dpkg -i libopencv4tegra-repo_l4t-<version>_<architecture>.deb
  3. Update the repository:
    sudo apt-get update
  4. Install the library:
    sudo apt-get install libopencv4tegra libopencv4tegra-dev
    

Please consider that the default OpenCV4Tegra will be automatically removed when you will install the ROS packages that depends on OpenCV. ROS is designed such to depends on the release of OpenCV available in Ubuntu repository and it will not recognize OpenCV4Tegra as a good version, so it will replace the library. We are trying to understand how to overcome this problem… the solution is near, but not yet complete.
OpenCV in the official Ubuntu repository is not optimized for Tegra TK1 processor (2-3 FPS of performance difference on standard CPU code for a vehicle tracking application) and it has not CUDA GPU support… and we pretend to use OpenCV with CUDA ^_^


Tweaks

A few tweaks to make the Jetson TK1 more usable. The majority part of there Tweaks can be automatically applied using the scripts by Kangalow on Jetsonhack blog.

Add Universe and Multiverse packages repository

Open a new terminal (Ctrl+Alt+t) and enter the following commands:

sudo apt-add-repository universe
sudo apt-add-repository multiverse
sudo apt-get update

Change system hostname

The default hostname for “Linux for Tegra” system is “tegra-ubuntu”. We want to call our robot with its name also over the network.

  1. Change hostname
    sudo gedit /etc/hostname
  2. Replace “tegra-ubuntu” with “myzharbot
  3. Save and exit
  4. Modify hosts:
    sudo gedit /etc/hosts
  5. Replace each “tegra-ubuntu” with “myzharbot
  6. Save and exit

Activate Bash completition

Open a new terminal (Ctrl+Alt+t) and enter the following commands:

sudo apt-get install bash-completion command-not-found -y
exit

Now logout and login again

Install Git and Aptitude

sudo apt-get install git -y
sudo apt-get install aptitude -y

Shutdown to power button

To shutdown the board directly pressing the “Power” button, without confirmation:

  1. Install dconf-tools:
    sudo apt-get install dconf-tools
  2. Run dconf editor:
    dconf-editor
  3. Navigate to org.gnome.settings-daemon.plugins.power and set default button-power action to shutdown
Power Button option in dconf-tools

Power Button option in dconf-tools

Disable Lock by timeout

Disable the “Lock” functionalities:

  1. Click on “System Settings” in the Unity sidebar
  2. Select “Brightness & Lock”
  3. Put “Lock” to OFF
  4. Uncheck “Require my password when waking from suspend”

Internet browser

I like “Chrome”, but I faced continuous blocks using “Chromium”, so I suggest to use “Firefox” internet browser that comes with Jetson TK1 by default.

CPU performances

MyzharBot needs elaboration power… so we set CPU to “performance” automatically al boot.

  1. Open a new terminal (Ctrl+Alt+t)
  2. Create maxPerformance.sh:
    sudo gedit /usr/local/bin/maxPerformance.sh
  3. Add the following code in it:
    #!/bin/sh
    
    # Set CPU to full performance on NVIDIA Jetson TK1 Development Kit
    if [ $(id -u) != 0 ]; then
    echo "This script requires root permissions"
    echo "$ sudo "$0""
    exit
    fi
    
    # To obtain full performance on the CPU (eg: for performance measurements or benchmarking or when you don't care about power draw), you can disable CPU scaling and force the 4 main CPU cores to always run at max performance until reboot:
    echo 0 > /sys/devices/system/cpu/cpuquiet/tegra_cpuquiet/enable
    echo 1 > /sys/devices/system/cpu/cpu0/online
    echo 1 > /sys/devices/system/cpu/cpu1/online
    echo 1 > /sys/devices/system/cpu/cpu2/online
    echo 1 > /sys/devices/system/cpu/cpu3/online
    echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
    
    # Clock the GPUs to max speed
    echo 852000000 > /sys/kernel/debug/clock/override.gbus/rate
    echo 1 > /sys/kernel/debug/clock/override.gbus/state
    
  4. Save and exit
  5. Modify /etc/rc.local adding the following lines just before exit o:
    # Turn up the CPU and GPU for max performance
    /usr/local/bin/maxPerformance.sh
  6. Save and exit
  7. Reboot to apply

Remote Desktop

It may be useful to connect to MyzharBot remotely using a graphical interface. Ubuntu 14.04 provides a default Desktop sharing tools named “vino“.  We must activate it:

  1. Open Unity’s finder (Alt+F2)
  2. Enter: Desktop sharing
  3. Select the “Desktop Sharing” icon
  4. Check “Allow other users to view your desktop
  5. Check “Allow other users to control your desktop
  6. Uncheck “You must confirm each access to this machine
  7. [optional] Check “Require the user to enter this password:
  8. Check “Automatically configure UPnP router to open and forward ports

You can now connect from a remote computer using: vncviewer <jetson’s IP or hostname>

Running scripts on boot

The easiest way to run scripts as root on every boot, is to add your commands to /etc/rc.local editing it with gedit or nano or vi.

Enable Serial Port access

In Ubuntu “normal” users have not the right to access serial port unless you change access right ( e.g. sudo chmod 666 /dev/ttyUSB0).

To automatically access a serial port is enough to add the user to the group “dialup“:

sudo usermod -a -G dialout ubuntu

Remember to replace “ubuntu” with the correct username if you do not use the default user provided by Jetson Linux 4 Tegra.

Disable USB Autosuspend and Enable USB 3.0

By default USB3.0 port is not enabled and it is detected as a “simple” USB2.0 port.
You can enable it with the folowing command

sudo sed -i 's/usb_port_owner_info=0/usb_port_owner_info=2/' /boot/extlinux/extlinux.conf

Default Linux for Tegra is configured to save energy, so the USB ports are turned off when not used. This can bring problems with USB periferals. To disable USB autosuspend we can use this command:

sudo echo -1 > /sys/module/usbcore/parameters/autosuspend

To avoid to enter manually this command every time we boot the robot we can execute it automatically at every boot:

 

  • Open a new terminal (Ctrl+Alt+t)
  • Create maxPerformance.sh:
    sudo gedit /usr/local/bin/disableUSBAutosuspend.sh
  • Add the following code in it:
    #!/bin/sh
    
    sudo sh -c 'for dev in /sys/bus/usb/devices/*/power/autosuspend; do echo -1 >$dev; done'
    
  • Save and exit
  • Modify /etc/rc.local adding the following lines just before exit o:
    # disable USB autosuspend
    /usr/local/bin/disableUSBAutosuspend.sh
  • Save and exit
  • Reboot to apply

 


Jetson TK1 as WiFi access point

To connect to the robot it is very useful that it can act as a WiFi access point, so you do not need to know its IP address, only turn on the controller PC and connect to the “MyzharBot-WiFi” SSID.

There is a simple way to enable Wifi access point on Ubuntu using Unity default Network Manager:

  1. Disable WIFI and plug in an internet cable to your laptop so that your Ubuntu is connect to a wired internet and wireless is disabled.
  2. Go to Network Icon on top panel -> Edit Connections …, then click the Add button in the pop-up window.
  3. Choose Wi-Fi from the drop-down menu when you’re asked to choose a connection type
    1. In next window, do:
    2. Type in a connection name (i.e. MyzharBot-WiFi). The name will be used later.
    3. Type in a SSID (i.e. MyzharBot-WiFi)
    4. Select mode: Infrastructure
    5. Device MAC address: select your wireless card from drop-down menu.
  4. Go to Wi-Fi Security tab, select security type WPA & WPA2 Personal and set a password. You can also leave the connection Open… it’s your oen choise.
  5. Go to IPv4 Settings tab, from Method drop-down box select Shared to other computers.
  6. Click Save

After above steps, a configuration file created under “/etc/NetworkManager/system-connections“directory. File name is the same to the connection name you typed in step 3-B.

  1. Now press Ctrl+Alt+T on keyboard to open terminal. When it opens, paste the commands below and hit enter to edit the configuration file:
    gksu gedit /etc/NetworkManager/system-connections/wifi-hotspot
  2. Replace wifi-hotspot with the connection name you typed in step 3-B.
  3. When the file opens, find out the line mode=infrastructure and change it to mode=ap.
  4. Finally save the file.

When everything’s done, enable WIFI from Network Manager icon on the panel. It should automatically connect to the hotspot you created. If not, select “Connect to Hidden Wi-Fi Network …” and select it from the drop-down box.

The robot will now get automatically the IP 10.42.0.1 and a DHCP server is enabled, so every device that connects to “MyzharBot-WiFi” will get an IP in the class 10.42.0.*

When you will boot the Jetson TK1 after this configuration the MyzharBot-WiFi willl be automaticaclly active, so if you want to connect to a different wifi network you must disconnect it and select one of the available connection using Network Manager.

You can find the original full guide and other interesting stuffs on UbuntuHandbook Blog


ROS – Robot Operating System installation

Since September 2014 MyzharBot is driven by ROS, the Robot Operating System provided by Willow Garage. ROS is free and is supported by a huge worldwide community.

The installation of ROS on Jetson TK1 is really simple, the guide to install the base package is available on the ROS wiki site. Please follow the guide step by step, remembering at step 2.5 to install only “ros-indigo-ros-base” package, other package will be needed for MyzharBot, but they will be installed in the next future.

To install the software to control MyzharBot you can follow the guide on the page “RoboController-ROS“.

The software to control MyzharBot is getting available on the official repository of “Officine Robotiche” on Github platform.

The full documentation is available in the section of the site dedicated to ROS


 

OpenNI2 installation for Asus Xtion Pro Live outside ROS framework

Even if MyzharBot will use ROS framework to work, a guide about the installation of OpenNI2 for Asus Xtion Pro Live outside ROS is available here

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.