I have a question related to the serial terminal. It is sometimes possible to connect to a device using a command such as screen. One example would be screen /dev/ttyUSB0 115200.

I can connect through a Linux ARM device with it (even passing the login phase). Thus, I can easily transfer everything that is text. Now, I would like to copy a binary file through it. How can it be done?


Instead of using screen, you might want to use a dedicated serial terminal emulator program, such as minicom, since it has built-in support for the local side of serial-port binary transfer protocols like ZMODEM.

To transfer a file from local system to an ARM device, you would need to have the command-line tool for the ZMODEM protocol installed on both devices. At least on Debian, it comes in package named lrzsz.

First, you would login to the ARM device and run the rz (Receive Zmodem) command on it. It will output a special "waiting to receive" character sequence which can be detected by a ZMODEM-aware terminal emulator program, such as minicom. At that point, the terminal emulator program should automatically allow you to select a file for sending to the remote ARM device. If that does not happen, you can still select the "send file using ZMODEM" (or "upload file...") function manually from your terminal emulator.

Some terminal emulators may have full internal implementation of the ZMODEM protocol, but minicom just uses the sz (Send Zmodem) command-line tool to do the actual file transfer, so you'll need to have the lrzsz package installed locally too.

Transferring from the remote ARM to the local system works essentially the same: you run the sz <filename> command at the remote end, and the incoming transfer ("download") should be automatically detected by your terminal emulator.

Since the sz and rz tools are designed to be used at the remote end and will transfer the file over what is essentially the standard input and output of your shell session, using the commands at the local side requires specific input/output redirections and the terminal emulator must stop reading the serial port while the file transfer program is running. All these things would make it extremely inconvenient to use the sz/rz tools on the local side with a program like screen that does not have the necessary features for accommodating external file transfer tools.

  • That is a very good answer and would have most likely solved my problem! However, in my particular case, I can't install rz since I don't have internet on my ARM device. Since you answered correctly and I don't want to let your answer sink because I find it very useful, I'll accept it and ask another more specific question. – Emile D. Oct 6 '19 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.