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.
Hello everyone. I am trying to secure my uC by writing new passwort to addresses 0x3F7FF8-0x3F7FFF. Does it means I just have to take the CSMPassword.asm file and change all Fs
.sect "csmpasswds"
.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)
to some random numbers and my MCU will be automatically password protected?
How can I unsecure the CSM, I have read something about it in "System Control and Interrupts..." manual, but I am still a bit confused. There is some code available like,
volatile int *CSM = (volatile int *)0x000AE0; //CSM register file
volatile int *PWL = (volatile int *)0x3F7FF8; //Password location
volatile int tmp;
int I;
// Read the 128-bits of the password locations (PWL)
// in flash/ROM at address 0x3F7FF8-0x3F7FFF
// If the device is secure, then the values read will
// not actually be loaded into the temp variable, so
// this is called a dummy read.
for (I=0; i<8; I++) tmp = *PWL++;
// If the password locations (PWL) are all = ones (0xFFFF),
// then the device will now be unsecure. If the password
// is not all ones (0xFFFF), then the code below is required
// to unsecure the CSM.
// Write the 128-bit password to the KEY registers
// If this password matches that stored in the
// PWL then the CSM will become unsecure. If it does not
// match, then the device will remain secure.
// An example password of:
// 0x11112222333344445555666677778888 is used.
asm(" EALLOW"); // Key registers are EALLOW protected
*CSM++ = 0x1111; // Register KEY0 at 0xAE0
*CSM++ = 0x2222; // Register KEY1 at 0xAE1
*CSM++ = 0x3333; // Register KEY2 at 0xAE2
*CSM++ = 0x4444; // Register KEY3 at 0xAE3
*CSM++ = 0x5555; // Register KEY4 at 0xAE4
*CSM++ = 0x6666; // Register KEY5 at 0xAE5
*CSM++ = 0x7777; // Register KEY6 at 0xAE6
*CSM++ = 0x8888; // Register KEY7 at 0xAE7
asm(" EDIS");
but where should I add it to my code? to my software?
I am a bit confused, would be thankfull for some help.
Dennis
I did it. I wrote in the first line of the password ABCD instead FFFF and have tried to write my MCU. unfortunatelly I got an error during writing process, and now I cannot write anything anymore to my MCU, I am gettin always the same error,
C28xx: Flash Programmer: Error erasing flash memory. Device is locked or not connected. Operation cancelled
C28xx: Flash Programmer: Error erasing Flash memory.
C28xx: Flash Programmer: Device is locked or not connected. Operation cancelled.
C28xx: Trouble Writing Memory Block at 0x3f6000 on Page 0 of Length 0x164
Cannot write to target
OK, I was able to unlock the device, by using "On-Chip Flash" function of CCS. But is the system proteced this way, if I am writing a password to my CSMPassword.asm file, as mentioned above, to avoid that anyone could read the code which is stored on my MCU?
Thanks
I am not sure what happened in your programming experience that first led the tools to believe it was locked and then later believe it wasn't. However, changing the CSMPassword.asm file is the correct way to go about securing your device. The compiler will place these values at 0x3F7FF8 - 0x3F7FFF as part of your .out file. Once the .out file is properly programmed into the device and you pull a reset, the device should be locked with the value you chose in CSMPassword as the password. To unlock the device this value should be written to the CSMKEY register (0xAE0 - 0xAE7) and a dummy read of the password locations in flash (0x3F7FF8 - 0x3F7FFF) should be performed. Once these two steps are complete the device should be unlocked until you pull reset again (or write to the FORCESEC bit - bit 15 of 0xAEF). You can also unlock the device via the plugin by putting the password into the KEY field and telling it to unlock. The plugin will do the steps necessary. Also, the debugger typically has a gel function that will dummy read the flash password and write a value to the KEY. You can change the GEL script to contain your password so all you have to do is execute the script to unlock the device. By default I think the GEL script runs at device reset, so if you have the password written into the GEL script your device may appear to come out of reset unlocked. Don't be fooled though, this is just because the GEL script knows the password. Hope this helps.
Regards,
Dave Foley
Hi David, thanks for your response. Is there maybe somewhere a description how to read code from microcontroller. I would like to try it, to be sure everything worked fine.
Dennis