cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F031 uart bootloader write command

Gregory Holcomb
Associate II
Posted on July 13, 2017 at 18:00

I am using a STM32F031 micro and app note AN3155, using the built in UART bootloader on serial pins A9 and A10.  I wish to write sixteen bytes of zeros to an address near the start of flash, 0x08000010.  Referencing page 18 and 19 in the app note.  The micro is sending ACK for accepting the write command and sending ACK for accepting the address.  The sequence to send the data to write is not clear, with my interpretation the micro neither ACK nor NACK until I send one extra byte.

I do note that footnote 2 on page 19 says (N+1) must be a multiple of 16.  Does that mean I can't write 16 bytes because 16+1 is 17, and must instead write 15 or 19?

My assumptions:

Write 16, my N is equal to 16.

Write sixteen zeros.

Write the checksum, 16 and 16 zeros, checksum is 16.

Problem:

STM never ACK or NACK.

Observation:

If I write an extra zero byte, the checksum would be correct still and that makes the STM will ACK.

Data decoded in hex on an oscilloscope in HEX if that is clearer than my description.

0690X00000603wbQAA.jpg
1 ACCEPTED SOLUTION

Accepted Solutions
Posted on July 13, 2017 at 18:08

No it means you send it a count of 15, and then 15+1 bytes to the loader. Sending 0 doesn't make sense, so always at least 1 byte, and depending on the part, enough to fill the whole/aligned flash line.

Writing 16 bytes to SRAM at 0x20000000

BYTE data[25] = { 0x31, 0xCE, 0x20, 0x00, 0x00, 0x00, 0x20,

0x0F, // 16 Bytes

0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,

0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,

0x0F };

Sending a count of 255 means 256 bytes of payload, as I recall

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

View solution in original post

2 REPLIES 2
Posted on July 13, 2017 at 18:08

No it means you send it a count of 15, and then 15+1 bytes to the loader. Sending 0 doesn't make sense, so always at least 1 byte, and depending on the part, enough to fill the whole/aligned flash line.

Writing 16 bytes to SRAM at 0x20000000

BYTE data[25] = { 0x31, 0xCE, 0x20, 0x00, 0x00, 0x00, 0x20,

0x0F, // 16 Bytes

0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,

0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,

0x0F };

Sending a count of 255 means 256 bytes of payload, as I recall

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 13, 2017 at 20:02

That makes sense, everything works and the flash is loading complete now.  Thank you.