Installing and Configuring Ubuntu on the PandaBoard

From HBRC Wiki

Jump to: navigation, search

[Updated for Ubuntu 12.04 and the 3.4.9 RT kernel patches.]

This tutorial describes how to install and configure Ubuntu on the PandaBoard. The tutorial includes instructions for:

  • Installing Ubuntu from scratch.
  • Configuring WiFi to work as an access point.
  • Installing the TI OMAP Extras, which provide capabilities such as accelerated video.
  • Compiling a new kernel with the real-time patches.
  • Testing the latency of the system with the real time patches.


You don't need to complete the steps in every section of this tutorial. The following table shows you which section you should complete.

Goal Complete These Sections
Basic installation
(no WiFi)
Installing The Ubuntu TI OMAP4 Pre-Built Binary,
Completing The Initial Ubuntu Configuration
WiFi Configuring The PandaBoard WiFi
Code Development System Installing Additional Packages And Tweaking Ubuntu
Real-Time Performance Installing Additional Packages And Tweaking Ubuntu,
Building A New Real-Time Kernel From Source,
Verifying That The Real Time Patches Were Installed Successfully
Video Acceleration Installing The TI OMAP Extras


Contents

Prerequisites

To complete this tutorial, you need

  • A PandaBoard.
  • An SD card. [The best size seems to be 8 GB. I've had lot's of problems with 16 GB cards. --Osman]
  • A Linux build system. This is another computer, preferably a fast one, running Ubuntu.
  • A way to access a command prompt on the PandaBoard. You have two choices:
    • Connect your build system to the PandaBoard with a serial cable, and use a program such as minicom.
    • Connect a monitor and keyboard to the PandaBoard.

Installing The Ubuntu TI OMAP4 Pre-Built Binary

This section describes how to install the "preinstalled" version of Ubuntu for the TI OMAP4 processor, which is the processor on the PandaBoard. You can install either a desktop image or a server image. The desktop image contains the Gnome desktop manager, which enables you to use your PandaBoard like a PC. The server image does not include a window manager: interaction with the OS is through a command prompt. The server image is appropriate for a robot that doesn't need the ovehead of a graphical desktop. This tutorial uses the server image. If you prefer to use the desktop image, replace "server" with "desktop" in the steps below.

To install the Ubuntu image, complete the following steps.

  1. Download the latest Ubuntu Texas Instruments OMAP4 preinstalled server image from http://cdimage.ubuntu.com/releases/12.04/release.
  2. Mount an SD card, and make note of the path to the mount point. It might look like /dev/sdc, for example. The last letter should be something other than an "a." The /dev/sda node points to you primary disk; if you copy the Ubuntu image to /dev/sda, you will erase your disk.
  3. Write the Ubuntu image to the SD card by entering the following command:
    sudo sh -c 'zcat ./ubuntu-12.04-preinstalled-server-armhf+omap4.img.gz | dd bs=4M of=/dev/sdx ; sync'
    Replace /dev/sdx with the path to your SD card.

At this point, you have a clean version of Ubuntu on the SD card, but it needs to be configured, which you will do in the next section.


Completing The Initial Ubuntu Configuration

To configure Ubuntu, complete the following steps.

  1. Make sure you will be able to access a command prompt on the PandaBoard either by connecting a serial cable to the PandaBoard or by attaching a monitor, keyboard, and mouse.
  2. Inset the SD card containing the Ubuntu image into the PandaBoard.
  3. Apply power to the PandaBoard.
  4. When prompted, answer the Ubuntu configuration questions.
  5. Approximately five minutes after answering the last question, the PandaBoard will reboot and display a log in prompt.
    Note: There is a bug in the Ubuntu configuration that causes the configuration to start again after the reboot. If you are presented with the configuration questions again after the PandaBoard reboots, mount the sd card on your build system and delete the file /var/lib/oem-config/run.
  6. Verify that you can log in using the user name and password that you created during the configuration.

At this point, you have a functional version of Ubuntu running on your PandaBoard.


Installing Additional Packages And Tweaking Ubuntu

