stm32 custom bootloader
"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."
