BaudBuddy

XMODEM, YMODEM and ZMODEM on macOS

Four protocols from the modem era, still the only way into a device with no network. Which one your equipment actually supports, and why an IOS image at 9600 takes eleven hours.

You only reach for these when there is no network. A switch with a corrupt image and no working Ethernet, an embedded board with nothing but a UART, a device whose ROM monitor predates anything better. In that situation the serial line is the only way in, and one of these four protocols is how you use it.

The differences that matter

Block Sends the filename Sends the exact size Can resume
XMODEM 128 bytes no no, pads to a block no
XMODEM-1K 1024 bytes no no, pads to a block no
YMODEM 1024 bytes yes yes no
ZMODEM streaming yes yes often, when both ends support recovery

Two of those columns decide most real choices.

Padding. XMODEM has no idea how long your file is, so it rounds up to a whole block and fills the rest with 0x1A. For a text file, harmless. For a firmware image or anything checksummed, you now have a file that is up to 1023 bytes longer than the original and fails verification. You strip the padding afterwards, or you use a protocol that knows the length.

Resume. XMODEM and YMODEM restart from zero. ZMODEM picks up where it stopped. On a link that drops after forty minutes of a fifty minute transfer, this is the only column you care about.

What your equipment supports is the real constraint

The table is theoretical. In practice:

Many legacy Cisco recovery environments offer XMODEM. The exact command, available variants and speed controls depend on the platform and software release. Follow the recovery guide for the exact model rather than applying a router or Catalyst procedure to a different product family.

Most embedded bootloaders are similar. U-Boot has loadx, loady and loadz, so you sometimes get a choice. Vendor bootloaders usually do not.

Anything running a real operating system with rz and sz available will do ZMODEM, and you should use it.

The protocol you pick is the intersection of both ends, and the far end is almost always the limiting one.

The eleven hour problem

Here is the arithmetic nobody does before starting.

A serial console at 9600 baud moves roughly 960 bytes per second, and that is before protocol overhead, acknowledgements and retries. Call it 800 bytes a second in practice.

A 32 MB IOS image at 800 bytes per second is about eleven and a half hours.

If the device documentation allows it, raise the console speed before starting the transfer. For example, Cisco documents this command for specific legacy Catalyst switches:

switch: set BAUD 115200

Then reconnect your terminal at 115200 and start the transfer. The same 32 MB image takes a little under an hour at the estimated effective rate above. Do not enter this command on another platform unless its own documentation uses the same syntax.

Remember to put the speed back afterwards, or the next person to console in gets silence at 9600 and starts the whole diagnostic dance.

The connection sheet showing baud rate, data bits, parity, stop bits and flow control, with the current setting summarised as 9600 8-N-1

Changing the console speed for a transfer and putting it back afterwards is much less annoying when the connection is saved and you can switch between two of them.

Sending, and where it goes wrong

The order is always the same: tell the receiving end to expect a file, then start sending. Get it the other way round and the sender talks into a device that is not listening, times out, and gives up.

Supported Cisco platforms use a documented variation of a copy xmodem: or xmodem command. Enter the exact receive command for your model first, then start sending from the Mac. An XMODEM receiver commonly sends C characters while it waits for a CRC-mode transfer.

Things that break it:

  • Flow control mismatch. Software flow control uses XON and XOFF, which are 0x11 and 0x13, and a binary file contains those bytes. The transfer stops dead when your image happens to contain an XOFF. Use hardware flow control, or none, never software.
  • The line is not clean. These protocols retry, but a link with real errors turns a one hour transfer into a four hour one. Check the cable before you start rather than after.
  • Something else is echoing. A terminal with local echo on will corrupt a binary stream.
  • Sending as text. Any translation of line endings destroys a binary file. If your tool has an ASCII mode, this is what it is for, and it is not what you want here.

Checking what arrived

Assume nothing. Verify.

Switch# verify /md5 flash:c2960x-universalk9-mz.bin

Compare the result with the checksum published by the vendor. If it does not match, do not install or boot the file. XMODEM block padding can affect the received length in some workflows, but only the vendor’s recovery procedure can tell you whether and how that padding may be handled safely.

Which to reach for

  • Recovering a Cisco device from its monitor: use the protocol and speed change documented for that exact model.
  • A bootloader offering a choice: YMODEM at minimum, so the filename and length come across.
  • A device with a shell and rz: ZMODEM, always. Resume alone justifies it.
  • A file you could move any other way: use the other way. These protocols are for when there is no alternative.

BaudBuddy handles all four in both directions with progress and cancel, which is the part that matters at hour three when you want to know whether it is moving or hung.

Sources