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.

CSM password question.

Other Parts Discussed in Thread: TMS320F2806

Hello,

I wanna use pasword protection. When I am flashing my code to my TMS320F2806, I am getting an error during writing process at around 98% for few seconds. Then following error occurs,

//C28xx: Flash operation timed out waiting for the algorithm to complete. Operation cancelled.
//C28xx: Trouble Writing Memory Block at 0x3f7f80 on Page 0 of Length 0x76
//Cannot write to target

is it normal?
Anyway it looks like my uC is protected, because I cannot write/read it without correct password, but I can unlock my uC in "On-Chip-Flash" and my address 0xAEF, where CSMSCR register is located, has got a value of 0x0041.

I am asking that becasue with password my programm makes problems and doesn't run properly how it should be, but without password protection everything is fine.

/***********************************

MEMORY
{
PAGE 0:    /* Program Memory */
           /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE1 for data allocation */

   RAML0       : origin = 0x008000, length = 0x001000     /* on-chip RAM block L0 */
   OTP         : origin = 0x3D7800, length = 0x000400     /* on-chip OTP */
   FLASHD      : origin = 0x3F0000, length = 0x002000     /* on-chip FLASH */
   FLASHC      : origin = 0x3F2000, length = 0x002000     /* on-chip FLASH */
   
   
   FLASHA      : origin = 0x3F6000, length = 0x001F80     /* on-chip FLASH */
   
 
   
   ROM         : origin = 0x3FF000, length = 0x000FC0     /* Boot ROM */
   RESET       : origin = 0x3FFFC0, length = 0x000002     /* part of boot ROM  */
   VECTORS     : origin = 0x3FFFC2, length = 0x00003E     /* part of boot ROM  */
   
   CSM_RSVD    : origin = 0x3F7F80, length = 0x000076     /* Part of FLASHA.  Program with all 0x0000 when CSM is in use. */
   BEGIN       : origin = 0x3F7FF6, length = 0x000002     /* Part of FLASHA.  Used for "boot to Flash" bootloader mode. */
   CSM_PWL     : origin = 0x3F7FF8, length = 0x000008     /* Part of FLASHA.  CSM password locations in FLASHA */
   
PAGE 1 :   /* Data Memory */
           /* Memory (RAM/FLASH/OTP) blocks can be moved to PAGE0 for program allocation */
           /* Registers remain on PAGE1                                                  */

   RAMM0       : origin = 0x000000, length = 0x000400     /* on-chip RAM block M0 */
   BOOT_RSVD   : origin = 0x000400, length = 0x000080     /* Part of M1, BOOT rom will use this for stack */
   RAMM1       : origin = 0x000480, length = 0x000380     /* on-chip RAM block M1 */
   RAML1       : origin = 0x009000, length = 0x001000     /* on-chip RAM block L1 */
   FLASHB      : origin = 0x3F4000, length = 0x002000     /* on-chip FLASH */
   
}

/* Allocate sections to memory blocks.
   Note:
         codestart user defined section in DSP28_CodeStartBranch.asm used to redirect code
                   execution when booting to flash
         ramfuncs  user defined section to store functions that will be copied from Flash into RAM
*/
 
