Compiling for lpc on linux system

Started by Aditya Bankar January 31, 2009
Hi,

I want to know how to compile programs written in C and in assembly on Linux based host system. I don't want to use linux on my microcontroller. I saw that uClibc document. It seems that this library is for compiling software for ARM microcontroller running Linux on it.
Say I just want to assemble the instruction: MOV R0, #10H
And say I just want to compile the program:
main()
{
int a,b,c;
a=3,b=5;
c=a+b;
}

How can I do it with as (gcc assembler) and gcc compiler respectively?

Thanks,
Aditya

Bring your gang together. Do your thing. Find your favourite Yahoo! group at http://in.promos.yahoo.com/groups/


An Engineer's Guide to the LPC2100 Series

> I want to know how to compile programs written in C and in assembly
> on Linux based host system. I don't want to use linux on my
> microcontroller. I saw that uClibc document. It seems that this
> library is for compiling software for ARM microcontroller running
> Linux on it.
> Say I just want to assemble the instruction: MOV R0, #10H
> And say I just want to compile the program:
> main()
> {
> int a,b,c;
> a=3,b=5;
> c=a+b;
> }
>
> How can I do it with as (gcc assembler) and gcc compiler respectively?

You need to have toolchain, startup file and linker script. Toolchain
you can compile yourself (I documented my own experience here: http://only.mawhrin.net/~alexey/prg/lpc2103/toolchain/)
. Startup file and linker script are board-specific. When you have all
three components, you just do the compilation; see http://only.mawhrin.net/~alexey/prg/lpc2103/tutorial-hello/
for an example of doing something with the board without C library.

--
Alexey

--- In l..., Alexey Vyskubov wrote:
>
> > I want to know how to compile programs written in C and in assembly
> > on Linux based host system. I don't want to use linux on my
> > microcontroller. I saw that uClibc document. It seems that this
> > library is for compiling software for ARM microcontroller running
> > Linux on it.
> > Say I just want to assemble the instruction: MOV R0, #10H
> > And say I just want to compile the program:
> > main()
> > {
> > int a,b,c;
> > a=3,b=5;
> > c=a+b;
> > }
> >
> > How can I do it with as (gcc assembler) and gcc compiler respectively?
>
> You need to have toolchain, startup file and linker script. Toolchain
> you can compile yourself (I documented my own experience here:
http://only.mawhrin.net/~alexey/prg/lpc2103/toolchain/)
> . Startup file and linker script are board-specific. When you have all
> three components, you just do the compilation; see
http://only.mawhrin.net/~alexey/prg/lpc2103/tutorial-hello/
> for an example of doing something with the board without C library.
>
> --
> Alexey
>

Eventually, you will need a C library. Newlib is the easiest to use.

Grab all of the latest toolchain from www.gnuarm.org (NOT
www.gnuarm.com) and follow the build instructions on the Support tab.
You need to build the toolchain with these instructions for it to be
aware of the library. This part of the configure command enables
newlib: --with-newlib --with-headers=[newlib-source]/newlib/libc/include

Newlib provides stubs for IO and memory management code that you have
to provide. After all, newlib can't possibly know who to send bytes
out the serial port. Heap management is another nightmare. For
examples of the stub code look at www.jcwren.com/arm Grab the Linux
download and look in the newlib subdirectory of the archive.

It is possible to build applications without using the C library but
you have to provide all of the get & put functions as well as all of
the string functions. But it can be done...

You will also want an IDE See http://www.eclipse.org/downloads/ and
grab the version for C/C++ Development

The GNU documentation is here: http://www.gnu.org/manual/

Richard

> Grab all of the latest toolchain from www.gnuarm.org (NOT
> www.gnuarm.com) and follow the build instructions on the Support tab.

...or download a pre-built version.
http://www.codesourcery.com/gnu_toolchains/arm/portal/release642

Regards,
Richard.

+ http://www.FreeRTOS.org
Designed for Microcontrollers. More than 7000 downloads per month.

+ http://www.FreeRTOS.org/Documentation
New FreeRTOS eBook - learn how to use an RTOS.

Thanks for help. I will try this in evening time today.

________________________________
From: FreeRTOS.org Info
To: l...
Sent: Sunday, 1 February, 2009 10:35:45 PM
Subject: RE: [lpc2000] Re: Compiling for lpc on linux system
> Grab all of the latest toolchain from www.gnuarm.org (NOT
> www.gnuarm.com) and follow the build instructions on the Support tab.

...or download a pre-built version.
http://www.codesour cery.com/ gnu_toolchains/ arm/portal/ release642

Regards,
Richard.

+ http://www.FreeRTOS .org
Designed for Microcontrollers. More than 7000 downloads per month.

+ http://www.FreeRTOS .org/Documentati on
New FreeRTOS eBook - learn how to use an RTOS.

Add more friends to your messenger and enjoy! Go to http://messenger.yahoo.com/invite/