cancel
Showing results for 
Search instead for 
Did you mean: 

STM32Fxx USART application bootloader

nus
Associate
Posted on January 29, 2016 at 05:07

I am writing an application bootloader for stm32f4xx. What is the best way to detect end of transmission over serial line?

#!stm32f4-!stm32f401
6 REPLIES 6
pkumar1883
Associate II
Posted on January 29, 2016 at 06:49

hi,

You can use YModem File transfer protocol. It takes care of all. ST provides this boot loader example.

nus
Associate
Posted on January 29, 2016 at 06:58

I'll see that example. From concepts point of view, what would one look for to realize of file transmission on serial line? 

Posted on January 29, 2016 at 09:12

You send a terminal packet or symbol to indicate completion?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
gmate1
Associate II
Posted on January 29, 2016 at 15:13

You send a terminal packet or symbol to indicate completion?

 

What if this terminal packet or symbol could also appear in the payload ? 

I had similar problem while trying to parse the Firmware binary file that I was receiving over UART. In my case, the HTTP server responded with the payload size, which could be used for parsing the data, however, in a continuous stream of data over UART, there is no such guarantee that in __every__ scenario, the particular symbol will never be part of actual data.

As a side note, it would be interesting to see, how the networking protocol stack handles this. 

Posted on January 29, 2016 at 22:34

You're writing your own bootloader and not using the built-in STM32 bootloader, correct?

If so, you're going to want to define some sort of protocol, not just for the purpose of data boundary detection (your ''end of transmission'' question), but also to guarantee error-free delivery of the data. You're not trying to simply stream a full firmware image, are you? That's what it sounds like, given the concern you expressed (i.e., having some ''end of transmission'' marker byte that could appear in the firmware image data).

Packetize your data and add some flavor of consistency checking, like a CRC-8 or CRC-16. Serial communication can be noisy. User kk above mentioned YModem - that's a fine idea, though you still may want to roll your own depending on what your bootloader feature set is going to be.

You might want to read through ST's AN3155 for inspiration.

-Cyg

(BTW, this sort of thing is precisely what ''networking protocol stack[s]'' do, though in a much more complex fashion due to the nature of the problem something like TCP/IP was built to address.)

Posted on January 29, 2016 at 23:22

What if this terminal packet or symbol could also appear in the payload ?

 

You have a packet format that infers length, or if purely stream based you could use escape sequences. 

For context, what was your degree in? Mine was an EE, and I was doing serial data transfers as a teenager.

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