6

Would it be too much of an effort to have FPC compile to the Arduino platform?

I would really like to use Lazarus to do some "sketches".

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Gustavo Carreno
  • 9,499
  • 13
  • 45
  • 76

2 Answers2

10

I'am working from time to time on the FPC AVR port. Current state is: an AVR FPC compiler can be built and it creates reasonable code and we are working on the startup code. After this, we will start to debug the code of simple programs.

If you want to play with it, you can build (not sure though if it currently builds, we run no regression tests yet on avr) an avr cross compiler from FPC trunk by

make all OS_TARGET=embedded CPU_TARGET=avr CROSSOPT=-O-

having avr binutils (avr-embedded-*) and FPC 2.4.4 installed (don't forget the CROSSOPT=-O-, the optimizer is currently broken for AVR).

Edit: Formatting

Updating my old answer: FPC for AVR got significant improvements

make all OS_TARGET=embedded CPU_TARGET=avr

works now (FPC trunk) and creates reasonable code (still needs improvements and fixes though).

FPK
  • 2,008
  • 13
  • 19
0

I would look into http://en.wikipedia.org/wiki/GNU_Compiler_Collection since GCC is already implemented for the AVR and this front end should be easy to add.

Jeff
  • 1,364
  • 1
  • 8
  • 17
  • 1
    that port is for the AVR32 family which, you guess it, is a 32 bits family processor. The ATMega is a 8 bit device... – fvu Sep 04 '11 at 08:58
  • Aren't WinAVR and AVR-GCC based on the same GCC as the AVR32 is based on? – Jeff Sep 04 '11 at 18:11
  • 1
    Indeed - http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/AVR-Options.html#AVR-Options GCC apparently supports a wide range of AVR devices nowadays - thanks for the tip! – fvu Sep 04 '11 at 18:33
  • 1
    +1; It's probably a better idea to go with GCC (yes it _does_ support 8-bit AVRs) as it's more tested, more stable and has many more features. I do comment @FPK for his work on the FPC compiler though! – Bojangles Sep 05 '11 at 18:30
  • My -1 is actually for the same reason that MvdV mentions. You can't fit a nail with a wrench... :) – Gustavo Carreno Sep 05 '11 at 22:03
  • JamWaffles: the question was not what would be better. And if so, I'd say to chuck it and go microchip :-) – Marco van de Voort Sep 06 '11 at 07:18
  • 2
    You are correct MvdV, better is not the question. However, I offered GCC as a source that might offer some details to help with implementing FPC or allow Gustavo to start using Pascal on the AVR sooner instead of working on implementing FPC. They look like two different hammers to me and sometimes you'd like to start hammering instead of going out and making a hammer. Best of luck on the path chosen! – Jeff Sep 18 '11 at 18:48
  • @JamWaffles Thanks for trying to get me a ready made hammer solution, I appreciate it. But the Arduino/AVR-GCC/AVRDUDE chain that I'm already using suits me fine. I'm just too much of a Pascal fan not to have an OPEN Pascal implementation of the compile tool chain for my adored Arduino Platform. On top of that, call me spoiled rotten, I do like a proper IDE to code in, whatever language, and the Arduino IDE is pretty crap at being one. – Gustavo Carreno Sep 21 '11 at 15:38
  • @Gustavo I agree the Arduino IDE is very limited. As soon as I hit a wall, I change to using the WinAVR editor Programmers Notepad. WinAVR also includes Avr-gcc and Avrdude. Usually I start using it. – Jeff Sep 22 '11 at 11:00