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
Pavel A.
Evangelist III

@pvall.1 Of course you can use any adapter from the TTL UART of the STM32 to a PC. For a modern PC that does not have RS-232 ports, TTL to USB adapter is the best choice. If compatibility with RS-232 is needed, use a passive TTL to RS-232 adapter.

If on the other side you're using TeraTerm, I suggest to develop your MCU counterpart from TeraTerm source code.
Remember: from the TeraTerm serial connection, you always receive a stream of bytes in open chain, so you have to write your own parser to scan the received bytes and detect XMODEM packets. I remark this since I don't know your experience with pure UARTs, maybe you're expecting to receive something structured, i.e. like an udp datagram.

MCU speaks VHDL and CPU speaks assembly. Neither of them speaks HAL.

Hi,

I utilized the above code and changed it as per requirements. I am able to receive one packet correctly with a matching CRC value. However, when I send an ACK or NAK from the receiver end, the sender is not sending the second packet. What could be the possible reason?

Your ACK or NAK must be incorrect in some way.

Try capturing the traffic from a "good" transfer, and compare with a failing one ...

Does the sender give any error details to help?

Have you tried with any other sender(s)?

 

The sender didn't provide any details like EOT or CAN. It's timing out and the X-Modem send popup disappears. After timing out, I'm able to see the NAK sent by the receiver in the command Prompt.

Pavel A.
Evangelist III

Have you seen one of Ymodem examples from ST? they have Ymodem-1K in several examples and demo apps for several MCU models: IAP, SBSFU... It works well with latest Teraterm. Xmodem is older simpler protocol.