嵌入式Linux:串口传输文件的工具lrzsz软件的移植


 在网络没有通的时候,串口才是YYDS!喏,这个就是咯。

Buildroot直接配置

Target packages  --->
	Networking applications  ---> 
		[*] lrzsz

在这里插入图片描述
选上就好了!

下载源码

官网:https://ohse.de/uwe/software/lrzsz.html
在这里插入图片描述

解压配置

解压出来后,进入解压出来的目录,然后配置一下:

$ tar -zxvf lrzsz-0.12.20.tar.gz 
$ cd lrzsz-0.12.20/
$ CC=arm-linux-gnueabihf-gcc CFLAGS=-O2 ./configure

打印日志:

liefyuan@ubuntu:~/Liefyuan/bingpi-v3s$ tar -zxvf lrzsz-0.12.20.tar.gz 
lrzsz-0.12.20/
lrzsz-0.12.20/Makefile.in
lrzsz-0.12.20/README
lrzsz-0.12.20/ABOUT-NLS
lrzsz-0.12.20/AUTHORS
...
liefyuan@ubuntu:~/Liefyuan/bingpi-v3s$ cd lrzsz-0.12.20/
liefyuan@ubuntu:~/Liefyuan/bingpi-v3s/lrzsz-0.12.20$ CC=arm-linux-gnueabihf-gcc CFLAGS=-O2 ./configure
creating cache ./config.cache
checking for a BSD compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... yes
checking for working aclocal... found
checking for working autoconf... found
checking for working automake... found
checking for working autoheader... found
checking for working makeinfo... missing
checking for gcc... arm-linux-gnueabihf-gcc
checking whether the C compiler (arm-linux-gnueabihf-gcc -O2 ) works... yes
checking whether the C compiler (arm-linux-gnueabihf-gcc -O2 ) is a cross-compiler... yes
checking whether we are using GNU C... yes
checking whether arm-linux-gnueabihf-gcc accepts -g... yes
checking how to run the C preprocessor... arm-linux-gnueabihf-gcc -E
checking whether arm-linux-gnueabihf-gcc needs -traditional... no
checking for ranlib... ranlib
checking for POSIXized ISC... no
checking for AIX... no
checking for minix/config.h... no
checking for arm-linux-gnueabihf-gcc option to accept ANSI C... none needed
checking for function prototypes... yes
checking for working const... yes
checking for inline... inline
checking for syslog in -lsocket... no
checking for syslog in -lbe... no
checking for gethostbyname in -lnsl... yes
checking for ANSI C header files... yes
checking for fcntl.h... yes
checking for limits.h... yes
checking for sys/ioctl.h... yes
checking for sys/time.h... yes
checking for unistd.h... yes
checking for sys/times.h... yes
checking for termios.h... yes
checking for sys/termios.h... yes
checking for termio.h... yes
checking for sys/termio.h... no
checking for sgtty.h... yes
checking for termios.h... (cached) yes
checking for sys/termios.h... (cached) yes
checking for termio.h... (cached) yes
checking for sys/termio.h... (cached) no
checking for sgtty.h... (cached) yes
checking for sys/mman.h... yes
checking for utime.h... yes
checking for syslog.h... yes
checking for sys/syslog.h... yes
checking for sys/param.h... yes
checking for sys/select.h... yes
checking for strings.h... yes
checking for arpa/inet.h... yes
checking for size_t... yes
checking for mode_t... yes
checking for off_t... yes
checking for speed_t... yes
checking for st_rdev in struct stat... yes
checking whether time.h and sys/time.h may both be included... yes
checking whether sys/time.h and sys/select.h may both be included... yes
checking whether struct tm is in sys/time.h or time.h... time.h
checking for errno declaration... yes
checking return type of signal handlers... void
checking for unistd.h... (cached) yes
checking for getpagesize... yes
checking for working mmap... no
checking for working alloca.h... yes
checking for alloca... yes
checking for gettimeofday... yes
checking for settimeofday... yes
checking for strchr... yes
checking for memcpy... yes
checking for select... yes
checking for vprintf... yes
checking for times... yes
checking for rdchk... no
checking for utime... yes
checking for syslog... yes
checking for siginterrupt... yes
checking for mkdir... yes
checking for mktime... yes
checking for strerror... yes
checking for strstr... yes
checking for strdup... yes
checking for strtoul... yes
checking for strtol... yes
checking for strpbrk... yes
checking for stpcpy... yes
checking for strftime... yes
checking for vasprintf... yes
checking for getopt_long... yes
checking for ftime... yes
checking that ftime works correctly... will check at run time
checking for timezone variable... yes
checking for LOG_UUCP... yes
checking for argz.h... yes
checking for limits.h... (cached) yes
checking for locale.h... yes
checking for nl_types.h... yes
checking for malloc.h... yes
checking for string.h... yes
checking for unistd.h... (cached) yes
checking for values.h... yes
checking for sys/param.h... (cached) yes
checking for getcwd... yes
checking for munmap... yes
checking for putenv... yes
checking for setenv... yes
checking for setlocale... yes
checking for strchr... (cached) yes
checking for strcasecmp... yes
checking for __argz_count... yes
checking for __argz_stringify... yes
checking for __argz_next... yes
checking for LC_MESSAGES... yes
checking whether NLS is requested... yes
checking whether included gettext is requested... no
checking for libintl.h... yes
checking for gettext in libc... yes
checking for msgfmt... /usr/bin/msgfmt
checking for dcgettext... yes
checking for gmsgfmt... /usr/bin/msgfmt
checking for xgettext... /usr/bin/xgettext
checking for catalogs to be installed...  de
updating cache ./config.cache
creating ./config.status
creating Makefile
creating intl/Makefile
creating lib/Makefile
creating testsuite/Makefile
creating man/Makefile
creating po/Makefile.in
creating src/Makefile
creating debian/rules
creating Specfile
creating systype
creating src/lrzszbug
creating config.h

