cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 - IAP - USART not working after jump to main application

rafaelBR
Associate

Hello there,

I'm trying to implement IAP using an STM32F030K6T6. I based my code on the example provided by ST, this tutorial (http://marcelojo.org/marcelojoeng/2015/09/bootloader-on-stm32f0.html) and also reading through threads in the forum with problems similar to mine. I was successful in getting most functions of my firmware working, but I'm still struggling trying to make the USART peripheral work. 

In short, the "transfer complete" flag is not being set when I'm putting data in the pheripheral's register for transmission.

I don't use the USART to program the flash memory with the new code. I store the new code in the an external flash chip. Then, I use SPI to read the code from the external flash to program it inside the STM32. The SPI is working fine, both in the bootloader as well as in the main application.

Things I already investigated:

Interrupts: They are working correctly. I use timers that use interrupts and they're working correctly. The vector table seems to be remapped to the RAM without any issues.

USART configuration: I have a non-IAP version of the firmware that uses the same code to configure the USART peripheral and in this case the USART is working fine. Maybe I have to change something in the configuration, but I don't think that's the case since stop bits, baud rate and things like that don't change in the IAP-context.

The SYSCFG peripheral: I read in a thread that there's a mistake in the example IAP code from ST. Instead of enabling the syscfg, it is resetting it. I already changed that. Still, even if this was the problem, I don't know what the syscfg would have to do with the usart not working.

My main suspicion is that the USART clock is not being enabled even if I'm using the correct driver function that enables it.

I'm using the MDK-ARM Keil toolchain to code, compile and debug.

2 REPLIES 2

I'd look at the code, but don't see any

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
rafaelBR
Associate

I solved it. It was a problem on my bootloader. It wasn't programming the code correctly on the internal flash. There was a small part at the end that was missing. I noticed after checking the memory map using uVisions debugger.

In short, my bootloaded looked at the external flash then copied what was there on the internal flash until it found a "OxFFFFFFFF" word. There was such a word near the end of my main application code, but still there were some bytes beyond that that the bootloader didn't program into the internal flash. I changed the criteria that the bootloader used to recognize the end of the code and that was enough to make it work correctly. I feel so dumb.

Anyway, thank you for the attention.