AnsweredAssumed Answered

No Errorflag when writting to Write-Protected Sector

Question asked by andi z on Jun 14, 2017
Latest reply on Jun 20, 2017 by andi z


I'm evaluating some flash functionalities of the STM32F469NI. I have configured the Sector 12 of my STM32F469 Flash (2MB) with a Write-Protection. When I debug my Firmware I see that the corresponding bit gets set in the FLASH_OPTCR1 Register.

I also run a test when I initialize my Flash Driver which only writes a word (32bit) into the beginning of Sector 12 (0x08100000). Now there should be an error in the SR of the Flash Module. But I don't see anything here.

So I tried to rise an other error and wrote a half word into a word-configured Data Register. Now I got an Error.


But why do I not get any error when writting into a Write-Protected area? Did I misconfigure something? I don't see anything else in the UserManual.

Here is my code

enReturn_t HAL_UserFlash::setWriteProtection(void)
     enReturn_t errorCode = RET_ERROR;
     HAL_StatusTypeDef status = HAL_OK;
//     FLASH_OBProgramInitTypeDef flashInit;
     /*Unlock Option Bytes*/
     status = HAL_FLASH_OB_Unlock();
     if(status == HAL_ERROR)
          return RET_ERROR;
     /*write option bytes and set errorCode RET_OK */
     status = HAL_FLASHEx_OBProgram(&(FLASH_OBProgramInitTypeDef)flashConfig);
     if(status == HAL_OK)
          errorCode = RET_OK;

     /*Lock Option Bytes again*/
     status = HAL_FLASH_OB_Lock();
     if(status == HAL_ERROR)
          return RET_ERROR;

     return errorCode;

my flashConfig Variable:

static const FLASH_OBProgramInitTypeDef flashConfig = {     
WP_FLASH_SECTOR,      //<-- this is set to OB_WRP_SECTOR_12


I use the STM32F4 Cube Lib in Version 1.14


Is there anything I have to activated also?

PS.: I don't need a Read-out Protection now. I just need to make sure that writes on protected areas are now allowed.


Kind regards