2024-03-01 04:58 AM
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
2024-03-01 05:29 AM
Hello,
Google it ..
Example: https://github.com/ferenc-nemeth/stm32-bootloader/blob/master/Src/xmodem.c
2024-03-01 05:37 AM
See also Application note AN4657, STM32 in-application programming (IAP) using the USART
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
2024-03-01 05:56 AM
Thank you @Andrew Neil I totally forget the AN4657!
2024-03-01 06:00 AM
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"
2024-03-01 06:36 AM
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...
2024-03-03 06:14 PM
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
2024-03-03 06:29 PM
@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.
2024-03-06 09:22 PM
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?
2024-03-07 02:41 AM
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 ...