Playing with DS-5 CE and BeagleBone Black

The ARM® Development Studio 5 (DS-5) Community Edition (CE) has been extended to support the community of ARM Embedded Linux users, and it now works on Apple Mac hosts too!  DS-5 Community Edition is available as a free download from ARM, and enables you to create, compile, debug and profile Linux applications quickly and easily, whilst retaining its debug and profiling capabilities for Android native application developers too.

  
DS-5 Community Edition running on Apple MacBook, connected to BeagleBone Black



In this blog, I'll show how to debug and profile the Open Source "Xaos" fractal rendering application running under Linux on the new BeagleBone Black using DS-5 Debugger, and how to profile the system using the ARM Streamline performance analyzer.  BeagleBone Black is based on an ARM Cortex®-A8 Sitara AM3359 processor running at 1GHz, with 512MB DDR3 RAM.


BeagleBone Black, close-up


Of course, DS-5 Debugger and Streamline can also be used to debug and profile your own Linux or Android applications on other ARM processor-based platforms in a similar way.  This blog is not intended to be a detailed tutorial, but just an overview of the main steps needed to debug a Linux application.

Setting Up

To get started, first download DS-5 Community Edition from ARM and install it on your host machine (Windows PC, Linux box, or Apple Mac).  On start-up, enter the Activation Code to license DS-5 CE - this will give you access to all the DS-5 CE components.  Alternatively, if you already have Eclipse installed, you can download and install the DS-5 Debugger and Streamline plug-ins from the Eclipse Update Site, and on start-up, you'll be prompted to install a DS-5 CE license.  In either case, if you want, you can purchase a license upgrade later that enables even more features.

Next, prepare your ARM processor-based Linux target platform.  Consult the Getting Started instructions for BeagleBone Black.  Other detailed instructions are available elsewhere on how to build a kernel and setup a filesystem for BeagleBone Black "" we chose Ubuntu 12.10.  To allow Linux application debug, you'll need to ensure gdbserver is present on the Linux target (apt-get install gdbserver).  DS-5 CE comes with Remote System Explorer that allows you to easily copy files between your host PC and the Linux target. To use RSE, the ssh daemon (sshd) must be running on the Linux target.  For file transfer, RSE makes use of sftp-server, so that must be present on the Linux target too.  To profile your application with Streamline, you must build gatord and gator.ko alongside the kernel in the usual way.  To run a graphics-intensive application like Xaos, you may also need to apt-get some graphics libraries such as gtk, cairo, pango, glib.

Next build your application.  We used the Open Source "Xaos" fractal rendering application.  This is provided within the Examples supplied with DS-5 or can alternatively the sources can be downloaded from SourceForge.  For best performance on BeagleBone Black, we built Xaos for hardware floating-point, to match the Ubuntu 12.10 hardware floating-point file system.  We also built Xaos multi-threaded, to demonstrate DS-5's support for debug and analysis of multi-threaded apps.

Debugging the Linux Application

We'll be debugging this Linux application via gdbserver.  The simplest way to establish an application debug connection to the BeagleBone Black is to set up a Linux/SSH connection with "Remote System Explorer" (RSE), then create a debug launch configuration that uses that RSE connection.

In the Remote Systems tab, create a New connection.  Select "Linux" [Next], enter the IP Address, and name it (e.g. "My BeagleBone Black") [Next], select "ssh.files" [Finish].  When you first try to connect to the target, RSE will ask you to enter the User ID and Password.  The Properties for the connection will end-up looking something like:

  Following a successful RSE connection, you can drill down into the remote target's file system in Eclipse, and drag'n'drop any needed files from host to target:

To create a debug launch configuration that uses that RSE connection, select Run -> Debug Configurations..., then create a New configuration named, for example, "xaos-gdbserver-example". 

In the Connection tab's target tree view, select Linux Application Debug -> Application Debug -> Download and debug application.  It will automatically use the RSE connection made earlier by default:

4-ConnectTab_updated.png

In the Files tab, enter the stripped executable to download, and the location of the unstripped executable containing the debug information to allow debug at source level:

5-FilesTab_updated.png

Finally, click on Debug.  DS-5 Debugger will download the stripped executable onto the target via RSE, start gdbserver on the target, read the debug information from the unstripped executable, and run to a breakpoint at main().  You can then view the source, run, stop, single-step, set breakpoints, set watchpoints, view registers, view variables, view disassembly, view memory, view symbols, view the stack backtrace for each thread, and so on.

6-Debug.png
(click to enlarge)


  
To view the graphical output from Xaos, we didn't have an LCD screen connected to the BeagleBone Black, but could redirect the graphical screen output to the XQuartz X server instead, by setting e.g. "export DISPLAY=[host IP address]:0.0" in the Environment tab of the Debug Configurations dialog:

Profiling the Linux Application

Streamline is ARM's performance analyzer, for profiling the behaviour of individual applications within whole Linux and Android systems.  To analyse the performance of the Xaos application, we simply need to start the application running, then point Streamline at it, to capture analysis data.

In the Streamline tab, first enter the IP address of the target:

Then click on the Capture & Analysis Options button, and add the location of the unstripped executable from which to read debug information, then press Save.



