Flash protection

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User15718
Level 1
Level 1
Hi everyone,

I have several questions about flash protection.
I flash the XMC4200 microcontroller with DAVE over JTAG which also allows me to debug my applications. I use the following code to protect global read/write flash content.


#include
#include
#include
#include
#include
#include
#include

uint8_t user = 0;
uint32_t protection_mask = XMC_FLASH_PROTECTION_READ_GLOBAL;
uint32_t password_0 = 0x0;
uint32_t password_1 = 0x0;

int main(void){

//##### SET UP #####
if ((XMC_FLASH_GetStatus() & XMC_FLASH_STATUS_PROTECTION_INSTALLED) == 0) {
XMC_FLASH_EraseUCB(XMC_FLASH_UCB0);
XMC_FLASH_InstallProtection(user, protection_mask, password_0, password_1);
XMC_FLASH_ConfirmProtection(user);
}

// ... rest of my code
}


My first question is: Must I include the flash protection code in the same DAVE project as my application code? If I do so, the application works but it is not possible to flash any code again. This is obviously what I am looking for, but I also need to temporary disable protection (with correct passwords) to allow flashing new programs.
The second one is: in this forum link: https://www.infineonforums.com/threads/4731-Flash-read-protection-cannot-connect-anymore jferreira (an Infineon employee) suggest to implement a backdoor to disable protection. What exactly does he mean? Can I do it over JTAG?

Thanks in advance
Diego
0 Likes
2 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

Have a look to the XMCLib example at XMCLib\examples\XMC4500\FLASH\FLASH_PROTECTION. It uses a shell which implements a command that allows to disable temporarily the flash protection.
The way of disabling temporarily the flash protection are multiple, i.e. pin level at start up...
Regards,
Jesus
0 Likes
User22519
Level 1
Level 1
Hello,

I tried implementing the function that jferreira mentioned to temporarily disable the flash protection in order to use the JTAG for debugging.
After disabling the protection, I read the FSR register and the bit 19(RPRODIS1) is set which means that "Read and global write protection is temporarily disabled."
Still, when I try to connect with Micrium/Dave to debug it fails.

It seems that during a debug request the drive resets. I saw that ferreira recommended to temporarily disable the flash protection at start-up and I did so in both the main firmware and the ABMs and still failed.

Thanks in advance,
Mihai
0 Likes