[ECOS] Re: eCos linking question

Tom Deconinck t.deconinck@gmail.com
Wed Feb 20 13:11:00 GMT 2008


On Feb 20, 2008 1:59 PM, Tom Deconinck <t.deconinck@gmail.com> wrote:
> Hi,
>
> I'm trying to update the linker scripts to have code running from an
> external flash on a Atmel at91sam7se32.
> I started with the linker script for the at91sam7s32 (doesn't have an
> external bus), and I started change that LDI script.
>
> My LDI file now looks like this:
> #include <cyg/infra/cyg_type.inc>
> #include <pkgconf/hal_arm_at91sam7.h>
> #include CYGBLD_HAL_PLATFORM_H
>
> MEMORY
> {
>     sram : ORIGIN = 0x00200000, LENGTH = 0x02000
> ram : ORIGIN = 0x20000000, LENGTH = CYGHWR_AT91_SAM7SE_RAM_SIZE
>         srom : ORIGIN = 0x00100000, LENGTH = 0x8000
>     rom : ORIGIN = 0x10000000, LENGTH = CYGHWR_AT91_SAM7SE_FLASH_SIZE
> }
>
>
> SECTIONS
> {
>     SECTIONS_BEGIN
>     SECTION_rom_vectors (rom, CYGNUM_HAL_ARM_AT91_IMAGE_ADDRESS, LMA_EQ_VMA)
>     SECTION_text (rom, ALIGN (0x1), LMA_EQ_VMA)
>     SECTION_fini (rom, ALIGN (0x4), LMA_EQ_VMA)
>     SECTION_rodata (rom, ALIGN (0x4), LMA_EQ_VMA)
>     SECTION_rodata1 (rom, ALIGN (0x4), LMA_EQ_VMA)
>     SECTION_fixup (rom, ALIGN (0x4), LMA_EQ_VMA)
>     SECTION_gcc_except_table (rom, ALIGN (0x4), LMA_EQ_VMA)
>         SECTION_fixed_vectors (sram, 0x00200040, LMA_EQ_VMA)
>     SECTION_data (ram, ALIGN (0x4), FOLLOWING (.gcc_except_table))
>     SECTION_bss (ram, ALIGN (0x4), LMA_EQ_VMA)
>     CYG_LABEL_DEFN(__heap1) = ALIGN (0x8);
>     SECTIONS_END
> }
>

Sorry... sent to early

Some clarification:
sram refers to the at91sam7se32 internal 8KB of ram
ram refers to my external SDRAM
srom refers to the internal flash (which I don't intend to use for eCos)
rom refers to my external flash (this is where I would like to run
code from, so CYG_HAL_STARTUP is set to ROM)

With my current LDI file (see below), the linker gets confused trying
to link the eCos hello world example.
It crashes and burns with the following error:
arm-elf-gcc -nostartfiles -L../ecos_test_flashv2/rdm243x/install/lib
-Ttarget.ld -mcpu=arm7tdmi -Wl,--gc-sections -Wl,-static -g -nostdlib
-o hello hello.o
/opt/ecos/gnutools/arm-elf/bin/../lib/gcc-lib/arm-elf/3.2.1/../../../../arm-elf/bin/ld:
address 0x2005ac of hello section .data is not within region ram
/opt/ecos/gnutools/arm-elf/bin/../lib/gcc-lib/arm-elf/3.2.1/../../../../arm-elf/bin/ld:
address 0x2048f4 of hello section .bss is not within region ram
collect2: ld returned 1 exit status
make: *** [hello] Error 1

So .data and .bss get addresses from the internal RAM.. but I don't
get why, they should get addresses from ROM, following
.gcc_except_table. According to the startup assembly code, these
sections should then get copied into ram at startup.
I know I need to use the internal ram too, since the exception vectors
(.rom_vectors and .fixed_vectors) need to start at address 0x0.
I think it should be possible to run code from my external flash or am
I mistaken?
Any suggestions would be greatly appreciated.



Tom

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss



More information about the Ecos-discuss mailing list