Embedded Systems Firmware Demystified

The monitor now includes a flash file system, serial port communications, and Ethernet connectivity. The next natural step is to provide a mechanism that allows file transfer to and from the target. The file transfer protocols presented in this chapter are not new but remain popular because of their simplicity. The monitor uses Xmodem and TFTP for RS-232 and Ethernet implementations respectively. Data can be transferred as raw memory or as a file for both protocols. The MicroMonitor package includes code for a PC-based TFTP client/server and PC-based Xmodem transfer. I will limit this discussion to the target side. Complete implementation details are beyond the scope of this discussion. (Refer to the CD for a full source listing.)
Both Xmodem and TFTP are lock step protocols, meaning that when one end sends some data, it doesn t send any new data until it receives acknowledgment from the other end indicating that the data was received. Although this design slows things down a bit, especially with respect to TFTP, the lock step approach offers the benefit of simplicity.
I think Xmodem has been around since dirt. Xmodem is one of those things that just won t go away, which is good because Xmodem can be found just about anywhere and it s not too difficult to implement. Xmodem has spawned many variants, including derivatives that support CRC versus checksum, 128- versus 1024-byte packets, and multiple files per transfer. I won t discuss these variants here, because my focus is MicroMonitor s Xmodem support not...