Skip to main content

3 replies

Andrew Neil
Super User
October 10, 2024

Set the receive size to 1 - receive 1 byte at a time.

Doing it with HAL_UART_Receive_IT is quite an overhead, but it can work - depends on how fast you want/need it to be...

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Associate III
October 10, 2024

@Andrew Neil  Thank you for the suggestion to receive 1 byte at a time using HAL_UART_Receive_IT. I understand that this approach can add overhead, but it might work for my use case. However, I’m still unclear about how to determine the end of the file.

Since I will be receiving the file byte-by-byte, how can I know when I have received the complete binary file so I can proceed with writing the data to flash and jumping to the application?

Andrew Neil
Super User
October 10, 2024

@shyamparmar wrote:

I’m still unclear about how to determine the end of the file.


well, that's an entirely different question - nothing to do with the UART handling of the bytes!

As @Tesla DeLorean suggested, you will need some sort of protocol to handle that - X/Y/Z-modem are specifically designed for this very application, and are widely supported by terminal software.

https://web.cecs.pdx.edu/~rootd/catdoc/guide/TheGuide_226.html

https://en.wikipedia.org/wiki/XMODEM

https://en.wikipedia.org/wiki/YMODEM

https://cambium.inria.fr/~doligez/zmodem/ymodem.txt 

ST Use Y-modem in their IAP Application Note - AN4657STM32 in-application programming (IAP) using the USART:

https://www.st.com/resource/en/application_note/an4657-stm32-inapplication-programming-iap-using-the-usart-stmicroelectronics.pdf

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
Tesla DeLorean
Guru
October 10, 2024

You'll need to manage as bytes or blocks, or create circular/ring buffers where you consume the data elsewhere. 

For files, where size is imparted, look at Y-MODEM 

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Associate III
October 11, 2024

I just wrote this program a few days ago. You should use DMA to receive data.Regularly query data and receive data for splicing。And my bin file transfer added crc check