extern int fnEnableBackdoor(unsigned long key[2]){ unsigned long *ulKeyLocation = (unsigned long *)0x400; if (CFMSEC & SECSTAT) { // device secured— if (CFMSEC & KEYEN) { // is backdoor key access enabled– CFMMCR |= KEYACC; // enable backdoor key access *(unsigned long*)(BACKDOOR_FLASH + ulKeyLocation++)) = key[0]; // write backdoor access keys *(unsigned long*)(BACKDOOR_FLASH + ulKeyLocation)) = key[1]; CFMMCR &= ~KEYACC; // normal flash access if (!(CFMSEC & SECSTAT)) { // check whether the device could be unsecured return 1; } else { return 0; } } else { return 0; } } return 1;}
Hi Mark,
Enclosed is a CodeWarrior for ColdFire 7.0 project that runs on the M5213EVB.
If you don’t have or don’t want to install the free version, there are s19 and elf files in the ~ FlashSecurityCode\mcf5213\obj\mwerks\m5213evb folder. I’ve tested using CF Flasher with S19 that it works.
Set your terminal window to 19200, 8, 1, no parity.
Instructions get printed with reset…and by typing “help”.
The simplest test is to secure the flash, try accessing via BDM (and you will not be able to), then unsecure the flash and try accessing via BDM (and you will be able to).
The command line steps to secure the flash:
CFM> fsw 4ac8 //writing to the CFM security register indicating you want to secure the flash
CFM> flash //copies the CFM security register to flash (actually erases the 1st page of flash, copies vector table and CFM registers to flash
CFM> rst //resets the MCU to have flash mode of operation take affect.
Try accessing MCU via BDM and you should fail
The command line steps to un-secure flash:
CFM> fsw 0 //clear the CFM security register
CFM> flash // copies the updated CFM security register to flash
CFM> rst // resets the MCU to have flash mode of operation take affect.
Try accessing MCU via BDM and you should succeed
I’ll also post this reply to the WildRice ColdFire Forum.
Regards,
David