Skip to main content
Graduate
October 27, 2023
Question

OpenBootloader release binary is not working but the debug binary does work

  • October 27, 2023
  • 2 replies
  • 1150 views

Hi Community,

                       I have a customized OpenBootloader that works well in debug build but is not working when the same is built for release. After some investigation, it was found that execution hitting hard fault at OPENBL_FLASH_JumpToAddress when OpenBootloader_DeInit() is executed which in turn calls HAL_RCC_DeInit().

What may be the reason it is not working in the release build?

Please find the OPENBL_FLASH_JumpToAddress implementation:

void OPENBL_FLASH_JumpToAddress(uint32_t Address)
{
 Function_Pointer jump_to_address;

 /* Deinitialize all HW resources used by the Bootloader to their reset values */
 OpenBootloader_DeInit();

 /* Enable IRQ */
 Common_EnableIrq();

 jump_to_address = (Function_Pointer)(*(__IO uint32_t *)(Address + 4U));

 /* Initialize user application's stack pointer */
 Common_SetMsp(*(__IO uint32_t *) Address);

 jump_to_address();
}

 

    This topic has been closed for replies.

    2 replies

    Visitor II
    February 16, 2024

    In Release set optymalization level to (-O1). Than works without hard fault. 

    Graduate
    February 16, 2024

    Yes, I am aware of this. I fixed it a few months back while experimenting with different optimization levels. But the reason for this is still unknown.

    @KrzysztofK Do you have any input on why changing the optimization level works?

    Visitor II
    February 16, 2024

    After investigation, it seems to me that in the case of optimizations at the -O1 level, push/pop instructions are used to write and restore processor registers, which allows a safe call and return from the function. In contrast, in the case of -Os-level optimization, the ldmia.w and stmia.w instructions are used, which are more efficient in terms of memory occupied but can lead to errors.