Yahoo Groups archive

Lpc2000

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

Message

Re: [lpc2000] stack, srt0.S and *.ld files in WinARM

2006-03-02 by Thiago Takehara

Hello, Mr. Reszka,

I´m a noob in ARM and GNUARM too, and I don´t know a lot about LD and AS, but I would like to help. I´m so sorry if what I try to explain here is just basic things, but I´ll try to do my best.

When you compile your C code, all symbols are relative addressed, and is a task of your OS to translate this symbols to real addresses. But when you don´t have a OS, you must use a locator to place all this symbols on their places. In GNU-ARM´s case, the location function is made by LD program, and it uses the LD script to do this task.

I don´t know why you have to run all over your RAM if you are on debug mode, because I´ve never used an in-system debugger. For my case, I always locate my .text on ROM.

The crt0.s file is a initialization file. It prepares your environment so your C code can run as expected. It´s made up on assembly language because you have total control over the output. See, for example, the 'Vectors' section on your crt0.s file: these vectors are supposed to be (better: they must be) on the first 64 bytes of your addressing space. The eight first words are instructions called when you have an interruption or exception; the 'reserved' word is not used, but Phillips uses it to make a 2's complement checksum of the other vectors so your system have a chance to suppose the code inside is a valid code.

Following this words are the addresses where resides every ISR´s for the eight vector's positions. In your _mainCRTStartup section, 
all your stack pointers are configured by moving in the operation modes, setting stack pointers and leaving the operation mode. Then, your initialized variables are copied from ROM to RAM and the space for unitialized variables is reserved.

I have made my startup code and ld script based on uVision´s examples, but I couldn´t make it work with GNU-ARM. Then, I have tried the lpc2106_gcc.zip project, as suggested by mr. Maurer, and with a little bit of modifications, I could make my project work well. For support material, I use the "The Insider´s Guide To The Philips ARM7-Based Microcontrollers' book (http://www.cecs.csulb.edu/~brewer/347/lpc-ARM-book_srn.pdf) and the processor User Manual. Of course I use the GNU Toolchain books too, you can find then on www.gnuarm.org .

I´m developing for LPC2144 and I believe our start codes should be slightly different. Anyway, if you want I send you my startup codes... The only problem with ´em is they are all portuguese commented, so I believe you will not be able to understand then!

Regards,

Thiago Takehara
Computer Engineer
Engworks Industrial LTDA - R&D Division
 

----- Original Message ----- 
  From: Grzegorz Reszka 
  To: lpc2000@yahoogroups.com 
  Sent: Wednesday, March 01, 2006 9:27 PM
  Subject: [lpc2000] stack, srt0.S and *.ld files in WinARM


  Hello,
    I`m newbie in ARM uC and I wanted to write in WinARM a simple  (transition of LED) programme on LPC2138. But during linking (when I  use RUN_MODE=ROM_RUN, that means LPC2138-ROM.ld file) it returns  following error:
    
    Linking: LED.elf
    arm-elf-gcc -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2  -DROM_RUN  -Os -Wall -Wcast-align -Wcast-qual -Wimplicit   -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow  -Wunused -Wa,-adhlns=crt0.lst   -MD -MP -MF .dep/LED.elf.d  crt0.o    LED.o      --output  LED.elf -nostartfiles -Wl,-Map=LED.map,--cref -lc  -lm -lc  -lgcc  -lstdc++ -TLPC2138-ROM.ld
    c:\winarm\bin\..\lib\gcc\arm-elf\4.0.2\..\..\..\..\arm-elf\bin\ld.exe:  address 0x600 of LED.elf section .stack is not within region RAM
    make.exe: *** [LED.elf] Error 1
    
    > Process Exit Code: 2
    > Time Taken: 00:02
    
    
    I don`t understand why it wants to use the 0x600 size stack whilst the  size of this stack is declared in LPC2138-ROM.ld file as 0x400:
    STACK_SIZE = 0x400;
    
    And when I change in Makefile RUN_MODE to RAM_RUN (LPC2138-RAM.ld file) I receive following message:
    
    Linking: LED.elf
    arm-elf-gcc -mthumb -mcpu=arm7tdmi-s -mthumb-interwork -I. -gdwarf-2  -DRAM_RUN  -Os -Wall -Wcast-align -Wcast-qual -Wimplicit   -Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow  -Wunused -Wa,-adhlns=crt0.lst   -MD -MP -MF .dep/LED.elf.d  crt0.o    LED.o      --output  LED.elf -nostartfiles -Wl,-Map=LED.map,--cref -lc  -lm -lc  -lgcc  -lstdc++ -TLPC2138-RAM.ld
    crt0.o: In function `abort':D:\ARMprogramy\LED/crt0.S:215: undefined reference to `__bss_start'
    :D:\ARMprogramy\LED/crt0.S:215: undefined reference to `__bss_end__'
    :D:\ARMprogramy\LED/crt0.S:215: undefined reference to `__ctors_start__'
    :D:\ARMprogramy\LED/crt0.S:215: undefined reference to `__ctors_end__'
    make: *** [LED.elf] Error 1
    
    And also I don`t understand it - in line 215 of crt0.S is only this:
        b      .                          // loop until reset
    and it returns error about undefined refrence to: `__bss_start` , `__bss_end__' , etc.
    
    What should I do in this case? What should I change in my files which I attached to this message?
    
    More over: Could somebody explain me for what str0.S, RAM.ld and ROM.ld  files are needed exactly in ARM projects? Which parts of these files  are important?  When should I use RAM.ld and when ROM.ld files? By  the way could somebody give me those files which will be suitable for  LPC2138 uC?
    
    Thanks for every advice and response.
    
    Regards
    GR
    
  __________________________________________________
  Do You Yahoo!?
  Tired of spam?  Yahoo! Mail has the best spam protection around 
  http://mail.yahoo.com 

  [Non-text portions of this message have been removed]



  SPONSORED LINKS Microcontrollers  Microprocessor  Intel microprocessors  
        Pic microcontrollers  


------------------------------------------------------------------------------
  YAHOO! GROUPS LINKS 

    a..  Visit your group "lpc2000" on the web.
      
    b..  To unsubscribe from this group, send an email to:
     lpc2000-unsubscribe@yahoogroups.com
      
    c..  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service. 


------------------------------------------------------------------------------



[Non-text portions of this message have been removed]

Attachments

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.