cancel
Showing results for 
Search instead for 
Did you mean: 

Issues with Jumping to Application from Custom Bootloader on STM32F407

Vignesh_M
Associate II

I am currently working on a custom bootloader for an STM32F407 microcontroller and facing issues when attempting to jump to the application. The application is located at the address 0x08080000.

Here are the details:

Problem Description

When the bootloader tries to jump to the application, the stack pointer and reset handler are not set correctly, and the application does not start. The values read for the stack pointer and reset handler seem incorrect, which prevents the jump from happening successfully.

 

#define APPLICATION_ADDRESS 0x08080000

void JumpToApp(void)

{

// Read the initial stack pointer and reset handler from the application address

appStackPointer = *(__IO uint32_t*)APPLICATION_ADDRESS;

appResetHandler = *(__IO uint32_t*)(APPLICATION_ADDRESS + 4);

// Print debug information

UART_Printf("appStackPointer: 0x%08X\n", appStackPointer);

UART_Printf("appResetHandler: 0x%08X\n", appResetHandler);

// Validate the stack pointer and reset handler

if ((appStackPointer & 0x2FFE0000) == 0x20000000 && (appResetHandler & 0xFF000000) == 0x08000000)

{

// Disable interrupts

__disable_irq();

// Set Vector Table base address

SCB->VTOR = APPLICATION_ADDRESS;

// Set stack pointer

__set_MSP(appStackPointer);

// Function pointer to the reset handler

JumpToApplication = (pFunction)appResetHandler;

// Jump to application reset handler

JumpToApplication();

}

else

{

// Print error message if values are not valid

UART_Printf("Invalid stack pointer or reset handler\n");

}

}

 

1.What could be the reason for the stack pointer and reset handler values being incorrect?

2.Are there any additional steps needed to ensure the correct values are read from the application address?

3.Could there be an issue with how the application is compiled or linked?

 

 

13 REPLIES 13

Hi,

   I used STM32CubeProgrammer to flash via UART and USB, and it worked. But now I need to update the firmware without using STM32CubeProgrammer. How can I do this?

 

>> How can I do this?

You'd have to code a method, using an interface you chose.

Should be IAP examples using UART and Y-MODEM, or USB and FLASH Stick

For a drag-n-drop type interface, perhaps look at how Arduino uses UF2

https://github.com/microsoft/uf2

 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hi Tesla DeLorean,

        Could you please explain? This is my first time working on a custom bootloader, so I need more clarification on this. I would appreciate your guidance on how to proceed.

 

 

Hi MM..1,

     Can you guide me for how to jump from bootloader to Application without using stm32cubeprogrammer