comp.lang.ada
 help / color / mirror / Atom feed
* Building gnat-gpl-2011-avr-windows from scratch in GPS
@ 2012-04-09  3:18 Rego, P.
  2012-04-09  7:23 ` Simon Wright
  0 siblings, 1 reply; 9+ messages in thread
From: Rego, P. @ 2012-04-09  3:18 UTC (permalink / raw)


Hello,

I am trying to build the gnat-gpl-2011-avr-windows toolchain in GPS with a simple project (which I do not expect to run on an AVR chip for now). So I have installed on Windows 7 machine the gnat-gpl-2011-i686-pc-mingw32-bin.exe and the AVR gnat-gpl-2011-avr-windows-bin on c:\GNAT\2011. 

I configured a GPS project file as

project Test is
   package Compiler is
      for Default_Switches ("ada") use ("-gnat05");
   end Compiler;

   package Ide is
      for Gnat use "avr-gnat";
      for Gnatlist use "avr-gnatls";
      for Debugger_Command use "avr-gdb";
   end Ide;

   for Source_Dirs use (".", "src");
   for Main use ("main.adb");
end Test;

When I try to build, it returns me

avr-gnatmake -f -d -PC:\test\test.gpr main.adb
avr-gcc -c -gnat05 -I- -gnatA C:\test\src\main.adb
avr-gnatbind -I- -x C:\test\main.ali
avr-gnatlink C:\test\main.ali -o C:\test\main
c:/gnat/2011/bin/../lib/gcc/avr/4.5.3/../../../../avr/bin/ld.exe: cannot find -lc
collect2: ld returned 1 exit status
avr-gnatlink: error when calling C:\GNAT\2011\bin\avr-gcc.exe
avr-gnatmake: *** link failed.

[2012-04-09 00:13:05] process exited with status 4 (elapsed time: 00.25s)

So I included in GPS project file some options:

   package Linker is
      for Default_Switches ("ada") use ("-O", "-mmcu=avr6", "-nostdlib", "-lgcc", "-Wl,-mavr6,-Tdata=0x00800200");
   end Linker;

and now when I try to build it returns me

avr-gnatmake -f -d -PC:\test\test.gpr main.adb
avr-gcc -c -gnat05 -I- -gnatA C:\test\src\main.adb
avr-gnatbind -I- -x C:\test\main.ali
avr-gnatlink C:\test\main.ali -O -mmcu=avr6 -nostdlib -lgcc -Wl,-mavr6,-Tdata=0x00800200 -o C:\test\main
c:/gnat/2011/bin/../lib/gcc/avr/4.5.3/../../../../avr/bin/ld.exe: avr architecture of input file `b~main.o' is incompatible with avr:6 output
c:/gnat/2011/bin/../lib/gcc/avr/4.5.3/../../../../avr/bin/ld.exe: avr architecture of input file `C:\test\main.o' is incompatible with avr:6 output
collect2: ld returned 1 exit status
avr-gnatlink: error when calling C:\GNAT\2011\bin\avr-gcc.exe
avr-gnatmake: *** link failed.

[2012-04-09 00:15:00] process exited with status 4 (elapsed time: 00.25s)

Thus, what did I miss in setup? I just want to generate a .hex file for a dummy main.adb.

Thanks.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Building gnat-gpl-2011-avr-windows from scratch in GPS
  2012-04-09  3:18 Building gnat-gpl-2011-avr-windows from scratch in GPS Rego, P.
@ 2012-04-09  7:23 ` Simon Wright
  2012-04-11 22:06   ` Rego, P.
  0 siblings, 1 reply; 9+ messages in thread
From: Simon Wright @ 2012-04-09  7:23 UTC (permalink / raw)


That looks like an incompatibility between -mmcu=avr6 which you've set
in package Linker and the default options used elsewhere.

I _think_ that there may be a way of saying this sort of thing globally,
but as is frequently the case the GPR documentation isn't easy to get to
grips with (I guess that people don't post bug reports about it enough
to let AdaCore know how difficult it can be to use? I know I didn't when
I worked for a paying customer).

Is there a worked example with the toolchain?



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Building gnat-gpl-2011-avr-windows from scratch in GPS
  2012-04-09  7:23 ` Simon Wright
@ 2012-04-11 22:06   ` Rego, P.
  2012-04-15 16:02     ` Rolf
  0 siblings, 1 reply; 9+ messages in thread
From: Rego, P. @ 2012-04-11 22:06 UTC (permalink / raw)