编译安装

编译安装命令:

make -j16

编译完毕后进入/src目录,里面就有两个重要文件:lrz lsz
在这里插入图片描述

拷贝文件到开发板

 将生成的 lrz 和 lsz 复制到开发板的 /bin 目录(或者你自己的目录,但是那就需要设置系统环境变量 echo $PATH可以查看环境变量,查看设置效果)

liefyuan@ubuntu:~/Liefyuan/bingpi-v3s/lrzsz-0.12.20/src$ ls
ansi2knr.1  lrz          lsyslog.o    Makefile.in  tcp.o      zm.o
ansi2knr.c  lrz.c        lsz          protname.c   timing.c   zmodem.h
canit.c     lrz.o        lsz.c        protname.o   timing.h   zperr.c
canit.o     lrzszbug     lsz.o        rbsb.c       timing.o   zperr.o
crctab.c    lrzszbug.in  Makefile     rbsb.o       zglobal.h  zreadline.c
crctab.o    lsyslog.c    Makefile.am  tcp.c        zm.c       zreadline.o
liefyuan@ubuntu:~/Liefyuan/bingpi-v3s/lrzsz-0.12.20/src$ scp lrz [email protected]:/bin
[email protected]'s password: 
lrz                                           100%   70KB  70.4KB/s   00:00    
liefyuan@ubuntu:~/Liefyuan/bingpi-v3s/lrzsz-0.12.20/src$ scp lsz [email protected]:/bin
[email protected]'s password: 
lsz                                           100%   76KB  75.6KB/s   00:00    

开发板上的/bin目录:
在这里插入图片描述
传输文件和接收文件都是在MobaXterm软件上进行的!

使用lrz从PC传输文件到开发板

  • 第一步:MobaXterm命令行输入lrz,这时命令行有乱码也就是开发板正在等待接收的意思。
  • 第二步:鼠标在MobaXterm的黑框框内点右键,选择下图的选项:
    在这里插入图片描述- 第三步:这时就是在电脑上选择要发送的文件
    在这里插入图片描述在这里插入图片描述
# lrz
▒Sending: hehehehheh.txt*B0100000023be50
▒*B0900000000a87c
Bytes Sent:      9   BPS:55
▒*B0800000000022d
Transfer complete

就可以了。

使用lsz从开发板传输文件到PC

开发板终端里面发送文件

# lsz helloliefyuan.txt

会出现乱码,这时,需要控制鼠标在终端点右键
在这里插入图片描述
在这里插入图片描述

# lsz helloliefyuan.txt
▒lrz waiting to receive.*CD@@@@▒Q▒3helloliefyuan.txt@16 4577 100644 0 1 16@k▒I▒▒

Receiving: helloliefyuan.txt
Downloading: 100% kBytes received:      0/     0   kBPS:0
▒OO# 00000000022d
Transfer complete

然后就接收下来了。

注意,如果要发送的文件已经存在会有问题的!

猜你喜欢

转载自blog.csdn.net/qq_28877125/article/details/127505798