cancel
Showing results for 
Search instead for 
Did you mean: 

Code flash

ssk
Associate II
Posted on January 15, 2016 at 10:49

I want to protect the flash on SPC560 MCU. I came across few terms like Shadow flash and its use. I have used C90LC Flash drive to access data flash. Can I use the same driver for shadow flash also? I see few bits for shadow flash inside the data structure. Any example for using Censorship feature using the shadow flash?

Thanks.

Mike
4 REPLIES 4
Erwan YVIN
ST Employee
Posted on January 20, 2016 at 10:10 Hello Mike , Yes , you can use the same driver to access to the shadow flash. cf example in SPC560Dxx OS-Less Flash Test Application for Discovery you can protect the shadow row as below :

/*==================== Lock to Protect Shadow Row ====================*/
test_string_print(&SD1, 
''Lock shadow row: ''
);
returnCode = pSetLock( &ssdConfig, LOCK_SHADOW_PRIMARY, 1, FLASH_LMLR_PASSWORD );
if
( C90FL_OK != returnCode )
{
ErrorTrap(returnCode);
}
returnCode = pSetLock( &ssdConfig, LOCK_SHADOW_SECONDARY, 1, FLASH_SLMLR_PASSWORD );
if
( C90FL_OK != returnCode )
{
ErrorTrap(returnCode);
}
test_string_print(&SD1, 
''DONE

''
);

More informations are detailed in Chapter 27 RM0 Best regards Erwan
ssk
Associate II
Posted on January 20, 2016 at 15:48

Thanks Erwan for the reply. I have couple of queries related to Flash Integration test application.

1. Does the statement 'Lock to Protect Shadow Row' protects only Shadow flash ? I want to protect full code and data flash from read/write access.

2. Looking at the code, I do understand that it first writes the password to shadow and then uses the combination of Get and Set lock functions. Is it required to follow this sequence for Censorship feature?

3. Also for C-Flash, the application does this Get and Set functions and then goes on performing the flash operations like erase, blank check, program, verify etc. But for D-flash, it first resets the lock state and then performs the flash operations. How is this?

4. In this application, I do see use of variable 'blkLockState' for D Flash handling but this is not done for C Flash. How is it?

5. Where the 'RUN_IN_FLASH' is defined? or not defined?

6. How about the recovery from lockout? I do understand that it is not possible to recover the MCU in case of lockout but using serial flash boot, is it possible to gain the access for flash memory?

Look forward for your earliest reply as I am stuck for this censorship feature. Thanks in advance.

Mike

ssk
Associate II
Posted on January 22, 2016 at 12:39

Hello Erwan,

I tried understanding the Flash Integration Test Application. I am writing my answers for my earlier queries about this application. Please let me know your views and please answer for the remaining queries at the earliest.

1. Does the statement 'Lock to Protect Shadow Row' protects only Shadow flash ? I want to protect full code and data flash from read/write access.

Mike: It protects the shadow row/flash only. The SetLock function locks the block for program/erase. The passwords used for this lock/unlock are different from the NVPWD0/1 values.

2. Looking at the code, I do understand that it first writes the password to shadow and then uses the combination of Get and Set lock functions. Is it required to follow this sequence for Censorship feature?

Mike: No specific sequence for Get/Set lock function required. The combination can be used to verify if a block is locked for program/erase.

3. Also for C-Flash, the application does this Get and Set functions and then goes on performing the flash operations like erase, blank check, program, verify etc. But for D-flash, it first resets the lock state and then performs the flash operations. How is this?

4. In this application, I do see use of variable 'blkLockState' for D Flash handling but this is not done for C Flash. How is it?

5. Where the 'RUN_IN_FLASH' is defined? or not defined?

Mike:It is defined under ‘Application Configuration’->’Runtime Settings’->Load in RAM. Is this correct?

6. How about the recovery from lockout? I do understand that it is not possible to recover the MCU in case of lockout but using serial flash boot, is it possible to gain the access for flash memory?

7. Can I use FlashWrite function to write to Shadow block? I want to write new NVPWD0/1 values to achieve Censorship.

Best Regards,

Mike
ssk
Associate II
Posted on January 27, 2016 at 15:01

Hello Erwan,

I tried implementing the Censorship feature using C90LC flash driver. I am observing following error codes from the flash driver,

0x00000002 - EER bit is set before Flash operations.

This error is mainly for the FlashInit call. I tried clearing the ERR bit from CFLASH.MCR register but does not work.

0x00000700 - There is a mismatch between the source

data and the content in the checked Flash memory.

This error is for FlashWrite call.

Both the error codes are observed at random and not consistent. I have already used the C90LC flash driver for Data flash and used the same call with new ssdConfig pointing to Code flash but still the errors are there. I am unable to test the censorship feature as the init and write calls are not functioning correctly. Can you please clarify if I am missing anything for Censorship feature?

Your earliest help in this regard will be highly appreciated. Thanks in advance.

Best Regards,

Mike