Em segunda-feira, 9 de abril de 2012 04h23min07s UTC-3, Simon Wright  escreveu:
> That looks like an incompatibility between -mmcu=avr6 which you've set
> in package Linker and the default options used elsewhere.
> 
> I _think_ that there may be a way of saying this sort of thing globally,
> but as is frequently the case the GPR documentation isn't easy to get to
> grips with (I guess that people don't post bug reports about it enough
> to let AdaCore know how difficult it can be to use? I know I didn't when
> I worked for a paying customer).
I agree. GPR documentation sometimes is a bit difficult to understand.

> Is there a worked example with the toolchain?
No. I could not find any example that I could run yet. But googling today I found this tutorial by Maciej Kucia:
http://student.agh.edu.pl/~mkucia/wiki/doku.php?id=avrada

which looks to be very interesting. The tutorial requires GNAT AVR + GPS +
WinAVR GNU gcc tools and libraries for AVR + Atmel AVR Studio 5. I use all of them frequently, so that's no problem, but I'd expect that I could use just GNAT AVR + GPS to build the .hex. However sure it can be a very good starting point. I will try it.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Building gnat-gpl-2011-avr-windows from scratch in GPS
  2012-04-11 22:06   ` Rego, P.
@ 2012-04-15 16:02     ` Rolf
  2012-04-17  1:01       ` Rego, P.
  2012-04-17 16:58       ` Brian Drummond
  0 siblings, 2 replies; 9+ messages in thread
From: Rolf @ 2012-04-15 16:02 UTC (permalink / raw)


> > Is there a worked example with the toolchain?
>
> No. I could not find any example that I could run yet.

AdaCore's AVR compiler comes with a sample application somewhere (I
don't remember where).

When using gcc for AVR you have to specify the target MCU at the
compile and link steps with the option -mmcu=<name of mcu>. In your
example you missed that option in the compile step.


> But googling today I found this tutorial by Maciej Kucia:http://student.agh.edu.pl/~mkucia/wiki/doku.php?id=avrada
>
> which looks to be very interesting. The tutorial requires GNAT AVR + GPS +
> WinAVR GNU gcc tools and libraries for AVR + Atmel AVR Studio 5. I use all of them frequently, so that's no problem, but I'd expect that I could use just GNAT AVR + GPS to build the .hex. However sure it can be a very good starting point. I will try it.

AVR-Ada /= AdaCore's AVR compiler.

AVR-Ada V1.1 still uses gcc-4.3.x, AdaCore's AVR compiler is based on
gcc-4.5. That version has a serious problem if you use locally renamed
variables of the MCU's registers.  Either use AVR-Ada V1.1 or wait a
few days/weeks for AVR-Ada V1.2 which will use gcc-4.7

HTH
    Rolf





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Building gnat-gpl-2011-avr-windows from scratch in GPS
  2012-04-15 16:02     ` Rolf
@ 2012-04-17  1:01       ` Rego, P.
  2012-04-17 15:37         ` Simon Wright
  2012-04-17 16:58       ` Brian Drummond
  1 sibling, 1 reply; 9+ messages in thread
From: Rego, P. @ 2012-04-17  1:01 UTC (permalink / raw)


> AdaCore's AVR compiler comes with a sample application somewhere (I
> don't remember where).
I also could not find.

> When using gcc for AVR you have to specify the target MCU at the
> compile and link steps with the option -mmcu=<name of mcu>. In your
> example you missed that option in the compile step.
Ok. I will put this.
 
> AVR-Ada /= AdaCore's AVR compiler.
Yes. The http://student.agh.edu.pl/~mkucia/wiki/doku.php?id=avrada tutorial does not refer to AVR-Ada, but to Adacore's AVR compiler. I believe he entitled the tutorial "avrada" just to simplify things. Actually I have to congratulate him, because of the initiative. It also brings some good examples (like something we are used to get in AVR tutorials in C). Just it would be easier if he had written all text and the comments in english (not in polish) but Chrome helps on it :-p.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Building gnat-gpl-2011-avr-windows from scratch in GPS
  2012-04-17  1:01       ` Rego, P.
@ 2012-04-17 15:37         ` Simon Wright
  0 siblings, 0 replies; 9+ messages in thread
From: Simon Wright @ 2012-04-17 15:37 UTC (permalink / raw)


"Rego, P." <pvrego@gmail.com> writes:

>> AdaCore's AVR compiler comes with a sample application somewhere (I
>> don't remember where).
> I also could not find.
>
>> When using gcc for AVR you have to specify the target MCU at the
>> compile and link steps with the option -mmcu=<name of mcu>. In your
>> example you missed that option in the compile step.
> Ok. I will put this.
>  
>> AVR-Ada /= AdaCore's AVR compiler.
> Yes. The http://student.agh.edu.pl/~mkucia/wiki/doku.php?id=avrada
> tutorial 

