2025-05-15 12:35 AM
Hi Experts,
I'm almost a newbie at STM32F7xx even though I've been working with STM32F4 series.
I wanted to handle the flash memory as IAP.
I tried flash erase as same as what I do on STM32F4 but it failed.
So I checked and found that thera are two kind of bank modes in STM32F7.
I'm familiar with the address map of single bank mode and I tried to change Dual bank mode to Single bank mode in my code like below.
FLASH_OBProgramInitTypeDef OBInit = {0};
// 1. Unlock Flash and Option Bytes
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
// 2. Read current Option Bytes
HAL_FLASHEx_OBGetConfig(&OBInit);
// 3. Set DBANK to 0 (Single Bank)
OBInit.OptionType = OPTIONBYTE_USER;
OBInit.USERConfig = OB_NDBANK_SINGLE_BANK;
if (HAL_FLASHEx_OBProgram(&OBInit) != HAL_OK)
{
// Error handling
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
return;
}
// 4. Launch Option Bytes loading (MCU will reset)
HAL_FLASH_OB_Launch();
// 5. Lock Option Bytes and Flash
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
When I did it, system has halted and I can't make it reboot any more.
With STM32CureProgrammer, I can connect to the STM32F746NG Discovery board and programm again but MCU doesn't run at all.
I asked chatgpt about this but its answer was not helpful for me.
Please help me.
Thank you.
Best regards,
James.
2025-05-20 2:37 AM
Hello @jamesYSKim and welcome to the community,
@jamesYSKim wrote:
So I checked and found that thera are two kind of bank modes in STM32F7.
I'm familiar with the address map of single bank mode and I tried to change Dual bank mode to Single bank mode in my code like below.
There is no Dual bank feature on STM32F746 device. The dual bank is available on STM32F76x and STM32F77x devices.
For Flash erase example, please refer to the example provided in the STM32CubeF7 package at this link: https://github.com/STMicroelectronics/STM32CubeF7/tree/master/Projects/STM32746G-Discovery/Examples/FLASH/FLASH_EraseProgram
Hope that helps.