2014-10-25 02:43 PM
I want to set Readprotectionlevel=1. After the initialisation i can't see toggling of GPIO_PIN_7. The function HAL_FLASH_OB_Launch(); causes problems. When commenting out the function HAL_FLASH_OB_Launch() the while(1) loop will be reached. Is there anything wrong setting RDP=1 like this ? I use HAL_DRIVER. I got the same problem with STD_PERIPHERAL_DRIVER. Tools: Keil 4.73, EWARM 7.2, ST-LINKV2
void
MX_Flash_Init(void
) { FLASH_OBProgramInitTypeDef Optbyte; HAL_FLASHEx_OBGetConfig(&Optbyte);// read out RDPLvL
if
(Optbyte.RDPLevel ==RESET){// Lvl 0 = 0, Lvl 1,2 =1
Optbyte.OptionType=OPTIONBYTE_RDP;// select RDP optionbyte
Optbyte.RDPLevel=OB_RDP_LEVEL_1;// select RDP level 1
HAL_FLASH_Unlock();// unlock Flash
HAL_FLASH_OB_Unlock();// unlock Optionbytes
HAL_FLASHEx_OBProgram(&Optbyte);// set RDP=1
HAL_FLASH_OB_Launch();// write OB to Flash and reset
} HAL_FLASH_OB_Lock();// Lock Optionbytes
HAL_FLASH_Lock();// lock Flash
}int
main(void
) { MX_GPIO_Init(); MX_Flash_Init();while
(1
) { GPIOA->ODR^=GPIO_PIN_7; } } #flash #option-bytes #stm32f02015-03-13 03:20 AM
Did you manage to resolve this issue ?
We had the same problem on an STM32F030R8 design, even running the code on theSTM32F0308-Discovery board. If you haven't already then I think you will find that the HAL_FLASHEx_OBProgram(&Optbyte) call is failing (!=HAL_OK) when it gets to FLASH_OB_RDP_LevelConfig, specifically the WRITE_REG(OB->RDP, ReadProtectLevel) call - at least that's what we surmised.
It is possible the HAL code is broken here, but I have no evidence of that, apart from this issue. Keil uVision 5.12.0.0 ArmCC V5.05 (build 41) stm32f0xx_hal_flash_ex.c V1.0.1 (18-June-2014)2015-06-17 08:20 AM
Do one of you have the solution ?
I have the same issue here, I agree with the post above : since the launch make a reset of the device. as long as RDP is not changed we infinitly reset. but the writed register seems to correspond with the register of the datasheet. I will post here more information. edit: I'm too onSTM32F030R8
2015-06-17 08:25 AM
And do any of these functions return ERROR or STATUS information that might help you understand the failure?
Do you clear any pending error/status flags from the controller?2015-06-17 09:09 AM
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
FLASH_OBProgramInitTypeDef initFlash;
initFlash.OptionType = OPTIONBYTE_RDP;
initFlash.RDPLevel= OB_RDP_LEVEL_1;
status = HAL_FLASHEx_OBProgram(&initFlash);
if
(status != HAL_OK)
{
if
(status == HAL_ERROR)
{
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_9,GPIO_PIN_SET);
}
if
(status == HAL_BUSY)
{
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_9,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_14,GPIO_PIN_SET);
}
if
(status == HAL_TIMEOUT)
{
HAL_GPIO_WritePin(GPIOA,GPIO_PIN_9,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_14,GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_15,GPIO_PIN_SET);
}
while
(1);
}
HAL_FLASH_OB_Launch();
HAL_FLASH_OB_Lock();
I use stm32 cube to generate a project. (only init 3 pin from basic project for feedback)
I add just the code above to have a feedback.
The result is that we have flash error. ''HAL_ERROR''
thanks for your time :)
I'll go further tomorow.
regards
G.M.
2015-06-17 10:08 AM
Not a HAL guy, this is an SPL thread covering this
[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/flash%20readback%20protection&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=891]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2Fflash%20readback%20protection&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=8912015-06-18 01:00 AM