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



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

    Buildroot直接配置

    Target packages  --->
    	Networking applications  ---> 
    		[*] lrzsz
    
    • 1
    • 2
    • 3

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

    下载源码

    官网: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
    
    • 1
    • 2
    • 3

    打印日志:

    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
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147

    编译安装

    编译安装命令:

    make -j16
    
    • 1

    编译完毕后进入/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 root@192.168.1.103:/bin
    root@192.168.1.103's password: 
    lrz                                           100%   70KB  70.4KB/s   00:00    
    liefyuan@ubuntu:~/Liefyuan/bingpi-v3s/lrzsz-0.12.20/src$ scp lsz root@192.168.1.103:/bin
    root@192.168.1.103's password: 
    lsz                                           100%   76KB  75.6KB/s   00:00    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14

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

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

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

    就可以了。

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

    开发板终端里面发送文件

    # lsz helloliefyuan.txt
    
    • 1

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

    # 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
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    然后就接收下来了。

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

  • 相关阅读:
    Swagger实现在生产环境中使用,在发布时不使用
    【zmq】ZeroMQ安装与入门案例
    C和指针 第12章 使用结构和指针 12.7 问题
    计算机自顶向下
    自动驾驶中的感知模型:实现安全与智能驾驶的关键
    JNI编程之java层和native层的数组数据的交互
    中学语文教学参考杂志社中学语文教学参考编辑部2022年第27期目录
    Shiro入门以及Shiro与web整合
    vs2017编译的64位libssh2库
    iNFTnews | 佳能推出“佳能传奇”计划以支持摄影NFT事业
  • 原文地址:https://blog.csdn.net/qq_28877125/article/details/127505798