cancel
Showing results for 
Search instead for 
Did you mean: 

XMODEM protocol for file transfer

pvall.1
Associate II

Hi,

I'm currently working on file transfer through the XMODEM protocol, and I want to implement the logic in STM32CubeIDE. If anyone has already implemented it, please share the source code. It would be helpful for me.

 

Thanks

15 REPLIES 15
SofLit
ST Employee

Hello,

Google it ..

Example: https://github.com/ferenc-nemeth/stm32-bootloader/blob/master/Src/xmodem.c

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Andrew Neil
Evangelist III

See also Application note  AN4657, STM32 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

Code is available as X-CUBE-IAP-USART:

https://www.st.com/en/embedded-software/x-cube-iap-usart.html

It actually uses YMODEM, but that's very similar to XMODEM:

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

 

Thank you @Andrew Neil I totally forget the AN4657!

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

IIRC, an (the?) advantage of YMODEM was that it tells you how much data is to come?

Also, it defaults to 1K + CRC.

"Ymodem is essentially Xmodem 1K that allows multiple batch file transfer"

Andrew Neil
Evangelist III

Full description of the XMODEM, YMODEM, and ZMODEM protocols:

https://techheap.packetizer.com/communication/modems/xmodem-ymodem_reference.html

It's not that hard to implement from scratch...

Hi,

Thanks for the reply.

However, the source code provided above is for receiving X-Modem/Y-Modem packets from a serial COM port to a microcontroller using a USB-UART bridge. In my case, I want to send data stored on an SD card to UART in X-Modem format. There is no direct connection between USB and UART in my case, so whatever data I receive from USB needs to be stored on the SD card as a file, which will later be transmitted to UART through X-Modem format.

Is there any source code available which suits my requirement?

Thanks

Pavel A.
Evangelist III

@pvall.1 The Ymodem source provided by ST in "IAP" and other examples is very intermixed with flash write & erase routines. When I used it in my projects I had to decouple Ymodem logic from the internal flash stuff. It was tedious but not too hard. You can do the same to reuse these examples to send files from any source including files from SD. 

 

Hi @Pavel A.  Do we need to have USB-UART connector to receive data directly in X-Modem format  into microcontroller through Teraterm? Or any configuration is required to acheive this?

X-Modem is oblivious to what transport you use - it's just a stream of bytes.

But, if you're using TeraTerm, then a UART link is the obvious way to go ...