Installing Ubuntu 14.04 on Pandaboard

Standard

Introduction

Deployment of ROS Indigo requires all Ubuntu platforms tied to ROS Indigo run Ubuntu 14.04.  The PandaBoard is one of the platforms, so upgrading it from Ubuntu 12.04 to 14.04 is a must.   However, at the time of this writing, we weren’t able to find a pre-built image for PandaBoard, so we followed a relatively complex but well documented procedure published by Robert Nelson.

The procedure basically has these major parts:

  • Download the build tools
  • Download and build the boot-loader (U-Boot)
  • Download and build the Linux Kernel
  • Download the Root file system (Ubuntu 14.04.1)
  • Setup the SD Card
  • Install Kernel and Root File System on the SD Card
  • Setup Networking and Serial I/O
  • Sync and Unmount the SD Card

Once these steps are done, boot the Pandaboard from the SD card, and then perform some additional sudo apt-get install steps to upgrade to the LXDE desktop.

If you prefer just get a pre-built image, download the image from here, and insert a 8 GB SD card, make sure it is unmounted, and apply the following command:

tar zxvf ubuntu_14.04_lxde_panda.img.tar.gz
sudo dd if=ubuntu_14.04_lxde_panda.img of=/dev/mmcblk0 bs=1M

If you prefer doing it the hard way, read on…

Download the Build Tools

Install the 32-bit library prerequisites:

sudo apt-get install libc6:i386 libstdc++6:i386 libncurses5:i386 zlib1g:i386
sudo apt-get install build-essential

Now download the build tools:

wget -c https://releases.linaro.org/14.09/components/toolchain/binaries/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
tar xf gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux.tar.xz
export CC=`pwd`/gcc-linaro-arm-linux-gnueabihf-4.9-2014.09_linux/bin/arm-linux-gnueabihf-

Now test to ensure installation is done properly:

${CC}gcc --version
arm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09) 4.9.2 20140904 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Download and Build the Boot-Loader (U-Boot)

Download the boot-loader

git clone git://git.denx.de/u-boot.git
cd u-boot/
git checkout v2015.01 -b tmp

Now apply the required patches:

wget -c https://raw.githubusercontent.com/eewiki/u-boot-patches/master/v2015.01/0001-omap4_common-uEnv.txt-bootz-n-fixes.patch
patch -p1 < 0001-omap4_common-uEnv.txt-bootz-n-fixes.patch

Build U-Boot:

make ARCH=arm CROSS_COMPILE=${CC} distclean
make ARCH=arm CROSS_COMPILE=${CC} omap4_panda_defconfig
make ARCH=arm CROSS_COMPILE=${CC}

 Download and Build Linux Kernel

First download it:

git clone https://github.com/RobertCNelson/armv7-multiplatform.git
cd armv7-multiplatform

Now check out the proper branch:

git checkout origin/v3.18.x -b tmp

Finally, build it with the supplied script:

./build_kernel.sh

When the build completes successfully, take note of the version number on the screen; it looked something like this:

-----------------------------
Script Complete
eewiki.net: [user@localhost:~$ export kernel_version=3.X.Y-Z]
-----------------------------

Download the Root File System (Ubuntu 14.04.1)

Robert Nelson provide several types of file system, including Debian 7, Debian 8, Ubuntu 14.04.1, and a Debian 7 small flash file system.  For our purpose, we need to install the Ubuntu 14.04.1 file system.

First, download:

wget -c https://rcn-ee.net/rootfs/eewiki/minfs/ubuntu-14.04.1-minimal-armhf-2015-01-20.tar.xz

Then verify:

md5sum ubuntu-14.04.1-minimal-armhf-2015-01-20.tar.xz
fc71da62babe15e45c7e51f8dba22639  ubuntu-14.04.1-minimal-armhf-2015-01-20.tar.xz

and finally extract the file system:

tar xf ubuntu-14.04.1-minimal-armhf-2015-01-20.tar.xz

The extracted files will be copied to the SD card later.

Setup SD Card

Typically a 4 GB SD card will work well. Plug in the SD card into your system. Make sure all partitions on the card are unmounted. Find out the device name, it should be either /dev/sdx or /dev/mmcblk0. You can use the lsblk command to find out (under the /sr0 section):

NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 232.9G  0 disk 
├─sda1        8:1    0   487M  0 part /boot/efi
├─sda2        8:2    0 200.7G  0 part /
└─sda3        8:3    0  31.8G  0 part [SWAP]
sdb           8:16   0 931.5G  0 disk 
└─sdb1        8:17   0 931.5G  0 part 
sdc           8:32   0 238.5G  0 disk 
├─sdc1        8:33   0     1G  0 part 
├─sdc2        8:34   0   260M  0 part 
├─sdc3        8:35   0   128M  0 part 
├─sdc4        8:36   0 223.3G  0 part 
└─sdc5        8:37   0  13.9G  0 part 
sr0          11:0    1  1024M  0 rom  
mmcblk0     179:0    0   3.7G  0 disk 
├─mmcblk0p1 179:1    0  25.5K  0 part 
└─mmcblk0p2 179:2    0   3.7G  0 part 

In this case, the SD card is located at mmcblk0, and it has two partitions.
Now we will define and export a macro:

export DISK=/dev/mmcblk0

and erase the SD card:

sudo dd if=/dev/zero of=${DISK} bs=1M count=10