This section show you how to install a few programs that you will need on your Ubuntu system. This section also describes a tweak that can make Ubuntu more responsive.

  1. Install some useful and necessary programs by running the following command:
    sudo apt-get update ; sudo apt-get install git gcc make ssh hostapd python-software-properties dnsmasq
  2. OPTIONAL: To get maximum performance out of your PandaBoard at the expense of power consumption, use the following tweak:
    sudo sh -c "echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"
    The effect of this tweak is most noticable when running the real-time patches (see below). See the following site for more info on this tweak: http://www.pantz.org/software/cpufreq/usingcpufreqonlinux.html. Many thanks to Grégoire for uncovering this tweak.

Configuring The PandaBoard WiFi

This section describes how to configure your PandaBoard's WiFi to connect to a router or, when a router is not available, to start up a WiFi access point.

The instructions here are based on the Advanced Networking for Turtlebot tutorial at ros.org, which is located here:http://www.ros.org/wiki/turtlebot/Tutorials/Advanced%20Networking%20Setup.

  1. Install dnsmasq by running the following command:
    sudo apt-get update ; sudo apt-get install dnsmasq
  2. Download the following three files:
    1. File:Wpa supplicant.conf.doc
    2. File:Dnsmasq.conf.doc
    3. File:Interfaces.doc
  3. Copy the files to their correct locations on your PandaBoard by running the following commands:
    sudo cp Wpa_supplicant.conf.doc /etc/wpa_supplicant/wpa_supplicant.conf
    sudo cp Dnsmasq.conf.doc /etc/dnsmasq.conf
    sudo cp Interfaces.doc /etc/network/interfaces
  4. In the dnsmasq.conf file, change pb7 to the name of your PandaBoard, which you can find by running the hostname command.
  5. In the interfaces file, change wlan-osman to whatever you want. Remember the new name. You will use it in the wp_supplicant.conf file.
  6. In the wpa_supplicant.conf file you will see two networks. The first network is associated with your router. Change the id string to match the new name you chose in the previous step. To generate the other lines for the first network, run the wpa_passphrase command. The second network is the access point that will be created if your router is not available. Don't change the id string: it has to match the string in the interfaces file. You can change the ssid if you want.
  7. Fix a problem with the resolvconf config file by running the following commands:
    sudo mkdir -p /run/resolvconf
    sudo mv /etc/resolv.conf /run/resolvconf
    sudo ln -s /run/resolvconf/resolv.conf /etc/resolv.conf
  8. Reboot.

If all goes well, when you reboot you will have an IP address for eth0 if you are connected to a router with ethernet, and you will have another IP address for wlan0. The IP address for wlan0 will be given by your router if a wireless connection to your router is available, or it will be the address of an access point running on the PandaBoard.

The only problem is that if a wired connection on eth0 is not available, the PandaBoard waits for about two minutes during boot up. Thus, if you know you are going to using the PandaBoard as an access point, you can speed up boot time by manually disabling eth0. To do this, change auto eth0 to allow-hotplug eth0 in the interfaces file.

To force your PandaBoard into access point mode even when your wireless router is available, edit the /etc/wpa_supplicant/wpa_supplicant.conf file, and comment out the lines for your wireless network.

Installing The TI OMAP Extras

The TI OMAP Extras package give you access to the hardware capabilities on the OMAP4 processor, such as video acceleration. Installing this package has the side effect of upgrading the kernel on your PandaBoard to version 3.4. To install this package, complete the following steps:

  1. Add the TI repository by running the following commands:
    sudo apt-get install python-software-properties
    sudo add-apt-repository ppa:tiomap-dev/release
    sudo apt-get update
  2. Install the TI OMAP extra package:
    sudo apt-get install ubuntu-omap4-extras
  3. Reboot.
  4. Run the uname command to verify that the kernel on your PandaBoard in now at version 3.4:
    uname -a

At this point, the TI OMAP Extras are installed on your PandaBoard.

Building A New Real-Time Kernel From Source

This section describes how to build a new version of the kernel that includes the real time patches.

