eone
Posts: 10
Joined: Thu Jul 11, 2013 3:49 am

Transfer file over serial connection using Minicom

Tue Jul 15, 2014 7:12 am

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.

User avatar
joan
Posts: 15086
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Transfer file over serial connection using Minicom

Tue Jul 15, 2014 7:31 am

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 .

User avatar
topguy
Posts: 6774
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Transfer file over serial connection using Minicom

Tue Jul 15, 2014 9:31 am

Maybe try commanline versions of zmodem with the package "lrzsz".

eone
Posts: 10
Joined: Thu Jul 11, 2013 3:49 am

Re: Transfer file over serial connection using Minicom

Tue Jul 15, 2014 9:50 am

topguy wrote:Maybe try commanline versions of zmodem with the package "lrzsz".
Hi topguy

Is the lrzsz already pre-installed in RPi?

User avatar
topguy
Posts: 6774
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Transfer file over serial connection using Minicom

Tue Jul 15, 2014 10:18 am

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.

klricks
Posts: 7288
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Transfer file over serial connection using Minicom

Tue Jul 15, 2014 10:43 am

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.
Unless specified otherwise my response is based on the latest and fully updated RPiOS Buster w/ Desktop OS.

eone
Posts: 10
Joined: Thu Jul 11, 2013 3:49 am

Re: Transfer file over serial connection using Minicom

Tue Jul 15, 2014 2:55 pm

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.

John356
Posts: 1
Joined: Wed Apr 27, 2016 5:11 am

Re: Transfer file over serial connection using Minicom

Wed Apr 27, 2016 5:29 am

I use this script for xmodem transfer as I can manually send or automate full process : Xmodem using minicom

Return to “Beginners”