Ada on the BeagleBone Black

I have been doing some Ada programming on the BeagleBone Black using gnat and gnat-gps from the Debian repository. One of the things that I’ve been doing is developing a library of routines to access various bits of the board’s I/O. The source is available at https://github.com/BrentSeidel/BBS-BBB-Ada.git and currently covers the LEDs, GPIO, I2C, PWM, and Analog Inputs. I don’t claim that this is anywhere near production ready, but it might provide some useful examples or information, even if you’re not using Ada.

Comments, questions, suggestions are welcome.

Brent

So here is a suggestion / comment. Perhaps write a short blog, or additional readme.md that comments on which files are for what purpose( a few are hard to tell ). Then a blog perhaps for walking through one of the source files from a beginners point of view.

Here is why. Myself, I’m a very experienced programmer in several languages, but I’ve never picked up Ada, and have been meaning to. A very thorough explanation on one of the source files, would answer a lot of questions for me personally.

Anyway, I realize it is not your “job” to necessarily teach Aa from a beginners standpoint. But I do think this would go a long ways to help some experienced developers understand why using Ada in an embedded context could be beneficial. Me, I understand the “selling points” of Ada. At least a few, but what has been holding me back is reading / understanding a language that is very different from C. Ada is actually one of those languages, at least for me personally, where I can not necessarily just start reading through the code, and understand what’s going on.

For instance, it seems like you’re wrapping the sysfs object for each separate peripheral object, but I can not tell exactly how. discussing the finer points of the code, such as that would help me( and hopefully others ) understand the code better. But again, is this your “job” ? No it’s not, but I’d appreciate it, and I’m sure others would as well.

Additionally, how does one duplicate your development system ? An experienced developer will probably be able to figure this out even if they had no prior experience with Ada’s toolset. But an inexperienced developer is going to run into hurdle, after hurdle, until they become frustrated, and just not bother with it all. An experienced developer like me however who knows how to avoid most of these hurdles, will eventually run into the language barrier I spoke of above ( if no prior Ada experience ), and they’re very likely to attempt to learn how to duplicate something similar to what you’ve done in code, from scratch. My own reasoning here is that if I have to learn the language already anyhow, why bother attempting to understand someone elses code, when I can write my own . . .

Brent:

It is a rare treat to see well documented code, which includes explicit handling of (MKS) units. Your Ada raises the bar for anyone designing maintainable code for the BBB. It, at the very least, serves as pseudo-code for anyone programming in any language.

Ada and Jovial before it leaves a bad taste in my mouth from years back. I recall spending more time patching compilers than getting assigned tasks done.

Keep up the good work!

Paul

The compiler and IDE are in the Debian repository. I used aptitude to get them, but once can probably get them from the command line using apt get. There is lots of information and documentation at adacore.com. The problem that I’ve found is that there are plenty of resources that tell you how to do the equivalent of “Hello World” in Ada, but not much to move you beyond the basic state. So, I guess I’m assuming that someone can compile and run “Hello World” in Ada and are looking for a bigger project. I am trying to improve the quality of the comments in the code and README.md as time goes by. I also note that GitHub has an option to create a wiki. I may look into doing something with that should I run into “coder’s block”.

Thank! Today I decided to strip out all of the unit definitions and move them into one common package. Unfortunately, this makes the BBS-BBB repository dependent on the BBS repository. But it will allow all of my projects to see the same units, conversion routines, and functions. Should anyone be doing something else and just want those units, they can grab that package without all of the other dependencies. I would say that Ada has much improved since I first encountered it briefly in the early 90s.

The compiler and IDE are in the Debian repository. I used aptitude to get them, but once can probably get them from the command line using apt get. There is lots of information and documentation at adacore.com. The problem that I’ve found is that there are plenty of resources that tell you how to do the equivalent of “Hello World” in Ada, but not much to move you beyond the basic state. So, I guess I’m assuming that someone can compile and run “Hello World” in Ada and are looking for a bigger project. I am trying to improve the quality of the comments in the code and README.md as time goes by. I also note that GitHub has an option to create a wiki. I may look into doing something with that should I run into “coder’s block”.

