AnsweredAssumed Answered

STM32F4 USART Programming

Question asked by cornwell_mott.ben on Nov 14, 2015
Latest reply on Nov 16, 2015 by cornwell_mott.ben
I am trying to program the STM32F4 Discovery board through the UART and am having a very perplexing problem. 

I am getting into the bootloader through my program code, following the same method as the ST video that demonstrates how to do this. I can successfully get into the bootloader section and run GET (0x00), Get Version (0x01), Get ID (0x02), and Go (0x21) commands. 

For the most part, I can also use the Read (0x11) and Write (0x31) commands. However, while attempting to re-program the microcontroller, I am running into an issue where a specific chunk of data is not writing correctly. I have a short example below:

Get into the Bootloader
Send: 0x7F
Receive: 0x79

Try to write 8 bytes to address 0x08000000
Send: 0x31
Receive: 0x79
Send: 0x08 0x00 0x00 0x00 0x08
Receive: 0x79
Send: 0x07 0x00 0x00 0x02 0x20 0xF1 0x5A 0x01 0x08 0x87
Receive: 0x79

Try to read 8 bytes at address 0x08000000
Send: 0x11
Receive: 0x79
Send: 0x08 0x00 0x00 0x00 0x08
Receive: 0x79
Send: 0x07 
Receive: 0x79 0x00 0x00 0x02 0x20 0x31 0x5A 0x01 0x08

So one of the bytes did not get write correctly. If I immediately repeat the same code and try to rewrite the memory at the same location (to fix the error), I get the following output:

Try to write 8 bytes to address 0x08000000
Send: 0x31
Receive: 0x79
Send: 0x08 0x00 0x00 0x00 0x08
Receive: 0x79
Send: 0x07 0x00 0x00 0x02 0x20 0xF1 0x5A 0x01 0x08 0x87
Receive: 0x79

Try to read 8 bytes at address 0x08000000
Send: 0x11
Receive: 0x79
Send: 0x08 0x00 0x00 0x00 0x08
Receive: 0x79
Send: 0x07 
Receive: 0x79 0x00 0x00 0x02 0x20 0xF1 0x5A 0x01 0x08

So it appears that the device memory was correctly written this time. However, when I later use ST-LINK to read my program memory, the value of that byte is not 0xF1, but the original read value of 0x31.

I cannot for the life of me figure out why the read command is reporting an incorrect value. 

If anyone has any suggestions, I'm very grateful...

Outcomes