From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Adam Jensen Newsgroups: comp.lang.ada 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) Organization: A noiseless patient Spider Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 25 May 2018 03:29:59 -0000 (UTC) Injection-Info: h2725194.stratoserver.net; posting-host="ae072277fe39e8be4e367dedd6651a12"; logging-data="30167"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/BlBH/oKkKn8ttIxe3X4ki" User-Agent: Pan/0.144 (Time is the enemy; 28ab3ba git.gnome.org/pan2) Cancel-Lock: sha1:OAj8+umBBmPxbGhs8S+MKlts7uU= Xref: reader02.eternal-september.org comp.lang.ada:52662 Date: 2018-05-25T03:29:59+00:00 List-Id: I am trying the "Digital Output" example described here: 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. > 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" 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).