ARM Development Studio 5 (DS-5) provides a user friendly interface for debugging Linux applications running on ARM platforms. Also built into DS-5 is ARM Streamline, a powerful profiling tool that allows us to measure the performance of Linux applications running on ARM Linux.The PandaBoard is a compact mobile platform built around the Texas Instruments OMAP 4430 processor. With a dual-core Cortex-A9 processor at its heart, it is ideal for running ARM-Linux, and has good connectivity. In this article we will go through the steps required to setup Linux on the PandaBoard using files supplied from Linaro and also the further steps required to setup Linux for use with Development Studio 5 (DS-5) and the Streamline Profiler. This article has been written with PandaBoard as an example but the configuration steps detailed here for DS-5 can be used for any platforms supported by Linaro releases. Linaro images are also pre configured for profiling and tracing in general, so the additional kernel configuration steps can be skipped for Linaro images. Following the Linux setup, we will demonstrate how to debug and profile applications running on ARM Linux using DS-5.
The task of reliably setting up a complete Linux system from scratch can sometimes be a frustrating one. Linaro provides Linux images for several popular development boards based on the ARM architecture, including the PandaBoard. The following sections describe how to use a minimal (called “nano”) build from the 11.05 Linaro release (most recent at the time of writing) to setup ARM Linux on the PandaBoard. The image and hardware pack used below are examples and shall be replaced with images and hardware packs appropriate for your target. Hardware packs are the Linaro way of distributing the hardware-specific packages needed to make an image (such as the nano or ALIP image) work on a particular board without including them in the image itself
To setup Linux on the PandaBoard using the process described here you will need:
Firstly, insert the SD card into your card reader. Then you will need to determine the device node name – most likely it will be /dev/mmcblk0 or /dev/sdb. To find out, you can issue the following commands:Host $ mount | grep /media $ sudo fdisk -l
Re-trying the above commands with and without the SD card inserted will indicate its device node.Once you have determined the device node of your SD card you will then need to unmount the device. To do this, enter the following command:
Host $ sudo umount /media/*
From here on the device node for the SD card will be assumed to be /dev/sdx – please replace this with the device node for your own card.Before we write any images, we’ll need the Linaro image tools. We can use apt-get to get these.
Host $ sudo add-apt-repository ppa:linaro-maintainers/tools $ sudo apt-get install linaro-image-tools
The latest Linaro nano ARM Linux images.Next, pull the latest image and hardware pack from this location using wget below.
Host $ wget http://releases.linaro.org/platform/linaro-n/nano/latest/nano-n-tar-20110628-1.tar.gz $ wget http://releases.linaro.org/platform/linaro-n/nano/latest/hwpack_linaro-panda_20110629-1_armel_supported.tar.gz
After we have downloaded the image and hardware pack, enter the line below to extract the image to the SD card. You will need to execute this as a sudo user. Also, remember to replace sdx with the name of your SD card node.
Host $ sudo linaro-media-create --rootfs ext3 --mmc/dev/sdx --binary nano-n-tar-20110628-1.tar.gz --hwpack hwpack_linaro-panda_20110629-1_armel_supported.tar.gz --dev panda
This will take some time so it might be time for a well earned break and go and make your preferred beverage at this point!After this step is complete your SD card will contain 2 partitions. The first partition contains a FAT32 boot partition containing the boot loader and kernel. The second is an ext3 partition containing the extracted file system.You are now ready to boot up the board. Power off the PandaBoard, place the SD card into its SD card slot and connect the Ethernet port to a DHCP enabled network. So that you can see the board booting and access the console you will also need to setup a serial port connection from your host to the target. The port parameters are 115200bps, 8 Data bits, 1 stop bit, with no parity or flow control. Switch the board on and after booting you should be greeted with a Linux shell prompt!
To enable DS-5 debug support and streamline profiling we will need to install a few things onto the target, including:
All of these can be obtained using apt-get. Before doing this, we’ll need to add the following line to the end of the /etc/apt/sources.list file.
deb http://ppa.launchpad.../arm-ds5/ubuntu natty main
Following this, to get all the required packages on the target, enter the following using your serial console connection to the PandaBoard. Please observe the reserve apostrophes in the command line below.
Target # apt-get update # apt-get install openssh-server gdbserver gator-module-`uname –r` gator-daemon
To confirm correct installation, re-boot the target and then enter ‘lsmod’ at the command prompt. The gator module should be automatically inserted at boot time.
Target # lsmod
This command will output a list of currently inserted modules, one of which should now be gator.ko.
Now that we have sshd installed, we can ssh into the target rather than using the serial connection, which will provide a better command line experience. Firstly, using the serial port set a password for the root user, this must not be blank!
Target # passwd root
Then, find out the IP address of your target by typing:
Target # ifconfig
Following this, confirm you can connect using ssh from your host.
Host # ssh root@<IP_ADDRESS>
Congratulations - the target is now setup for Linux application debugging and profiling with DS-5!
To demonstrate Linux application debugging, we will make use of the “Hello World” example that comes as part of the DS-5 examples. The process is pretty much the same for any Linux executable you need to debug – with the exception that you may also need to pull shared libraries across to the target in where you need to debug shared libraries loaded by the applications. To debug this example follow the steps below. Please refer to the DS-5 user guide if you require more detail.
7. You can now drag and drop the stripped “hello” image from the “hello” project we imported to the file system onto your PandaBoard.
8. On the target, set execute permission on the hello executable: chmod +x hello
9. Now switch to the DS-5 Debug perspective in Eclipse and create a new debug configuration.
10. In the connection tab (see image) use the following settings: Platform: – pandaboard.org – OMAP 4430 Project type: - Linux Application Debug Debug operation: - Start gdbserver and debug target resident application
11. Use the RSE connection you have already setup for the connection as shown in the screenshot below.
12. In the Files tab, enter the absolute path to the hello executable on the target and also add the unstripped hello executable from your workplace. This is required so that debugger can load symbolic information for the target binary.
13. Finally, in the Debugger tab, select "Debug from main".
14. Select "Apply" and "Debug" to start a debug session and connect to your target.
15. You can now debug and step through your application code, set break points, all in a nicely contained fully featured debug user interface.
We will now show how to profile a Linux application running on the PandaBoard. As a simple example, we will profile the “threads” example application supplied with DS-5. To do this, follow the steps below.
16. You can now see where the threads example is being executed on the timeline. In the screenshot above, it’s to the right hand side of the timeline where there is clear cpu activity.
You can now browse through the various views to investigate functions, callpaths and areas of the code that are of interest in more detail.
In summary, we have seen how to setup a Linaro ARM Linux image on the PandaBoard using tools from Linaro that make the setup process relatively straightforward and hassle free. Following this we configured the Linaro image on PandaBoard for use with DS-5 using simple apt-get commands that installs the DS-5 dependencies on target and used DS-5 for debugging and profiling Linux applications running on PandaBoard. In a future article, we shall be discussing Linux Kernel debug using DS-5 on a Linaro image.
Until then, happy debugging and profiling!