EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

GCC for ARM

Started by Aditya Bankar February 13, 2008
Hi all,
My question is to all those who use GCC. I wrote a code in C and compiled it for ARM using GCC and a ".o" was created. But how do I specify where the address of registers specific to my microcontroller. Is there any include file for that? If I use keil then there is an include file which has all addresses specific to the chip being used.
How do I select between different ARM cores? I mean how do I tell GCC that I want the compilation for ARM7?
Can GDB be used for debugging of this ".o" file? Can this ".o" file be converted to INTEL HEX format?

Regards,
Aditya Bankar.

Why delete messages? Unlimited storage is just a click away. Go to http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html

An Engineer's Guide to the LPC2100 Series

Thanks Richard, I will try this.

----- Original Message ----
From: FreeRTOS.org Info
To: l...
Sent: Wednesday, 13 February, 2008 6:09:10 PM
Subject: RE: [lpc2000] GCC for ARM

> Hi all,
> My question is to all those who use GCC. I wrote a code in C
> and compiled it for ARM using GCC and a ".o" was created.

It sounds like you have only compiled your source files, not linked them
into a single executable.

> But
> how do I specify where the address of registers specific to
> my microcontroller.

When linking you supply a linker script to describe the memory layout of
your device. You can also obtain header files for peripheral register
locations.

> How do I select between different ARM cores?

Using the compile switches, as per all compilers its just that some IDE's
hide this detail from you. Manuals, etc are available on http://gcc.gnu. org
that will tell you all you need to know, but you are better off just copying
an example. Examples exist in the files section of this group, you can also
obtain numerous complete examples from the FreeRTOS.org distribution, for
example: http://www.freertos .org/portlpc2106 .html These will show you a
complete compile and link setup that you can then just modify to suit your
own setup.

> ".o" file be converted to INTEL HEX format?

For this you need objcopy - again lookup the manual or more simply, just
copy an existing example.

Regards,
Richard.

+ http://www.FreeRTOS .org
14 official architecture ports, 5000 downloads per month.

+ http://www.SafeRTOS .com
Certified by TÜV as meeting the requirements for safety related systems.








Save all your chat conversations. Find them online at http://in.messenger.yahoo.com/webmessengerpromo.php





> Hi all,
> My question is to all those who use GCC. I wrote a code in C
> and compiled it for ARM using GCC and a ".o" was created.

Why do you compile manually?
Use makefile, it can write to flash also.

> But
> how do I specify where the address of registers specific to
> my microcontroller.

> How do I select between different ARM cores?

> ".o" file be converted to INTEL HEX format?

.o file is of no use to you unless you link it.

Download some demo code and try with make file.
Warm Regards,

Mukund Deshmukh,
Beta Computronics Pvt Ltd.
10/1 IT Park, Parsodi,
Nagpur -440022 India.
Web site - http://betacomp.com

MEET US AT,

Chinaplas 2008, Shanghai, China.
> How we can write to flash using gcc.?
> please explain..

You can't - but you can include OpenOCD commands in your makefile to program
the flash automatically as part of your build (probably Flash Magic too and
the Philips flash utilities too, although I have not tried it).

Regards,
Richard.

+ http://www.FreeRTOS.org
14 official architecture ports, 5000 downloads per month.

+ http://www.SafeRTOS.com
Certified by T as meeting the requirements for safety related systems.



Aditya,

I would recommend using make to handle all of the conversion, but I have
attached the necesary commands to compile a program below:

*arm-elf-gcc ../main.c -c -mcpu=arm7tdmi -MD -Wall -O -mapcs-frame
-mthumb-interwork -I "$PWD/.." -o main.o
arm-elf-as ../startup.s -m arm7tdmi -mthumb-interwork --MD *.d -I "$PWD/.."
-o startup.o
arm-elf-gcc -T ../Flash.ld -mthumb-interwork
-Wl,-Ttext=0x00000000,-Tdata=0x40000000 --gc-sections -o main.elf "startup.o"
"main.o" -nostartfiles -lm
arm-elf-objcopy -O ihex main.elf main.hex*

The commands are run from a folder called Flash and will build an intel hex
file to load into flash memory. You will of course need to get a copy of the
Flash.ld and Startup.s files, but you should be able to find something in
the files section.

I use lpc21isp to load the hex file to the uC once compiled with the
following command:

*l**pc21isp main.hex /dev/ttyUSB0 19200 19660*

As a word of warning, if you are using windows (without cygwin at least) you
might need to change some of the paths/file names around a little to match
your OS.

