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.

linker & #pragma unexpected result

Other Parts Discussed in Thread: TEST2

Hi everyone,

I am trying to make a linker and I have an odd problem. In my linker , I assign certain addresses & length to different section, but when I run the program on the the DSP, the address I assigned in the linker aren't the same in the DSP.

Here is a bit of my code where I've tried to figure out what is going on.

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

file : lnkx.cmd

MEMORY
{
 PAGE 0:  /* ---- Unified Program/Data Address Space ---- */

  MMR    (RWIX): origin = 0x000000, length = 0x0000c0  /* MMRs */
  DARAM0 (RWIX): origin = 0x0000c0, length = 0x00ff40  /*  64KB - MMRs */
  SARAM0 (RWIX): origin = 0x010000, length = 0x010000  /*  64KB */
  SARAM1 (RWIX): origin = 0x020000, length = 0x020000  /* 128KB */
  SARAM2 (RWIX): origin = 0x040000, length = 0x00FE00  /*  64KB */
  VECS   (WRIX): origin = 0x04FE00, length = 0x000200  /*  512B */
  PDROM   (RIX): origin = 0xff8000, length = 0x008000  /*  32KB */

 PAGE 2:  /* -------- 64K-word I/O Address Space -------- */

  SPIREG (RWI) : origin = 0x003000, length = 0x14
  TESTREG (RWI) : origin = 0x1000, length = 0x100
  TESTREG2 (RWI) : origin = 0x0500, length = 0x100

}
 
/* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */

SECTIONS
{
   .text     >> SARAM1|SARAM2|SARAM0  /* Code                        */

   /* Both stacks must be on same physical memory page               */
   .stack    >  DARAM0                /* Primary system stack        */
   .sysstack >  DARAM0                /* Secondary system stack      */

   .data     >> DARAM0|SARAM0|SARAM1  /* Initialized vars            */
   .bss      >> DARAM0|SARAM0|SARAM1  /* Global & static vars        */
   .const    >> DARAM0|SARAM0|SARAM1  /* Constant data               */
   .sysmem   >  DARAM0|SARAM0|SARAM1  /* Dynamic memory (malloc)     */
   .switch   >  SARAM2                /* Switch statement tables     */
   .cinit    >  SARAM2                /* Auto-initialization tables  */
   .pinit    >  SARAM2                /* Initialization fn tables    */
   .cio      >  SARAM2                /* C I/O buffers               */
   .args     >  SARAM2                /* Arguments to main()         */

    vectors  >  VECS                  /* Interrupt vectors           */
    spireg  >  SPIREG PAGE 2    /* SPI REGISTER */
    testreg >  TESTREG PAGE 2
    testreg2 > TESTREG2 PAGE 2
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

i've modified the last section. At first there was ioport, but with the odd error, i've tried to see what was going on so i temporarily removed it.

and here is a bit from my main.c file where I allocate the memory to some structures.

 

file : main .c

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma DATA_SECTION (SPIREG,"spireg") // check out linker
#pragma DATA_SECTION (TEST,"testreg")
#pragma DATA_SECTION (TEST2,"testreg2")
// Structure instanciation to map to memory

volatile struct spi SPIREG;
volatile struct spi TEST,TEST2;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

on the DSP , SPIREG is at 0x1800 @ I/O space ( should be 0x3000 @ I/O space according to linker)

TEST is at 0x800 @ I/O space (should be at 0x1000 @ I/O space according to linker)

TEST2 is at 0x280 @ I/O space ( should be at 0x500 @I/O space according to linker)

 

I am completely lost on what to do next. I 've tried to see if the address change was linear but doesnt seems so.

Any help would be appreciated

Thanks

Jean-Francois

 

  • After checking the .map of my program, i found out this

    section   page  orgn(bytes) orgn(words) len(bytes) len(words)   input sections
    --------  ----  ----------- ----------- ---------- ----------

    testreg      2   [ 00000000 ]  00000000          *   0000000a   UNINITIALIZED

    testreg2     2   [ 00000126 ]  00000093          *   0000000a   UNINITIALIZED

    spireg       2   [ 00003000 ]  00001800          *   0000000a   UNINITIALIZED

     

    I'm not sure I understand what is going on here. From the look of it, the origin I have to put in origin = should be the address I want ( i.e. 0x3000) x 2? (so 0x6000)

    how come ?

     

    thanks

     

     

     

     

  • Hi Gagnon, I am having problems when I include a .cmd file on my project. Until now I am using the memory configuration supplied by DSP/BIOS (VC5505_CSL_BIOS_cfg.tcf  file).

    http://e2e.ti.com/support/dsp/tms320c5000_power-efficient_dsps/f/109/p/84703/349471.aspx#349471 ( start at Mar 11 2011)

    Maybe your problem could be happening with me.

    Please, do you find the solution? Could you share it with me?

    Regards,

    Andrea