The LEON 3 ELF Bareboard Example

This tutorial shows how to build an interactive example and run it with GNATemulator.

Compiling the example

The example comprises 3 small ada units:

  • hello.adb, the main subprogram.
  • uart.ads and uart.adb which perform I/O using the UART.

To build, simply invoke gprbuild in the example directory:

gprbuild --target=leon3-elf --RTS=ravenscar-sfp-leon3

the option ‘–RTS=ravenscar-sfp-leon3’ selects the small foot print ravenscar profile.

Running the example

To launch the example just run:

leon3-elf-gnatemu hello

GNATemulator will automatically load the ELF file (hello) and start execution at the entry point.

Here is a quick run scenario:

Menu:
1) Hello
2) Bye
3) Quit
You choice:
1
hello
Menu:
1) Hello
2) Bye
3) Quit
You choice:
2
bye
Menu:
1) Hello
2) Bye
3) Quit
You choice:
3
qemu: fatal: Trap 0x80 while interrupts disabled, Error state

(The double trap which is an error is used to stop the simulator).

Redirecting the uart

It is possible to redirect the UART to a TCP port:

leon3-elf-gnatemu --serial=tcp::1234,server hello

This will redirect UART1 to the TCP port 1234 of localhost. With the ‘server’ option, GNATemulator will wait for the TCP connection.