Serial File Uploads With Serio – /dev/ttyS0

So you’ve got an embedded device that’s running Linux, you’ve tapped into the board’s serial port and you have a root shell. You’re poking around and want to run netstat/netcat/grep/whatever – but it’s not installed! And what’s worse, the device doesn’t have any utilities to perform a network file transfer. How do you get the file you want to execute from your host machine up to the embedded device?

Transferring ASCII files can be done with minicom, but that method won’t work properly for binary files. ASCII encoding a binary file usually isn’t an option since most embedded systems won’t have utilities like base64 or uuencode in order to un-encode the transferred file, and other transfer methods (Xmodem/Ymodem/Zmodem, Kermit) require a corresponding utility to already be installed on the embedded device.

If the echo command on your serial shell supports the -n and -e options (most do), serio can help. It takes any local file and transfers it to the embedded system via the serial port with a series of echo commands.

The -n option is required in order to ensure that no additional new line characters get echoed into the resulting file, and the -e option allows serio to encode binary files as a series of escaped hex characters (x41, x42, etc).

This allows binary files to be transferred to a remote system via the serial port without any additional software requirements on the remote system:

Serio in action

Serio in action

File uploads are not very fast, so you’ll probably want to upload netcat/wget/tftp or similar utility in order to transfer additional files over the network. But in a pinch it works great for getting your cross-compiled binaries off your host system and onto that crippled embedded device that you’ve been dying to play with.

Bookmark the permalink.

Comments are closed.