Skip to main content
simon2
Associate
July 25, 2009
Question

Read Protection with bootloader error - Can anyone help?

  • July 25, 2009
  • 2 replies
  • 760 views
Posted on July 25, 2009 at 20:23

Read Protection with bootloader error - Can anyone help?

    This topic has been closed for replies.

    2 replies

    simon2
    simon2Author
    Associate
    May 17, 2011
    Posted on May 17, 2011 at 13:18

    Hi,

    I have a propriatory bootloader which switches between application and bootloader via setting a couple of variables in the backup register ram which does not get erased on a reset.

    The problem in question is that when i use the read protection below when the bootloader has loaded a application into the flash starting at 0x8008000 the chip erases the flash (so both bootloader and application) on reset.

    When in debug, I can read protect and unprotect the bootloader as expected - the erase only happens when the application is loaded. I have tried doing the read protect at different points (before loading the application, after loading the application and in the application) all to the same conclusion - the flash gets fully erased.

    This is my read protect/unprotect code:

    void Debug_Read_Protection(FunctionalState u8Enable)

    {

    u32 u32iDelay;

    CommsDebug_TxString(''\n\rP1'');

    FLASH_Unlock();

    if((FLASH->CR & CR_LOCK_Set) == 0)

    {CommsDebug_TxString(''\n\rUnlocked'');}

    else{CommsDebug_TxString(''\n\rLocked'');}

    FLASH_ReadOutProtection(u8Enable);

    FLASH_Lock();

    // insert a delay here //

    u32iDelay = (u32)70000000;

    Debug_Print_FlashRegisters();

    do

    {u32iDelay--;}

    while(u32iDelay!=0);

    NVIC_GenerateSystemReset();

    }// Debug_Read_Protection() //

    void Debug_Print_FlashRegisters(void)

    {

    CommsDebug_TxString(''\n\rOBR = '');

    CommsDebug_TxU32(FLASH->OBR);

    CommsDebug_TxString(''\n\rCR = '');

    CommsDebug_TxU32(FLASH->CR);

    }// Debug_Print_FlashRegisters() //

    Can anyone help??

    16-32micros
    Associate III
    May 17, 2011
    Posted on May 17, 2011 at 13:18

    Hi Simon,

    You can refer to

    http://www.st.com/stonline/products/literature/pm/13259.pdf

    for more details regarding Protections, Go the Section 2.4, then subsections 2.4.1 Read protection and 2.4.2 Write protection. You should not remove the Read-out protection when you have your own boot-loader else it will be erased too.

    Cheers,

    STOne-32.