Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

Many thanks to ariusdsp -> how to build application ?

Many thanks to ariusdsp -> how to build application ?

2003-12-16 by capiman@t-online.de

Hello,

first many thanks to ariusdsp for their arm toolchain, seems to be running
fine under cygwin (WinXP)
Already compiled some C code from this newsgroup.

But: Can you tell me how to proceed ?

arm-elf-gcc -S helloworld.c
arm-elf-gcc -mcpu=arm7tdmi -mthumb -O2 -g -c helloworld.c
arm-elf-gcc -mcpu=arm7tdmi -mthumb -o helloworld helloworld.o -lc
arm-elf-objcopy --output-target srec helloworld helloworld.srec
arm-elf-objcopy --output-target ihex helloworld helloworld.hex
arm-elf-objcopy --output-target binary helloworld helloworld.bin

Theoretically i would say i can load the intel binary helloworld.hex ? Is
this correct ?
I think i remember to read something the program start was 0x8000,
and when i call gdb i see that start is 0x8000. But for LPC210x this must be
0x0000 ?
Can someone send me the option again ?

Must i have the startup stub or why can't i directly jump to main ?
Is the stub for initializing the variable & other things ?

Greetings and many thanks for the help,

               Martin Maurer

Re: [lpc2100] Many thanks to ariusdsp -> how to build application ?

2003-12-16 by Lewin A.R.W. Edwards

Hello,

> I think i remember to read something the program start was 0x8000,
> and when i call gdb i see that start is 0x8000. But for LPC210x this

You need to use a linker script.

I have made the example programs from my getting-started-with-ARM book
available for download from my web site :
<http://www.zws.com/publications/downloads/sourcecode.tar.gz> (If you
are downloading with certain versions of Internet Explorer, you may have
to correct the filename - MSIE will try to save it as "sourcecode.tar.tar").

These will show you how to link applications for various startup
methods. I suggest you look at the rom-blinker example. These code
snippets are actually for Atmel AT91R40807, but the makefiles and linker
scripts are what you want to look at. The startup code could be of
interest too.

> Must i have the startup stub or why can't i directly jump to main ?
> Is the stub for initializing the variable & other things ?

The minimum startup code must:

* contain the ARM exception vector table (which lives at 0x0000)
* copy initialized variables from ROM to RAM
* set up stack(s)
* zero out the heap (optional but STRONGLY RECOMMENDED)
* jump to main()

-- Lewin A.R.W. Edwards (http://www.zws.com/)
Learn how to develop high-end embedded systems on a tight budget!
http://www.amazon.com/exec/obidos/ASIN/0750676094/zws-20

Re: [lpc2100] Many thanks to ariusdsp -> how to build application ?

2003-12-16 by Robert Adsett

At 03:57 PM 12/16/03 -0500, you wrote:
>Hello,
>
> > I think i remember to read something the program start was 0x8000,
> > and when i call gdb i see that start is 0x8000. But for LPC210x this
>
>You need to use a linker script.
>
>I have made the example programs from my getting-started-with-ARM book
>available for download from my web site :
><http://www.zws.com/publications/downloads/sourcecode.tar.gz> (If you
>are downloading with certain versions of Internet Explorer, you may have
>to correct the filename - MSIE will try to save it as "sourcecode.tar.tar").
>
>These will show you how to link applications for various startup
>methods. I suggest you look at the rom-blinker example. These code
>snippets are actually for Atmel AT91R40807, but the makefiles and linker
>scripts are what you want to look at. The startup code could be of
>interest too.
>
> > Must i have the startup stub or why can't i directly jump to main ?
> > Is the stub for initializing the variable & other things ?
>
>The minimum startup code must:
>
>* contain the ARM exception vector table (which lives at 0x0000)
>* copy initialized variables from ROM to RAM
>* set up stack(s)
>* zero out the heap (optional but STRONGLY RECOMMENDED)
>* jump to main()

Also set uninitialized globals to 0.  That way you get a fairly standard C 
run-time environment.

