This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: ATMEL EB40 demo board


Attached are the linker script and crt0.S
If you have any questions, drop me a line.

Cheers,
Shaun


Richard Slaughter wrote:

> Hello All,
> 
>  
> 
> Has anyone successfull gotten the GNU tool chain to build/debug programs 
> for the atmel eb40 demo board.
> 
> Thanks
> 
> Richard


STARTUP( crt0.o)
ENTRY( _start)

MEMORY
{
	ram : ORIGIN = 0x02000000, LENGTH = 512k
}
  
SECTIONS
{
  .text      :
  {
    __start__ = .;
    *(.text)
    *(.text.*)
    *(.stub)
    /* .gnu.warning sections are handled specially by elf32.em.  */
    *(.gnu.warning)
    *(.gnu.linkonce.t*)
    *(.glue_7t) *(.glue_7)
  } > ram = 0

  .rodata   :
  {
    *(.rodata)
    *(.rodata.*)
    *(.gnu.linkonce.r*)
  } > ram

  .data    :
  {
    *(.data)
    *(.data.*)
    *(.gnu.linkonce.d*)
    SORT( CONSTRUCTORS)
  } > ram

  _bss_start__ = . ; __bss_start__ = . ;
  .bss       :
  {
    *(.dynbss)
    *(.bss)
    *(.bss.*)
    *(COMMON)
    /* Align here to ensure that the .bss section occupies space up to
       _end.  Align after .bss to ensure correct alignment even if the
       .bss section disappears because there are no input sections.  */
    . = ALIGN(32 / 8);
  } > ram
  . = ALIGN(32 / 8);
  _end = .;
  _bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
  PROVIDE (end = .);
	

  /* DWARF debug sections.
     Symbols in the DWARF debugging sections are relative to the beginning
     of the section so we begin them at 0.  */
  /* DWARF 1 */
  .debug          0 : { *(.debug) }
  .line           0 : { *(.line) }
  /* GNU DWARF 1 extensions */
  .debug_srcinfo  0 : { *(.debug_srcinfo) }
  .debug_sfnames  0 : { *(.debug_sfnames) }
  /* DWARF 1.1 and DWARF 2 */
  .debug_aranges  0 : { *(.debug_aranges) }
  .debug_pubnames 0 : { *(.debug_pubnames) }
  /* DWARF 2 */
  .debug_info     0 : { *(.debug_info) }
  .debug_abbrev   0 : { *(.debug_abbrev) }
  .debug_line     0 : { *(.debug_line) }
  .debug_frame    0 : { *(.debug_frame) }
  .debug_str      0 : { *(.debug_str) }
  .debug_loc      0 : { *(.debug_loc) }
  .debug_macinfo  0 : { *(.debug_macinfo) }
  /* SGI/MIPS DWARF 2 extensions */
  .debug_weaknames 0 : { *(.debug_weaknames) }
  .debug_funcnames 0 : { *(.debug_funcnames) }
  .debug_typenames 0 : { *(.debug_typenames) }
  .debug_varnames  0 : { *(.debug_varnames) }
}

__stack_start__ = 0x02080000;
__stackirq_start__ = 0x1000;
/* ARM crt0.S from newlib
** modified for a custom board
** Atmel AT91 processor
*/

/* ANSI concatenation macros.  */
#define CONCAT(a, b) CONCAT2(a, b)
#define CONCAT2(a, b) a ## b

#ifdef __USER_LABEL_PREFIX__
#define FUNCTION( name ) CONCAT (__USER_LABEL_PREFIX__, name)
#else
#error __USER_LABEL_PREFIX is not defined
#endif

/* .text is used instead of .section .text so it works with arm-aout too.  */
	.text
	.code 32
	.align 	0

	.global	_mainCRTStartup
	.global	_start
	.global	start
start:
_start:
_mainCRTStartup:

#if 1
        nop
        nop
        nop
        nop
        nop
        nop
        nop
        nop
