Sign in Join
Wiki copytemporary

AVR: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-[![Warning-icon.png](/wiki-images/b/b2/Warning-icon.png)](</File:Warning-icon.png>)
2-
3-**Warning:** The FPC-AVR port is experimental and might be broken from time to time. If this is the case, please fill a [bug report](<http://bugs.freepascal.org>)
4-
5-**FPC-AVR** is the [[FPC|Free Pascal Compiler]] port for the AVR microcontroller. It uses the GCC AVR tool chain and will be compatible with GCC regarding calling conventions etc.
6-
7-For instructions on how to program AVR's with Free Pascal, see the article [[AVR Programming]].
1+> **Warning:** The FPC-AVR port is experimental and might be broken from time to time. If this is the case, please fill a [bug report](http://bugs.freepascal.org)
82
9-## Contents
3+**FPC-AVR** is the [[FPC|Free Pascal Compiler]] port for the AVR microcontroller. It uses the GCC AVR tool chain and will be compatible with GCC regarding calling conventions etc.
104
11- * 1 Implementation details
12- * 2 Building cross-compiler
13- * 3 Subarchitecture
14- * 4 Resources
5+For instructions on how to program AVR's with Free Pascal, see the article [[AVR Programming]].
156
167## Implementation details
178
18-FPC considers AVR to be a 16 bit CPU. So the type TRegister actually describes a register pair with the second register implicitly named.
9+FPC considers AVR to be a 16 bit CPU. So the type TRegister actually describes a register pair with the second register implicitly named.
1910
2011## Building cross-compiler
2112
22-There are some requirements, you should know about:
13+There are some requirements, you should know about:
2314
24- * You should use the latest Free Pascal sources as there is the most recent support for more controllers.
25- * Binutils for avr target
26- * Microchip (previously Atmel) provides bintuils binaries for Linux, macOS (Darwin) and Windows.
27-[Download](<https://www.microchip.com/mplab/avr-support/avr-and-arm-toolchains-c-compilers>) using the appropriate link for your operating system]
28- * On a Linux host, you may either install binutils for the avr target from your distribution or use also the binaries provided by Microchip (previously Atmel).
29- * You may also use the binutils distributed with the Arduino IDE; on Windows they are installed to eg C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\bin
30- * Keep in mind that the Free Pascal Compiler will search for eg avr-embedded-as. So you must either rename the binary files, create symlinks (on Linux only) or adjust command line switch -XP<prefix> for FPC.
31- * You may need to set FPC's command line switch -FD<directory with binutils>
32- * Latest _stable_ Free Pascal Compiler.
15+- You should use the latest Free Pascal sources as there is the most recent support for more controllers.
16+- Binutils for avr target
17+ - Microchip (previously Atmel) provides bintuils binaries for Linux, macOS (Darwin) and Windows.\
18+ [Download](https://www.microchip.com/mplab/avr-support/avr-and-arm-toolchains-c-compilers) using the appropriate link for your operating system\]
19+ - On a Linux host, you may either install binutils for the avr target from your distribution or use also the binaries provided by Microchip (previously Atmel).
20+ - You may also use the binutils distributed with the Arduino IDE; on Windows they are installed to eg C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\bin
21+ - Keep in mind that the Free Pascal Compiler will search for eg avr-embedded-as. So you must either rename the binary files, create symlinks (on Linux only) or adjust command line switch -XP\<prefix\> for FPC.
22+ - You may need to set FPC's command line switch -FD\<directory with binutils\>
23+- Latest *stable* Free Pascal Compiler.
3324
34-Then you can build your cross compiler. Please choose SUBARCH according to your Arduino board / AVR microcontroller.
35-```
25+Then you can build your cross compiler. Please choose SUBARCH according to your Arduino board / AVR microcontroller.
26+
27+``` bash
3628make buildbase installbase CPU_TARGET=avr OS_TARGET=embedded SUBARCH=avr5 CROSSINSTALL=1 INSTALL_PREFIX=~/fpc NOGDB=1 PP=/usr/bin/fpc CROSSBINDIR=/usr/avr/bin
3729```
3830
39-You may also set the binutils prefix for this (equivalent to the **-XP** switch)
40-```
31+You may also set the binutils prefix for this (equivalent to the **-XP** switch)
32+
33+``` bash
4134make buildbase installbase CPU_TARGET=avr OS_TARGET=embedded SUBARCH=avr5 CROSSINSTALL=1 INSTALL_PREFIX=~/fpc NOGDB=1 PP=/usr/bin/fpc CROSSBINDIR=/usr/avr/bin BINUTILSPREFIX=avr-
4235```
4336
44-The instructions above is good if only one subarchitecture is required. To install several subarchitectures, a unique unit install prefix needs to be specified for each subarchitecture using **INSTALL_UNITPREFIX** :
45-```
37+The instructions above is good if only one subarchitecture is required. To install several subarchitectures, a unique unit install prefix needs to be specified for each subarchitecture using **INSTALL_UNITPREFIX**:
38+
39+``` bash
4640make buildbase installbase CPU_TARGET=avr OS_TARGET=embedded CROSSINSTALL=1 NOGDB=1 FPC=/usr/bin/fpc CROSSBINDIR=/usr/avr/bin BINUTILSPREFIX=avr- INSTALL_PREFIX=~/fpc INSTALL_UNITPREFIX=~/fpc/lib/fpc/3.2.2/units/avr-embedded/avr5 SUBARCH=avr5
4741```
4842
49-Remember to change both **SUBARCH** and **INSTALL_UNITPREFIX** when building a different subarchitecture.
43+Remember to change both **SUBARCH** and **INSTALL_UNITPREFIX** when building a different subarchitecture.
5044
51-Together with this change, the fpc.cfg file paths needs to be updated to find units in this new structure. Below is an example of updating the unit specific search paths in fpc.cfg:
52-```
45+Together with this change, the fpc.cfg file paths needs to be updated to find units in this new structure. Below is an example of updating the unit specific search paths in fpc.cfg:
46+
47+```text
5348# searchpath for units and other system dependent things
54- #IFDEF EMBEDDED
55- -Fu~/fpc/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch
56- -Fu~/fpc/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch/*
57- -Fu~/fpc/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch/rtl
58- #ELSE
59- -Fu~/fpc/lib/fpc/$fpcversion/units/$fpctarget/*
60- -Fu~/fpc/lib/fpc/$fpcversion/units/$fpctarget/rtl
61- #ENDIF
49+#IFDEF EMBEDDED
50+-Fu~/fpc/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch
51+-Fu~/fpc/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch/*
52+-Fu~/fpc/lib/fpc/$fpcversion/units/$fpctarget/$fpcsubarch/rtl
53+#ELSE
54+-Fu~/fpc/lib/fpc/$fpcversion/units/$fpctarget/*
55+-Fu~/fpc/lib/fpc/$fpcversion/units/$fpctarget/rtl
56+#ENDIF
6257```
6358
64-Adapt paths as required.
59+Adapt paths as required.
6560
6661## Subarchitecture
6762
68-The operating system target _embedded_ requires that you specify a subarchitectures when building a cross compiler. The subarchitectures are compatible with the ones used by GCC.
63+The operating system target *embedded* requires that you specify a subarchitectures when building a cross compiler. The subarchitectures are compatible with the ones used by GCC.
6964
7065## Resources
7166
72- * [Atmel Studio 7](<https://www.microchip.com/mplab/avr-support/atmel-studio-7>)
73- * [Downloads Archive for AVR tools](<https://www.microchip.com/mplab/avr-support/avr-and-sam-downloads-archive>)
74- * [General information about Atmel AVR in Wikipedia](<http://en.wikipedia.org/wiki/Atmel_AVR>)
75- * [Calling conventions](<http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_reg_usage>)
76- * [list of subarchitectures](<http://www.nongnu.org/avr-libc/user-manual/using_tools.html>)
77- * [Discussion on lazarusforum.de (German)](<http://www.lazarusforum.de/viewtopic.php?f=9&t=5444&start=30>)
78- * [[AVR Programming]]
79- * [[Arduino]]
80- * [[AVR Embedded Tutorial|AVR Embedded Tutorials]] \- Tutorials with code examples
67+- [Atmel Studio 7](https://www.microchip.com/mplab/avr-support/atmel-studio-7)
68+- [Downloads Archive for AVR tools](https://www.microchip.com/mplab/avr-support/avr-and-sam-downloads-archive)
69+- [General information about Atmel AVR in Wikipedia](http://en.wikipedia.org/wiki/Atmel_AVR)
70+- [Calling conventions](http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_reg_usage)
71+- [list of subarchitectures](http://www.nongnu.org/avr-libc/user-manual/using_tools.html)
72+- [Discussion on lazarusforum.de (German)](http://www.lazarusforum.de/viewtopic.php?f=9&t=5444&start=30)
73+- [[AVR Programming]]
74+- [[Arduino]]
75+- [[AVR Embedded Tutorial|AVR Embedded Tutorials]] - Tutorials with code examples
8176
8277---
83-*From the Free Pascal wiki, page "AVR", as the Internet Archive kept it on 2022-12-31. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
78+*From the Free Pascal wiki, page "AVR", as it stood on 2021-12-26 after a change by Ccrause, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history