It is also possible here to select the use of ARM's low-cost Energy Probe that can be used to correlate target activity with energy usage on up to three power rails simultaneously.

  Then click on the Counter Configurations button, and select the target's hardware counters and kernel's events that you want to track, then press Save.


The list of available counters and events is dependent on the target ARM processor, the kernel in use, and the DS-5 licence in use.

Finally, start the application running and click on the Capture button to start capturing.  Streamline's Live View (new in DS-5 v5.14) immediately shows you the data coming from the BeagleBone Black in real time.  Once you have captured activity over a sufficient length of time, stop the capture, and Streamline will generate an analysis report, starting with the Timeline:

10-Timeline.png
(click to enlarge)

Here, we can see the workload of each thread within Xaos, together with their interaction with the Linux scheduler and other parts of the system, augmented by Streamline's textual and visual annotation feature.  In this example, Streamline is showing an intense period of activity by all five Xaos threads (bottom centre of this view), where the first set of calculations are made before the first Mandelbrot graphics frame is displayed, followed by regular bursts before each subsequent frame.

Clicking on the Functions tab then reveals the contribution of individual functions.  Here we can see that calculate() is the function within Xaos that consumes most time:

In the full-featured version with the upgraded license, we could see more detail, for example, which lines in the source code / assembler were taking the most execution time.