To build the new kernel, complete the following steps:

  1. On your build system, create a new directory, and change to the directory:
    mkdir src ; cd src
  2. Get a copy of the kernel source code from omapzoom.org:
    git clone git://dev.omapzoom.org/pub/scm/integration/kernel-ubuntu.git
    cd kernel-ubuntu
    git checkout ti-ubuntu-3.4-1485.7
  3. Download to the current directory the following patches:
    1. File:000-ducati-rt.patch.doc
    2. File:000-eeti ts.patch.doc
    3. File:000-ezx-pcap.patch.doc
    4. File:000-serial.patch.doc
    5. File:Patch-3-4-9-rt17.patch.doc
  4. Rename each patch file by removing the .doc extension.
  5. Apply the patches.
    patch -p0 < ./000-ducati-rt.patch
    patch -p1 < ./000-eeti_ts.patch
    patch -p1 < ./000-ezx-pcap.patch
    patch -p1 < ./000-serial.patch
    patch -p1 < ./Patch-3-4-9-rt17.patch
    Make sure there are no failing hunks when applying the rt17 patch.
  6. Correct an error in one of the source files by adding #include <linux/cache.h> to the file ./security/apparmor/sid.c.
  7. Download the .config file: File:Config-3-4-9-rt17.doc. Rename the file to .config. Don't forget the dot before "config".
  8. Compile the new uImage file.
    make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- uImage
    If necessary, change arm-linux-gnueabi- to the name required by your cross compiler.
  9. Compile the new module files.
    make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules
  10. "Install" the modules files in a directory called modules. You will copy the module files to your SD card later in this procedure.
    INSTALL_MOD_PATH=../modules make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- modules_install
  11. Insert SD card into card reader on build system.
  12. Mount the partitions on the SD card. In the following commands, replace sdx with the actual path to the SD card partitions on your system.
    sudo mkdir /media/1
    sudo mount /dev/sdx1 1
    sudo mkdir /media/2
    sudo mount /dev/sdx2 2
    If the mount command fails, check if your OS automatically mounted the partitions when you inserted the SD card. If the OS did mount the partitions automatically, either unmount the partitions and remount them using the commands above or use the mounted paths instead of /media/1 and /media/2 in the following steps.
  13. Copy the uImage and the new modules directory to the SD card.
    sudo cp ./arch/arm/boot/uImage /media/1
    sudo cp -r ../modules/lib/modules/3.4.0-rt17+ /media/2/lib/modules
  14. Unmount the SD card partitions.
    sudo umount /media/1
    sudo umount /media/2

At this point, the SD card contains a working version of Ubuntu for the PandaBoard with the real time patches. You can now remove the SD card from the build system and insert it into the PandaBoard.

Verifying That The Real Time Patches Were Installed Successfully

To verify the successful application of the real time patches, insert the SD into the PandaBoard and apply power. Log in, open a terminal, and run uname -r. If the command returns 3.4.0-rt17+, you have successfully applied the real time patches.

To check the latency of the OS, run the cyclictest tool. You can download and build cyclictest by running the following commands:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/clrkwllms/rt-tests.git
cd rt-tests
make

The output of cyclictest before applying the real time patches shows a latency of about 14 ms:

root@panda1:~# sudo ./cyclictest -t1 -p99 -n -i 100 -l 10000
policy: fifo: loadavg: 0.00 0.01 0.05 1/277 1542         
T: 0 ( 1542) P:99 I:100 C:  10000 Min:      0 Act: 1701 Avg:  729 Max:   14157

The output of cyclictest after applying the real time patches shows a latency of 40 us:

root@panda1:~# sudo ./cyclictest -t1 -p99 -n -i 100 -l 10000
policy: fifo: loadavg: 1.62 1.59 0.70 1/308 1738         
T: 0 ( 1738) P:99 I:100 C:  10000 Min:     11 Act:   12 Avg:   12 Max:      40

Acknowledgments

Many thanks to the members of the Robot Reference Platform mailing list and the linux-rt-users mailing list for providing valuable information that helped create this tutorial. In particular, thanks go to Grégoire Gentil for creating a stripped-down config file and for identifying the code branch to use for recompiling the kernel. Thanks to Bob Smith for creating the config file used in the initial version of this tutorial. Finally, thanks to Austin Hendrix for creating the Advanced Networking for Turtlebot tutorial on ros.org, on which the networking instructions in this tutorial are based. --Osman Eralp

More Information

If you have any questions about this procedure, please send a message to the RRP mailing list: http://groups.google.com/group/robotreferenceplatform. You can also track me (Osman) down at the HBRC main monthly meeting or SIG meeting.

Personal tools