cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476RG perform a DFU via UART from another board

devtty
Associate III

 Hello all, I'm pretty stuck and could use a pointer in the right direction. I have a nucleo communicating with another board via UART. I would like to be able to update the application on the nucleo board via UART from the other board. Is there any example somewhere on kicking off the bootloader (buttonless)/ nor moving any jumpers. I have read some docs on the USART bootloader sequence but it looks like that requires a strange pattern of moving jumpers around (see attached image). I cant find much more than that.0693W00000D0OTJQA3.pngperhaps I need to start looking at some template bootloader code and toying with writing my own?

Thanks and sorry for the n00bness

15 REPLIES 15

This is sending 240 bytes, not 239. The checksum is a single byte and must be XOR'd with all the data bits, plus the first byte you send to indicate length.

I'm guessing your data doesn't all XOR to 0.

If you feel a post has answered your question, please click "Accept as Solution".

Thanks. I sorted that all out and converted a simple program (blinky program) from a .bin to an array as "const unsigned char MyBinImage[] = {

0x00, 0xEF, 0xBF, 0xBD, 0x01, 0x20, 0xEF, 0xBF, 0xBD, 0x08, 0x00, 0x08,

0xEF, 0xBF, 0xBD, 0x07, 0x00, 0x08, 0xEF, 0xBF, 0xBD, 0x07, 0x00, 0x08,

0xEF, 0xBF, 0xBD, 0x07, 0x00, 0x08, 0xEF, 0xBF, 0xBD, 0x07, 0x00, 0x08,

0xEF, 0xBF, 0xBD, 0x07, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xEF, 0xBF,

0xBD, 0x07, 0x00, 0x08, 0x05, 0x08, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,

0x13, 0x08, 0x00, 0x08, 0x21, 0x08, 0x00, 0x08, 0xEF, 0xBF, 0xBD, 0x08 .. etc.

"

I received ACKS as i wrote it in 256 byte chunks to flash starting at address 0x08000000. However, after finishing all the writes my nucleo did nothing. Bootloader didn't launch nor did the program i tried to write. I also tried issuing a "Go command" and same result.

In regards to my other comment. It still looks like my write command does not actually write anything to flash. For example I write like so:

0x31 0xCE

ACK

0x08 0x00 0x00 0x00 0x08

ACK

0x03 0x00 0x55 0xAA 0xFF 0x03

ACK

Now i try to read:

0x11 0xEE

ACK

0x08 0x00 0x00 0x00 0x08

ACK

0xFF 0x00

Data:

00 00 00 00 55 08 08 2B 08 08 58 08 08 16 08 08 5B 08 08 00 00 

00 00 00 00 00 00 2E 08 08 60 08 08 00 00 0C 00 A8 86 00 A8 95 00 A8 95 

00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 

00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 

00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 

00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 

00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 

00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 A8 95 00 F8 

Even tho I am getting acks on my write nothing seems to change.

Flash must be erased before it can be written. You must erase the entire page.
If you feel a post has answered your question, please click "Accept as Solution".

I tried that too and its still not what I would expect.

I do a mass erase with:

0x44 0xBB

ACK

0xFF 0xFF <-- mass erase

0x00 checksum

ACK

I then read the data same way as above and I do see its erases because all data returned from read is FF.

Then i issue the write command mentioned above with the same data to write(0x00 0x55 0xAA 0xFF)

and my read results in:

55 B5 00 00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF 

FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 

FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 

FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 

FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 

FF FF FF FF FF FF FF FF FF FF FF FF FF FF 

Thank you.

welp... I managed to update the FW ! �� but the read being different from what I wrote doesnt make sense to me