Forum > PDAs and Smartphones

[Tutorial] Cross Compile for arm-linux (Finally it works!)

(1/20) > >>

Kjooow:
How To setup Lazarus/FPC for arm-linux cross compiling.

I decided to remove this post to link ONLY the authoritative/updated WiKi-tutorial.

Please follow these links:

* Setup Cross Compile For ARM
* Lazarus Manager

Ocye:
It seems to me, ARM isn't the prefered target platform of most users. I didn't get any respond to my questions. Anyway, I would appreciate an updated tutorial. Maybe that helps growing the community.

Kjooow:

--- Quote from: Ocye on December 03, 2009, 05:06:18 pm ---It seems to me, ARM isn't the prefered target platform of most users. I didn't get any respond to my questions. Anyway, I would appreciate an updated tutorial. Maybe that helps growing the community.

--- End quote ---

For this reason I would the help to create a tutorial "step-by-step", so users could create itself all necessary for development. There is a lot of unknowledge about this and tutorials are often outdated or cryptic.

Kjooow:
First post updated.

Ocye:
Some notes from my experiences. First, I would suppose that fpc is installed, updated and used correctly. Omit the part until arm-linux from your tutorial. By the way, you say v2.2.4 and use 2.5.1. You just create Binutils and not Newlib. This have be done to have more function than "writeln" only. Actually, I appended some more options to configure binutils. Don't "cp" use "ln". I'm confused with your compiler name "ppcarm" instead of "ppcrossarm". I thought "cross" comes from the options crossinstall. You insert ARM options (i.e. -CfSOFT -CaEABI) into the fpc.cfg but add them to compilation too. Perhaps both are not needed since you created the compiler with them. AT least, a good tutorial should provide informations about the applied options. Why do you insert them, what happens, where are the files etc.

My procedure with binutils is as follows. I'm running Ubuntu where Synaptic or apt-get can be used to access repositories. How to create an ARM Toolchain is from the german wiki http://wiki.ubuntuusers.de/GNU_ARM-Toolchain

1. Synaptic -> binutils-source -> /usr/src/binutils -> binutils-2.19.1
download patch from http://sourceware.org/bugzilla/attachment.cgi?id=3058&action=view

* patch -p0 -b -i binutils-2.19-arm.patch binutils-2.19/gas/config/tc-arm.c
* ./configure --target=arm-elf --prefix=/opt/gnuarm --enable-interwork --enable-multilib --enable-target-optspace --with-float=soft
* make all
* sudo make install
* sudo ln -s /opt/gnuarm/bin/* /usr/local/bin
2. Synaptic -> gcc-4.3-source -> /usr/src/gcc-4.3 -> gcc-4.3.3

* replace ./gcc/config/arm/t-arm-elf by http://www.gnuarm.org/t-arm-elf
* ./configure --target=arm-elf --prefix=/opt/gnuarm --enable-interwork --enable-multilib --enable-languages="c,c++" --enable-target-optspace --with-float=soft --with-newlib --with-headers=../../newlib/newlib-1.17.0/newlib/libc/include/ --disable-nls
* sudo make all-gcc install-gcc
* sudo ln -s /opt/gnuarm/bin/* /usr/local/bin
3. Synaptic -> newlib-source -> /usr/src/newlib -> newlib-1.17.0

* ./configure --target=arm-elf --prefix=/opt/gnuarm --enable-interwork --enable-multilib --enable-target-optspace --with-float=soft
* sudo make install
4. back to gcc (perhaps not necessary for freepascal)

* sudo make all install (does not work for me)
After all it creates a structure in /opt/gnuarm which can be used to compile Hello-World. I was missing at least libgl and did not find a way to build it. So one can access different precompiled toolchains as well (http://www.gnuarm.com/, http://www.yagarto.de/, http://www.codesourcery.com/). I downloaded this file decompressed it to /opt (arm-2009q3) and applied that path to all further steps.

5. fpc

* make distclean
* make crosszipinstall CPU_TARGET=arm OS_TARGET=linux OPT="-dFPC_ARMEL" CROSSOPT="-XR/opt/arm-2009q3/arm-none-linux-gnueabi -dFPC_ARMEL -CfSOFT -Cparmv5" FPC=/usr/local/lib/fpc/2.5.1/ppcx64
- crosszipinstall to create but not install
- -XR<> root dir where as and ld can be found
- ppcx64 is the compiler on 64bit systems, for 32bit it is called ppc386

It results in a packed file like fpc-2.5.1.arm-linux.tar.gz just where the makefile resides. Unpack the content to /usr/local/lib/fpc... and create a link for ppcrossarm into /usr/local/bin. Now ppcrossarm can be used to compile sources

6. Compilation

* ppcrossarm -Xd -Fl/opt/arm-2009q3/arm-none-linux-gnueabi/libc/usr/lib -CaEABI -Parm -CfSOFT -CpARMV5 Example.pas
-Xd don't use standard lib path
-Fl use directory to search for libs
I don't know if it works without -C options.

Navigation

[0] Message Index

[#] Next page

Go to full version