Actually, I think the comments you have are fine, and if anything there are too much in the way of comments. Which in this particular case is a good thing. But yes, I realize that gnat, and all that is installed via the Debian package manager, and was speaking more to specific package names. As in which packages are needed. If it’s just gnat, an the other you mentioned, well then I imagine it’ll all be pretty easy to setup.

I also realize there is not much in the way of more than “hello world” out there in the context for help. Which is why I was suggesting that perhaps you could go over one of the source files in greater detail. As far as further documentation goes, I actually found an eBook online which I do believe is free that seems to be very good from an experienced programmers perspective. I believe it was “Ada for java programmers” or some such title. I’m no Java programmer, but Java is syntactically close enough to C that I’ve not had many problems reading though the book yet.

Hi Mr. Brent how can I Use yous Libs ?
For example GPIO . I´ve got a BBB rev.c
Do you hab=ve any example of how to use GPIO and Analog in ?
I got compile the main.adb it´s working nice ! But I don´t know how to use GPIO.

Thanks a lot .!

My email is jmiracy@gmail.com
I´m master degree student in Brasil, Amazonas university
I´ve been installed Xenomai in BBB and ADA. I nee show a Reel time example .
I need You help sir

Thanks a lot in advance

Hi Brent,

Thank you for your excellent work.! Please guide me with two questions.
I have a custom board based on BBB with Linux TI SDK-EVM-06.xx, compiled with arm-linux-gnueabihf- on Ubuntu Linux host machine (board port and embedded Linux works 100%).
Q1: When building BBS-BBB-Ada, do I have to ‘somehow’ point to my gnueabihf toolchain, or can I make it to work with AdaCore’s arm-eabi toolchain? (my TI toolchain don’t have *gnat compiler)
Q2: I would like to use http://www.dmitry-kazakov.de/ada/aicwl.htm widgets in my gui application. I’m not sure how to go about this…?

I managed to get other native Ada examples to work, but can’t get any embedded target examples going (not even a cmd line “Hello World”).

I’m new to Ada development (and fairly new to embedded Linux dev), I appreciate any help, pointers and advice.

Regards
Steph

Hi Brent,

  You are responding to a nearly four year old post.

  <SNIP>

I managed to get other native Ada examples to work, but can't get any
embedded target examples going (not even a cmd line "Hello World").

  If your board is running Linux (one of the Beagleboard Debian releases
from http://beagleboard.org/latest-images ) you could install GNAT (and
GNAT-GPS if running the LXQT desktop with a monitor attached). It may be
slow and resource starved but it will compile stuff.

debian@beaglebone:~$ cat hw.adb
with ada.text_io;
use ada.text_io;
procedure hw is
begin
        put_line("Command Line creation of Ada Program on BBB");
end hw;
debian@beaglebone:~$ gnatmake hw
gcc-6 -c hw.adb
gnatbind-6 -x hw.ali
gnatlink-6 hw.ali
debian@beaglebone:~$ ./hw
Command Line creation of Ada Program on BBB
debian@beaglebone:~$

  I do have to confess that I haven't managed to get GNAT GPS to cross
build Ada programs on Windows. Can't find the compiler. Must be some
missing prefix or something in the project settings since it seems to work
for C programs.

I'm new to Ada development (and fairly new to embedded Linux dev), I
appreciate any help, pointers and advice.

  What is your definition of an "embedded target example"? If you mean
bare-board (no OS) you are going to have to provide an Ada Runtime System
and a lot of configuration stuff to even get it loaded.. (cf:
http://www.inspirel.com/articles/Ada_On_Cortex.html for the effort
involved)

  The desire for GTK-based widgets, OTOH, implies running enough of an
operating system to support X-window applications. That either means you
have a display/keyboard/mouse connected to the BBB and the BBB is running
some X-server software (an LXQT desktop, perhaps) or you have a network
connection to a machine that runs an X-server and accepts client (your
application) connections from the BBB.