AnsweredAssumed Answered

P128, flash securnig

Question asked by Lukasz Prymula on Jan 8, 2010
Latest reply on Sep 3, 2010 by kef

Hello!

 

My project is finished :smileyhappy: and the last thing i will have to do is flash securing. So,  project contains bootloader at last page (0xC400...0xFEFF) and main program. That works fine. Next I have to secure flash from unauthorised access. In bootloader I wrote:

 

volatile const tU16 FlashSecurity @ 0xFF0E = 0xFFBC;  // backdoor enabled, flash secured

 

Now, when user wants to chang a FW, i must unsecure flash. Backdoor keys I wrote also in bootloader:

 

volatile const tU16 BKD_KEY0 @ 0xFF00 = BOOKDOOR_ACCESS_KEY0;
volatile const tU16 BKD_KEY1 @ 0xFF02 = BOOKDOOR_ACCESS_KEY1;
volatile const tU16 BKD_KEY2 @ 0xFF04 = BOOKDOOR_ACCESS_KEY2;
volatile const tU16 BKD_KEY3 @ 0xFF06 = BOOKDOOR_ACCESS_KEY3;

 

I was looked on AN3275(S12 All-Access Bootloader for the HCS12 Microcontroller Family) and there flash is uncesured in this way:

 

<code>

void near UseBackdoor(uint8 cmd)
{
  FlashSectorBackup();
  InterruptVectorBackup();
  if (!(FSEC & 0x02))                                    /* If Secured */
  {
    vfnSCITxMsg(gi8aMCUSecuredMsg);         /* Asks for current BackdoorKey */
    EnterKeys();
    vfnSCITxMsg(gi8aUnSecuringMsg);         /* Display message */
    Unsecure();
    //(void)RunFunctionInRAM(&Unsecure);      /* Call restoreKeys procedure to unsecure the MCU */
    if ((FSEC & 0x03) == 0x02)
    {
      vfnSCITxMsg(gi8aUnSecuredMsg);        /* Display message if unsecure succesful */
    }
    else
    {
      vfnSCITxMsg(gi8aCantUnsecureMsg);     /* Display message if unsecure failed */
      return;
    }
  }
  if((uint8)cmd==ChangeKeys)
  {
    EnterKeys();
  }
  KeysNSec[7] = cmd;
  FlashSectorRestore();
  InterruptVectorRestore();   
  vfnSCITxMsg(gi8aNewSecurityAppliedMsg);   /* Display messages */
}

</code>

 

And now I have problem. When I do this in the same way it dont works. If I set at the begin  FSEC to 0xBC , program read 0xFF from this register (I sent this value by SCI), but if I set this register to 0xBE program read it right. I dont know whats wrong.

 

And other question. Text form documentation to family P128:

"Access Key command match the backdoor keys stored in the Flash memory, the SEC bits in the FSEC
register (see Table 13-10) will be changed to unsecure the MCU. Key values of 0x0000 and 0xFFFF are
not permitted as backdoor keys. While the Verify Backdoor Access Key command is active, P-Flash
memory and D-Flash memory will not be available for read access and will return invalid data."

So, when Backdoor Key unlock flash securiy, it will be possible to  read a flash data for example by BDM? In other way, while the user dont finish sending of new FW the flash will be unsecured but will it be readable from extern?

 

Sorry for my english :smileyhappy:

Best regards

Lukasz

Outcomes