SECTIONS
{

 
   /* Allocate program areas: */
   .cinit              : > FLASHA      PAGE = 0
   .pinit              : > FLASHA,     PAGE = 0
   .text               : > FLASHC      PAGE = 0
   codestart           : > BEGIN       PAGE = 0
   
       Flash28_API:
   {
        -lFlash2806_API_V302.lib(.econst)
        -lFlash2806_API_V302.lib(.text)
   }                   LOAD = FLASHD,
                       RUN = RAML0,
                       LOAD_START(_Flash28_API_LoadStart),
                       LOAD_END(_Flash28_API_LoadEnd),
                       RUN_START(_Flash28_API_RunStart),
                       PAGE = 0
                       
   ramfuncs            : LOAD = FLASHD,
                         RUN = RAML0,
                         LOAD_START(_RamfuncsLoadStart),
                         LOAD_END(_RamfuncsLoadEnd),
                         RUN_START(_RamfuncsRunStart),
                         PAGE = 0

   csmpasswds          : > CSM_PWL     PAGE = 0
   csm_rsvd            : > CSM_RSVD    PAGE = 0
   
   /* Allocate uninitalized data sections: */
   .stack              : > RAMM0       PAGE = 1
   .ebss               : > RAML1       PAGE = 1
   .esysmem            : > RAML1       PAGE = 1

   /* Initalized sections go in Flash */
   /* For SDFlash to program these, they must be allocated to page 0 */
   .econst             : > FLASHA      PAGE = 0
   .switch             : > FLASHA      PAGE = 0      

   /* Allocate IQ math areas: */
   IQmath              : > FLASHC      PAGE = 0                  /* Math Code */
   IQmathTables        : > ROM         PAGE = 0, TYPE = NOLOAD   /* Math Tables In ROM */

   /* .reset is a standard section used by the compiler.  It contains the */
   /* the address of the start of _c_int00 for C Code.   /*
   /* When using the boot ROM this section and the CPU vector */
   /* table is not needed.  Thus the default type is set here to  */
   /* DSECT  */
   .reset              : > RESET,      PAGE = 0, TYPE = DSECT
   vectors             : > VECTORS     PAGE = 0, TYPE = DSECT

}
/****************************************

Thanks
  • Are you facing problems in programming even after unlocking the part using "unlock password" button in on-chip flash tool? From what i understand, you are able to program the part once it is unlocked, correct? If so, then the behavior is correct. When using the on-chip flash programmer tool, it is required to unlock the part before programming the flash. The on-chip flash tool uses the API library from un-secure memory  to perform flash program, hence the device must be in unlocked state before trying to program flash. stored in ROM which is not secure. The Code Security Module in the device will not allow any operation on flash from un-secure memory if the device is secure.

  • Hi, thanks for the response.

    As I wrote, I am able to secure my uC, and using the "On-Chip-Flash" option I am also able to unlock it, by writing the correct passwotd in Code Security fields and erasing my FlashA section.

    But as I said with password protection my program doesnt work properly. Its like some parts of my code (functions/methods) are not executed. The problem is I have to ship my equipment within the next few days, and now the password implementation is screwing everything completelly. Without password protection everything works great.

    I am running my firmware from Flash, as it can be seen in my first post. No memory allocations are overlapping, no errors occure, except the one I described above, when using password protection option I am getting the one error at the end of loading process (98%) of my firmware on uC

    Somehow I got stuck...!

  • The cmd file in the first post seems to have the sections defined as required. The device seems to be in secure state when you are attempting to program flash.

    To help debug further, we need some more information on how you are securing the device. Can you provide what steps you are following to secure the device and load your firmware onto flash and also the version of CCS used.

    Try the below steps in the same sequence and let us know if this works.

    1. Unlock the device by entering the password using on-chip flash tool and erase the FlashA

    2. Program your firmware on to the device

    3. Now program the password using on-chip Flash tool

    4. Perform a reset. After reset,  when you refresh your memory window the programmed flash locations must not be visible. Your device is secure.

    5. Once secure, if you are booting to flash (boot to flash option selected) then your code must run without having to unsecure the device.

    Here are a few links on how to run code from flash for your reference : http://processors.wiki.ti.com/index.php/Flash_Training_and_Application_Notes_for_C2000

    -Vaish

  • Also made a correction to my first reply regarding API in ROM. I misread the part number as F2806x

  • Hi Vaish, thank you very much for your help. I did what you've wrote and looks like it works now, at least I didn't have any problems yet. Before your advice, I was trying to program the Password by writing it directly into the CSMPassword.asm file, I not really understand why it didn't work the way it should.

    But anyway , Thanks

    Bye

  • Glad to know, you were able to flash and secure the device.

    You can also program the password using the CSMPassword.asm file. Once the .asm has the password locations updated and recompiled. You should be able to load this new .out and be able to program the passwords. Only thing to be ensured is that, the part should be unlocked every time you want to re-prorgam/erase the flash.

    -Vaish

  • Hi!

    I have the same issue, I've tried what you said, but it's not working. I've posted the problems I have with CSM and on-chip flash, but didn't get any answer. Maybe you can help.

    Thanks,

    Monica

    http://e2e.ti.com/support/microcontrollers/tms320c2000_32-bit_real-time_mcus/f/171/t/183962.aspx#663546

    http://e2e.ti.com/support/microcontrollers/tms320c2000_32-bit_real-time_mcus/f/171/t/183749.aspx

  • Hi Monica. When I have tried to protect MCU using the CSM_Password,asm file my program didn't work properly. Some parts of the code weren't executed as they should have been. Some simple mathematical functions weren't processed in correct manner or just conversions from one type to another weren't working etc. Instead of changing the PW by using the file mentioned above I programmed my microcontroller withoud PW, error free. Afterwards I have done what has been suggested by Vaish. I went to the "on-chip flash tool " which is available in debug window. There I had a chance to enter my preferred PW into the PW fields and just pressed the button "Lock". After restarting the device everything worked as it should be.

    Gruesse

    Dennis


  • Hi!

    My program runs fine, it just goes wrong when I unlock it using on-chip flash tool.

    Regards,

    Monica