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.
- What's The Difference: Ada Then and Now
- C++11 and Ada 2012 - renaissance of native languages?
- Interview: Jason Kridner Discusses The BeagleBone Black
- Ada 2012: The Joy of Contracts
- Ada Offers Advantages Over C And C++
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 – BeagleBoard.org’s $45 1GHz Linux computer”). Also check out beagleboard.org for more details.
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.