I've never bothered zeroing the heap since after the first free it's not 
zeroed anyway so why bother?


" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Re: [lpc2100] Many thanks to ariusdsp -> how to build application ?

2003-12-16 by capiman@t-online.de

Has someone in the group already created such a linker script for the
LPC2106 ?
I started to modify the example, but it seems to be a non trivial task,
without knowing the right syntax of a linker script.

I think, what i am searching for is a "hello world" for LPC2106 with gnu arm
toolchain from source to hex-file...
Leon: This is perhaps worth uploading to your website ?

Greetings,

          Martin

Re: [lpc2100] Many thanks to ariusdsp -> how to build application ?

2003-12-16 by Robert Adsett

At 11:05 PM 12/16/03 +0100, you wrote:
>Has someone in the group already created such a linker script for the
>LPC2106 ?
>I started to modify the example, but it seems to be a non trivial task,
>without knowing the right syntax of a linker script.
>
>I think, what i am searching for is a "hello world" for LPC2106 with gnu arm
>toolchain from source to hex-file...
>Leon: This is perhaps worth uploading to your website ?
>
>Greetings,
One linker script coming up.  This is for the 2104 but should be trivial to 
modify for the 2106.  I've got more to do, particularly for the register 
definitions.  The endless loop references provide default traps for any 
exception vectors I don't define.

SEARCH_DIR( /home/radsett/install/arm-elf/lib)
SEARCH_DIR( /home/radsett/install/lib/gcc-lib/arm-elf/3.3.2)
MEMORY {
   flash : ORIGIN = 0, LENGTH = 120K
   ram : ORIGIN = 0x40000000, LENGTH = 16K
   }

__stack_end__ = 0x40000000 + 16K - 4;
SECTIONS {
  . = 0;
  startup : { *(.startup)} >flash
  prog : {
         *(.text)
         *(.rodata)
         *(.rodata*)
         *(.glue_7)
         *(.glue_7t)
         } >flash
  __end_of_text__ = .;
  .data : {
         __data_beg__ = .;
         __data_beg_src__ = __end_of_text__;
         *(.data)
         __data_end__ = .;
         } >ram AT>flash
  .bss : {
         __bss_beg__ = .;
         *(.bss)
         } >ram
    /* 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);
   }
   . = ALIGN(32 / 8);
   _end = .;
   _bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
   PROVIDE (end = .);
INPUT( -lc -lgcc)
PROVIDE( undefined_instruction_exception = endless_loop);
PROVIDE( software_interrupt_exception = endless_loop);
PROVIDE( prefetch_abort_exception = endless_loop);
PROVIDE( data_abort_exception = endless_loop);
PROVIDE( reserved_exception = endless_loop);
PROVIDE( interrupt_exception = endless_loop);
PROVIDE( fast_interrupt_exception = endless_loop);

PROVIDE( PINSEL0 = 0xE002C000);
PROVIDE( IODIR = 0xE0028008);
PROVIDE( IOCLR = 0xE002800C);
PROVIDE( IOSET = 0xE0028004);

/* UART 0 */

PROVIDE( U0RBR = 0xE000C000);
PROVIDE( U0THR = 0xE000C000);
PROVIDE( U0IER = 0xE000C004);
PROVIDE( U0IIR = 0xE000C008);
PROVIDE( U0FCR = 0xE000C008);
PROVIDE( U0LCR = 0xE000C00C);
PROVIDE( U0LSR = 0xE000C014);
PROVIDE( U0SCR = 0xE000C01C);
PROVIDE( U0DLL = 0xE000C000);
PROVIDE( U0DLM = 0xE000C004);

/* PLL */

PROVIDE( PLLCON = 0xE01FC080);
PROVIDE( PLLCFG = 0xE01FC084);
PROVIDE( PLLSTAT = 0xE01FC088);
PROVIDE( PLLFEED = 0xE01FC08C);

/* MAM */

PROVIDE( MAMCR = 0xE01FC000);
PROVIDE( MAMTIM = 0xE01FC004);

/* VPB */

PROVIDE( VPBDIV = 0xE01FC100);

/* TIMER 0 */

PROVIDE( T0IR = 0xE0004000);
PROVIDE( T0TCR = 0xE0004004);
PROVIDE( T0TC = 0xE0004008);
PROVIDE( T0PR = 0xE000400C);
PROVIDE( T0PC = 0xE0004010);
PROVIDE( T0MCR = 0xE0004014);
PROVIDE( T0MR0 = 0xE0004018);
PROVIDE( T0MR1 = 0xE000401C);
PROVIDE( T0MR2 = 0xE0004020);
PROVIDE( T0MR3 = 0xE0004024);
PROVIDE( T0CCR = 0xE0004028);
PROVIDE( T0CR0 = 0xE000402C);
PROVIDE( T0CR1 = 0xE0004030);
PROVIDE( T0CR2 = 0xE0004034);
PROVIDE( T0EMR = 0xE000403C);


Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Re: [lpc2100] Many thanks to ariusdsp -> how to build application ?

2003-12-16 by Lewin A.R.W. Edwards

> Has someone in the group already created such a linker script for the
> LPC2106 ?
> I started to modify the example, but it seems to be a non trivial task,
> without knowing the right syntax of a linker script.

It should be a very simple task, all you would really need to do is
change the ROM and ROM addresses.

But then, I did spend 100+ pages in my book talking about how linker
scripts and makefiles are put together :)

