2017-06-14 05:46 AM
Hi,
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;
kprintf(0,'%s...\n',__FUNCTION__);
/*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 = {
OPTIONBYTE_WRP,
OB_WRPSTATE_ENABLE,
WP_FLASH_SECTOR, //<-- this is set to OB_WRP_SECTOR_12
FLASH_BANK_2
};�?�?�?�?�?�?�?�?�?�?�?�?
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
Andreas
Solved! Go to Solution.
2017-06-20 02:32 AM
Hi,
Problem solved.
I had to set the OPTSTART Bit in the FLASH_OPT Regsiter. This triggers a write of the Option Bits.
This was a little bit confusing in the Reference Manual Rev.13 as it had only been mentioned at 'Modify Option Bytes' (Ch 3.4.2). The description of this Bit in the Register Description refers only on the User Byte Options.
Kind regards
Andreas
2017-06-19 11:28 PM
Hi again,
does anyone have an idea how to set the Write-Protection to get Error Flags when writing on the sector?
Kind regards
Andreas
2017-06-20 02:32 AM
Hi,
Problem solved.
I had to set the OPTSTART Bit in the FLASH_OPT Regsiter. This triggers a write of the Option Bits.
This was a little bit confusing in the Reference Manual Rev.13 as it had only been mentioned at 'Modify Option Bytes' (Ch 3.4.2). The description of this Bit in the Register Description refers only on the User Byte Options.
Kind regards
Andreas