To summarize, we have seen how the features of DS-5 Debugger and Streamline make it easy to debug and profile Linux-based systems, and how these can be deployed successfully on latest low-cost development boards such as the BeagleBone Black.

  
Below is a video that introduces the new features in the ARM DS-5 toolchain version 5.14 including ARM big.LITTLE Processing support, improved compiler, multi-core debugger and trace synchronization, power and temperature monitoring and much more...

  • I didn't happen to see an option for OSX.  Assuming you have to add the plugin to an existing Eclipse install for OSX?
  • I didn't happen to see an option for OSX.  Assuming you have to add the plugin to an existing Eclipse install for OSX?


      Yes, that's correct.  For OS X, you must add the DS-5 plug-in to an existing Eclipse installation.  OS X versions 10.7 and 10.8 are currently  supported.  The DS-5 plug-in includes both DS-5 Debugger (for native language application debug) and the ARM Streamline performance analyzer (Basic features), to assist your application development and optimization.  Hope this is useful to you.


  • Stephen,

    When installing the Eclipse plugin instead of the standalone DS-5, I do not see that it includes the Xaos demo. So I downloaded it from SourceForge, configured it, built it on the target using the default Angstrom Linux with GTK+3-dev and the usual packages installed. I could not get DS-5 to cross compile the xaos project using the makefile generated from the ./configure on the target (after right-clicking the remote xaos-3.5 folder and selecting "Create Remote Project", which seemed to sync the folder contents and create a project out of it).

    Currently, I am running Windows 7, so I installed Xming. It did not work. I plugged the BBB into my Mac and the xaos demo displays over X11 just fine. A little more digging is showing that the Xming is denying the remote connections. I could not find the way to do the equivalent "xhost +" so it is not being used.

    I would like some clarification for the DS-5 Debugger configuration. How can I use the example binary when it is not shipped with the plugin installation? My debug configuration displays the error: "[Files]: Variable references non-existent resource : ${workspace_loc:/BBB_xaos-3.5/bin/xaos}". I sftp copied from remote to local and pointed the debug configuration to that and it works now.

    So really the only point left is this: How can I cross compile the Xaos project on the host before deploying to the BBB?

    Cheers,
    Joe
  • Hi Joe,  Thanks for trying out DS-5 - I'm glad to hear you were able to build Xaos at least natively on your target.

    >When installing the Eclipse plugin instead of the standalone DS-5, I do not see that it includes the Xaos demo.

    As shown at http://ds.arm.com/ds-5-community-edition, the DS-5 Examples are not provided as part of the DS-5 plugins from the Eclipse update site (red box on the right), but they are provided as part of the full DS-5 CE installation (green box on the left).  So suggest you install the full DS-5 CE version, if only to get hold of the DS-5 Examples.  You can even uninstall it afterwards if you don't want to use it.  You can find the DS-5 Examples for Linux in ...\DS-5\examples\Linux_examples.zip.

    >How can I cross compile the Xaos project on the host before deploying to the BBB?

    The DS-5 Linux Examples include Xaos and Gnometris, and a hand-crafted set of makefiles that make use of the Linaro cross-compiler (arm-linux-gnueabihf-gcc) as supplied with DS-5.  The makefiles also need access to some Linux headers and libraries, that you can either copy from your target to the host, or download from the DS-5 Downloads page of ARM Development Studio 5 (DS-5) Web Site

    >Xming is denying the remote connections.

    Try selecting “No access control”.  Start the XLaunch wizard from All Programs > Xming > XLaunch. Choose Multiple Windows, "Next >", Start no client, "Next >", check No Access Control, "Next >" and click the Finish button.  Use of No Access Control is simple, but insecure. Any machine connected to the same network as your host will be able to open windows on the host.

    Hope this helps with your investigations.

  • Stephen,

    Thank your for the prompt reply.

    In an attempt to have a more "native" experience with development, I have installed Linux (Mint/Ubuntu) onto my development machine and have started with a "fresh" DS-5 Community Edition full install plus Linux Distribution optional download (DS500-BN-00009-r5p0-15rel1.zip). Things are definitely smoother, so far.

    As per the README, I used the Help->Cheat Sheets... trick to import the locally installed examples to my workspace as well as the optional Linux distribution package. A potential gotcha is that you must click the "Click to Perform" or "Click to Begin" link within the "Introduction" section first. Then you must skip the Baremetal things in order to get to the Linux imports. There are two Linux imports, one for the builtin examples and one for the optional distribution package, which you need if you care about things like building the builtin linux examples.

    If one wanted to use the default Angstrom distribution of the BBB, it is not immediately clear which "distribution" files you might use in order to successfully compile xaos. Perhaps it would be enough to change the "kernel" folder to the Angstrom distro's kernel source?

    In any case, with the default settings and the optional distribution package installed, the first build failed. The Eclipse PATH to /usr/local/DS-5/bin had not been set. We do this via the menu: Window->Preferences->C/C++>Build->Build Variables->Show system variables->PATH. Add /usr/local/DS-5/bin to the top of the list. Apply. OK. Now it builds.

    Like a typical embedded engineer, the successful build is my success for today. Tomorrow I shall actually test the build by deploying it. Wish me luck. =)

    Cheers,

    Joe

  • Hi again Joe,

    Hope you are still having fun playing with DS-5 CE and BeagleBone Black.


        >If one wanted to use the default Angstrom distribution of the BBB, it is not immediately
    >clear which "distribution" files you might use in order to successfully compile xaos.
    >Perhaps it would be enough to change the "kernel" folder to the Angstrom distro's kernel source?

        Building Xaos does not depend on the kernel sources, but does depend on the filesystem. 

        Taking a look inside the makefile, you'll see we've configured this Xaos build to use the GTK driver, so the GTK-related graphics libraries such as gtk-x11-2.0, gio-2.0, gdk-x11-2.0, cairo, ... need to be present on your host machine and in the target's filesystem, and the corresponding header (include) files need to be present on the host.  Alternatively, you could experiment with building using one of the other graphics drivers supported by Xaos. 

        In addition, Xaos can be built as hard-float ABI or full software floating point ABI (see the FLOAT switch in the makefile), to match your BBB filesystem.

        Hope this helps you to make some further progress.

  • Stephen,

    Thanks for all the help so far. My hello worlds and the xaos apps compile fine, now it's time to lock down the development environments and platform for the team.

    I saw that you mentioned OS X is now supported for DS-5. I downloaded the latest Eclipse CDT, installed the DS-5 plugin via the ARM url, but cannot compile anything. I have looked around a little bit, but it appears that the plugin does not install any sort of Linaro GCC (specifically, arm-linux-gnueabihf). I assume this means I have to source my own arm-linux-gnueabihf-gcc and get it into the Eclipse path for things to work, right? #1

    Also, is there any good documentation about getting that DS-5 Eclipse plugin bootstrapped to the point of compiling code (such as importing the Linux examples without cheat sheets, how to extract the cheat sheets from the DS-5 full installers, compiler setup)?

    EDIT: #1 I found an older Linaro for OS X here which seems to get the DS-5 plugin to the next step:
    http://trismer.com/downloads/arm-linux-gnueabihf-osx-2012-08-28.tar.gz

    Cheers,
    Joe
  • Hi again Joe,

    Glad to hear you're planning to roll-out DS-5 to your team.

    You are correct that the Linaro GCC toolchain is not provided as part of the DS-5 plugin from the Eclipse update site, though is provided as part of the full DS-5 CE installation.  The DS-5 plugin is intended for folk who want to augment an existing working development environment with DS-5 Debugger and the ARM Streamline performance analyser.  It does not include any compiler as it is assumed that you already have one.  By contrast, the full DS-5 CE install includes everything you need to get started, including a recent Linaro GCC (v4.7.3 2013.03).  Are you able to install that instead?

    If not, then you'll need to source your own arm-linux-gnueabihf-gcc and add it into the Eclipse environment.  There is a Knowledge Article that describes how to do this:
    How do I use a custom gcc toolchain with Eclipse?

    To import the Linux examples without using the cheat sheets, perform the following steps: 

    • Launch Eclipse for DS-5
    • Close the Welcome screen, if it appears
    • Go to 'Project' menu and ensure that 'Build automatically' is NOT ticked.
    • Go to 'File' menu and select 'Import...'. The Import wizard opens.
    • Open the 'General' folder
    • Select 'Existing Projects into Workspace'
    • Press 'Next'
    • Select 'Select archive file', then press 'Browse...' next to it. A file dialog opens.
    • Navigate to the directory where the example zips are located.
      For a default install on Windows, this is C:\Program Files\DS-5\examples
    • Select Linux_examples.zip, then press 'OK'
      The 'Projects:' field populates with all of the projects found in that folder.
    • Press 'Finish'. The 'Project' view populates with all of the projects.


    Hope this helps your deployment of DS-5!