ksstms
ksstms

Reputation: 11

STM32 DFU over UART writes incorrect data

I'm working on a firmware updater, so that the main controller in the system can program the other STM32 chips. I'm using UART at 115200 bps with 8E1 as written in the app notes AN2606 and AN3155. Currently I'm trying to flash an STM32F429. I can read the flash without problems.

To test the writing functionality I'm writing 8 bytes to addresses which are multiples of 4 as suggested in AN3155. I've checked the data lines with a logic analyzer, and everything is sent correctly and the STM responds ACK to everything.

When I try to read it back, I get random values at those locations. The values are always the same when writing to the same base address, but they change when writing elsewhere.

I've set the Voltage Range Configuration Register (AN2606 page 30) to 0x03, because my power supply is 3.3V. The explanation of this register is pretty confusing, so I'm not even sure if this setting is right and I couldn't find anything else that could go wrong.

UPDATE:

I have tried to write to all 4-byte aligned addresses, and then read it back for comparison. I did this with various data sizes. All writes are incorrect to the base address of a sector. The failed addresses have these patterns:

Bytes   Incorrect write addresses
  4     0, 10, 20, 30, ...
  8     0, 0C, 1C, 2C, 3C, ...
 12     0, 08, 18, 28, 38, ...
 16     0, 04, 14, 24, 34, ...
 32     0  04, 14, 24, 34, ...
 64     0, 04, 08, 0C, 14, 18, 1C, 24, ...
128     all 
256     all 

SOLUTION:

Doh! There was an issue with flash erasing that I haven't noticed.

Upvotes: 1

Views: 824

Answers (1)

user10558543
user10558543

Reputation:

Original STM bootloader is not good in the real development as it does not provide two essential functions.

  • it does not provide any decryption and your firmware can be stolen by anyone (so protecting the device does not make any sense as you have to publish "plain" not encrypted binary image)

  • it does not check the integrity of the application in the flash

  • it does not work with the protected devices

The easiest way is to write your own bootloader and implement all those functions.

Upvotes: 1

Related Questions