使用minicom传输文件

时间:2021-03-14 19:45:06

安装配置minicom并实现通过minicom传输文件

参考文献:嵌入式linux系统与主机通过串口传输文件ubuntu 下minicom的安装及使用操作系统:ubuntu10.04交叉编译器:arm-linux-gcc-4.1.1一、安装配置minicom1、安装minicomlingd@ubuntu:~$ sudo apt-get install minicom2、配置minicomlingd@ubuntu:~$ sudo minicom -s      出现这样的配置界面:            +-----[configuration]------+            | Filenames and paths      |            | File transfer protocols  |            | Serial port setup        |            | Modem and dialing        |            | Screen and keyboard      |            | Save setup as dfl        |            | Save setup as..          |            | Exit                     |            | Exit from Minicom        |            +--------------------------+     选择Serial port setup, 会看到这样的选项:    +-----------------------------------------------------------------------+    | A -    Serial Device      : /dev/ttyS0                                |    | B - Lockfile Location     : /var/lock                                 |    | C -   Callin Program      :                                           |    | D -  Callout Program      :                                           |    | E -    Bps/Par/Bits       : 115200 8N1                                |    | F - Hardware Flow Control : No                                        |    | G - Software Flow Control : No                                        |    |                                                                       |    |    Change which setting?                                              |    +-----------------------------------------------------------------------+输入前面对应的字母即可进入相应的选项。将选项A的值设置为/dev/ttyS0 表示是串口1,将选项E的值设置为115200,将选项F设置为NO(请根据实际情况配置).     设置默认上传/下载的目录,选择Filenames and paths , 会看到这样的选项:    +-----------------------------------------------------------------------+    | A - Download directory : /home/lingd/arm/download                     |    | B - Upload directory   : /home/lingd/arm/upload                       |    | C - Script directory   :                                              |    | D - Script program     : runscript                                    |    | E - Kermit program     :                                              |    | F - Logging options                                                   |    |                                                                       |    |    Change which setting?                                              |    +-----------------------------------------------------------------------+注意:开发板发送给pc的文件将保存在Download directory所设定的目录中,而pc要下载到开发板的文件保存在Upload directory所设定的目录中     设置完成后,选择”Save setup as dfl”,保存为默认设置.然后选择“Exit”,即可进入Minicom的主界面:Welcome to minicom 2.4
OPTIONS: I18n Compiled on Jan 25 2010, 06:49:09.Port /dev/ttyS0
Press CTRL-A Z for help on special keys                                                                   按Ctrl-A,再按z,可以获取到minicom CTRL-A命令的帮助信息Welco+-------------------------------------------------------------------+     |                     Minicom Command Summary                       |OPTIO|                                                                   |Compi|          Commands can be called by CTRL-A <key>                   |Port |                                                                   |     |               Main Functions                  Other Functions     |Press|                                                                   |     | Dialing directory..D  run script (Go)....G | Clear Screen.......C |     | Send files.........S  Receive files......R | cOnfigure Minicom..O |     | comm Parameters....P  Add linefeed.......A | Suspend minicom....J |     | Capture on/off.....L  Hangup.............H | eXit and reset.....X |     | send break.........F  initialize Modem...M | Quit with no reset.Q |     | Terminal settings..T  run Kermit.........K | Cursor key mode....I |     | lineWrap on/off....W  local Echo on/off..E | Help screen........Z |     | Paste file.........Y                       | scroll Back........B |     |                                                                   |     |      Select function or press Enter for none.                     |     |                                                                   |     |             Written by Miquel van Smoorenburg 1991-1995           |     |             Some additions by Jukka Lahtinen 1997-2000            |     |             i18n by Arnaldo Carvalho de Melo 1998                 |     +-------------------------------------------------------------------+ CTRL-A Z for help |115200 8N1 | NOR | Minicom 2.4    | VT102 |      Offline   其中,我们用CTRL-A s来发送文件给开发板;而用CTRL-A r来接收开发板上的文件二、为pc安装lrzszlrzsz is a unix communication package providing the XMODEM, YMODEM ZMODEM file transfer protocols.lingd@ubuntu:~$ sudo apt-get install lrzsz三、交叉编译lrzsz并下载到开发板上1、下载lrzsz源码包到http://download.chinaunix.net/download/0007000/6293.shtml,下一个lrzsz的tar包,2、解压缩后,到解压目录中执行./configurelingd@ubuntu:~/arm$ tar -zxf lrzsz-0.12.20.tar.gz lingd@ubuntu:~/arm$ cd lrzsz-0.12.20/lingd@ubuntu:~/arm/lrzsz-0.12.20$ ./configure creating cache ./config.cachechecking for a BSD compatible install... /usr/bin/install -cchecking whether build environment is sane... yeschecking whether make sets ${MAKE}... yeschecking for working aclocal... missingchecking for working autoconf... missingchecking for working automake... missingchecking for working autoheader... missingchecking for working makeinfo... missingchecking for gcc... gccchecking whether the C compiler (gcc  ) works... yeschecking whether the C compiler (gcc  ) is a cross-compiler... nochecking whether we are using GNU C... yeschecking whether gcc accepts -g... yeschecking how to run the C preprocessor... gcc -Echecking whether gcc needs -traditional... nochecking for ranlib... ranlibchecking for POSIXized ISC... nochecking for AIX... nochecking for minix/config.h... nochecking for gcc option to accept ANSI C... none neededchecking for function prototypes... yeschecking for working const... yeschecking for inline... inlinechecking for syslog in -lsocket... nochecking for syslog in -lbe... nochecking for gethostbyname in -lnsl... yeschecking for ANSI C header files... yeschecking for fcntl.h... yeschecking for limits.h... yeschecking for sys/ioctl.h... yeschecking for sys/time.h... yeschecking for unistd.h... yeschecking for sys/times.h... yeschecking for termios.h... yeschecking for sys/termios.h... yeschecking for termio.h... yeschecking for sys/termio.h... nochecking for sgtty.h... yeschecking for termios.h... (cached) yeschecking for sys/termios.h... (cached) yeschecking for termio.h... (cached) yeschecking for sys/termio.h... (cached) nochecking for sgtty.h... (cached) yeschecking for sys/mman.h... yeschecking for utime.h... yeschecking for syslog.h... yeschecking for sys/syslog.h... yeschecking for sys/param.h... yeschecking for sys/select.h... yeschecking for strings.h... yeschecking for arpa/inet.h... yeschecking for size_t... yeschecking for mode_t... yeschecking for off_t... yeschecking for speed_t... yeschecking for st_rdev in struct stat... yeschecking whether time.h and sys/time.h may both be included... yeschecking whether sys/time.h and sys/select.h may both be included... yeschecking whether struct tm is in sys/time.h or time.h... time.hchecking for errno declaration... yeschecking whether setvbuf arguments are reversed... nochecking return type of signal handlers... voidchecking for unistd.h... (cached) yeschecking for getpagesize... yeschecking for working mmap... yeschecking for working alloca.h... yeschecking for alloca... yeschecking for gettimeofday... yeschecking for settimeofday... yeschecking for strchr... yeschecking for memcpy... yeschecking for select... yeschecking for vprintf... yeschecking for times... yeschecking for rdchk... nochecking for utime... yeschecking for syslog... yeschecking for siginterrupt... yeschecking for mkdir... yeschecking for mktime... yeschecking for strerror... yeschecking for strstr... yeschecking for strdup... yeschecking for strtoul... yeschecking for strtol... yeschecking for strpbrk... yeschecking for stpcpy... yeschecking for strftime... yeschecking for vasprintf... yeschecking for getopt_long... yeschecking for ftime... yeschecking that ftime works correctly... yeschecking for timezone variable... yeschecking for LOG_UUCP... yeschecking for argz.h... yeschecking for limits.h... (cached) yeschecking for locale.h... yeschecking for nl_types.h... yeschecking for malloc.h... yeschecking for string.h... yeschecking for unistd.h... (cached) yeschecking for values.h... yeschecking for sys/param.h... (cached) yeschecking for getcwd... yeschecking for munmap... yeschecking for putenv... yeschecking for setenv... yeschecking for setlocale... yeschecking for strchr... (cached) yeschecking for strcasecmp... yeschecking for __argz_count... yeschecking for __argz_stringify... yeschecking for __argz_next... yeschecking for LC_MESSAGES... yeschecking whether NLS is requested... yeschecking whether included gettext is requested... nochecking for libintl.h... yeschecking for gettext in libc... yeschecking for msgfmt... /usr/bin/msgfmtchecking for dcgettext... yeschecking for gmsgfmt... /usr/bin/msgfmtchecking for xgettext... /usr/bin/xgettextchecking for catalogs to be installed...  deupdating cache ./config.cachecreating ./config.statuscreating Makefilecreating intl/Makefilecreating lib/Makefilecreating testsuite/Makefilecreating man/Makefilecreating po/Makefile.increating src/Makefilecreating debian/rulescreating Specfilecreating systypecreating src/lrzszbugcreating config.h3、修改Makefile有三个Makefile需要修改,分别是~/arm/lrzsz-0.12.20/Makefile、~/arm/lrzsz-0.12.20/lib/Makefile、~/arm/lrzsz-0.12.20/src/Makefilelingd@ubuntu:~/arm/lrzsz-0.12.20$ vi Makefilelingd@ubuntu:~/arm/lrzsz-0.12.20$ vi lib/Makefilelingd@ubuntu:~/arm/lrzsz-0.12.20$ vi src/Makefile将这三个Makefile中的所有gcc替代成你开发板所需要的交叉编译器,如arm-linux-gcc即:CC = gccCPP = gcc -E都改成CC = arm-linux-gccCPP = arm-linux-gcc -E4、编译lingd@ubuntu:~/arm/lrzsz-0.12.20$ make在lrzsz-0.12.20/src目录下会生成两个可执行文件lsz、lrz(或者sz、rz),把它们下载到开发板linux系统的/bin目录下。lingd@ubuntu:~/arm/lrzsz-0.12.20$ cd srclingd@ubuntu:~/arm/lrzsz-0.12.20/src$ lsansi2knr.1  lrz          lsyslog.o    Makefile.in  tcp.o      zm.oansi2knr.c  lrz.c        lsz          protname.c   timing.c   zmodem.hcanit.c     lrz.o        lsz.c        protname.o   timing.h   zperr.ccanit.o     lrzszbug     lsz.o        rbsb.c       timing.o   zperr.ocrctab.c    lrzszbug.in  Makefile     rbsb.o       zglobal.h  zreadline.ccrctab.o    lsyslog.c    Makefile.am  tcp.c        zm.c       zreadline.o四、测试1、开发板-->PC机在开发板上输入 lsz filename,然后会出现一个传输界面,传输完成后可以在你设置的默认下载目录Download directory里找到这个文件。2、PC机-->开发板在开发板上先进入/tmp 目录,然后输入lrz。# cd /tmp# lrz                                                                         �z waiting to receive.**B0100000023be50按Ctrl-A,再按s,选择zmoden,会出现一个选择文件的界面,选择你要传输的文件(按一下空格键选择目录,按两下空格键进入目录),回车后出现一个传输界面,传输完成后,便可以在开发板的/tmp目录下找到这个文件了。