adaavr-gccgnatalire

How can I install the ZFP (Zero Foot Print) RTS (Run Time System) for AVR with the Alire package manager for Ada?


How can I install the ZFP (Zero Foot Print) RTS (Run Time System) for AVR with the Alire package manager for Ada?

My project file, I think correctly, contains:

project Avr is
   for Runtime("Ada") use "zfp";
   for Target use "avr-elf";
end Avr;

alire.toml hopefully correction contains:

[[depends-on]]
gnat_avr_elf = ">=11.2.4"

Unfortunately, when running alr build, I get:

gprconfig: can't find a toolchain for the following configuration:
gprconfig: language 'ada', target 'avr-elf', runtime 'zfp'

I found documentation for programming AVR with Ada, but this assumes that I build the tool-chain myself and not have a package manager at least providing the GNU tool-chain.

The same applies to Programming Arduino with Ada.


Solution

  • https://github.com/Fabien-Chouteau/bare_runtime is very adaptable and can at least be brought to build.

    However, the following changes are required:

    diff --git a/bare_runtime.gpr b/bare_runtime.gpr
    index 1f6059c..69b4dd6 100644
    --- a/bare_runtime.gpr
    +++ b/bare_runtime.gpr
    @@ -13,7 +13,7 @@ project Bare_Runtime is
       for Library_Dir use "adalib";
       for Object_Dir use "obj";
     
    -  for Source_Dirs use ("src");
    +  for Source_Dirs use ("src", "config");
     
       package Naming is
          for Spec_Suffix ("Asm_CPP") use ".inc";
    @@ -39,6 +39,26 @@ project Bare_Runtime is
            & ("-g");
          for Switches ("raise-gcc.c") use Target_Options.ALL_CFLAGS
            & ("-fexceptions");
    +     for Switches ("s-stoele.adb") use Target_Options.ALL_ADAFLAGS
    +       & ("-gnatwn");
    +     for Switches ("s-secsta.adb") use Target_Options.ALL_ADAFLAGS
    +       & ("-gnatwn");
    +     for Switches ("s-memtyp.ads") use Target_Options.ALL_ADAFLAGS
    +       & ("-gnatwn");
    +     for Switches ("s-memory.adb") use Target_Options.ALL_ADAFLAGS
    +       & ("-gnatwn");
    +     for Switches ("s-fatsfl.ads") use Target_Options.ALL_ADAFLAGS
    +       & ("-gnatwn");
    +     for Switches ("s-fatllf.ads") use Target_Options.ALL_ADAFLAGS
    +       & ("-gnatwn");
    +     for Switches ("s-fatlfl.ads") use Target_Options.ALL_ADAFLAGS
    +       & ("-gnatwn");
    +     for Switches ("s-fatflt.ads") use Target_Options.ALL_ADAFLAGS
    +       & ("-gnatwn");
    +     for Switches ("a-tags.adb") use Target_Options.ALL_ADAFLAGS
    +       & ("-gnatwn");
    +     for Switches ("a-elchha.adb") use Target_Options.ALL_ADAFLAGS
    +       & ("-gnatwn");
     
          --  Don't inline System.Machine_Reset otherwise we can loose our common
          --  exit system.
    diff --git a/src/s-memory.adb b/src/s-memory.adb
    index bcb4494..a3d3f93 100644
    --- a/src/s-memory.adb
    +++ b/src/s-memory.adb
    @@ -31,7 +31,7 @@
     
     --  Simple implementation for use with ZFP
     
    -pragma Restrictions (No_Elaboration_Code);
    +--  pragma Restrictions (No_Elaboration_Code);
     --  This unit may be linked without being with'ed, so we need to ensure
     --  there is no elaboration code (since this code might not be executed).
    

    The issue seems to be that the GCC/ GNAT toolchain for AVR seems to have unsupported combinations of word sizes for addresses and/ or basic datatypes.

    So far I did not investigate that further, but still wanted to document the status.

    FYI, I did not do any testing so far, so this is really just compiling and most probably will not run without issues.

    To include that, call alr with --use=./bare_runtime bare_runtime, where I assume that you have the code for the bare_runtime as a sub-folder in your project.