cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possilbe to check(and may be write)the DB1M option byte from the firmware? I am using an STMF4427IG (1MB with double bank via DB1M option byte)

Henry Brasil
Associate II
Posted on January 15, 2018 at 14:11

Is it possilbe to check(and may be write)the DB1M option byte from the firmware? I am using an STMF4427IG (1MB with double bank via DB1M option byte)?

thanks

3 REPLIES 3
Posted on January 15, 2018 at 15:14

Yes, the options bytes are accessible with the normal address space of the processor.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Szymon PANECKI
Senior III
Posted on January 15, 2018 at 15:31

Hello Henry,

If you use HAL in your application, there is a function inside Flash driver library (stm32f4xx_hal_flash_ex.c) to read Option Bytes:

void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit);�?

So in your code you need to create a C structure and call a function with this structure as an argument:

FLASH_OBProgramInitTypeDef flashOptionByte;
HAL_FLASHEx_OBGetConfig(&flashOptionByte);�?�?

Writing to Option Bytes is a bit more complex. You need to unlock access to Flash, unlock access to Option Bytes, write to Option Bytes and finally confirm your modification. In terms of code it looks like below:

HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
if (HAL_FLASHEx_OBProgram(&flashOptionByte) != HAL_OK)
{
Error_Handler();
}
HAL_FLASH_OB_Launch();�?�?�?�?�?�?�?

After last function call MCU will make a reset.

Regards

Szymon
Posted on January 15, 2018 at 18:22

Thanks Sir, is not clear to me the reason of two different functions:

HAL_FLASHEx_AdvOBGetConfig

and

HAL_FLASHEx_OBGetConfig