[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A. Bareboard and Custom Kernel Topics

This chapter describes how to use the GNAT Pro cross tools to build programs that do not require support from any kernel running on the target hardware.

A.1 Introduction  
A.2 Specifying the Run-Time Library  
A.3 Specifying the Target  
A.4 Character Input/Output  
A.5 Examples  
A.6 Bareboard Debugging  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.1 Introduction

Since GNAT Pro version 7.3, bareboard run-times for powerpc-elf, p55-elf, leon-elf, leon3-elf and arm-elf are provided as customized run-times. They target only specific boards so unless you are using the same board they must be ported to your target. This simplifies the build of a user program as explained in this appendix. However this requires (as before) an initial porting effort. Note that any such changes must be revisited (and likely re-ported) if you update the compiler. See P. Customized Run-Time Topics for adapting a run-time to your board.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.2 Specifying the Run-Time Library

You select the run-time library for your application by specifying the library name to the tools. The name is that of a directory containing the run-time files and directories. (See P. Customized Run-Time Topics for those files and directories.) The name will be a simple directory name when using a run-time library located in a default location. Otherwise, you will specify a path to the directory.

The pre-built run-time libraries have names that reflect their characteristics. For example, those that include "ravenscar" in their names provide a subset of the Ada tasking facilities defined by the Ravenscar profile. Similarly, those libraries with "zfp" in the name implement the "Zero Foot Print" profile.

The pre-built run-time libraries also include the name of the target board they support. The names therefore vary with the target and corresponding toolchain.

For example, the name "ravenscar-full-tms570" denotes a run-time library targeted to the Texas Instruments TM570 board. The library will provide the Ravenscar Profile tasking subset. The "full" in the name indicates that the full sequential (i.e., non-tasking) part of Ada is supported.

There are two ways to specify the run-time library name, depending upon where you do so. Within a project file, you specify the name via the Runtime attribute, as shown in the example below:

 
project Demo is
   ...
   for Runtime ("Ada") use "ravenscar-full-tms570";
   ...
end Demo;

This attribute within the gpr file is the preferred approach.

On the command line, you can use the `--RTS=' switch to specify the run-time library. The switch can also appear in project files but the attribute is preferred.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.3 Specifying the Target

There are two ways to specify the target name, depending upon where you do so. Within a project file, you specify the name via the Target attribute, as shown in the example below:

 
project Demo is
   ...
   for Target use "arm-eabi";
   ...
end Demo;

This attribute within the gpr file is the preferred approach.

On the command line, you can use the `--target' switch to specify the run-time library.

For example, the following shows an invocation of the builder for an ARM target, with the target specified on the command-line.

 
gprbuild --target=arm-eabi -P demo_leds.gpr


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.4 Character Input/Output

The bareboard run-time libraries provide a customized version of package Ada.Text_IO that exports a minimal set of facilities. The package declaration of this customized version is as follows, for all the bareboard run-time libraries:

 
package Ada.Text_IO is

   procedure Get (C : out Character);
   --  Read from console

   procedure Put (Item : Character);
   --  Output character to the console

   procedure Put (Item : String);
   --  Output string to the console

   procedure Put_Line (Item : String);
   --  Output string followed by new line to the console

   procedure New_Line;
   --  Output new line character to the console

end Ada.Text_IO;

The cut-down package is provided for the sake of initial board check-out and development and is not intended to be a production I/O capability.

The implementations of the package body are target dependent, but in each case they work with whatever low-level serial I/O hardware is provided by the board. You may connect a "terminal" application to this hardware in order to interact with the board. This connection, if present, is the "console" mentioned in the comments above.

For example, for the ARM STM32F4 Discovery board, the implementation drives USART1 for this purpose. You can use a USB-to-Serial conversion cable to connect the three pins for this port to a USB port on the host computer, and run an application on the host to monitor that port in order to interact with the board.

The package GNAT.IO is also provided by the bareboard run-time libraries. The interface is slightly different, as shown below:

 
package GNAT.IO is
   pragma Preelaborate;

   procedure Put (X : Integer);
   --  Output integer to specified file, or to current output file, same
   --  output as if Ada.Text_IO.Integer_IO had been instantiated for Integer.

   procedure Put (C : Character);
   --  Output character to specified file, or to current output file

   procedure Put (S : String);
   --  Output string to specified file, or to current output file

   procedure Put_Line (S : String);
   --  Output string followed by new line to specified file, or to
   --  current output file.

   procedure New_Line (Spacing : Positive := 1);
   --  Output new line character to specified file, or to current output file

end GNAT.IO;

Note, in particular, the ability to output an integer value, and the absence of any input routine.

In both the GNAT.IO and Ada.Text_IO cases, the underlying board-specific implementation part is in an internal System.Text_IO package provided by the run-time library. You can change that package to reflect your target's hardware I/O capabilities. However, since the exported interfaces are minimal, you may want to consider using a more target-specific facility as an alternative to GNAT.IO and Ada.Text_IO.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.5 Examples

Given the many variations on the host and target environment that you may be using, it is not possible to formulate a universally applicable sequence of commands for building, loading, and running a program. Instead, this section presents a representative scenario. For illustration purposes the example assumes a Freescale QorIQ P2020 board. Note that there is a full tutorial for building, running, and debugging using one of the ARM boards supported: R. Tutorial: Embedded ARM Ada Project.

Let's start with a simple hello world program:

 
with Ada.Text_IO; use Ada.Text_IO;

procedure Hello is
begin
   Put_Line ("Hello zfp world");
end Hello;

Let's also have a project file `hello.gpr' for this program:

 
project hello is
   for Main use ("hello.adb");
end hello;

Use gprbuild to build the application. You need to specify both the target and the run-time to use.

 
$ gprbuild --target=powerpc-eabispe --RTS=zfp-p2020 -P hello.gpr

This creates an ELF executable `hello' that can be loaded in RAM on the p2020 target. This particular run-time assumes:

In other words, the monitor on the target board is relatively "smart". To run a program that you've built with GNAT Pro Cross (an executable ELF file) you just need to load the program and "go" -- the monitor program keeps track of the start address recorded in the ELF file.

Other targets may have other mechanisms for loading and invoking applications. These mechanisms are described in the target-specific sections within this document.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

A.6 Bareboard Debugging

Debugging applications on bareboard targets involves connecting gdb to the board. You can then either use gdb directly, on the command line, or use GPS to drive it. For some targets, you can also use an emulator (or simulator) instead of an actual target board. Typically a JTAG probe or something similar is involved. The specific mechanisms for connecting, and whether an emulator and/or simulator is available, are target-specific and are discussed in the corresponding sections within this document.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by GNAT Mailserver on October, 23 2014 using texi2html