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.

Keeping linker cmd file in sync with memory configuration registers c28x

Is there any way to keep the memory allocation in the linker command file in sync with the memory ownership registers of a c28x?

MemCfgRegs.GSxMSEL.bit.MSEL_GS0 = 1/0;

MemCfgRegs.LSxMSEL.bit.MSEL_LS0 = 1/0

MemCfgRegs.LSxCLAPGM.bit.CLAPGM_LS0 = 1/0;

My understanding is I will need to adjust my *.cmd file to allocate the memory that each CPU uses in the GSxMSEL but I also must then set the bit as shown above when CPU1 starts up to allow each CPU access to that memory.  In essence if I didn't then the default power on state would determine ownership of the memory, and no matter what I put in my linker command file, the other processors wouldn't be able to write to that memory.

As such this creates a double update in coding... ie: I must change the same thing in two places, I must update how I allocate the memory in the linker cmd file, then I must in a different piece of code update the registers that assign the ownership.

Ideally in code we only update things in one place to avoid errors, at best I can put a comment in each place telling it about the other place they need to make an update.

Is there anyway to 'automate' this procedure?  (fingers crossed)

  • You can use C-style preprocessing in linker command files.  So you can define a header file ...

    /* memstate.h */
    #define MEM_STATE1 1
    #define MEM_STATE2 2
    /* and so on */
    
    /* This one line designates the overall state of memory */
    #define MEM_STATE_IN_USE MEM_STATE1

    Both your C code and your linker command file can #include "memstate.h", and have code similar to ...

    #if MEM_STATE_IN_USE == MEM_STATE1
    /* do it one way */
    #elsif MEM_STATE_IN_USE == MEM_STATE2
    /* do it another way */
    #else
    #warn No definition of MEM_STATE_IN_USE
    #endif

    Thanks and regards,

    -George