2024-10-15 07:05 AM - last edited on 2024-10-16 08:09 AM by SofLit
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:
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?
2024-10-16 10:30 AM
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?
2024-10-16 10:35 AM
>> 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
2024-10-16 11:48 PM
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.
2024-10-21 12:03 AM
Hi MM..1,
Can you guide me for how to jump from bootloader to Application without using stm32cubeprogrammer