1

I am configuring my raspberry pi device of the serial console (like this https://learn.adafruit.com/adafruits-raspberry-pi-lesson-5-using-a-console-cable/overview)

How can I do the equivalent of scp? (copy files to the raspberry pi)

Currently I am just going cat > newfile.py and then pasting in the file content.

Maybe the following matrix will explain what I am missing:

over network                    | over serial
--------------------------------------------------------------
ssh pi@192.168.1.10             | picocom -b 115200 /dev/ttyU*
--------------------------------------------------------------
scp script.py pi@192.168.1.10:~ | ????????????????

additional stuff:

  • I would like to put this in a script, so a non interactive way would be preferable.
  • All of your suggestions sound great.. but an example would be really handy.
  • You are essentially back to the old modem days. Does picocom support zmodem? If yes, install "rz" and "sz" on both ends and just upload. – Thorbjørn Ravn Andersen Jul 20 at 6:23
  • I was tempted to suggest xmodem but seriously I could not recommend a 1970s protocol. If you really are limited to a serial link this family of protocols at least has a proven track record. I wouldn't even use scp - FTP is much easier and more reliable. – Milliways Jul 20 at 9:52
  • How about running a point-to-point IP connection over serial (with pppd and wvdial) then run a standard ssh session over that link. – Dougie Jul 20 at 11:31
  • would that be done using the same uart adapter and usb? can you point me in the right direction to get started? – Alex028502 Jul 20 at 11:36
  • Your parallel to ssh here is incorrect; see my comment on Dmitri's answer. If you want to send a file while the serial port is configured as a console, then what you are really asking is parallel to "How can I send a file within an ssh login session?" because if the console is enabled, it cannot be turned off except by restarting the system (as far as I know). – goldilocks Jul 20 at 16:33
3

There's nothing wrong with your approach for individual text files. For a binary file (or a large number of files/directories which you'd pack together with tar/gzip), you can use base64 to encode them as text:

Receiver (Pi over picocom):

cat | base64 -di > file

Sender (another terminal on the PC):

cat file | base64 > /proc/`pidof picocom`/fd/0

Also note that if you want to try out X/Y/ZMODEM (which will be about 30% faster than gzip/base64), the client in Debian goes by the name lrzsz and can be installed with apt. Other apps with ZMODEM support are cutecom/minicom.

| improve this answer | |
  • 1
    You are right: it is better to use mainstream Debian package. I corrected it in my answer. – Ljm Dullaart Jul 20 at 9:36
  • I don't think this will work if the port is configured as a serial console, ie., a login. Using the port for just data this way is the equivalent of scp to ssh, because scp doesn't use a console interface. It uses the same network protocol to send file data that ssh uses to establish a console/terminal based login; the parallel would be UART. However, UART is more restricted in that it is as if you could configure sshd to allow logins or file transfer but not both. This is why there are those wacky modem protocols. – goldilocks Jul 20 at 16:30
  • @goldilocks You can still push text though a tty. Perhaps a simple cat | base64 -di > file on the Pi side will work. – Dmitry Grigoryev Jul 21 at 6:55
  • 1
    True. But you can't capture that as far as I know. It isn't the stdin of a process you run in that tty, so cat > file won't work. It's the stdin of the getty or shell process, I think, since if you send ANSI control codes through to a terminal the output will appear appropriately formatted. Unfortunately they probably don't have those for file transfer. – goldilocks Jul 21 at 13:42
  • @goldilocks You're right, I got it all mixed up. Hopefully my last edit is more to the point. – Dmitry Grigoryev Jul 21 at 14:18
1

Although old fashioned, Picocom supports filetransfer, x-modem, y-modem, z-modem and ascii-xfr. If I where you, i'd go for z-modem. The package you are looking for is lrzsz (and notzmodem as I stated earlier). Note that it operates a bit different from scp.

| improve this answer | |

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.