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.

Why can't my program run on Flash Memory?

Hi, everyone,

I'm using F2812 and CCS3.3

I set the jumper to 'boot to flash' and tried to flash out the example project on to my dsp. Everything works fine.

My project can run in internal memory. In order to let it work in flash memory, i changed the memory map and added memcpy and initflash functions into my c code file.And in order to test my project, i configured the pwm outputs. But I got nothing. It seemed that my project didn't run at all. Why is this? What I did is just a little bit change of memory map.

This is my .c file.

...................................

   InitPieVectTable();
   MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
   InitFlash();

...................................

   InitPWM();
    for(i=0;i<6;i++)
        PWM[i]=60;
    SetPWMDIR(PWM,DIR);

 

The following is my .cmd file.

MEMORY
{
PAGE 0:    /* Program Memory */
   ZONE2       : origin = 0x080000, length = 0x080000
   ZONE6       : origin = 0x100000, length = 0x080000
/*   OTP         : origin = 0x3D7800, length = 0x000800*/
   BEGIN       : origin = 0x3F7FF6, length = 0x000002
   RAMH0       : origin = 0x3F8000, length = 0x002000
/*   ROM         : origin = 0x3FF000, length = 0x000FC0 */
   RESET       : origin = 0x3FFFC0, length = 0x000002
   VECTORS     : origin = 0x3FFFC2, length = 0x00003E
   FLASHJ      : origin = 0x3D8000, length = 0x002000     /* on-chip FLASH */
   FLASHI      : origin = 0x3DA000, length = 0x002000     /* on-chip FLASH */
   FLASHH      : origin = 0x3DC000, length = 0x004000     /* on-chip FLASH */
   FLASHG      : origin = 0x3E0000, length = 0x004000     /* on-chip FLASH */
   FLASHF      : origin = 0x3E4000, length = 0x004000     /* on-chip FLASH */
   FLASHE      : origin = 0x3E8000, length = 0x004000     /* on-chip FLASH */
   FLASHD      : origin = 0x3EC000, length = 0x004000     /* on-chip FLASH */
   FLASHC      : origin = 0x3F0000, length = 0x004000     /* on-chip FLASH */
   FLASHB      : origin = 0x3F4000, length = 0x002000     /* on-chip FLASH */
   FLASHA      : origin = 0x3F6000, length = 0x001F80     /* on-chip FLASH */
PAGE 1 :   /* Data Memory */
   RAMM0       : origin = 0x000000, length = 0x000400
   RAMM1       : origin = 0x000400, length = 0x000400
   ZONE2       : origin = 0x080000, length = 0x080000
   ZONE6       : origin = 0x100000, length = 0x080000
   CSM_PWL     : origin = 0x3F7FF8, length = 0x000008
}


    
SECTIONS
{
/*   codestart           : > RAMH0       PAGE = 0                */
/*   .text               : > RAMH0       PAGE = 0                */
/*   .switch             : > RAMH0       PAGE = 0                */
/*   .cinit              : > RAMH0       PAGE = 0                */
/*   .pinit              : > RAMH0,      PAGE = 0                */
/*   .reset              : > RESET,      PAGE = 0, TYPE = DSECT    */
/*   .econst             : > RAML1       PAGE = 1*/
/*    ramfuncs           : > RAML1       PAGE = 1 */
   codestart           : > FLASHE       PAGE = 0               
   .text               : > FLASHF       PAGE = 0               
   .switch             : > FLASHG       PAGE = 0               
   .cinit              : > FLASHH       PAGE = 0               
   .pinit              : > FLASHC,      PAGE = 0               
   .econst             : > FLASHB      PAGE = 0
   ramfuncs            : LOAD = FLASHD,
                         RUN = RAMH0,
                         LOAD_START(_RamfuncsLoadStart),
                         LOAD_END(_RamfuncsLoadEnd),
                         RUN_START(_RamfuncsRunStart),
                         PAGE = 0
   .reset              : > RESET,      PAGE = 0, TYPE = DSECT   
   .stack              : > RAML1       PAGE = 1
   .ebss               : > RAML1       PAGE = 1
   .esysmem            : > ZONE6       PAGE = 1
   .zone2data           : > ZONE2       PAGE = 1
   PieVectTableFile  : > PIE_VECT,     PAGE = 1
}


Thanks.

Any help is appreciated!

  • Haibin,

    the InitFlash() routine needs to be called from Secure RAM (i.e. L0 or L1 RAM). See the flash example in the 281x header files and peripheral examples. In order to copy InitFlash to RAM, make sure you are calling:

    #pragma CODE_SECTION(InitFlash, "ramfuncs");

    (called in the DSP281x_SysCtrl.c file already).

    The problem with your .cmd file seems like you are running ramfuncs from H0 (not secure RAM).

    The above might help...

  • Hi, CChang,

    Thanks. I tried to modify my cmd file according to your suggestion. but it still didn't work.

    Here is my new cmd file.

    ..............................................................

    PAGE 0:    /* Program Memory */
       RAML0       : origin = 0x008000, length = 0x001000     /* on-chip RAM block L0 */


       codestart           : > FLASHE       PAGE = 0               
       .text               : > FLASHF       PAGE = 0               
       .switch             : > FLASHG       PAGE = 0               
       .cinit              : > FLASHH       PAGE = 0               
       .pinit              : > FLASHC,      PAGE = 0               
       .econst             : > FLASHB      PAGE = 0
       ramfuncs            : LOAD = FLASHD,
                             RUN = RAML0,
                             LOAD_START(_RamfuncsLoadStart),
                             LOAD_END(_RamfuncsLoadEnd),
                             RUN_START(_RamfuncsRunStart),
                             PAGE = 0
       .reset              : > RESET,      PAGE = 0, TYPE = DSECT   
       .stack              : > RAML1       PAGE = 1
       .ebss               : > RAML1       PAGE = 1
       .esysmem            : > ZONE6       PAGE = 1
       .zone2data           : > ZONE2       PAGE = 1
    ...........................................................................................

  • Haibin,

    Have you stepped through the code while watching changes to variables and registers to try and determine where things go "wrong"?

    -Lori

  • Hi Lori,

    I didn't tried that debug. Is it possible for us to debug the program while it's running from flash? I never tried this.

    What i did is, flashing out my program,  restarting the dsp board , and waiting for it runing from dsp flash memory.

    So could you tell me how to debug? Really appreciated for you reply.

  • Haibin - you debug the same way you would if you were debugging your code running from RAM. The only difference is that instead of loading  your code directly (in CCSv3.3), You load symbols only.

    i.e. Load Symbols only... select your .out file.

  • Hi CChang,

    Thanks for your quick reply. Do you mean after I downloading the code to the dsp flash memory, I just load the symbols? Before loading the symbol, I shouldn't restart the board. Is my understanding right?

    Thanks again. Hopefully It will work.

  • Yes. First program your flash.If you want you can reset your board.

    Then just load the symbols and debug as usual in CCS.

    See section 6.1 in this app note: http://focus.ti.com/lit/an/spraal3/spraal3.pdf

    For more information on setting up  your .cmd file for flash programming and programming internal flash memory this app note is really useful as well:

    http://focus.ti.com/general/docs/litabsmultiplefilelist.tsp?literatureNumber=spra958h