Ask Electrical Engineering Engineering

STM32F105 bootloader: jump address problem, bootloader loops

Problem: The bootloader loops.
I think there is a problem with the transfer address.

The entry point of the main program is at:
enter image description here

This is how the entry point to the main program looks like in the microcontroller memory (0x801F24D)
enter image description here

The address of the transition to the main program looks like this
enter image description here
Jump address to main program is not equal 0x801F24C (Reset_Handler main program has an address 0x801F24C)

Jump function code:

#define MAIN_PROGRAM_START_ADDRESS  0x08010000    
void ExecMainFW(void)
        uint32_t app_jump_address;
        typedef void(*pFunction)(void);             
        pFunction Jump_To_Application;              
        app_jump_address = *( uint32_t*) (MAIN_PROGRAM_START_ADDRESS + 4);      
        //app_jump_address &= ~(uint32_t)0x01;
        Jump_To_Application = (pFunction)app_jump_address;                      
        __set_MSP(*(volatile  uint32_t*) MAIN_PROGRAM_START_ADDRESS);          

If I run the code as shown above, the loader will loop. The controller seems to reload itself as soon as it calls the function Jump_To_Application().

If I uncomment the line app_jump_address &= ~(uint32_t)0x01; I get the correct jump address 0x801F24C but then the loader loops at HardFault_Handler().
I don’t understand where is my mistake? help me please.

Main app settings:

/* Memories definition */
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 64K
  FLASH    (rx)    : ORIGIN = 0x8010000,   LENGTH = 64K

int main(void)
  /* USER CODE END 1 */

Leave a Reply

Your email address will not be published. Required fields are marked *