Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I am trying to port PyMite from STM32F1 to STM32F2. One of the files that I am assuming must be changed is called stm32f10x.ld. I have looked around for an equivalent of this (called stm32f2xx.ld?) but haven't found anything.

I'm now thinking that I should maybe port "by hand" the linker script. Below is the original linker script. What kind of changes should I be making to have it work for STM32F2?

MEMORY
{
    sram (W!RX) : ORIGIN = 0x20000000, LENGTH = 64k
    flash (RX) : ORIGIN = 0x08000000, LENGTH = 512k
}

SECTIONS
{  
    .text :
    {
        . = ALIGN(4);
        _text = .;
        PROVIDE(stext = .);
        KEEP(*(.isr_vector))
        KEEP(*(.init))
        *(.text .text.*)        
        *(.rodata .rodata.*)        
        *(.gnu.linkonce.t.*)
        *(.glue_7)
        *(.glue_7t)
        *(.gcc_except_table)
        *(.gnu.linkonce.r.*)
        . = ALIGN(4);
        _etext = .;
        _sidata = _etext;
        PROVIDE(etext = .);   
            _fini = . ;
                *(.fini)

    } >flash

    .data : AT (_etext)
    {
        . = ALIGN(4);
        _sdata = .;
        *(.ramfunc .ramfunc.* .fastrun .fastrun.*)
        *(.data .data.*)
        *(.gnu.linkonce.d.*)
        . = ALIGN(4);
        _edata = .;
    } >sram

        .ARM.extab :
        {
            *(.ARM.extab*)
        } >sram

        __exidx_start = .;
        .ARM.exidx :
        {
            *(.ARM.exidx*)
        } >sram
        __exidx_end = .;

    .bss (NOLOAD) : {
        . = ALIGN(4);
        /* This is used by the startup in order to initialize the .bss secion */
        _sbss = .;
        *(.bss .bss.*)
        *(.gnu.linkonce.b.*)
        *(COMMON)
        . = ALIGN(4);        
        _ebss = .;
    } >sram

    end = .;
    PROVIDE( _estack = 0x20010000 );
}
share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

Most Chip "families" use a similar memory layout, so it might "just work" without changes.

There are only 2 interseting things in this script:

MEMORY
{
    sram (W!RX) : ORIGIN = 0x20000000, LENGTH = 64k
    flash (RX) : ORIGIN = 0x08000000, LENGTH = 512k
}

The MEMORY section needs to be checked agains datasheet/reference manual whether the addresses and sizes of the SRAM and FLASH are correct.

The other point is the stack end _estack, as it is hardcoded:

PROVIDE( _estack = 0x20010000 );

You might have noticed that this is the "end of SRAM", as 0x20000000 + 64k is exactly 0x20010000. You might need to change this accordingly.

share|improve this answer
    
IIRC the STMF32 has fairly different register maps and changes to vector table also, so be ready to make more changes... –  Toby Jaffey Mar 22 '12 at 15:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.