-- Lewin A.R.W. Edwards (http://www.zws.com/)
Learn how to develop high-end embedded systems on a tight budget!
http://www.amazon.com/exec/obidos/ASIN/0750676094/zws-20

Re: [lpc2100] Many thanks to ariusdsp -> how to build application ?

2003-12-16 by Pablo Bleyer Kocik

At 17:39 2003-12-16, you wrote:
>Hello,
>
>first many thanks to ariusdsp for their arm toolchain, seems to be running
>fine under cygwin (WinXP)

  Please, let us know if you find any problems.

  I have tested it with a few targets and it seems to work alright, but 
with Windows you never know ;^) Do you have CygWin installed in your system 
or you are using the supplied CygWin DLLs?

  ARM compilation for the current GCC is particularly buggy in some 
situations, and specially for thumb mode. I know most of the [known] 
roaches (á là http://www.intercorr.com/roach.htm) have been eliminated in 
the 3.4 series. I hope this release comes out soon. If not, I will study 
the possibility to release an intermediate 3.4 snapshot build.

>Already compiled some C code from this newsgroup.
>
>But: Can you tell me how to proceed ?
>
>arm-elf-gcc -S helloworld.c
>arm-elf-gcc -mcpu=arm7tdmi -mthumb -O2 -g -c helloworld.c
>arm-elf-gcc -mcpu=arm7tdmi -mthumb -o helloworld helloworld.o -lc
>arm-elf-objcopy --output-target srec helloworld helloworld.srec
>arm-elf-objcopy --output-target ihex helloworld helloworld.hex
>arm-elf-objcopy --output-target binary helloworld helloworld.bin

  Please, always use the appropriate cpu and interwork switches, since the 
toolchain targets all arm architecture versions.

>Theoretically i would say i can load the intel binary helloworld.hex ? Is
>this correct ?

  That really depends on the tool but, yes, most of them will recognize 
Intel HEX format.

>I think i remember to read something the program start was 0x8000,
>and when i call gdb i see that start is 0x8000. But for LPC210x this must be
>0x0000 ?
>Can someone send me the option again ?
>Must i have the startup stub or why can't i directly jump to main ?
>Is the stub for initializing the variable & other things ?

  As Lewin pointed out, this will depend on the linker scripts.

  If you are getting started with the GNU toolchain for ARM7TDMI, I have 
found that a very good learning approach is to use the VisualBoyAdvance 
emulator (http://vboy.emuhq.com/). The architecture of Nintendo's GBA is 
simple and well described all over the net 
(http://www.cs.rit.edu/~tjh8300/CowBite/CowBiteSpec.htm), and Jeff Frohwein 
has written the necessary scripts and C-runtime code in a well documented 
fashion (http://www.devrs.com/). Nice thing about the VBA is that the GDB 
debug stub is built in, so you can use GDB remotely with it. This is a very 
good virtual learning platform.

  Regards.


--
PabloBleyerKocik /"...I didn't want to be kissing Kevin Spacey.
  pbleyer        / Come on! Lying there naked with rose petals?"
   @... /- Kirsten Dunst on turning down American Beauty

Re: [lpc2100] Many thanks to ariusdsp -> how to build application ?

2003-12-16 by Robert Adsett

At 05:13 PM 12/16/03 -0500, you wrote:
>At 11:05 PM 12/16/03 +0100, you wrote:
> >Has someone in the group already created such a linker script for the
> >LPC2106 ?
> >I started to modify the example, but it seems to be a non trivial task,
> >without knowing the right syntax of a linker script.
> >
> >I think, what i am searching for is a "hello world" for LPC2106 with gnu arm
> >toolchain from source to hex-file...
> >Leon: This is perhaps worth uploading to your website ?
> >
> >Greetings,
>One linker script coming up.

Oh and the startup that goes with it.

/* Sample initialization file */

         .extern main
         .extern exit

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

         .text
         .code 32


         .align  0

         .extern __bss_beg__
         .extern __bss_end__
         .extern __stack_end__
         .extern __data_beg__
         .extern __data_end__
         .extern __data+beg_src__

         .global start
/*      .global _mainCRTStartup */
/*      .global _start */
         .global endless_loop

start:
_start:
_mainCRTStartup:
/* Start by setting up a stack */
         /*  Set up the stack pointer to end of bss */
         ldr             r3, .LC6
         mov     sp, r3

         sub             sl, sp, #512    /* Still assumes 512 bytes below sl */

         mov     a2, #0          /* Second arg: fill value */
         mov             fp, a2          /* Null frame pointer */
         mov             r7, a2          /* Null frame pointer for Thumb */

/*      ldr             r1, #__bss_beg__*/      /* First arg: start of 
memory block */

         ldr     r1, .LC1                        /* First arg: start of 
memory block */
/*      ldr     r3, #__bss_end__*/      /* Second arg: end of memory block */
         ldr     r3, .LC2                        /* Second arg: end of 
memory block */
         subs    r3, r3, r1                      /* Third arg: length of 
block */
         beq             .end_clear_loop
         mov     r2, #0

.clear_loop:
         strb    r2, [r1], #1
         subs    r3, r3, #1
         bgt             .clear_loop

.end_clear_loop:

         ldr             r1, .LC3                /* First arg: start of 
memory block */
         ldr     r2, .LC4                /* Second arg: end of memory block */
         ldr     r3, .LC5
         subs    r3, r3, r1              /* Third arg: length of block */
         beq             .end_set_loop

.set_loop:
         ldrb    r4, [r2], #1
         strb    r4, [r1], #1
         subs    r3, r3, #1
         bgt     .set_loop

.end_set_loop:


         mov             r0, #0          /*  no arguments  */
         mov             r1, #0          /* no argv either */

         bl              main

endless_loop:
         b               endless_loop

         bl              exit            /* Should not return */

         /* For Thumb, constants must be after the code since only
         positive offsets are supported for PC relative addresses. */

         .align 0
.LC1:
.word   __bss_beg__
.LC2:
.word   __bss_end__
.LC3:
.word   __data_beg__
.LC4:
.word   __data_beg_src__
.LC5:
.word   __data_end__
.LC6:
.word   __stack_end__

.section .startup,"ax"
         .code 32
         .align 0

         b       start
         b       undefined_instruction_exception
         b       software_interrupt_exception
         b       prefetch_abort_exception
         b       data_abort_exception
         b       reserved_exception
         b       interrupt_exception
         b       fast_interrupt_exception

Robert


" 'Freedom' has no meaning of itself.  There are always restrictions,
be they legal, genetic, or physical.  If you don't believe me, try to
chew a radio signal. "

                         Kelvin Throop, III

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.