2024-10-16 07:25 AM
hello
I am developping on a STM32G0B0RE, I've learned after finishing my board and everything that boot pin can be used by default.
It is not a problem since I have ST-Link for production but I would like to be able to do firmware update through bootloader.
The issue is, since nBOOT_SEL is set to '1' by default I need to change it to 0 so I go in bootloader if my pin PA14-BOOT0 is tied up at startup. I find how to change it in STM32CubeProgrammer but I would like to do it in my firmware so the flashing process is not too complicated in factory.
I've tried this but it does not have any effect :
Best Regards
Thibaud HABRAND
2024-10-22 07:44 AM
Hello
Thank you
Are you sure about the reset with HAL_FLASH_OB_Launch() ? Because I am doing this, and my application is never launching after I flashed it, I have to flash the application twice.
/* USER CODE BEGIN Init */
FLASH_OBProgramInitTypeDef initboot;
HAL_FLASHEx_OBGetConfig(&initboot);
if (initboot.USERConfig != 0x67f6000)
{
HAL_FLASH_Unlock();
HAL_FLASH_OB_Unlock();
initboot.USERConfig = 0x67f6000; //set bit to 0
//initboot.USERConfig = 0x77f6000; //set bit to 1
HAL_FLASHEx_OBProgram(&initboot);
//start_timer_cmd()
HAL_FLASH_OB_Launch();
// WIll never reach here
HAL_FLASH_OB_Lock();
HAL_FLASH_Lock();
HAL_FLASHEx_OBGetConfig(&initboot);
}
/* USER CODE END Init */
Thibaud
2024-10-22 07:48 AM
I've also tried to do like you and both times I need to flash my board twice.
2024-10-22 07:55 AM
FLashing twice or do a Power Reset.
2024-10-22 07:58 AM
setting the OB_LAUNCH Bit should generata a reset, as descripted in the RM044 (for my MCU) in capter 3.4.2
2024-10-22 08:18 AM
Thank you I missed this part in the RM044.
But if OBL_LAUNCH generates a reset why do I have to do a 2nd flashing or a Power Reset after i flashed my board with the nBOOT_SEL bit test ?
Thibaud
2024-10-22 11:48 AM
Sorry, cant help You with this.
I don't remember if this was the case with my HW, but as the function get's called only on the first installation of the Application I did not investigate a lot.
Martin
2024-10-23 03:05 AM