sudo apt-get install binutils-avr
sudo apt-get install avrdude
SET FPC_PATH=%CD%\3.0.0\bin\i386-win32
SET PPCBIN=%FPC_PATH%\fpc.exe
SET INSTALL_PATH=%CD%\Win32
SET PATH=%FPC_PATH%;%NDK_BIN%;%PATH%
make clean crossall crossinstall FPC=%PPCBIN% OS_TARGET=embedded CPU_TARGET=avr SUBARCH=avr5 INSTALL_PREFIX=%INSTALL_PATH% CROSSBINDIR=%GNU_BIN_PATH% BINUTILSPREFIX=avr-embedded- CROSSOPT="-O3 -XX -CX"
In above code, adjust the paths as needed. Pay special attention to "GNU_BIN_PATH", which should point to the path, where you downloaded FPCBuild binaries for AVR.#!/bin/sh
set -e
make clean crossall OS_TARGET=embedded CPU_TARGET=avr SUBARCH=avr5 BINUTILSPREFIX=avr- CROSSOPT="-O3 -XX -CX"
sudo make crossinstall OS_TARGET=embedded CPU_TARGET=avr SUBARCH=avr5
sudo ln -s -f /usr/local/lib/fpc/3.1.1/ppcrossavr /usr/local/bin/ppcrossavr
#ifdef embedded
-FD$GNU_BIN_PATH$
-OoFastMath
#-XX
-CX
-Oonostackframe
#ifdef avr
-XPavr-embedded-
#endif
#endif
Note that "GNU_BIN_PATH" should be set as a global environment variable pointing to AVR tools that you've installed in step 2.#IFDEF embedded
-OoFastMath
-XX
-CX
-OoNoStackFrame
#IFDEF cpuavr
-XPavr-
#ENDIF
#ENDIF
sudo avrdude -v -patmega328p -carduino -P/dev/ttyACM0 -b115200 -D -Uflash:w:Blinky.hex:i
In above command, on Linux, "/dev/ttyACM0" is the path to mapped serial port after connecting Arduino, make sure to adjust it as needed. On Windows, it would probably be something like:avrdude -v -patmega328p -carduino -P\\.\COM3 -b115200 -D -Uflash:w:Blinky.hex:i
Maybe if you told where you were stuck it would be easier to help :)
SET FPC_PATH=d:\lazarus\fpc
SET PPCBIN=%FPC_PATH%\fpc.exe
SET INSTALL_PATH=%CD%\Win32
SET PATH=%FPC_PATH%;%NDK_BIN%;%PATH%
make clean crossall crossinstall FPC=%PPCBIN% OS_TARGET=embedded CPU_TARGET=avr SUBARCH=avr5 INSTALL_PREFIX=%INSTALL_PATH% CROSSBINDIR=d:\lazarus\AVREmbedded BINUTILSPREFIX=avr-embedded- CROSSOPT="-O3 -XX -CX"
D:\Lazarus>install01
D:\Lazarus>SET FPC_PATH=d:\lazarus\fpc
D:\Lazarus>SET PPCBIN=d:\lazarus\fpc\fpc.exe
D:\Lazarus>SET INSTALL_PATH=D:\Lazarus\Win32
D:\Lazarus>SET PATH=d:\lazarus\fpc;;d:\lazarus\fpc;;d:\lazarus\fpc d:\lazarus\f
pc;;d:\lazarus\fpc;;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\W
indows\System32\WindowsPowerShell\v1.0\
D:\Lazarus>make clean crossall crossinstall FPC=d:\lazarus\fpc\fpc.exe OS_TARGET
=embedded CPU_TARGET=avr SUBARCH=avr5 INSTALL_PREFIX=D:\Lazarus\Win32 CROSSBINDI
R=d:\lazarus\AVREmbedded BINUTILSPREFIX=avr-embedded- CROSSOPT="-O3 -XX -CX"
makefile:29: *** You need the GNU utils package to use this Makefile. Stop.
%NDK_BIN% should be the path to your SDK. use SET NDK_BIN=Path_to_your_NDK_Directory
PS: Sometimes, the makefiles get confused by residue that was left behind.
Thanks, but what SDK? A Software Developers Kit for what? Do I have to download something else? What? Where?I am unfamiliar with this particular target, so you would need to ask the person that wrote the instructions :D
Clean of package fpc-all completed
MAKE[3]: Leaving directory `D:/Temp/Build-FPC-from-source/fpc-3.0.0/packages'
MAKE[2]: Leaving directory `D:/Temp/Build-FPC-from-source/fpc-3.0.0'
MAKE rtl_all FPC=D:/Temp/Build-FPC-from-source/fpc-3.0.0/compiler/ppcrossavr.exe FPCFPMAKE=D:/Temp/Build-FPC-from-source/fpc-3.0.0/compiler/ppc.exe RELEASE=1 'OPT='
MAKE[2]: Entering directory `D:/Temp/Build-FPC-from-source/fpc-3.0.0'
MAKE -C rtl all
MAKE[3]: Entering directory `D:/Temp/Build-FPC-from-source/fpc-3.0.0/rtl'
MAKE -C embedded all
MAKE[4]: Entering directory `D:/Temp/Build-FPC-from-source/fpc-3.0.0/rtl/embedded'
D:/Temp/Build-FPC-from-source/fpc-3.0.0/compiler/ppcrossavr.exe @rtl.cfg -Ur -Tembedded -Pavr -XPavr- -Xr -Ur -Xs -O2 -n -Fi../inc -Fi../avr -FDD:\WinDev\BinUtils -FE. -FUD:/Temp/Build-FPC-from-source/fpc-3.0.0/rtl/units/avr-embedded -davr -dRELEASE -Us -Sg system.pp
sstrings.inc(1004,1) Fatal: Internal error 200309041
Fatal: Compilation aborted
MAKE[4]: Leaving directory `D:/Temp/Build-FPC-from-source/fpc-3.0.0/rtl/embedded'
MAKE[3]: Leaving directory `D:/Temp/Build-FPC-from-source/fpc-3.0.0/rtl'
MAKE[2]: Leaving directory `D:/Temp/Build-FPC-from-source/fpc-3.0.0'
MAKE[1]: Leaving directory `D:/Temp/Build-FPC-from-source/fpc-3.0.0'
Log stopped zo 31-01-2016, 16:36:42,50
Quitter
.. it off for years. But, given that I am 76 and retired there seemed no real point. Now that I am messing with Arduino, the point has become obvious.We can't have you switch to c(++), really there is no point especially at such respectable age :-)
I saw the mention of "trunks" ...Every FPC/Lazarus you can download from official link and install is a release (whether it is a beta, a release candidate or otherwise).
...if a large chunk of the instructions assumes I am an expert on Lazarus and the things needed to create a cross-compiler with it. By definition a Tutorial should be for the lowest common denominator.Although i understand that from end-user perspective, it is assumed that when using trunk that you know what you are doing.
Now, I am not by any stretch expecting that degree of detail on a free website, but I do expect tutorials to be just that. If a "trunk" version is need then a link to that download is mandatory.I think that was/is a small oversight in that the person writing the tutorial assumed that you understand where to 'fetch' trunk sources.
it is assumed that when using trunk that you know what you are doing.
Thanks to engkin, he wrote very detailed instructions that should work for you. (i was actually starting to write something similar, based on your return answer).
The FPC-AVR port is currently experimental and non working.Was too ominous to bother with trying.
Hint:
"arduino-using-lazarus-free-pascal"
https://bigdanzblog.wordpress.com/full-list-of-posts/
@engkin:
thank you very much.
There is a typo in the link to the FPC
http://ftp//ftp.freepascal.org/pub/fpc/snapshot/trunk/source/fpc.zip
should be...
ftp://ftp.freepascal.org/pub/fpc/snapshot/trunk/source/fpc.zip
For Windows:
3-Decompress that archive somewhere (if you did that in c:\avrtest then you should have a file named make in c:\avrtest\fpc\ folder )
avrbuild.bat <<- saved as per instructions. used all recommended Folders/Paths
fpmake.pp
fpmake_add1.inc
fpmake_proc1.inc
Makefile
makefile.fpc
readme.rev
C:\avrtest\fpc>avrbuild
C:\avrtest\fpc>REM if you installed Lazarus 1.6 RC2 in c:\Laz1.6RC2 it comes wit
h FPC.exe in c:\Laz1.6RC2\3.0.0\bin\i386-win32 folder
C:\avrtest\fpc>REM That is the folder we need to add here.
C:\avrtest\fpc>SET FPC_PATH=c:\Laz1.6RC2\3.0.0\bin\i386-win32
C:\avrtest\fpc>REM The compiler itself ( Which its location is saved in FPC_PATH
)
C:\avrtest\fpc>SET PPCBIN=c:\Laz1.6RC2\3.0.0\bin\i386-win32\fpc.exe
C:\avrtest\fpc>REM A folder where the generated cross compiler and run-time libr
aries are going to be saved
C:\avrtest\fpc>SET INSTALL_PATH=c:\avrtest\Win32
C:\avrtest\fpc>REM We need the path to avr-embedded-* files
C:\avrtest\fpc>SET NDK_BIN=c:\avrtest\
C:\avrtest\fpc>REM Make all the binary files that we need accessible
C:\avrtest\fpc>SET PATH=c:\Laz1.6RC2\3.0.0\bin\i386-win32;c:\avrtest\;C:\Windows
\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerSh
ell\v1.0\;
C:\avrtest\fpc>REM Start the process
C:\avrtest\fpc>make clean crossall crossinstall FPC=c:\Laz1.6RC2\3.0.0\bin\i386-
win32\fpc.exe OS_TARGET=embedded CPU_TARGET=avr SUBARCH=avr5 INSTALL_PREFIX=c:\a
vrtest\Win32 CROSSBINDIR= BINUTILSPREFIX=avr-embedded- CROSSOPT="-O3 -XX -CX"
'make' is not recognized as an internal or external command,
operable program or batch file.
C:\avrtest\fpc>
For Windows:
3-Decompress that archive somewhere (if you did that in c:\avrtest then you should have a file named make in c:\avrtest\fpc\ folder )
Thanks, I appreciate the help, but hit a snag, no Make, but I have 7 Folders and
C:\avrtest\fpc>make clean crossall crossinstall FPC=c:\Laz1.6RC2\3.0.0\bin\i386-
win32\fpc.exe OS_TARGET=embedded CPU_TARGET=avr SUBARCH=avr5 INSTALL_PREFIX=c:\a
vrtest\Win32 CROSSBINDIR= BINUTILSPREFIX=avr-embedded- CROSSOPT="-O3 -XX -CX"
'make' is not recognized as an internal or external command,
operable program or batch file.
I assume you did install Lazarus 1.6 RC2, check in your Lazarus folder c:\Laz1.6RC2\3.0.0\bin\i386-win32\ do you see a file named make.exe?
I assume you did install Lazarus 1.6 RC2, check in your Lazarus folder c:\Laz1.6RC2\3.0.0\bin\i386-win32\ do you see a file named make.exe?
Thanks for the follow up. That path is not what I have, but make.exe is here...
c:\Laz1.6RC2\fpc\3.0.0\bin\i386-win32\
I changed the batch file and it is doing stuff? It skipped all but two of the avr-embedded... files. Is that good?
I love this thread, will try it later. I will buy arduino first of course
If it succeeded then you should have:
1-a cross compiler named ppcrossavr.exe in c:\avrtest\win32\bin\i386-win32
2-compiled rtl units in c:\avrtest\units\avr-embedded\
For anyone interested, here is the Help page from the cross compiler { SHOCK HORROR }That's just the generic -h output, fpc -i should show architecture specific information.
I love this thread, will try it later. I will buy arduino first of course
:D Don't be too hasty, I have not found out how to use it yet.
I opened the IDE and went through every option, operational-function, plug-in and anything thing else. Nothing mentions compiling for Arduino. I may be ruing the moment and now heeding that ominous warning from engkin, "How to use them is a different story."
Open the project, and compile.
:D Don't be too hasty, I have not found out how to use it yet.
Open the project, and compile.
avrdude -CD:\_Programs\_ArduinoIDE\hardware\tools\avr\etc\avrdude.conf -v -patmega328p -carduino -P\\.\%1 -b115200 -D -Uflash:w:%2:i
D:\_Programs\_ArduinoIDE\hardware\tools\avr/bin/avrdude -CD:\_Programs\_ArduinoIDE\hardware\tools\avr/etc/avrdude.conf -v -patmega2560 -cwiring -PCOM5 -b115200 -D -Uflash:w:C:\Users\admin\AppData\Local\Temp\build5676851336824123120.tmp/Blink.cpp.hex:i
https://typeunsafe.wordpress.com/2011/07/22/programming-arduino-with-avrdude/
I am beginning to think it is the .hex file.
In above scripts, notice "avr5" subarch flag. This may be different for other Atmel chips, in FreePascal sources open to "/rtl/embedded/Makefile (http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/rtl/embedded/Makefile?view=co)" to see what chip corresponds to each subarch. For Arduino Uno and ATMega328P, this is "avr5".
ifeq ($(SUBARCH),avr6)
CPU_UNITS=atmega2561 atmega2560
CPU_UNITS_DEFINED=1
endif
So, it seems there is a command switch that the Arduino is supplying that I am not.
I believe you are right. The process was to show that FPC is able to compile for AVR, and it was specific for Arduino Uno (ATMega328P) as the main post explains:Quote
The avrdude will display all of it's parameters when run with no parameters and I mentioned they are case-sensitive so I'd like to retract that prior thought. :)
What I do, (being an old DOS guy) us
avrdude > out.txt
Which pipes it's output to the text file.
I agree that the Nano has the same Atmel chip, but it has a different serial bootloader. But I saw a youtube video of Julian Lett (I think) programming a Nano with the the Uno bootloader thus turning it into a Uno-like thing. I will try that as I have an ISP prorammer here somewhere. The Nano cost 5-bucks and if it never loads again I will not be crying.
If that fakes avrdude into thinking it is a Nano then I have won as the Uno bootloader is smaller and more efficient than the stock one on the Nano.
Moor to come soon.
I'm not actually sure why you bother with this...
The C/C++ offered by Arduino software is much more easier to learn than configure FPC/Lazarus properly in order to make workable .hex file from this experimental attempt to support AVRs.
board (actually ATmega2560 itself) can be blocked refusing further communication with avrdude
If you want to use Pascal anyway, you may start with Mikroelektronika's AVR Pascal compiler.
And, I will cry myself to sleep each night for a week over that $5 loss.
// This function simulates some kind of delay by looping.
procedure SomeDelay;
var
I: LongInt;
begin
for I := 0 to 400000 do
Dec(DelayVar);
end;