This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

duplicate execution regions in scatter file

In a scatter file can I put a code segment (eg the vector table) in two different places in the output file even though I only defined it in the code once eg:

LR_VECTORTABLE 0x08000000 0x00000140
{
        ER_VECTORTABLE 0x08000000 0x00000140
        {
                *.o (RESET, +First)             ; Duplicated for stand alone builds
        }
}

LR_APP 0x08008000 0x00038000
{
        ER_APP 0x08008000 0x00038000
        {
                *.o (RESET, +First)             ; Duplicated for bootloader systems (bootloader system will cut off the above hex)
                *(InRoot$$Sections)
                .ANY (+RO)
        }

        RW_ALL 0x20000000 0x00010000
        {
                .ANY (+RW +ZI)
        }
}

NB: this does not seem to work I get a error: "Error: L6223E: Ambiguous selectors found for startup_stm32f10x_hd.o(RESET) from Exec regions ER_VECTORTABLE and ER_APP.". What I want to know is can this be done somehow ?

  • This seems to be disallowed (I need to consult the linker manual myself to fully understand why). Either way, why not create a separate bootloader? What is the advantage in doing what you do? And what does "(bootloader system will cut off the above hex)" mean exactly?

  • Basically we can then have one output that can be programmed into flash using a JTAG, and the same output could be loaded in via a bootloader (it will just ignore addresses outside the app space ie < 0800 8000). I figured it may not be possible in which case we can just have two targets with two scatter files which will also work but there is more duplication. Cheers.

  • I never tried anything like this; but, I thing you don't need two scatter files - I _think_ you can create separate startup files, having a distinct AREA statement, like this (just above the vector table):

    AREA    RESET_BOOT, CODE, READONLY
    

    and

    AREA    RESET, CODE, READONLY
    

    You must of course adjust the scatter file as well.

  • Yeh I could do that, I was hoping not to have to duplicate code as it gets confussing but I guess this is just the limitations of the linker. I think the easiest way is going to be having to targets, one that is bootloadable and one that is standalone.

    Thanks for they help.