From: Adam Jensen <hanzer@riseup.net>
Subject: Re: How to configure GNAT GPL on x86-64 Linux for ARM ELF development
Date: Fri, 25 May 2018 03:29:59 -0000 (UTC)
Date: 2018-05-25T03:29:59+00:00 [thread overview]
Message-ID: <pe7vvn$ten$1@dont-email.me> (raw)
In-Reply-To: ly7enuhk14.fsf@pushface.org
I am trying the "Digital Output" example described here:
<http://www.inspirel.com/articles/Ada_On_Cortex_Digital_Output.html>
Compilation seems to be successful with these commands:
gprbuild -c -u -f utils.adb --target=arm-eabi --RTS=zfp-stm32f4
gprbuild -c -u -f pins.adb --target=arm-eabi --RTS=zfp-stm32f4
gprbuild -c -u -f program.adb --target=arm-eabi --RTS=zfp-stm32f4
But linking fails like this:
arm-eabi-ld -T ../flash.ld -o program.elf program.o pins.o utils.o
pins.o: In function `pins__enable_output':
pins.adb:(.text+0x20): undefined reference to `__gnat_last_chance_handler'
pins.o: In function `pins__write':
pins.adb:(.text+0x7a): undefined reference to `__gnat_last_chance_handler'
The symbols in "pins" are:
arm-eabi-nm pins.o
U __gnat_last_chance_handler
U GPIOA_BSRR
U GPIOA_MODER
00000000 D pins_E
00000000 T pins__enable_output
00000060 T pins__write
U RCC_AHB1ENR
Eager to move forward, I cobbled together a GPR project file targeting
the full Ravenscar profile.
#ravenScar.gpr
project Ravenscar is
for Source_Dirs use ("src");
for Ignore_Source_Sub_Dirs use (".svn");
for Object_Dir use "obj";
for Exec_Dir use ".";
for Main use ("program.adb");
for Runtime ("Ada") use "ravenscar-full-stm32f4";
for Target use "arm-eabi";
package Builder is
for Executable_Suffix use "";
for Global_Configuration_Pragmas use "src/gnat.adc";
end Builder;
package Compiler is
for Default_Switches ("ada") use ("-O0", "-gnatwa", "-gnatQ", "-
gnatw.X");
end Compiler;
package Binder is
for Required_Switches ("Ada") use Binder'Required_Switches
("Ada") &
("gnatbind_prefix=arm-eabi-") &
("--RTS=/home/hanzer/.local/gnat-arm/arm-eabi/lib/gnat/
ravenscar-full-stm32f4/") &
("-nostdlib");
for Driver ("Ada") use
"/home/hanzer/.local/gnat-arm/libexec/gprbuild/gprbind";
end Binder;
package Linker is
for Driver use Compiler'Driver ("Ada");
for Map_File_Option use "-Wl,-Map,";
for Response_File_Format use "GCC_GNU";
for Max_Command_Line_Length use "8192";
for Required_Switches use Linker'Required_Switches &
("-L/home/hanzer/.local/gnat-arm/arm-eabi/lib/gnat/ravenscar-
full-stm32f4/adalib",
"-nostartfiles", "-lgnat", "-lc", "-lgnat", "-lgcc",
"-L/home/hanzer/.local/gnat-arm/arm-eabi/lib/gnat/ravenscar-
full-stm32f4/ld",
"-T", "flash.ld");
end Linker;
end Ravenscar;
-------------------------------------------------------------------------
I didn't really expect it to work - I am well into the realm of wild-ass
guesses at this point. This is what happens:
gprbuild -P ./ravenscar.gpr
Compile
[Ada] program.adb
[Ada] pins.adb
[Ada] utils.adb
[Ada] registers.ads
Bind
[gprbind] program.bexch
[Ada] program.ali
program.adb:1: Program cannot be used as a main program
gprbind: invocation of gnatbind failed
gprbuild: unable to bind program.adb
On Wed, 23 May 2018 09:07:51 +0100, Simon Wright wrote:
> I think that the reason why the tutorial works and your attempt doesn't
> is that the tutorial was developed on a Raspberry Pi, which is already
> an ARM-based machine, so the native compiler actually has a runtime
> (i.e. system.ads etc etc) visible to it.
This is so very relevant yet the tutorial seems rather vague [to me] on
this point. It should be explicit, in bold, in a highlighted box on the
front page, IMO. Thanks again for pointing that out. Even on a second
reading, it isn't clear [to me] that using a Raspberry Pi as a software
development platform is the environment of the tutorial.
<http://www.inspirel.com/articles/
Ada_On_Cortex_Documentation_And_Tools.html>
> but a simpler (more memorable!) procedure might be to construct your
> own:
>
> 1. Create directories adainclude/, adalib/
>
> 2. Copy $prefix/arm-eabi/lib/gnat/zfp-stm32f4/gnat/system.ads to your
> adainclude/ ($prefix is the root of your compiler installation, I
> think ~/.local/gnat-arm)
>
> The zfp- (zero footprint) runtime is the closest to what you need, and
> the fact that the -stm32f4 part isn't quite right shouldn't matter; I
> suspect that system.ads is the same for all the zfp runtimes.
>
> Now,
>
> $ arm-eabi-gcc --RTS=. -c program.adb
I will try this next. It's a bit like learning to swim by jumping into
the deep end of the pool (or being thrown in). This article might help:
"Porting the Ada runtime to a new ARM board"
<https://blog.adacore.com/porting-the-ada-runtime-to-a-new-arm-board>
I also ordered a copy of this book (below) since I don't actually know
the Ada programming language (I have plenty of experience with VHDL).
<https://www.amazon.com/Programming-Ada-2012-John-Barnes/dp/110742481X/>
next prev parent reply other threads:[~2018-05-25 3:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-23 6:37 How to configure GNAT GPL on x86-64 Linux for ARM ELF development Adam Jensen
2018-05-23 8:07 ` Simon Wright
2018-05-24 7:35 ` Adam Jensen
2018-05-24 12:12 ` Brian Drummond
2018-05-25 4:45 ` Adam Jensen
2018-05-25 10:50 ` Brian Drummond
2018-05-26 5:06 ` Adam Jensen
2018-05-26 23:58 ` Brian Drummond
2018-05-27 8:26 ` Jacob Sparre Andersen
2018-05-30 19:52 ` JLotty
2018-05-30 21:58 ` Simon Wright
2018-06-03 23:21 ` JLotty
2018-06-04 7:11 ` Simon Wright
2018-05-25 3:29 ` Adam Jensen [this message]
2018-05-25 7:55 ` Simon Wright
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox