James Stanley


How to copy files to/from the RC2014 using XMODEM

Mon 28 December 2020
Tagged: rc2014

Every time I get the RC2014 out and try to copy files to/from it, I have to relearn how to do it, so I thought it best to document what I have found to be the easiest way.

The rx and sx programs are provided by the lrzsz package on Ubuntu:

$ sudo apt install lrzsz

The first thing you need to do is use stty to enable RTS/CTS handshaking (I don't really understand why, it's just magic) and set the baud rate:

$ stty -F /dev/ttyUSB0 115200 crtscts

Without this everything will just hang and you'll have no idea why it's not working. You need to re-run this every time you plug in the USB FTDI cable.

From Linux to CP/M

We'll send foo.txt from Linux to A:FOO.TXT on CP/M. When sending from Linux to CP/M I find you need to start the sending side before the receiving side otherwise it just hangs.

On Linux:

$ sx foo.txt < /dev/ttyUSB0 > /dev/ttyUSB0

sx seems to stand for "send with xmodem".

On CP/M:

B>XMODEM A:FOO.TXT /R /X1

/R means "receive", and /X1 means to communicate via CP/M's "reader and punch", i.e. the secondary serial port.

From CP/M to Linux

We'll send A:FOO.TXT from CP/M to foo.txt on Linux. When sending from CP/M to Linux it doesn't seem to matter whether you start the sending side or the receiving side first.

On Linux:

$ rx foo.txt < /dev/ttyUSB0 > /dev/ttyUSB0

rx seems to stand for "receive with xmodem".

On CP/M:

B>XMODEM A:FOO.TXT /S /X1

/S means "send".

Other notes

USB serial port permissions

On my system, /dev/ttyUSB0 becomes group-owned by dialout, so to access it you either need to be in the dialout group, or just be root.

Connecting to the RC2014

Using a USB FTDI cable, connect the Linux machine to the RC2014's secondary serial port. On my machine this is exposed with a 6-pin header on the back panel:

But on a bare RC2014 it is this one:

XM.COM vs XMODEM.COM

The RomWBW CP/M image that is included on the CompactFlash card contains a program called XMODEM.COM and a program called XM.COM. They both appear to implement XMODEM, but XMODEM.COM is the one to use. I couldn't work out how to use XM.COM.

Drive letter assignment

Drive A: is a ramdisk, so files written here will be lost across a power cycle.

Drive B: is a romdisk, so you can't write files here.

The rest of the drives are backed by the CompactFlash card.

CP/M file lengths

CP/M doesn't actually have a way to know exact file lengths, it just knows how many blocks a file takes up, which are 128 bytes long. This isn't a problem when transferring from Linux to CP/M, but text files transferred from CP/M to Linux will be padded to a multiple of 128 bytes with ^Z characters.

Example output

Linux:

$ rx foo.txt < /dev/ttyUSB0 > /dev/ttyUSB0
  
rx: ready to receive foo.txt
Bytes received:     128   BPS:121                   
  
Transfer complete

CP/M:

B>XMODEM A:FOO.TXT /S /X1
 
File open
Sending via RDR/PUN with checksums
*
OK
Sent 1 blocks



If you like my blog, please consider subscribing to the RSS feed or the mailing list: