ARMing Ada


The Ada programming language has changed over the years (see “What's The Difference: Ada Then and Now”). I recently had a chance to try out AdaCore's latest Ada development system, the GNAT Programming Studio (GPS), on an ARM-based BeagleBone Black (Fig. 1). The BeagleBone Black is home to a 1 GHz Texas Instruments' AM3335x processor based on ARM's Cortex-A8.

I really like the BeagleBone Black. You can check out a webinar I did with Jadon Kridner on the Electronic Design website (watch “BeagleBone Black –’s $45 1GHz Linux computer”). Also check out for more details.

The BeagleBone Black can run applications writing in just about any language. Some of the BeagleBone software is written in C, C++, Python and Javascript. It can also run applications written in just about any programming language including Ada. It can run barebone code but typically it runs Linux.

I can run GPS but it was much easier for me to run it on a PC. I used Fedora 20 but the recommended Linux host platform is Red Hat Enterprise Linux (RHEL). If you don't want to use RHEL then try CentOS. This is the free version.

In any case, the first step was to install GPS on the 32-bit Fedora (Fig. 2) that was running in a virtual machine on a copy of the 64-bit version of Fedora. This includes the IDE and tool suite but it lacks the target specific files needed to create a program. This actually makes sense since the BeagleBone Black version of Linux is not the only one that may be targeted. This tool suite targets Cortex-A class platforms. I'll be taking a look at one that targets barebones platforms based on the Cortex-M family in the future.

This meant that the second step was to copy the library and include files from the BeagleBone Black. It helps to check out the README file. After that it was a trivial exercise to create the quintessential Hello World program and run it on the BeagleBone Black.

One reason I started with the version that target Cortex-A is that there are no compromises on the Ada support. Things like Ada contracts (see “Ada 2012: The Joy of Contracts”) and other Ada safety features are available in all of AdaCore's platforms but some features such as multitasking can be limited by the target platform's capabilities. This is true for just about any programming language, not just Ada. I was able to move some simple Ada applications from x86 platforms to the BeagleBone Black without any changes other than recompilation.

I won't go into the build and debug details because they are the same as with any cross platform development system. It is trivial to set up a remote debug session using Ethernet since the BeagleBone Black has an Ethernet connection and runs Linux. The only difference between this and targeting an x86 system was how fast the host processor was running.

I only skimmed the unit test support available with GNATtest and the code coverage support that is available. AdaCore has a GNAT plug-in for Eclipse if you would rather use that IDE but I found GPS to have all the bells and whistles I was used to from autocomplete to pretty printing.

One nice feature that is portable is multitasking support. This is part of the Ada standard and this implementation takes advantage of the underlying Linux multitasking support (see “Ada Offers Advantages Over C And C++”). Another feature I liked was the coding standards that can be customized. This include SPARK rules (Fig. 3). SPARK is a more restricted form of Ada often used in safety critical applications. Rules can be applied selectively.

So my delving into Ada on the Cortex-A turned out to be almost a non-event. It was trivial to install and portability was great. I did not have a chance to check it out yet but Green Hills Software's AdaMULTI and Atego's ObjectAda also supports the Ada. AdaMulti supports the Ada 95 standard while ObjectAda supports up to Ada 2005 that includes object oriented support. Ada 2012 adds a number of new features including contracts.

You can download the Adacore tools for free from the Libre webite although the Arm tools are not part of the mix yet since they are brand new. The free x86 tools have been available for awhile. They are great for learning Ada. Check out the AdaCore Online University to get started (see “Learn Ada At The Online University”). That is free too. The content is limited but growing.

Many may wonder why I write a good bit about Ada and not just C or C++ but the kinds of embedded work that many developers do these days is bumping into the safety critical and high reliability space where Ada excels. I need to find the references but just using Ada tends to improve a project by reducing the number of errors and reducing project duration. Ada 2012 supports the latest programming methodologies including object oriented programming and support for features like generic functions. Its module system is one of the best and something that causes headaches with C. The standard multitasking support within the language itself makes portability better.

The news is full of computer related issues of major proportions these days from security breaches to automotive abnormalities. Toyota is paying a billion dollar fine for problems that start with programming issues although the fines are more for a cover up. General Motors key lock recall is actually a mechanical problem and Ada would not have helped there.

Still, massive recalls and software issues are not limited to large companies. Companies can incur significant costs with only a few customers when the products are costly or critical.

Anyway, the message here is that Ada is available for us on Arm microcontrollers from a number of sources and AdaCore's stuff works well with these platforms. It can utilize C APIs so existing platform support can be utilized directly although I tended to stick with the standard Ada runtime for portability reasons.

Discuss this Blog Entry 2

on Mar 20, 2014

Hi, I am one of the developers of the SPARK technology. Regarding the checking of SPARK rules (the last image in the post), I'd like to mention that we're about to release a new version (called SPARK 2014) that expands notably the language. The coding standard checker mentioned in the post only checks some rules in the previous SPARK technology (from SPARK 83 to SPARK 2005), for projects who wish to adopt some of these restrictions in their Ada code.

on Mar 26, 2014

I'm sorry, Bill; I've read this article three times, and I'm still a bit confused...

1 - Are you saying that you ran GPS on the BBB? Or that you compiled Ada code that ran on the BBB from an x86 cross-host? Or both?

2 - "You can download the Adacore tools for free from the Libre webite although the Arm tools are not part of the mix yet" So then, where /did/ you get the ARM tools? Did the Good Fairies at Adacore grant you a secret FTP URL?

I don't mean to sound stupid, but I'm honestly having trouble, trying to sort-out this picture...

thanks, - vic

Please or Register to post comments.

What's alt.embedded?

Blogs focusing on embedded, software and systems


William Wong

Bill Wong covers Digital, Embedded, Systems and Software topics at Electronic Design. He writes a number of columns, including Lab Bench and alt.embedded, plus Bill's Workbench hands-on column....
Commentaries and Blogs
Guest Blogs
Mar 6, 2015

Programming Efficiency: Part 2 2

A number of years ago I did some work on a PABX. The device was electromechanical and far from state of the art, but the owner had been talked into spending a bunch of money expanding it and couldn’t justify scrapping it....More
Jan 21, 2015

How To Dumb Down Smart Electronics 8

In our generation of microcontroller-enhanced everything, it has been frustrating at best to see how often the capability of smart hardware has been foiled by the design of poorly purposed software....More
Dec 15, 2014

Who Are You? (I Really Want to Know!) 7

Borrowing a stanza from The Who’s hit song seemed like a good way to bring attention to a critical topic often ignored by engineers. When finding information on a company that has an interesting product, what do we do? Of course, we look at its Web page to learn more....More

Sponsored Introduction Continue on to (or wait seconds) ×