EmbDev.net

Forum: ARM programming with GCC/GNU tools Problem with pointers


Author: Anoop Babu (Company: erdciit) (anoop)
Posted on:
Attached files:

Rate this post
0 useful
not useful
The following is my make file.. which is used to print a string using 
uart. i am getting the error 'undefined reference to memcpy' is there 
any thing wrong with this make file.. The complete code is attached 
here. i want to generate code for arm9

NAME    = sata

CC      = arm-elf-gcc
LD      = arm-elf-ld -v
AR      = arm-elf-ar
AS      = arm-elf-as
CP      = arm-elf-objcopy
OD    = arm-elf-objdump

CFLAGS  = -I./ -c -fno-common -O0 -g
AFLAGS  = -ahls -mapcs-32 -o start_up.o
LFLAGS  =  -Map main.map -Tmemory_map.cmd
CPFLAGS = -O ihex
ODFLAGS  = -x --syms

all: test

test: main.out
  @ echo "...copying"
  #$(CP) $(CPFLAGS) main.out main.hex
  $(CP) main.out main.elf
  $(OD) $(ODFLAGS) main.out > main.dmp

main.out: start_up.o main.o memory_map.cmd
  @ echo "..linking"
  $(LD) $(LFLAGS) -o main.out  start_up.o main.o

start_up.o: start_up.s
  @ echo ".assembling"
  $(AS) $(AFLAGS) start_up.s > start_up.lst

main.o: main.c
  @ echo ".compiling"
  $(CC) $(CFLAGS) main.c

#uart.o: uart.c
#  @ echo ".compiling"
#  $(CC) $(CFLAGS) uart.c

clean:
  -rm start_up.lst main.lst start_up.o main.o main.out main.hex main.map 
main.dmp main.elf

Author: Rolf Magnus (Guest)
Posted on:

Rate this post
0 useful
not useful
> i am getting the error 'undefined reference to memcpy'

From the compiler or from the linker?

> is there any thing wrong with this make file..

You're using ld for linking instead of gcc. That means that all the 
prerequisites for C are missing, like e.g. libc. You have to specify 
those manually.

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 useful
not useful
Rolf Magnus wrote:
>> i am getting the error 'undefined reference to memcpy'
>
> From the compiler or from the linker?
>
Undefined reference is a linker error.


>> is there any thing wrong with this make file..
>
> You're using ld for linking instead of gcc. That means that all the
> prerequisites for C are missing, like e.g. libc. You have to specify
> those manually.

I think that answers your own question. ;) Good catch.


@ Anoop Babu
add -lgcc -lc to LFLAGS, you may also need to add -L<path> directives to 
the appropriate library directories.  There are multiple versions of the 
libraries and you need to link the ones that match the the architecture 
the object files were compiled for.  This is why it may be easier to 
drive the linker through the compiler driver and pass both CFLAGS and 
LFLAGS so that the correct libraries are determined automatically.

Author: Anoop Babu (Company: erdciit) (anoop)
Posted on:

Rate this post
0 useful
not useful
thank you..

but i still have problems
can any one suggest the method to study WINARM..i.e books sites etc.. i 
am just a beginner. i need to know how to write the startup code etc.. 
and want to build source code for arm9 IP Core...

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 useful
not useful
Anoop Babu wrote:
> thank you..
>
> can any one suggest the method to study WINARM..i.e books sites etc..

WinARM is a package of open source tools from more than one project, but 
primarily the GNU GCC toolchain.  The main components of the toolchain 
are the compiler and the linker documented at 
http://gcc.gnu.org/onlinedocs/ and 
http://sourceware.org/binutils/docs-2.19/ld/index.html respectively.


> i am just a beginner. i need to know how to write the startup code etc..

You should start at the ARM-GCC development resources sticky thread at 
the top of this forum. (http://embdev.net/topic/129986). Especially the 
"Building bare-metal ARM with GNU" link.

> and want to build source code for arm9 IP Core...
Unfortunately most of the material including "Building bare-metal ARM 
with GNU" relates to ARM7, often for microcontrollers with on-chip Flash 
and SRAM.  An an ARM9 start-up is typically more complex; usually 
requiring configuration of the MMU, caches, and setting up of an SDRAM 
controller.  As an IP core, it will depend on what is included.

The "Insider's Guides" link has some ARM9 parts information, and the 
SevensAndNines.com site has some ARM9 resources.

Also to take full advantage of the ARM9's speed (assuming you are 
running at say > 60MHz - an ARM9 is typically around 200MHz, but it may 
depend on what your IP core is deployed on), you would generally want to 
run your code from RAM, which then requires the start-up code to copy 
the code to RAM at start-up.  This can get quite complex, and to make 
efficient use of Flash memory, you might store the image compressed, so 
that the start-up must decompress to RAM.  If you are running the core 
slower, then an ARM9 might not provide much over an ARM7 core.

It may be worth looking at an off-the-shelf bootloader.

Clifford

Author: Anoop Babu (Company: erdciit) (anoop)
Posted on:

Rate this post
0 useful
not useful
Thank u very much... hope that your support will be with me..

Anoop

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.