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.
Tool/software: Code Composer Studio
I used the On-Chip Flash Option under the Tools menu in Code Composer studio to set a password and lock my flash. I then call the code that I have pasted below in my app but my flash
remains locked. Can you please suggest what could be the problem?
#define STATUS_FAIL 0
#define STATUS_SUCCESS 1
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.
asm(" 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;
__asm(" 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;
}
I am wondering if I can get someone to spend a bit of time with me to get a solution to this. I tried all yesterday to get the flash to unlock with the code above. I even tried putting the function in secure ram to see if that is the problem with no luck. There really has to be something undocumented or I am missing something in the documentation. I should mention that code skin is able to unlock it but I am not able to from my app with the code above. What could codeskin be doing that I am not? I am desperate for a solution as this problem is holding up the shipment of my product. I would be very grateful if you could offer some more advice.
James,
I tested and things work as they are supposed to. I can unlock the CSM using exactly your code (with my passwords of course).
1) Try reversing the order of your passwords in the program.
2) Are you running this code from flash or secure RAM? Since the PWL in flash are protected by the CSM module, you can only do dummy reads of them from secure memory.
[Update 2018Apr27, 1056AM EDT, ALTER]: #2 above is incorrect. You can do the dummy reads from unsecure memory.
Regards,
David
James,
Try leaving your unlock function in flash instead of copying to RAM until you get this resolved. One less variable to deal with.
The unlock procedure is very simple, and you seem to have implemented it correctly. I'm wondering if your method for detecting the CSM status is flawed. What do you do with the 'status' variable? Are you using it to light an LED or something like that?
- David
James,
James Robb said:I don't do anything with the status variable. I now that the code is still locked because Code composer refuses the connection and tells me it is locked.
James,
Attached to this post is a simple code example that has the CSM passwords programmed, and the program unlocks the CSM. I am blinking GPIO34 which is connected to an LED on the F28035 ControlCard I am using. After the unlocking procedure, if the CSM is unlocked, the LED blinks fast (~5 Hz). If the CSM is locked, the LED blinks slow (~0.5 Hz).
You may need to modify the GPIO used for your board.
Note that the clocks/PLL is not configured, so the DelayMs() macro being used is not calibrated. It expects a 60 MHz clock, but the CPU is only running at 10/2 MHz (I think) off the internal oscillator.
I only changed the first password from 0xFFFF. I am using 0xFFFE. All the other passwords as still 0xFFFF. This isn't the issue though. I've run this program with all the passwords programmed. I am just sending it to you like this, with the first one 0xFFFE.
Regards,
David
BTW, the project is a CCSv8.0.0 project. You may need to install this if you are using an older version in order to load the project.
- David
James,
James Robb said:
As soon as I get to the statement
CsmRegs.CSMSCR.bit.FORCESEC = 1;
I get a message from CCS that asks if I want to bring the device out of lower power mode. I click yes.
This is expected. I get it too. CCS looses its connection to the processor when the CSM is locked by the code. Previously it was unlocked (since CCS was connected). You are not in a low-power mode.
James Robb said:The problem occurs when I recycle power. After the power is recycled the I/O
toggles slowly at the 1 second rate which suggests that the device is locked. I power cycle several times but still the device remains locked with the secure bit equal to 1. Would you not expect the device should be unlocked after power cycling since the key being written to the key registers matches the one you have programmed in the flash?
This is not expected. Try physically unplugging the emulator from your board and then power cycle.
- David