What would be involved in getting Free Pascal to compile into AVR, ATMega and Arduino?
Asked Answered
M

2

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".

Maniac answered 3/9, 2011 at 23:9 Comment(1)
Thanks Peter for the links. I should have done those myself, but was pretty lazy.Maniac
V
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).

Vorlage answered 4/9, 2011 at 14:15 Comment(0)
G
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.

Glorious answered 4/9, 2011 at 3:38 Comment(9)
that port is for the AVR32 family which, you guess it, is a 32 bits family processor. The ATMega is a 8 bit device...Jodhpurs
Aren't WinAVR and AVR-GCC based on the same GCC as the AVR32 is based on?Glorious
Indeed - gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/… GCC apparently supports a wide range of AVR devices nowadays - thanks for the tip!Jodhpurs
+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 @Vorlage for his work on the FPC compiler though!Avenge
My -1 is actually for the same reason that MvdV mentions. You can't fit a nail with a wrench... :)Maniac
JamWaffles: the question was not what would be better. And if so, I'd say to chuck it and go microchip :-)Cipango
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!Glorious
@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.Maniac
@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.Glorious

© 2022 - 2024 — McMap. All rights reserved.