2025-10-07 5:12 AM
I am using STM32F401, I had an application which communicates via USART1 by using DMA2. Both RX and TX DMAs are working fine. So I added a bootloader and moved application to 0x08008100. Bootloader is using same USART1 and DMA2. Now bootloader is working fine but I have problem with application.
All I changed in application is start address. Bootloader jumps to application, timer interrupt is working fine and toggles LED. When it receives or transmits a data via DMA it stops, LED is not toggling anymore. When debugging I tried these:
* SCB->VTOR is already set as 0x08008100. Timer interrupt is working fine.
* I changed application's start address back to 0x08000000 and its working fine.
* I removed USART and DMA code from bootloader so it only jumps to application. It didn't solve the problem (it lloks like not deinitialize-initialize issue).
* I added USART and DMA to bootloader back. In the application I didn't use DMA when sending data with USART, it could send without any problem. I tried this a few times, it stops when sending data with USART DMA but keeps working when sending without DMA.
* In the application, I added HAL_DMA_DeInit before HAL_DMA_Init, it stops before even trying to send message.
How can I solve this issue? Thank you.
Solved! Go to Solution.
2025-10-07 6:52 AM
Can VTOR be set to multiple of 0x100? Seems small. Pretty sure it needs to be a multiple of 0x200.
Should be able to debug the application in STM32CubeIDE at whatever offset you have it at, step through, see the issue.
2025-10-07 5:21 AM - edited 2025-10-07 5:21 AM
@alig_ones wrote:When it receives or transmits a data via DMA it stops
Microcontrollers don't just "stop".
Use the debugger to find what, exactly, it is actually doing in this state. And how it got there.
Is it, perhaps, stuck in the Hard Fault handler? Or some other "error handler" which just spins in a loop?
2025-10-07 6:41 AM
Sorry I meant its stuck in somewhere, is it possible to debug application code when using bootloader? I tried with bootloader now and I saw this error:
which means its in Hard Fault handler:
When I check call stack I see:
It fails in HAL_DMA_DeInit function. I was calling this function before initialization of DMA. I removed it.
After removing It keeps toggling LED but transmits data only once, then it doesn't send data (in the timer interrupt, I send test byte and toggle LED). Actually this was the my earlier problem, to solve it I added and removed many things (like HAL_DMA_DeInit ) whole day and forgot root cause. So I can summarize the issue: After jumping to application I send data with HAL_UART_Transmit_DMA function, data is sent once.
2025-10-07 6:47 AM
@alig_ones wrote:is it possible to debug application code when using bootloader?
Sure - you can connect the debugger to a running target
2025-10-07 6:52 AM
Can VTOR be set to multiple of 0x100? Seems small. Pretty sure it needs to be a multiple of 0x200.
Should be able to debug the application in STM32CubeIDE at whatever offset you have it at, step through, see the issue.
2025-10-07 7:20 AM
That was the problem, with 0x200 offset its working fine again, thank you very much @TDK and @Andrew Neil . I am using VS Code (it has useful features like git history, file timeline, code snippets, finding files functions etc.) but have less debug features unfortunately. I will try to use STM32CubeIDE. Thanks again.
2025-10-07 7:33 AM
@alig_ones wrote:VS Code (it has useful features like git history, file timeline, code snippets, finding files functions etc.) .
CubeIDE (being Eclipse) can do Git integration and finding files functions etc ...