Introduction
Sometimes I need to send some file to a target system but I don’t (yet) have any network services or clients on the host. Or I may not even have any network at all. Fortunately, there are couple ways of doing this using serial console. I’m presenting two examples on how to achieve that. Both are using different commands on the host side so depending on what’s available on your target device, choose one of them.
Sending in ASCII
If you want to send ASCII file, all you need on the target is cat
command. Just redirect its input to some file and then run minicom on
host machine and choose ascii
as a sending protocol (use CTRL+A S
to
enter file sending menu):
target$ cat >file
host$ minicom
CTRL+A S
+-[Upload]--+
| zmodem |
| ymodem |
| xmodem |
| kermit |
|>ascii< |
+-----------+
Then finish cat on target pressing CTRL+D
. Ensure that file has no
errors using checksums or hashes, for example:
target$ busybox md5sum file
61fd8fe62ae12b0ef2df2521a29ba272 file
host$ md5sum /tmp/file
61fd8fe62ae12b0ef2df2521a29ba272 /tmp/file
You may have problems sending CTRL-D
to your process if your shell
does not have controlling terminal (i.e. it’s running on
/dev/console
).
host$ (sleep 12; killall -HUP cat) & cat > tosend
You may also send binary file but you first have to encode it in
ASCII
. I’m using busybox uuencode/uudecode
for this:
host$ busybox uuencode file < file >tosend
target$ busybox uudecode <tosend
Sending using xmodem
If you have busybox rx
, there’s much simpler way of sending a file -
using xmodem protocol. All you have to do on the target side is to run
rx
. On host side, choose xmodem
protocol when sending file from
minicom
:
target$ busybox rx file
host$ minicom
CTRL+A S
+-[Upload]--+
| zmodem |
| ymodem |
|>xmodem< |
| kermit |
| ascii |
+-----------+
xmodem
should take care of encoding/decoding data, checking
checksums and detecting end of transfer.
Other possibilities
So far this was enough for me but numerous other ways exist. In case you
need it, you may for example want to try serio python script (just
delete self.s.open()
line, otherwise it won’t work).