Now we install the boot-loader:

sudo dd if=./u-boot/MLO of=${DISK} count=1 seek=1 conv=notrunc bs=128k
sudo dd if=./u-boot/u-boot.img of=${DISK} count=2 seek=1 conv=notrunc bs=384k

Next, create the partitions:

sudo sfdisk --in-order --Linux --unit M ${DISK} <<-__EOF__
1,,0x83,*
__EOF__

And format:

#for: DISK=/dev/mmcblk0
sudo mkfs.ext4 ${DISK}p1 -L rootfs
 
#for: DISK=/dev/sdX
sudo mkfs.ext4 ${DISK}1 -L rootfs

Now we mount the partitions (on some systems, auto-mount happens when the SD card is inserted).

sudo mkdir -p /media/rootfs/
 
#for: DISK=/dev/mmcblk0
sudo mount ${DISK}p1 /media/rootfs/
 
#for: DISK=/dev/sdX
sudo mount ${DISK}1 /media/rootfs/

Install Kernel and Root File System on SD Card

Here you will need the kernel version number saved after the kernel build.   Use it below by substituting “3.X.Y-Z” with the kernel version number you wrote down.

export kernel_version=3.X.Y-Z

Now, copy the file system to the SD card:

sudo tar xfvp ./*-*-*-armhf-*/armhf-rootfs-*.tar -C /media/rootfs/

and create the /boot/nEnv.txt:

sudo sh -c "echo 'uname_r=${kernel_version}' > /media/rootfs/boot/uEnv.txt"

Now, setup the device tree binary, depending on which version of Pandaboard you have:

PandaBoard EA1->A3
sudo sh -c "echo 'dtb=omap4-panda.dtb' >> /media/rootfs/boot/uEnv.txt"
 
PandaBoard A4->+ (non ES)
sudo sh -c "echo 'dtb=omap4-panda-a4.dtb' >> /media/rootfs/boot/uEnv.txt"
 
PandaBoard ES
sudo sh -c "echo 'dtb=omap4-panda-es.dtb' >> /media/rootfs/boot/uEnv.txt"
 
PandaBoard ES Rev B3
sudo sh -c "echo 'dtb=omap4-panda-es-b3.dtb' >> /media/rootfs/boot/uEnv.txt"

Now copy the kernel files, device tree binaries, and kernel modules:

sudo cp -v ./armv7-multiplatform/deploy/${kernel_version}.zImage /media/rootfs/boot/vmlinuz-${kernel_version}
sudo mkdir -p /media/rootfs/boot/dtbs/${kernel_version}/
sudo tar xfv ./armv7-multiplatform/deploy/${kernel_version}-dtbs.tar.gz -C /media/rootfs/boot/dtbs/${kernel_version}/
sudo tar xfv ./armv7-multiplatform/deploy/${kernel_version}-modules.tar.gz -C /media/rootfs/

Setup the file system table:

sudo sh -c "echo '/dev/mmcblk0p1  /  auto  errors=remount-ro  0  1' >> /media/rootfs/etc/fstab"

Setup Networking and Serial I/O

Edit the file /etc/network/interfaces:

sudo gedit /media/rootfs/etc/network/interfaces

and add the following:

auto lo
iface lo inet loopback
 
auto eth0
iface eth0 inet dhcp

To setup serial login on Ubuntu, we need to create a new file, /etc/init/serial.conf:

sudo gedit /media/rootfs/etc/init/serial.conf

and put the below contents in it:

start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]
 
respawn
exec /sbin/getty 115200 ttyO2

To setup the wifi, we have to first install some firmware:

git clone git://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git
 
sudo mkdir -p /media/rootfs/lib/firmware/ti-connectivity
sudo cp -v ./linux-firmware/ti-connectivity/* /media/rootfs/lib/firmware/ti-connectivity

and then edit the file:

sudo gedit /media/rootfs/etc/network/interfaces

and add the below contents in it:

auto wlan0
iface wlan0 inet dhcp
    wpa-ssid "essid"
    wpa-psk  "password"

Now, sync the file system, unmount and remove the SD card:

sync
sudo umount /media/rootfs

Booting Ubuntu and Install LXDE Desktop

Insert the SD card into Pandaboard and apply power. Connect HDMI to a monitor and you should see a simple console login. Enter username ubuntu and password temppwd.

To install LXDE desktop, perform the following steps:

sudo apt-get update
sudo apt-get -y install lxde-core slim xserver-xorg x11-xserver-utils

Other desktop configurations, such as ubuntu-desktop, do not work and the system locks up. If you’re having slow or disappearing mouse issue, add the following to the /etc/X11/xorg.conf file:

Section "Monitor"
   Identifier "Builtin Default Monitor"
EndSection
Section "Device"
   Identifier "Builtin Default fbdev Device 0"
   Driver "omap"
   Option "HWcursor" "false"
EndSection
Section "Screen"
   Identifier "Builtin Default fbdev Screen 0"
   Device "Builtin Default fbdev Device 0"
   Monitor "Builtin Default Monitor"
   DefaultDepth 16
EndSection
Section "ServerLayout"
   Identifier "Builtin Default Layout"
   Screen "Builtin Default fbdev Screen 0"
EndSection

After you finished, boot from the new SD card image, login and you should see a pretty desktop like the one shown at the top of this blog.