cancel
Showing results for 
Search instead for 
Did you mean: 

stm32 custom bootloader

shyamparmar
Associate III

"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:

  1. 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.
  2. 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.
  3. 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."

2 REPLIES 2
TDK
Guru

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.

If you feel a post has answered your question, please click "Accept as Solution".
mƎALLEm
ST Employee

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.