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.

CCS/TMS320F28034: How do I set CSM Module memory and password for the first time?

Part Number: TMS320F28034
Other Parts Discussed in Thread: CONTROLSUITE

Tool/software: Code Composer Studio

Hi 

I have the following locations reserved in my linker file for my TMS320F28034 for the CSM (Code Security Module). 

CSM_RSVD    : origin = 0x3F7F80, length = 0x000076     /* Part of FLASHA.  Program with all 0x0000 when CSM is in use. */

CSM_PWL_P0  : origin = 0x3F7FF8, length = 0x000008     /* Part of FLASHA.  CSM password locations in FLASHA */

How do people generally 0 fill CSM_RSVD for the first time?

How do people generally set a their password for the first time at CSM_PWL_P0?

Do they do it from code composer?  If so how?

Is there a way to do it from the linker file? If so how?

Or does it have to be done with a program I write?

  • James,

    The way I would suggest is to use a small .asm file to program the passwords and CSM_RSVD area.  Include this in your project and the two areas will get programmed along with all the rest of your flash.  Use named sections, and link these in your linker .cmd file.

    .asm file, for example call it passwords.asm:

    ***************************************************

     .sect "passwords"

     .int 0xFFFF  ;PWL0 (LSW of 128-bit password)
     .int 0xFFFF  ;PWL1
     .int 0xFFFF  ;PWL2
     .int 0xFFFF  ;PWL3
     .int 0xFFFF  ;PWL4
     .int 0xFFFF  ;PWL5
     .int 0xFFFF  ;PWL6
     .int 0xFFFF  ;PWL7 (MSW of 128-bit password)
     
    ***************************************************

     .sect "csm_rsvd"
     .loop (3F7FF5h - 3F7F80h + 1)
      .int 0x0000
     .endloop

    ***************************************************

     .end

    Above, change the 0xFFFF's to whatever you want your passwords to be.  Then in your linker command, link the sections to the appropriate memory.

    MEMORY
    {
    PAGE 0:    /* Program Memory */
       CSM_RSVD   (R) : origin = 0x3F7F80, length = 0x000076
       PASSWORDS  (R) : origin = 0x3F7FF8, length = 0x000008
    }

     
    SECTIONS
    {
       csm_rsvd          : > CSM_RSVD,              PAGE = 0
       passwords         : > PASSWORDS,             PAGE = 0
    }

    Regards,

    David

  • Thank you for your answer. I will keep this code snippit and add to my project later. For now I was able to lock my flash with a password using the options in Code Composer Studio. The option is in the tools\On chip flash when you are connected to the debugger. Now that my flash is locked I have been trying to unlock it with code inside my custom bootloader. My Bootloader is based on the project in this directory.
    C:\ti\controlSUITE\device_support\f2803x\v130\DSP2803x_examples_ccsv5\f2803x_flash_kernel
    I load the above project through the code that is at init_boot_addr = 0x003ff7dd;
    Its like my bootloader won't run properly or something when my flash is locked. I am not able to get the autobaud character back when my flash is locked. After the autobaud sequence there is a function CsmUnlock that I have pasted below which I would like to use to unlock the flash but I don't think the project is running properly or something when the flash is locked since I never get the autobaud character. My bootloader works when my flash is not locked. Can you suggest a reason why the code at
    C:\ti\controlSUITE\device_support\f2803x\v130\DSP2803x_examples_ccsv5\f2803x_flash_kernel
    may not run properly when the flash is locked?

    Uint16 CsmUnlock()
    {
    volatile Uint16 temp;

    // Load the key registers with the current password. The 0xFFFF's are dummy
    // passwords. User should replace them with the correct password for the DSP.

    EALLOW;
    CsmRegs.KEY0 = 0x1111;
    CsmRegs.KEY1 = 0x2222;
    CsmRegs.KEY2 = 0x3333;
    CsmRegs.KEY3 = 0x4444;
    CsmRegs.KEY4 = 0x5555;
    CsmRegs.KEY5 = 0x6666;
    CsmRegs.KEY6 = 0x7777;
    CsmRegs.KEY7 = 0x8888;
    EDIS;

    // Perform a dummy read of the password locations
    // if they match the key values, the CSM will unlock

    temp = CsmPwl.PSWD0;
    temp = CsmPwl.PSWD1;
    temp = CsmPwl.PSWD2;
    temp = CsmPwl.PSWD3;
    temp = CsmPwl.PSWD4;
    temp = CsmPwl.PSWD5;
    temp = CsmPwl.PSWD6;
    temp = CsmPwl.PSWD7;

    // If the CSM unlocked, return succes, otherwise return
    // failure.
    if (CsmRegs.CSMSCR.bit.SECURE == 0) return STATUS_SUCCESS;
    else return STATUS_FAIL;

    }
  • James,

    You can't erase / program the flash without unlocking the device. In f2803x_flash_kernel project, Shared_Boot.c calls CsmUnlock function. This function is defined DSP2803x_SysCtrl.c. Please update your CSM password here, compile and rerun f2803x_flash_kernel program.

    Regards,
    Manoj