Good luck

Ryan

On 2/13/08, Aditya Bankar wrote:

Hi all,
My question is to all those who use GCC. I wrote a code in C and
compiled it for ARM using GCC and a ".o" was created. But how do I specify
where the address of registers specific to my microcontroller. Is there any
include file for that? If I use keil then there is an include file which has
all addresses specific to the chip being used.
How do I select between different ARM cores? I mean how do I tell GCC
that I want the compilation for ARM7?
Can GDB be used for debugging of this ".o" file? Can this ".o" file be
converted to INTEL HEX format?

Regards,
Aditya Bankar.

Why delete messages? Unlimited storage is just a click away. Go to
http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html
Mr Deshmukh,
How we can write to flash using gcc.?
please explain..

Ravi
On Wed, 13 Feb 2008 Mukund Deshmukh wrote :
> > Hi all,
> > My question is to all those who use GCC. I wrote a code in C
> > and compiled it for ARM using GCC and a ".o" was created.
>
>Why do you compile manually?
>Use makefile, it can write to flash also.
>
> > But
> > how do I specify where the address of registers specific to
> > my microcontroller.
>
> > How do I select between different ARM cores?
>
> > ".o" file be converted to INTEL HEX format?
>
>.o file is of no use to you unless you link it.
>
>Download some demo code and try with make file.
>Warm Regards,
>
>Mukund Deshmukh,
>Beta Computronics Pvt Ltd.
>10/1 IT Park, Parsodi,
>Nagpur -440022 India.
>Web site - http://betacomp.com
>
>MEET US AT,
>
>Chinaplas 2008, Shanghai, China.
>




Thanks for the info. I will have to try out this and get back to you all.
----- Original Message ----
From: Ryan Gossink
To: l...
Sent: Thursday, 14 February, 2008 5:55:19 AM
Subject: Re: [lpc2000] GCC for ARM

Aditya,

I would recommend using make to handle all of the conversion, but I have
attached the necesary commands to compile a program below:

*arm-elf-gcc ../main.c -c -mcpu=arm7tdmi -MD -Wall -O -mapcs-frame
-mthumb-interwork -I "$PWD/.." -o main.o
arm-elf-as ../startup.s -m arm7tdmi -mthumb-interwork --MD *.d -I "$PWD/.."
-o startup.o
arm-elf-gcc -T ../Flash.ld -mthumb-interwork
-Wl,-Ttext=0x000000 00,-Tdata= 0x40000000 --gc-sections -o main.elf "startup.o"
"main.o" -nostartfiles -lm
arm-elf-objcopy -O ihex main.elf main.hex*

The commands are run from a folder called Flash and will build an intel hex
file to load into flash memory. You will of course need to get a copy of the
Flash.ld and Startup.s files, but you should be able to find something in
the files section.

I use lpc21isp to load the hex file to the uC once compiled with the
following command:

*l**pc21isp main.hex /dev/ttyUSB0 19200 19660*

As a word of warning, if you are using windows (without cygwin at least) you
might need to change some of the paths/file names around a little to match
your OS.

Good luck

Ryan

On 2/13/08, Aditya Bankar wrote:

Hi all,
My question is to all those who use GCC. I wrote a code in C and
compiled it for ARM using GCC and a ".o" was created. But how do I specify
where the address of registers specific to my microcontroller. Is there any
include file for that? If I use keil then there is an include file which has
all addresses specific to the chip being used.
How do I select between different ARM cores? I mean how do I tell GCC
that I want the compilation for ARM7?
Can GDB be used for debugging of this ".o" file? Can this ".o" file be
converted to INTEL HEX format?

Regards,
Aditya Bankar..

Get the freedom to save as many mails as you wish. To know how, go to http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html
--- In l..., "FreeRTOS.org Info" wrote:
>
> > How we can write to flash using gcc.?
> > please explain..
>
> You can't - but you can include OpenOCD commands in your makefile to
program
> the flash automatically as part of your build (probably Flash Magic
too and
> the Philips flash utilities too, although I have not tried it).
>
> Regards,
> Richard.

Add something like the following to your makefile:

program : ${TARGET}.hex
lpc21isp ${TARGET}.hex /dev/ttyS0 115200 14746

(nice neat indenting hosed by Yahoo!)

from the command line just use 'make program'

You can get lpc21isp here:
http://www.lumme.fi/code/c/lpc21isp/lpc21isp.tgz

Richard

The 2024 Embedded Online Conference