[<<][arm][>>][..]
Sun Jun 12 18:05:17 CEST 2011

AT91SAM7 setup from scratch

I've been using eCos up to now.  How to work on the bare metal?  This
is the program I'm trying to run, residing in the file sam7.S

main:   nop
        nop
        nop
        b main


Here's the contents of the makefile:

all: sam7.elf

clean:
	rm -rf *~ *.o *.elf

CC = arm-eabi-gcc  -mcpu=arm7tdmi -O0 -g
LD = arm-eabi-gcc  -mno-thumb-interwork -mcpu=arm7tdmi -Wl,-static -g -nostdlib
OBJDUMP = arm-eabi-objdump

%.o:	%.S
	$(CC) -o $@ -c $<

%.elf:	%.o %.ld
	$(LD) -T$*.ld -o $@ $*.o

%.dump: %.elf
	$(OBJDUMP) -h $<

I'm using the following linker script which places everything in RAM.

SECTIONS
{
  . = 0x200000;
  .text : { *(.text) }
  .data : { *(.data) }
  .bss : { *(.bss) }
}

Compiling this to arm7.elf and loading with gdb enables me to step
through the code if I use:

set $pc = 0x200000

Next is to set the reset vector and maybe put it in flash?  Though RAM
seems a lot more convenient if it fits..

Let's peek in the eCos code to see what vectors.o looks like:

  0 .text          00000564
  1 .data          000001d8
  2 .bss           00001310
  3 .vectors       00000040
  4 .fixed_vectors 00000140

It will place the .vectors at the start of rom.  So where is that
section defined?

  packages/hal/arm/arch/current/src/vectors.S

It seems that this space contains instructions either as branch or
direct pc load, but not addresses.

#ifdef CYGSEM_HAL_ROM_RESET_USES_JUMP
// Assumption:  ROM code has these vectors at the hardware reset address.
// A simple jump removes any address-space dependencies [i.e. safer]
        b       reset_vector                    // 0x00
#else        
        ldr     pc,.reset_vector                // 0x00
#endif 



Always difficult to see what is an ARM-ism, and what is an AT91-ism.
Looks like for arm the vectors are always code.  I'm not sure if they
are always at 0 though..  I seem to have found some info online about
an LPC that starts somewhere else, in Flash.  Some more info [1][2].

For linker docs see [3].

[1] http://sourceware.org/ml/ecos-discuss/1999-10/msg00087.html
[2] http://sourceware.org/ml/ecos-discuss/1999-10/msg00095.html
[3] http://www.delorie.com/gnu/docs/binutils/ld_9.html


[Reply][About]
[<<][arm][>>][..]