#else
/* freeze so we can grab a hold of it with the jeeni */
	b start
	b start
	b start
	b start
	b start
	b start
	b start
	b start
#endif

// test for a jeeni
        ldr     r0, have_jeeni
        cmp     r0, #0
        bne     have_jeeni0

// set up early read protocol and active chip selects
        ldr     r0, .LCebimcra
        mov     r1, #0x15
        str     r1, [r0]

// set up the flash cs
        ldr     r0, .LCflashcsa
        ldr     r1, .LCflashcsd
        str     r1, [r0]

// set up the sram cs
        ldr     r0, .LCsramcsa
        ldr     r1, .LCsramcsd
	str	r1, [r0]

// copy from flash to internal sram
        mov     r1, pc
        add     r0, r1, #0x00300000
        ldmia   r1, {r2-r10}
        stmia   r0, {r2-r10}

// remap
        ldr     r0, .LCremapa
        mov     r1, #1
        str     r1, [r0]

// jump to flash
        add     pc, pc, #0x01000000
        // using pc as an argument skips an instruction
        nop

have_jeeni0:

// set up a stack limit and frame pointer
	mov 	r0, #0
	mov     sl, r0                  /* Null stack limit */
	mov	fp, r0  		/* Null frame pointer */
	mov	r7, r0			/* Null frame pointer for Thumb */
	
// set up the stack pointer and cpsr
        mov     r3, #0x12
        msr     cpsr_c, r3
	ldr     r3, .LC00
	mov     sp, r3
        mov     r3, #0x10
        msr     cpsr_c, r3
        ldr     r3, .LC0
        mov     sp, r3

// test for a jeeni
        ldr     r0, have_jeeni
        cmp     r0, #0
        bne     have_jeeni1

// copy from flash to sram
	ldr	a1, .LC3 //dst
	ldr	a3, .LC4
	sub	a3, a3, a1 //len
	mov	a2, #0x01000000 //src
	bl	FUNCTION (memcpy)

// jump from flash to sram
	add     pc, pc, #0x01000000
        // using pc as an argument skips an instruction
	nop

have_jeeni1:

// clear bss
	ldr	a1, .LC1		/* First arg: start of memory block */
	ldr	a3, .LC2
	sub	a3, a3, a1		/* Third arg: length of block */
        mov     a2, #0

#ifdef __thumb__		/* Enter Thumb mode.... */

	add	a4, pc, #1	/* Get the address of the Thumb block */
	bx	a4		/* Go there and start Thumb decoding  */

	.code 16
	.global __change_mode
	.thumb_func
__change_mode:
#endif

	bl	FUNCTION (memset)

	mov	r0, #0		/*  no arguments  */
	mov	r1, #0		/*  no argv either */
	mov	r2, #0
	bl	FUNCTION (main)

	bl	FUNCTION (exit)		/* Should not return */

#ifdef __thumb__
	/* Come out of Thumb mode... This code should be redundant...   */

	mov	a4, pc
	bx	a4

	.code 32
	.global change_back
change_back:
        b       change_back
#endif
	
	/* For Thumb, constants must be after the code since only 
	positive offsets are supported for PC relative addresses. */
	
	.align 0
.LC0:
	.word	__stack_start__
.LC00:
        .word   __stackirq_start__
.LC1:
	.word	__bss_start__
.LC2:
	.word	__bss_end__
.LC3:
	.word	__start__
.LC4:
	.word	__end__

.LCflashcsa:
        .word   0xffe00000
.LCflashcsd:
        .word   0x01000000 | (1<<13) | (1<<12) | (1<<7) | (7<<2) | (1<<5) | (1<<0)

.LCsramcsa:
        .word   0xffe00008
.LCsramcsd:
        .word   0x02000000 | (1<<13) | (1<<12) | (1<<0)

.LCremapa:
        .word   0xffe00020

.LCebimcra:
        .word   0xffe00024

have_jeeni:
        .word   0

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]