2020-04-22 03:30 PM
Hi,
I'm trying to utilise the built-in UART bootloader in the STM32F031K6 to perform firmware update. I've read the AN3155 and AN2606 documentation but unfortunately, I'm out of luck so far when trying to write the firmware via the bootloader to the target MCU's internal flash.
What I've got working so far:
The following is not working for me:
Some observations:
"When a Read Memory command or Write Memory command is issued with an unsupported memory address and a correct address checksum (i.e. address 0x6000 0000), the command is aborted by the bootloader device, but the NACK (0x1F) is not sent to the host. As a result, the next two bytes (that is, the number of bytes to be read/written and its checksum) are considered as a new command and its checksum"
My questions:
Maybe I'm missing something obvious? All help and suggestions will be gratefully received.
Thanks to all in advance.
Solved! Go to Solution.
2020-04-22 04:24 PM
Seems like you're doing the correct thing.
Maybe your clock is a bit out of tolerance. The effect of this will only show up when you send a bunch of bytes together. Have you checked things on a logic analyzer or scope trace?
Sounds like something might be eating bytes, possibly as a result of framing errors. Certainly should have quite a few more supported commands in that list. Definitely check the clock.
2020-04-22 04:24 PM
Seems like you're doing the correct thing.
Maybe your clock is a bit out of tolerance. The effect of this will only show up when you send a bunch of bytes together. Have you checked things on a logic analyzer or scope trace?
Sounds like something might be eating bytes, possibly as a result of framing errors. Certainly should have quite a few more supported commands in that list. Definitely check the clock.
2020-04-23 02:48 AM
Hi,
Thanks very much for your quick response!
At the moment, I don't have access to any useful test tools that would help because of the current situation with self-isolation.
However, your suggestions lead me to double check my UART settings and my parity setting was incorrect. I have updated this to EVEN parity, as per the AN3155 document. It is now working much better!
For anyone curious, I am now seeing the following:
Stay safe and many thanks for your help and support!
2020-04-23 07:22 PM
Not quite there yet.....
The UART communication appears to be working and all the memory writes are correctly ACK'ed by the bootloader. However, when I dump the flash contents from the MCU, the retrieved bytes does not match those from the original firmware image.
Is it necessary to perform an erase first before writing?
2020-04-24 05:32 PM
For anyone else who might be having problems with the integrity of the data written by the bootloader.
I managed to get my issue resolved by pausing 2 milliseconds between each byte transmission.
Without the small delay, the firmware programmed by the bootloader never matched the original firmware image. There were only some matching bytes scattered throughout the flash.
Just to answer my own question - no, it is not necessary to erase the flash prior to writing.
2020-04-24 06:59 PM
What do you use as "master"?
I wonder, how could have been any command at all recognized and answered with the incorrect parity...
2ms between each *byte*? This must be excruciatingly slow! I'd this how the example programmer works?
JW
2020-04-26 09:10 AM
I'm not sure what "master" is but I transfer the firmware from a different MCU connected to the ST MCU via UART.
The required firmware can be provided to the host MCU via USB, UART, BLE, or external storage.
Regarding the timing, I agree with what you are saying: how could it work at all? But I'm afraid I don't know for sure without monitoring the UART line with a scope or logic analyzer (as per TDK's suggestion). Unfortunately, I don't have access to either tools at this point in time.
The download speed is not an issue for me but the integrity of the written data is of utmost importance. But even with that said, it doesn't take very long to download the maximum 32KB worth of firmware data. Of course, the time taken will also depend on the selected BAUD rate - which in my case is 19200.
Please note that the delay is only done for the "write memory" bootloader command - all the other commands (including read memory) works correctly.