In that tutorial, the author says

   The most important line is:
   avr-gnatmake main -o $@ -Os -mmcu=avr4 --RTS=zfp -largs crtm8._o
   -nostdlib -lgcc -mavr4 -Tdata=0x00800200

whch implies that [avr-]gnatmake knows to apply -mmcu= wherever needed;
might simplify things!



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Building gnat-gpl-2011-avr-windows from scratch in GPS
  2012-04-15 16:02     ` Rolf
  2012-04-17  1:01       ` Rego, P.
@ 2012-04-17 16:58       ` Brian Drummond
  2012-04-17 19:29         ` Simon Wright
  1 sibling, 1 reply; 9+ messages in thread
From: Brian Drummond @ 2012-04-17 16:58 UTC (permalink / raw)


On Sun, 15 Apr 2012 09:02:31 -0700, Rolf wrote:

> AVR-Ada V1.1 still uses gcc-4.3.x, AdaCore's AVR compiler is based on
> gcc-4.5. That version has a serious problem if you use locally renamed
> variables of the MCU's registers.  Either use AVR-Ada V1.1 or wait a few
> days/weeks for AVR-Ada V1.2 which will use gcc-4.7

Good news indeed!

I have just successfully(as far as I know!) built gcc-4.7 prerelease 
version (20120302) for AVR, and verified it makes the "Blinky" project 
http://sourceforge.net/apps/mediawiki/avr-ada/index.php?
title=USB_Boarduino#Blinky_in_Ada
which works with appropriate changes on three platforms.

I have also added a switch and modified the example along the lines : 
    Sw : Boolean renames MCU.PinB_Bits(1);
...
    MCU.DDRB_Bits := (1 => DD_Input, others => DD_Output); 
...
        LED <= not Sw;
and the fact that it works as expected suggests to me that the GCC4.5 bug 
with renamed registers has been fixed.

One of the platforms I tried, http://www.pjrc.com/teensy/
uses the Atmega32U4 which isn't in the list of AVRAda 1.1 supported 
devices. (however, mcu=atmega328p worked for this example)
Are there any guidelines how to add support for a new CPU, perhaps by 
modifying the 32u6 sources?

- Brian




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Building gnat-gpl-2011-avr-windows from scratch in GPS
  2012-04-17 16:58       ` Brian Drummond
@ 2012-04-17 19:29         ` Simon Wright
  2012-04-17 21:19           ` Brian Drummond
  0 siblings, 1 reply; 9+ messages in thread
From: Simon Wright @ 2012-04-17 19:29 UTC (permalink / raw)


Brian Drummond <brian@shapes.demon.co.uk> writes:

> I have also added a switch and modified the example along the lines : 
>     Sw : Boolean renames MCU.PinB_Bits(1);
> ...
>     MCU.DDRB_Bits := (1 => DD_Input, others => DD_Output); 
> ...
>         LED <= not Sw;
> and the fact that it works as expected suggests to me that the GCC4.5 bug 
> with renamed registers has been fixed.

Is that http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46192 ? If so, it's
certainly fixed in 4.7.0 and should be in 4.5, 4.6 too (releases after
21 January 2012; SVN revisions 18336[567]).



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Building gnat-gpl-2011-avr-windows from scratch in GPS
  2012-04-17 19:29         ` Simon Wright
@ 2012-04-17 21:19           ` Brian Drummond
  0 siblings, 0 replies; 9+ messages in thread
From: Brian Drummond @ 2012-04-17 21:19 UTC (permalink / raw)


On Tue, 17 Apr 2012 20:29:05 +0100, Simon Wright wrote:

> Brian Drummond <brian@shapes.demon.co.uk> writes:
> 
>> I have also added a switch and modified the example along the lines :
>>     Sw : Boolean renames MCU.PinB_Bits(1);
>> ...
>>     MCU.DDRB_Bits := (1 => DD_Input, others => DD_Output);
>> ...
>>         LED <= not Sw;
>> and the fact that it works as expected suggests to me that the GCC4.5
>> bug with renamed registers has been fixed.
> 
> Is that http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46192 ? If so, it's
> certainly fixed in 4.7.0 and should be in 4.5, 4.6 too (releases after
> 21 January 2012; SVN revisions 18336[567]).

That's the one. Glad it's fixed!

- Brian




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-04-17 21:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-04-09  3:18 Building gnat-gpl-2011-avr-windows from scratch in GPS Rego, P.
2012-04-09  7:23 ` Simon Wright
2012-04-11 22:06   ` Rego, P.
2012-04-15 16:02     ` Rolf
2012-04-17  1:01       ` Rego, P.
2012-04-17 15:37         ` Simon Wright
2012-04-17 16:58       ` Brian Drummond
2012-04-17 19:29         ` Simon Wright
2012-04-17 21:19           ` Brian Drummond

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox