This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problem with UNION, my mistake or bug?

Hi,

I'm trying to use the UNION linker statement to overlay two sections of code running in RAML0. I'm using CGT v. 5.2.7. The required code for copying from FLASH to RAM is working. But there is something strange...

Here is the relevant section of the .cmd-file:

CodeInRam : LOAD = FLASHA, PAGE = 0,
      LOAD_START(_CodeInRam_LoadStart),
      LOAD_END(_CodeInRam_LoadEnd)
ramfuncs : LOAD = FLASHA, PAGE = 0,
      LOAD_START(_RamfuncsLoadStart),
      LOAD_END(_RamfuncsLoadEnd)
UNION: RUN = RAML0, PAGE = 0
    {
        CodeInRam: RUN_START(_CodeInRam_RunStart)
        ramfuncs: RUN_START(_RamfuncsRunStart)
    }


 And here are some cutouts from the .map file:

MEMORY CONFIGURATION
name   origin   length    used    unused  attr fill
PAGE 0:
RAML0 00008000 00001000 00000000 00001000 RWIX

SECTION ALLOCATION MAP
section page origin length input sections
-------- ---- ---------- ---------- ----------------
CodeInRam 
*        0 00008000 00000000 UNINITIALIZED

ramfuncs 0 00008000 00000000 UNINITIALIZED


GLOBAL SYMBOLS: SORTED ALPHABETICALLY BY Name 

003f6bfc _CodeInRam_LoadEnd
003f6a95 _CodeInRam_LoadStart
00008000 _CodeInRam_RunStart

003f6d95 _RamfuncsLoadEnd
003f6c74 _RamfuncsLoadStart
00008000 _RamfuncsRunStart

This overlaying actually works, the code runs as expected, however the .map file indicates that no RAML0 is used by the UNION (yellow). This seems wrong !?

And if I add another segment to RAML0 outside the UNION that ends up overlapping the UNION, and the code does NOT run anymore. Even more wrong.

Am I using the UNION statement in a wrong way, or is there a linker bug here? I would be thankful if anyone would indicate how I could change the .cmd file to make this work.

st

  • Could you try the following syntax:

    UNION : run = RAML0, PAGE = 0
    {

    RamFuncs : LOAD = FLASHA, PAGE = 0 
                        LOAD_START(_RamFuncs_loadstart),
                        LOAD_END(_RamFuncs_loadend),
                        RUN_START(_RamFuncs_runstart)

     

     

    CodeInRam : LOAD = FLASHA, PAGE = 0
                         LOAD_START(_CodeInRam_loadstart),
                         LOAD_END(_CodeInRam_loadend),
                         RUN_START(_CodeInRam_runstart)

     

    }

    I tried something similar in an example and it worked fine and the section allocation in the linker map file was correct.

  • Thanks, that works. It seems like the obvious straight-forward way to do it now when I see it :)

    st