Grzegorz Reszka wrote:
>Hello,
>
> Thanks for link to the lpc-ARM-book_srn.pdf. I read it and my knowledge
about LPC uControllers now is better ;). Actually, I`m using startup.s and
linker.ld from KEIL uVision. I was making some tests with WinARM crt0.s and
LPC2138-ROM.ld files and using them is possible but only when I change
STACK_SIZE from 0x400 to 0x000, So it is quite strange - size of stack equals
zero???? What do you think about it?
>
> By the way, can you send me your *.s and *.ld files? It doesn`t matter
that they are commented in portuguese. I will compare them with my files and I
wil try to understand them. Eventually I will use to do it some translator or
dictionary ;).
>
>
Your linker script does look odd, this is mine from a gcc-4.0.2 Thumb
dev environ (binutils-2.16.1, gcc-4.0.2):
=============== begin LPC2138ROM.ld
===================/***********************************************************************/
/* */
/* ROM.ld: Linker Script File */
/* */
/***********************************************************************/
SEARCH_DIR( ../libs )
SEARCH_DIR( ./)
ENTRY(_boot)
STACK_SIZE = 0x800;
/* Memory Definitions */
MEMORY
{
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 0x00080000
RAM (rw) : ORIGIN = 0x40000000, LENGTH = 0x00008000
}
/* Section Definitions */
SECTIONS
{
/* first section is .text which is used for code */
.text :
{
*crt0.o (.text) /* Startup code */
*(.text) /* remaining code */
*(.rodata) /* read-only data (constants) */
*(.rodata*)
*(.glue_7)
*(.glue_7t)
} > ROM
. = ALIGN(4);
_etext = . ;
PROVIDE (etext = .);
/* .data section which is used for initialized data */
.data : AT (_etext)
{
_data = .;
*(.data)
} > RAM
. = ALIGN(4);
_edata = . ;
PROVIDE (edata = .);
/* .bss section which is used for uninitialized data */
.bss (NOLOAD) :
{
__bss_start = . ;
__bss_start__ = . ;
*(.bss)
*(COMMON)
. = ALIGN(4);
} > RAM
. = ALIGN(4);
__bss_end__ = . ;
PROVIDE (__bss_end = .);
.stack ALIGN(256) :
{
. += STACK_SIZE;
PROVIDE (_stack = .);
} > RAM
_end = . ;
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* 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 .gnu.linkonce.wi.*) }
.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) }
}
/* Libraries to link against. */
INPUT( -lc -lstdc -lgcc );
==================== snip =========================
I use the above script to create the elf image, then this image is then
used to create the binary image that goes into flash. If you are
running cygwin, it would be a good idea to install the manpages and run
an 'info ld' to see what is in these linker scripts. The ld info
pages
have a tutorial guiding you through just what is in these scripts.
Please note, the information regarding debugging information is strictly
for where to place this into the elf file. It is not used in the
binary. That debug info is used for Insight (gdb + gui).
I don't run cygwin (linux here) so I don't know what the details of
getting the manpages installed would be.
Regards,
TomW
--
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net,http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------
Hello,
Thanks for link to the lpc-ARM-book_srn.pdf. I read it and my knowledge about
LPC uControllers now is better ;). Actually, I`m using startup.s and linker.ld
from KEIL uVision. I was making some tests with WinARM crt0.s and
LPC2138-ROM.ld files and using them is possible but only when I change
STACK_SIZE from 0x400 to 0x000, So it is quite strange - size of stack equals
zero???? What do you think about it?
By the way, can you send me your *.s and *.ld files? It doesn`t matter that
they are commented in portuguese. I will compare them with my files and I wil
try to understand them. Eventually I will use to do it some translator or
dictionary ;).
Regards,
Grzegorz Reszka
grzegorz.reszka@grze...
Thiago Takehara <thiago@thia...> wrote: Hello, Mr. Reszka,
Im a noob in ARM and GNUARM too, and I dont know a lot about LD and AS, but I
would like to help. Im so sorry if what I try to explain here is just basic
things, but Ill 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 dont
have a OS, you must use a locator to place all this symbols on their places. In
GNU-ARMs case, the location function is made by LD program, and it uses the LD
script to do this task.
I dont know why you have to run all over your RAM if you are on debug mode,
because Ive 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. Its 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 ISRs 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 uVisions examples, but I
couldnt 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
Insiders 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 .
Im 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@lpc2...
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
__________________________________________________
SPONSORED LINKS Microcontrollers Microprocessor Intel microprocessors
Pic microcontrollers
------
YAHOO! GROUPS LINKS
a..
------
SPONSORED LINKS
Microcontrollers
Microprocessor
Intel microprocessors
Pic microcontrollers
---------------------------------
YAHOO! GROUPS LINKS
---------------------------------
---------------------------------
Yahoo! Mail
Bring photos to life! New PhotoMail makes sharing a breeze.
Reply by Thiago Takehara●March 2, 20062006-03-02
Hello, Mr. Reszka,
Im a noob in ARM and GNUARM too, and I dont know a lot about LD and AS, but I
would like to help. Im so sorry if what I try to explain here is just basic
things, but Ill 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 dont have
a OS, you must use a locator to place all this symbols on their places. In
GNU-ARMs case, the location function is made by LD program, and it uses the LD
script to do this task.
I dont know why you have to run all over your RAM if you are on debug mode,
because Ive 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. Its 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 ISRs 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 uVisions examples, but I
couldnt 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
Insiders 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 .
Im 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@lpc2...
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
__________________________________________________
SPONSORED LINKS Microcontrollers Microprocessor Intel microprocessors
Pic microcontrollers
------
YAHOO! GROUPS LINKS
a..
------
Reply by Grzegorz Reszka●March 2, 20062006-03-02
So, I tried to find some information about *.ld and crt0.S files in many
places and actually I don`t remeber exactly where do they come from (probably
from some other forum). Anyway, I use following files:
/***********************************************************************/
/* ROM.ld: Linker Script File */
/***********************************************************************/
ENTRY(_boot)
STACK_SIZE = 0x400;
/* Memory Definitions */
MEMORY
{
ROM (rx) : ORIGIN = 0x00000000, LENGTH = 512k
RAM (rw) : ORIGIN = 0x40000000, LENGTH = 32k
}
/* Section Definitions */
SECTIONS
{
/* first section is .text which is used for code */
.text :
{
*crt0.o (.text) /* Startup code */
KEEP(*(.init)) /* Startup code from .init-section */
*(.text .text.*) /* remaining code */
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.gcc_except_table)
*(.rodata) /* read-only data (constants) */
*(.rodata*)
*(.gnu.linkonce.r.*)
} > ROM
/***** old:
.text :
{
*crt0.o (.text)
*(.text)
*(.rodata)
*(.rodata*)
*(.glue_7)
*(.glue_7t)
} > ROM
/*****/
. = ALIGN(4);
/* .ctors .dtors are used for c++ constructors/destructors */
/* added by Martin Thomas 4/2005 based on Anglia Design example */
.ctors :
{
PROVIDE(__ctors_start__ = .);
KEEP(*(SORT(.ctors.*)))
KEEP(*(.ctors))
PROVIDE(__ctors_end__ = .);
} >ROM
.dtors :
{
PROVIDE(__dtors_start__ = .);
KEEP(*(SORT(.dtors.*)))
KEEP(*(.dtors))
PROVIDE(__dtors_end__ = .);
} >ROM
. = ALIGN(4);
/* mthomas - end */
_etext = . ;
PROVIDE (etext = .);
/* .data section which is used for initialized data */
.data : AT (_etext)
{
_data = .;
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
SORT(CONSTRUCTORS) /* mt 4/2005 */
. = ALIGN(4);
*(.fastrun) /* !!!! "RAM-Function" example */
} > RAM
. = ALIGN(4);
_edata = . ;
PROVIDE (edata = .);
/* .bss section which is used for uninitialized data */
.bss (NOLOAD) :
{
__bss_start = . ;
__bss_start__ = . ;
*(.bss)
*(.gnu.linkonce.b*)
*(COMMON)
. = ALIGN(4);
} > RAM
. = ALIGN(4);
__bss_end__ = . ;
PROVIDE (__bss_end = .);
.stack ALIGN(256) :
{
. += STACK_SIZE;
PROVIDE (_stack = .);
} > RAM
_end = . ;
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* 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 .gnu.linkonce.wi.*) }
.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) }
}
/***********************************************************************/
/* */
/* RAM.ld: Linker Script File */
/* */
/***********************************************************************/
ENTRY(_start)
STACK_SIZE = 0x400;
RAM_LIMIT = 0x40008000;
/* Memory Definitions */
MEMORY
{
FLASH (rx) : ORIGIN = 0x0, LENGTH = 0x80000 /* 512Kb of internal
FLASH */
SRAM (rwx) : ORIGIN = 0x40000000, LENGTH = 0x8000 /* 32Kb of internal
SRAM */
}
/* Section Definitions */
SECTIONS
{
/* first section is .text which is used for code */
.text :
{
*crt0.o (.text)
*(EXCLUDE_FILE(*crt0.o).text) /* remaining code */
*(.rodata) /* read-only data
(constants) */
*(.rodata*)
*(.glue_7)
*(.glue_7t)
} > FLASH
. = ALIGN(4);
_etext = . ;
/* .data section which is used for initialized data */
.data : AT (_etext)
{
_data = .;
*(.data)
. = ALIGN(4);
_edata = .;
} > SRAM
/* .bss section which is used for uninitialized data */
.bss (NOLOAD) :
{
_bss = . ;
*(.bss)
*(COMMON)
. = ALIGN(4);
_ebss = .;
} > SRAM
/* .heap ALIGN(4) :*/
/* { */
/* _heap_begin = .;*/
/* *(.data_heap)*/
/* } > SRAM**/
/*. += 0x4000;*/
/* _heap_end = .;*/
. = RAM_LIMIT - 8 - 4 - 4 - 4 - 1024 - 1024;
.stack ALIGN(4) :
{
_stack = .;
. += 4;
_undefined_stack = .;
. += 4;
_abort_stack = .;
. += 4;
_fiq_stack = .;
. += 4;
_svc_stack = .;
. += 1024;
_usr_stack = .;
. += 1024;
_irq_stack = .;
_estack = .;
} > SRAM
_end = . ;
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* 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 .gnu.linkonce.wi.*) }
.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) }
}
/************************************
crt0.S************************************/
/*
crt0.S for LPC2xxx
- based on examples from R O Software
- based on examples from newlib-lpc
- based on an example from Anglia Designs
collected and modified by Martin Thomas
*/
.global _etext // -> .data initial values in ROM
.global _data // -> .data area in RAM
.global _edata // end of .data area
.global __bss_start // -> .bss area in RAM
.global __bss_end__ // end of .bss area
.global _stack // top of stack
// Stack Sizes
.set UND_STACK_SIZE, 0x00000004
.set ABT_STACK_SIZE, 0x00000004
.set FIQ_STACK_SIZE, 0x00000004
.set IRQ_STACK_SIZE, 0X00000080
.set SVC_STACK_SIZE, 0x00000004
// Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs
.set MODE_USR, 0x10 // User Mode
.set MODE_FIQ, 0x11 // FIQ Mode
.set MODE_IRQ, 0x12 // IRQ Mode
.set MODE_SVC, 0x13 // Supervisor Mode
.set MODE_ABT, 0x17 // Abort Mode
.set MODE_UND, 0x1B // Undefined Mode
.set MODE_SYS, 0x1F // System Mode
.equ I_BIT, 0x80 // when I bit is set, IRQ is
disabled
.equ F_BIT, 0x40 // when F bit is set, FIQ is
disabled
.text
.arm
.section .init, "ax"
.code 32
.align 2
.global _boot
.func _boot
_boot:
// Runtime Interrupt Vectors
// -------------------------
Vectors:
b _start // reset - _start
ldr pc,_undf // undefined - _undf
ldr pc,_swi // SWI - _swi
ldr pc,_pabt // program abort - _pabt
ldr pc,_dabt // data abort - _dabt
nop // reserved
ldr pc,[pc,#-0xFF0] // IRQ - read the VIC
ldr pc,_fiq // FIQ - _fiq
#if 0
// Use this group for production
_undf: .word _reset // undefined - _reset
_swi: .word _reset // SWI - _reset
_pabt: .word _reset // program abort - _reset
_dabt: .word _reset // data abort - _reset
_irq: .word _reset // IRQ - _reset
_fiq: .word _reset // FIQ - _reset
#else
// Use this group for development
_undf: .word __undf // undefined
_swi: .word __swi // SWI
_pabt: .word __pabt // program abort
_dabt: .word __dabt // data abort
_irq: .word __irq // IRQ
_fiq: .word __fiq // FIQ
__undf: b . // undefined
__swi: b . // SWI
__pabt: b . // program abort
__dabt: b . // data abort
__irq: b . // IRQ
__fiq: b . // FIQ
#endif
.size _boot, . - _boot
.endfunc
// Setup the operating mode & stack.
// ---------------------------------
.global _start, start, _mainCRTStartup
.func _start
_start:
start:
_mainCRTStartup:
// Initialize Interrupt System
// - Set stack location for each mode
// - Leave in System Mode with Interrupts Disabled
// -----------
ldr r0,=_stack
msr CPSR_c,#MODE_UND|I_BIT|F_BIT // Undefined Instruction Mode
mov sp,r0
sub r0,r0,#UND_STACK_SIZE
msr CPSR_c,#MODE_ABT|I_BIT|F_BIT // Abort Mode
mov sp,r0
sub r0,r0,#ABT_STACK_SIZE
msr CPSR_c,#MODE_FIQ|I_BIT|F_BIT // FIQ Mode
mov sp,r0
sub r0,r0,#FIQ_STACK_SIZE
msr CPSR_c,#MODE_IRQ|I_BIT|F_BIT // IRQ Mode
mov sp,r0
sub r0,r0,#IRQ_STACK_SIZE
msr CPSR_c,#MODE_SVC|I_BIT|F_BIT // Supervisor Mode
mov sp,r0
sub r0,r0,#SVC_STACK_SIZE
msr CPSR_c,#MODE_SYS|I_BIT|F_BIT // System Mode
mov sp,r0
// Copy initialized data to its execution address in RAM
// -----------------
#ifdef ROM_RUN
ldr r1,=_etext // -> ROM data start
ldr r2,=_data // -> data start
ldr r3,=_edata // -> end of data
1: cmp r2,r3 // check if data to move
ldrlo r0,[r1],#4 // copy it
strlo r0,[r2],#4
blo 1b // loop until done
#endif
// Clear .bss
// ----------
mov r0,#0 // get a zero
ldr r1,=__bss_start // -> bss start
ldr r2,=__bss_end__ // -> bss end
2: cmp r1,r2 // check if data to clear
strlo r0,[r1],#4 // clear 4 bytes
blo 2b // loop until done
/*
Call C++ constructors (for objects in "global scope")
ctor loop added by Martin Thomas 4/2005
based on a Anglia Design example-application for ST ARM
*/
LDR r0, =__ctors_start__
LDR r1, =__ctors_end__
ctor_loop:
CMP r0, r1
BEQ ctor_end
LDR r2, [r0], #4
STMFD sp!, {r0-r1}
MOV lr, pc
MOV pc, r2
LDMFD sp!, {r0-r1}
B ctor_loop
ctor_end:
// Call main program: main(0)
// --------------------------
mov r0,#0 // no arguments (argc = 0)
mov r1,r0
mov r2,r0
mov fp,r0 // null frame pointer
mov r7,r0 // null frame pointer for thumb
ldr r10,=main
mov lr,pc
/* Enter the C code, use BX instruction so as to never return */
/* use BLX (?) main if you want to use c++ destructors below */
bx r10 // enter main()
/* "global object"-dtors are never called and it should not be
needed since there is no OS to exit to. */
/* Call destructors */
# LDR r0, =__dtors_start__
# LDR r1, =__dtors_end__
dtor_loop:
# CMP r0, r1
# BEQ dtor_end
# LDR r2, [r0], #4
# STMFD sp!, {r0-r1}
# MOV lr, pc
# MOV pc, r2
# LDMFD sp!, {r0-r1}
# B dtor_loop
dtor_end:
.size _start, . - _start
.endfunc
.global _reset, reset, exit, abort
.func _reset
_reset:
reset:
exit:
abort:
#if 0
// Disable interrupts, then force a hardware reset by driving P23 low
// -------------------------------
mrs r0,cpsr // get PSR
orr r0,r0,#I_BIT|F_BIT // disable IRQ and FIQ
msr cpsr,r0 // set up status register
ldr r1,=(PS_BASE) // PS Base Address
ldr r0,=(PS_PIO) // PIO Module
str r0,[r1,#PS_PCER_OFF] // enable its clock
ldr r1,=(PIO_BASE) // PIO Base Address
ldr r0,=(1<<23) // P23
str r0,[r1,#PIO_PER_OFF] // make sure pin is contolled by PIO
str r0,[r1,#PIO_CODR_OFF] // set the pin low
str r0,[r1,#PIO_OER_OFF] // make it an output
#endif
b . // loop until reset
.size _reset, . - _reset
.endfunc
.end
/************************Makefile*******************************/
And my Makefile (if it`s necessary to solve my problem):
# Hey Emacs, this is a -*- makefile -*-
#
# WinARM template makefile
# by Martin Thomas, Kaiserslautern, Germany
# <eversmith@ever...>
#
# based on the WinAVR makefile written by Eric B. Weddington, Jg Wunsch, et
al.
# Released to the Public Domain
# Please read the make user manual!
#
#
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
#
# make program = Download the hex file to the device, using lpc21isp
#
# (TODO: make filename.s = Just compile filename.c into the assembler code
only)
#
# To rebuild project do "make clean" then "make all".
#
# Changelog:
# - 17. Feb. 2005 - added thumb-interwork support (mth)
# - 28. Apr. 2005 - added C++ support (mth)
# - 29. Arp. 2005 - changed handling for lst-Filename (mth)
#
# MCU name and submodel
MCU = arm7tdmi-s
#MCU = arm7tdmi
SUBMDL = LPC2138
THUMB = -mthumb
THUMB_IW = -mthumb-interwork
## Create ROM-Image (final)
#RUN_MODE=ROM_RUN
## Create RAM-Image (debugging)
RUN_MODE=RAM_RUN
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
# Target file name (without extension).
TARGET = LED
# List C source files here. (C dependencies are automatically generated.)
# use file-extension c for "c-only"-files
SRC = $(TARGET).c
#SRC
# List C source files here which must be compiled in ARM-Mode.
# use file-extension c for "c-only"-files
SRCARM
# List C++ source files here.
# use file-extension cpp for C++-files
CPPSRC
# List C++ source files here which must be compiled in ARM-Mode.
# use file-extension cpp for C++-files
#CPPSRCARM = $(TARGET).cpp
CPPSRCARM
# List Assembler source files here.
# Make them always end in a capital .S. Files ending in a lowercase .s
# will not be considered source files but generated files (assembler
# output from the compiler), and will be deleted upon "make clean"!
# Even though the DOS/Win* filesystem matches both .s and .S the same,
# it will preserve the spelling of the filenames, and gcc itself does
# care about how the name is spelled on its command-line.
ASRC
# List Assembler source files here which must be assembled in ARM-Mode.
ASRCARM = crt0.S
# Optimization level, can be [0, 1, 2, 3, s].
# 0 = turn off optimization. s = optimize for size.
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
OPT = s
#OPT = 0
# Debugging format.
# stabs or dwarf-2,
#DEBUG = stabs
DEBUG = dwarf-2
# List any extra directories to look for include files here.
# Each directory must be seperated by a space.
#EXTRAINCDIRS = ./include
EXTRAINCDIRS
# Compiler flag to set the C Standard level.
# c89 - "ANSI" C
# gnu89 - c89 plus GCC extensions
# c99 - ISO C99 standard (not yet fully implemented)
# gnu99 - c99 plus GCC extensions
CSTANDARD = -std=gnu99
# Place -D or -U options for C here
CDEFS = -D$(RUN_MODE)
# Place -I options here
CINCS
# Place -D or -U options for ASM here
ADEFS = -D$(RUN_MODE)
# Compiler flags.
# -g*: generate debugging information
# -O*: optimization level
# -f...: tuning, see GCC manual and avr-libc documentation
# -Wall...: warning level
# -Wa,...: tell GCC to pass this to the assembler.
# -adhlns...: create assembler listing
#
# Flags for C and C++ (arm-elf-gcc/arm-elf-g++)
CFLAGS = -g$(DEBUG)
CFLAGS += $(CDEFS) $(CINCS)
CFLAGS += -O$(OPT)
CFLAGS += -Wall -Wcast-align -Wcast-qual -Wimplicit
CFLAGS += -Wpointer-arith -Wswitch
CFLAGS += -Wredundant-decls -Wreturn-type -Wshadow -Wunused
CFLAGS += -Wa,-adhlns=$(subst $(suffix $<),.lst,$<)
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
# flags only for C
CONLYFLAGS = -Wstrict-prototypes -Wmissing-declarations
CONLYFLAGS += -Wmissing-prototypes -Wnested-externs
CONLYFLAGS += $(CSTANDARD)
# flags only for C++ (arm-elf-g++)
# CPPFLAGS = -fno-rtti -fno-exceptions
CPPFLAGS
# Assembler flags.
# -Wa,...: tell GCC to pass this to the assembler.
# -ahlms: create listing
# -gstabs: have the assembler create line number information; note that
# for use in COFF files, additional information about filenames
# and function names needs to be present in the assembler source
# files -- see avr-libc docs [FIXME: not yet described there]
##ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:.S=.lst),-g$(DEBUG)
#Additional libraries.
#Support for newlibc-lpc (file: libnewlibc-lpc.a)
#NEWLIBLPC = -lnewlib-lpc
MATH_LIB = -lm
CPLUSPLUS_LIB = -lstdc++
# Linker flags.
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS = -nostartfiles -Wl,-Map=$(TARGET).map,--cref
LDFLAGS += -lc
LDFLAGS += $(NEWLIBLPC) $(MATH_LIB)
LDFLAGS += -lc -lgcc
LDFLAGS += $(CPLUSPLUS_LIB)
# Set Linker-Script Depending On Selected Memory
ifeq ($(RUN_MODE),RAM_RUN)
LDFLAGS +=-T$(SUBMDL)-RAM.ld
else
LDFLAGS +=-T$(SUBMDL)-ROM.ld
endif
# ---
# Flash-Programming support using lpc21isp by Martin Maurer
# Settings and variables:
#LPC21ISP = lpc21isp
LPC21ISP = lpc21isp_beta
LPC21ISP_PORT = com1
LPC21ISP_BAUD = 115200
LPC21ISP_XTAL = 14746
LPC21ISP_FLASHFILE = $(TARGET).hex
# verbose output:
## LPC21ISP_DEBUG = -debug
# enter bootloader via RS232 DTR/RTS (only if hardware supports this
# feature - see Philips AppNote):
#LPC21ISP_CONTROL = -control
# ---
# Define directories, if needed.
## DIRARM = c:/WinARM/
## DIRARMBIN = $(DIRAVR)/bin/
## DIRAVRUTILS = $(DIRAVR)/utils/bin/
# Define programs and commands.
SHELL = sh
CC = arm-elf-gcc
CPP = arm-elf-g++
OBJCOPY = arm-elf-objcopy
OBJDUMP = arm-elf-objdump
SIZE = arm-elf-size
NM = arm-elf-nm
REMOVE = rm -f
COPY = cp
# Define Messages
# English
MSG_ERRORS_NONE = Errors: none
MSG_BEGIN = -------- begin --------
MSG_END = -------- end --------
MSG_SIZE_BEFORE = Size before:
MSG_SIZE_AFTER = Size after:
MSG_FLASH = Creating load file for Flash:
MSG_EXTENDED_LISTING = Creating Extended Listing:
MSG_SYMBOL_TABLE = Creating Symbol Table:
MSG_LINKING = Linking:
MSG_COMPILING = Compiling C:
MSG_COMPILING_ARM = "Compiling C (ARM-only):"
MSG_COMPILINGCPP = Compiling C++:
MSG_COMPILINGCPP_ARM = "Compiling C++ (ARM-only):"
MSG_ASSEMBLING = Assembling:
MSG_ASSEMBLING_ARM = "Assembling (ARM-only):"
MSG_CLEANING = Cleaning project:
MSG_LPC21_RESETREMINDER = You may have to bring the target in bootloader-mode
now.
# Define all object files.
COBJ = $(SRC:.c=.o)
AOBJ = $(ASRC:.S=.o)
COBJARM = $(SRCARM:.c=.o)
AOBJARM = $(ASRCARM:.S=.o)
CPPOBJ = $(CPPSRC:.cpp=.o)
CPPOBJARM = $(CPPSRCARM:.cpp=.o)
# Define all listing files.
LST = $(ASRC:.S=.lst) $(ASRCARM:.S=.lst) $(SRC:.c=.lst) $(SRCARM:.c=.lst)
LST += $(CPPSRC:.cpp=.lst) $(CPPSRCARM:.cpp=.lst)
# Compiler flags to generate dependency files.
### GENDEPFLAGS = -Wp,-M,-MP,-MT,$(*F).o,-MF,.dep/$(@F).d
GENDEPFLAGS = -MD -MP -MF .dep/$(@F).d
# Combine all necessary flags and optional flags.
# Add target processor to flags.
ALL_CFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. $(CFLAGS) $(GENDEPFLAGS)
ALL_ASFLAGS = -mcpu=$(MCU) $(THUMB_IW) -I. -x assembler-with-cpp $(ASFLAGS)
# Default target.
all: begin gccversion sizebefore build sizeafter finished end
build: elf hex lss sym
elf: $(TARGET).elf
hex: $(TARGET).hex
lss: $(TARGET).lss
sym: $(TARGET).sym
# Eye candy.
begin:
@echo
@echo $(MSG_BEGIN)
finished:
@echo $(MSG_ERRORS_NONE)
end:
@echo $(MSG_END)
@echo
# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex
ELFSIZE = $(SIZE) -A $(TARGET).elf
sizebefore:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE);
echo; fi
sizeafter:
@if [ -f $(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE);
echo; fi
# Display compiler version information.
gccversion :
@$(CC) --version
# Program the device.
program: $(TARGET).hex
@echo
@echo $(MSG_LPC21_RESETREMINDER)
$(LPC21ISP) $(LPC21ISP_CONTROL) $(LPC21ISP_DEBUG) $(LPC21ISP_FLASHFILE)
$(LPC21ISP_PORT) $(LPC21ISP_BAUD) $(LPC21ISP_XTAL)
# Create final output files (.hex, .eep) from ELF output file.
# TODO: handling the .eeprom-section should be redundant
%.hex: %.elf
@echo
@echo $(MSG_FLASH) $@
$(OBJCOPY) -O $(FORMAT) $< $@
# Create extended listing file from ELF output file.
# testing: option -C
%.lss: %.elf
@echo
@echo $(MSG_EXTENDED_LISTING) $@
$(OBJDUMP) -h -S -C $< > $@
# Create a symbol table from ELF output file.
%.sym: %.elf
@echo
@echo $(MSG_SYMBOL_TABLE) $@
$(NM) -n $< > $@
# Link: create ELF output file from object files.
.SECONDARY : $(TARGET).elf
.PRECIOUS : $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM)
%.elf: $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ) $(CPPOBJ) $(CPPOBJARM)
@echo
@echo $(MSG_LINKING) $@
$(CC) $(THUMB) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ)
$(CPPOBJ) $(CPPOBJARM) --output $@ $(LDFLAGS)
# $(CPP) $(THUMB) $(ALL_CFLAGS) $(AOBJARM) $(AOBJ) $(COBJARM) $(COBJ)
$(CPPOBJ) $(CPPOBJARM) --output $@ $(LDFLAGS)
# Compile: create object files from C source files. ARM/Thumb
$(COBJ) : %.o : %.c
@echo
@echo $(MSG_COMPILING) $<
$(CC) -c $(THUMB) $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@
# Compile: create object files from C source files. ARM-only
$(COBJARM) : %.o : %.c
@echo
@echo $(MSG_COMPILING_ARM) $<
$(CC) -c $(ALL_CFLAGS) $(CONLYFLAGS) $< -o $@
# Compile: create object files from C++ source files. ARM/Thumb
$(CPPOBJ) : %.o : %.cpp
@echo
@echo $(MSG_COMPILINGCPP) $<
$(CPP) -c $(THUMB) $(ALL_CFLAGS) $(CPPFLAGS) $< -o $@
# Compile: create object files from C++ source files. ARM-only
$(CPPOBJARM) : %.o : %.cpp
@echo
@echo $(MSG_COMPILINGCPP_ARM) $<
$(CPP) -c $(ALL_CFLAGS) $(CPPFLAGS) $< -o $@
# Compile: create assembler files from C source files. ARM/Thumb
## does not work - TODO - hints welcome
##$(COBJ) : %.s : %.c
## $(CC) $(THUMB) -S $(ALL_CFLAGS) $< -o $@
# Assemble: create object files from assembler source files. ARM/Thumb
$(AOBJ) : %.o : %.S
@echo
@echo $(MSG_ASSEMBLING) $<
$(CC) -c $(THUMB) $(ALL_ASFLAGS) $< -o $@
# Assemble: create object files from assembler source files. ARM-only
$(AOBJARM) : %.o : %.S
@echo
@echo $(MSG_ASSEMBLING_ARM) $<
$(CC) -c $(ALL_ASFLAGS) $< -o $@
# Target: clean project.
clean: begin clean_list finished end
clean_list :
@echo
@echo $(MSG_CLEANING)
$(REMOVE) $(TARGET).hex
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).elf
$(REMOVE) $(TARGET).map
$(REMOVE) $(TARGET).obj
$(REMOVE) $(TARGET).a90
$(REMOVE) $(TARGET).sym
$(REMOVE) $(TARGET).lnk
$(REMOVE) $(TARGET).lss
$(REMOVE) $(COBJ)
$(REMOVE) $(CPPOBJ)
$(REMOVE) $(AOBJ)
$(REMOVE) $(COBJARM)
$(REMOVE) $(CPPOBJARM)
$(REMOVE) $(AOBJARM)
$(REMOVE) $(LST)
$(REMOVE) $(SRC:.c=.s)
$(REMOVE) $(SRC:.c=.d)
$(REMOVE) $(SRCARM:.c=.s)
$(REMOVE) $(SRCARM:.c=.d)
$(REMOVE) $(CPPSRC:.cpp=.s)
$(REMOVE) $(CPPSRC:.cpp=.d)
$(REMOVE) $(CPPSRCARM:.cpp=.s)
$(REMOVE) $(CPPSRCARM:.cpp=.d)
$(REMOVE) .dep/*
# Include the dependency files.
-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*)
# Listing of phony targets.
.PHONY : all begin finish end sizebefore sizeafter gccversion \
build elf hex lss sym clean clean_list program
rtstofer <rstofer@rsto...> wrote: --- In lpc2000@lpc2...,
Grzegorz Reszka <grzegorz.reszka@...>
wrote:
>
> 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
>
> __________________________________________________
>
>
>
>
Well, I can make a start on the problem. Others will have more insight.
First of all, you use the ROM version of the linker script (that's
what the .ld file is) when you want to run out of flash memory. You
use the RAM version when you want to run out of RAM. You might want
to run out of RAM during debugging. Or not...
Second, both of your .ld files are hosed, or so it seems. Where did
you get them?
Third, this tutorial is the absolute best reference available for
starting with the ARM. Later in the document there is some info for
the 2138, I believe. Anyway, here it is:
http://www.olimex.com/dev/pdf/ARM%20Cross%20Development%20with%20Eclipse%20version%203.pdf
Here it is tiny: http://tinyurl.com/camje
You could pick a configuration and post your .ld file. Someone may be
able to spot the problem quickly.
You can also wander over to www.olimex.com and paw through the LPC
2000 ARM boards. There are blinking LED samples for each.
Richard
SPONSORED LINKS
Microcontrollers
Microprocessor
Intel microprocessors
Pic microcontrollers
---------------------------------
YAHOO! GROUPS LINKS
---------------------------------
__________________________________________________
Reply by rtstofer●March 1, 20062006-03-01
--- In lpc2000@lpc2..., Grzegorz Reszka <grzegorz.reszka@...>
wrote:
>
> 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
>
> __________________________________________________
>
>
>
>
Well, I can make a start on the problem. Others will have more insight.
First of all, you use the ROM version of the linker script (that's
what the .ld file is) when you want to run out of flash memory. You
use the RAM version when you want to run out of RAM. You might want
to run out of RAM during debugging. Or not...
Second, both of your .ld files are hosed, or so it seems. Where did
you get them?
Third, this tutorial is the absolute best reference available for
starting with the ARM. Later in the document there is some info for
the 2138, I believe. Anyway, here it is:
http://www.olimex.com/dev/pdf/ARM%20Cross%20Development%20with%20Eclipse%20version%203.pdf
Here it is tiny: http://tinyurl.com/camje
You could pick a configuration and post your .ld file. Someone may be
able to spot the problem quickly.
You can also wander over to www.olimex.com and paw through the LPC
2000 ARM boards. There are blinking LED samples for each.
Richard
Reply by Grzegorz Reszka●March 1, 20062006-03-01
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
__________________________________________________