Page 1 of 1

Transfer file over serial connection using Minicom

Posted: Tue Jul 15, 2014 7:12 am
by eone
Hi all
My environment are the following:
  1. PC running Centos/Linux and Minicom
  2. Headless and Keyboardless Raspberry Pi running Raspbian with no network TCP/IP connection
Objective:
How to transfer file using minicom from PC to Raspberry Pi

Failed Attempts:
I tried to transfer one image file using minicom's XMODEM from PC to Raspberry Pi by the following steps:
  • I loaded the minicom on PC as root
    Connect the PC to Rpi using serial connection
    Login to RPi as pi user from PC host
    On PC host terminal, I entered: ]# sz -X softball.jpeg
    The message returned was:
    Give your local XMODEM receive command now.

    Then I went to RPi terminal and pressed Ctlr+A, Z, R, XMODEM and I entered softball.jpeg in the text field of the dialog box
    Subsequently, minicom printed the following messages

    rx: ready to receive softball.jpeg
    Retry 0: Got 07 sector header
    Retry 1: Got 07 sector header
    .....
    .....
    Retry 7: Got 07 sector header
    Retry 8: Got 07 sector header
    Retry 9: Got 07 sector header
    Blocks received: -1
    rx: softball.jpeg removed.
    Transfer incomplete
    READY: press any key to continue...
Can anyone show me the way to use minicom's XMODEM to transfer file from PC to Rpi?

Thanks in advance for reading this post.

Re: Transfer file over serial connection using Minicom

Posted: Tue Jul 15, 2014 7:31 am
by joan
Can't help with that apart from saying perhaps a binary mode needs to be set at one or both ends. I'm not familiar with xmodem.

If it's a one off you could just do the transfer from the terminal on either end.

On the Pi

cat </dev/ttyAMA0 >file.jpg

On the PC

copy /b file.jpg com1:

When the transfer completes at the PC end wait a second and press ctrl c at the Pi end.

You will need to ensure compatible baud rates

stty -F /dev/ttyAMA0 9600 # Pi

Some sort of mode command at the PC .

Re: Transfer file over serial connection using Minicom

Posted: Tue Jul 15, 2014 9:31 am
by topguy
Maybe try commanline versions of zmodem with the package "lrzsz".

Re: Transfer file over serial connection using Minicom

Posted: Tue Jul 15, 2014 9:50 am
by eone
topguy wrote:Maybe try commanline versions of zmodem with the package "lrzsz".
Hi topguy

Is the lrzsz already pre-installed in RPi?

Re: Transfer file over serial connection using Minicom

Posted: Tue Jul 15, 2014 10:18 am
by topguy
I dont know.. but very good point since you said the Pi was offline... so bad advice.

EDIT:
But... on the other hand you can download the package here: http://archive.raspbian.org/raspbian/po ... _armhf.deb

Either put it on the SD card with your linux-box or put it on a memory stick.

Install it with:

Code: Select all

dpkg -i lrzsz_0.12.21-7_armhf.deb


I hope it hasn't any dependencies.

Re: Transfer file over serial connection using Minicom

Posted: Tue Jul 15, 2014 10:43 am
by klricks
Are you using a GPIO to RS232 adapter or USB to RS232?
If GPIO then have you reconfigured the serial port to work as a standard serial port?
Can you type characters from /to the RPi and PC without error?

You may need to use the -b switch for binary files, both on the send and receive.
http://web.cecs.pdx.edu/~rootd/catdoc/g ... tml#SEC238

What is the path where the file is saved? You may not have permissions set correctly?
Can you transfer a file from RPi to PC?
You can try HyperTermiala on PC if you have XP or below.

Re: Transfer file over serial connection using Minicom

Posted: Tue Jul 15, 2014 2:55 pm
by eone
topguy wrote:I dont know.. but very good point since you said the Pi was offline... so bad advice.

EDIT:
But... on the other hand you can download the package here: http://archive.raspbian.org/raspbian/po ... _armhf.deb

Either put it on the SD card with your linux-box or put it on a memory stick.

Install it with:

Code: Select all

dpkg -i lrzsz_0.12.21-7_armhf.deb


I hope it hasn't any dependencies.
I followed your suggestion and fortunately package lrzsz_0.12.21-7_armhf.deb does not have dependencies. So I attempted the following steps and it worked:
  1. I loaded the minicom on PC as root
  2. Connect the PC to RPi using USB-Serial connection
  3. Login to RPi as pi user from PC host's minicom
  4. Install lrzsz package in RPi
  5. Type

    Code: Select all

    ~$ rz
  6. RPi display:

    Code: Select all

    <some junk characters> Waiting to receive <some junk characters>
  7. In minicom, pressed Ctlr+A, Z, S, ZMODEM
  8. Choose softball.jpeg
Subsequently, minicom printed the following messages:

Code: Select all

Sending: softball.jpeg                                       |                      
�CCB0100|Bytes Sent:   7424   BPS:2755                                |                      
         |Sending:                                                     |                      
         |Ymodem sectors/kbytes sent:   0/ 0k                          |                      
         |Transfer complete
So I learned that to transfer file from PC to RPi over serial console using minicom's zmodem protocol, I need to have rz running on RPi.

Re: Transfer file over serial connection using Minicom

Posted: Wed Apr 27, 2016 5:29 am
by John356
I use this script for xmodem transfer as I can manually send or automate full process : Xmodem using minicom