Linker error with LPC2378 - example code

OP #1307956
Rate this post
• ▲ useful
▼ not useful
Hi,

I am trying to use the WinARM (WinARM-20070505) for LPC2378.

I took the example "C:\WinARM\examples\lpc2378_demo1" and try to add a 
dummy code to just blink LED's. But, I am getting some linker errors.

So to single out the problem, I have only main.c and startup.S and 
removed all other files from the makefile. Even in the main.c I have 
removed all the other code and just have a while(1) loop to blink the 
LED's. With this again the same error happens (as mentioned below).

Any suggestions are welcome.

-------- begin (mode: ROM_RUN) --------
arm-elf-gcc (GCC) 4.1.2 (WinARM 4/2007)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is 
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR 
PURPOSE.


Assembling (ARM-only): Startup.S
arm-elf-gcc -c -mcpu=arm7tdmi-s  -I. -x assembler-with-cpp -DROM_RUN 
-D__WinARM__ -D__WINARMSUBMDL_LPC2378__ 
-Wa,-adhlns=Startup.lst,-gdwarf-2 Startup.S -o Startup.o

Compiling C: main.c
arm-elf-gcc -c  -mcpu=arm7tdmi-s  -I. -gdwarf-2 -DROM_RUN -D__WinARM__ 
-D__WINARMSUBMDL_LPC2378__  -Os -Wall -Wcast-align -Wimplicit 
-Wpointer-arith -Wswitch -ffunction-sections -fdata-sections 
-Wredundant-decls -Wreturn-type -Wshadow -Wunused -Wa,-adhlns=main.lst 
-ICommon/inc -Wcast-qual -MD -MP -MF .dep/main.o.d -Wnested-externs 
-std=gnu99 -Wmissing-prototypes  -Wstrict-prototypes 
-Wmissing-declarations main.c -o main.o

Linking: main.elf
arm-elf-gcc  -mcpu=arm7tdmi-s  -I. -gdwarf-2 -DROM_RUN -D__WinARM__ 
-D__WINARMSUBMDL_LPC2378__  -Os -Wall -Wcast-align -Wimplicit 
-Wpointer-arith -Wswitch -ffunction-sections -fdata-sections 
-Wredundant-decls -Wreturn-type -Wshadow -Wunused 
-Wa,-adhlns=Startup.lst  -ICommon/inc -Wcast-qual -MD -MP -MF 
.dep/main.elf.d Startup.o   main.o     --output main.elf -nostartfiles 
-Wl,-Map=main.map,--cref,--gc-sections -lc  -lm -lc -lgcc 
-T.//LPC2378-ROM.ld
c:/winarm/bin/../lib/gcc/arm-elf/4.1.2/../../../../arm-elf/bin/ld.exe: 
address 0x700 of main.elf section .stack is not within region RAM
collect2: ld returned 1 exit status
make.exe: *** [main.elf] Error 1

> Process Exit Code: 2
> Time Taken: 00:01

With best regards,
Phani.
Guest #1320577
Rate this post
• ▲ useful
▼ not useful
Hi,

The linker script is attached. Also the main.c, main() is as follows. 
Still not clear what may be missing.

/*
   "Epsilon"
   LPC2378 Demo by Martin Thomas, Kaiserslautern, Germany
   http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects

   Target:   LPC2378
   Board:    Olimex LPC-2378-STK
   Compiler: GNU arm-elf or arm-eabi toolchain
             (tested with WinARM 6/06)

   Partly based on drivers from the NXP LPC23xx & 24xx
   example-collection available from www.nxp.com.
*/

#define VERSION_STRING "0.3 beta^2 mthomas, KL, .de"

#include "LPC23xx.h"
#include "type.h"
#include "irq.h"
#include "target.h"
#include "timer.h"

#include "fio.h"
#include "uart.h"

// LED1 (MCIPWR on Olimex LPC-2378-STK has an indicator LED)
#define LED1_FIOPIN  FIO0PIN
#define LED1_FIOSET  FIO0SET
#define LED1_FIOCLR  FIO0CLR
#define LED1_MASK    (1UL<<21)

#define INBUF_SIZE   0x80

#define UART_NUM     0
#define NEXTLINE     "\r\n"
#define ENTERKEY     '\r'
static const char welcome[] = NEXTLINE "Welcome to the WinARM LPC2378 
Demo#1 \"Epsilon\"" NEXTLINE;
static const char version[] = "Version "VERSION_STRING NEXTLINE;

static void time_waste( unsigned int dv )
{
  volatile unsigned int cnt;

  for ( cnt=0; cnt<dv ; cnt++ ) { ; }
}


int main (void)
{
//Code added by Phani
  unsigned int u32counter = 0 ;

    FIO2DIR = 0x000000FF;    /* P2.0..7 defined as Outputs */
    FIO2CLR = 0x000000FF;    /* turn off all the LEDs */
  time_waste( 0x00090000 );
  FIO2CLR = 0x000000FF;
//#ifdef NOT_POSSIBLE_TO_COMPILE

  while(1)
  {
        FIO2CLR = 0x000000FF;
      FIO2SET = 1 << u32counter;
      u32counter++;
      time_waste( 0x00090000 );
      if ( u32counter > 8 )
      {
          u32counter = 0;
      }
  }
//#endif
//Till here
  return 0;
}
Attached files:
#1323708
Rate this post
• ▲ useful
▼ not useful
I found where the error comes from:
In your linker script, the lines below hide a mistake:
  . = ALIGN(4);
  _bss_end_ = . ;
  PROVIDE (__bss_end = .);

  .stack ALIGN(256) :
  {
    *(.stack)
  *(.STACK)
    PROVIDE (_stack = .);
    . = ALIGN(4);
  } > RAM

I imagine that you want the .stack section to be 256 bytes aligned in 
the RAM region, but the line ".stack ALIGN(256)" will set .stack to 
address 0x700
, and obviously this address is not within RAM region
You should do like this:
  . = ALIGN(4);
  _bss_end_ = . ;
  PROVIDE (__bss_end = .);

  . = ALIGN(256);
  .stack :
  {
    *(.stack)
  *(.STACK)
    PROVIDE (_stack = .);
    . = ALIGN(4);
  } > RAM

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.