stm32 custom bootloader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-25 2:54 AM
"I am currently developing a custom bootloader for the STM32F072RBT6 microcontroller. The bootloader is functioning correctly in terms of receiving via UART and writing application code of varying sizes into flash memory . I have verified the correctness of the flash writes using the ST-LINK Utility, and the data is written as expected.
However, I am encountering an issue with executing the application code after the bootloader completes its task. The behavior varies depending on the size and complexity of the application:
- In the first case, the application size is approximately 5160 bytes and contains a simple LED toggle in a while loop. This application executes correctly when launched via the bootloader.
- In the second case, the application size increases to 13604 bytes and includes LED toggling, ADC configuration, PWM generation, and UART for Modbus communication. In this scenario, while the ADC, PWM, and UART appear to function correctly, the LED toggling does not behave as expected.
- In the third case, the application size is around 17542 bytes. It includes all previous functionality along with multiple PWM outputs, dual UART (Modbus master and slave), ADC, and a timer used to periodically fire Modbus queries every 2 seconds. In this case, the application executes only once after a reset — the peripherals initialize and run momentarily, but the application does not continue running after that.
Based on this behavior, it appears that the bootloader is correctly flashing the code, but there is an issue during or after the transition to the application, especially as the application grows in size and complexity.
I would like to understand the root cause of this issue and the steps required to resolve it."
- Labels:
-
STM32F0 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-25 7:50 AM
You'll have to debug your program to understand why it's not working. It sounds like you just have general software bugs. If the bootloader flashed it correctly, the issue isn't directly related to the bootloader, but perhaps your program expects peripheral to be in a certain state at startup.
Debugging, stepping through code, will give you more information. This is part of programming, there is no general solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-25 8:32 AM - edited ‎2025-04-25 8:34 AM
Hello,
Better to forget about the bootloader for the moment and Flash and debug your application and check where it fails especially for the cases 2 and 3.
step your code, put break points where you have some doubts, put break point in Hardfault handler especially for the case 3 as it could be a stack overflow issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2025-04-25 2:41 PM
With STM32F0 this can be a vector table issue. The vectors should be re-mapped to address 0 and copied to the SRAM. Of course the SRAM area for the vectors must be properly reserved. Newer CM0+ based MCUs have the VTOR register, so this vectors issue is eliminated there.
