Android集成lrzsz

本文详细介绍了为何要在Android系统上移植lrzsz,以及如何进行交叉编译和集成,使得在Hikey开发板上能通过串口进行文件的发送与接收。lrzsz支持xmodem、ymodem和zmodem协议,解决了Android系统中缺乏串口文件传输的问题。文章还提供了Windows和Linux环境下使用lrzsz的步骤,并指出由于UART传输速率限制,该方法适合小文件传输。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

为啥要移植lrzsz

本文中的lrzsz代码点击此处获取
Hikey开发板有两类USB口,两组USB-TypeA母口作为Host,可以接键盘、鼠标。另一组mini-USB母口,作为devices,可以接到电脑上调试。但目前这两种接口无法同时使用,即通过键盘鼠标操作时不能使用ADB。
虽然可以通过minicom或者putty之类的工具连接串口查看LOG、执行命令。但Android系统中缺少通过串口传输文件的工具,有文件传输需求的时候还需要插上ADB口,通过adb push/pull操作,不是太方便。

通过busybox的rx命令虽然可以接收文件,但无法将系统中的文件传输到主机上。而且rx只支持xmodem协议。一些新的工具如Xshell只能支持Zmodem协议。
lrzsz能够同时支持xmodem、ymodem以及zmodem协议,具备发送接收功能,能满足我们的需要。

交叉编译lrzsz

交叉编译分为以下几步:

  1. 准备交叉编译链。

这里面使用的是arm-linux-gnueabihf-4.9。可以到Linaro的主页下载。将下载到的文件解压缩到/opt/目录,设置好环境变量。

[david@opt]$ cd arm-linux-gnueabihf-4.9/bin/
[david@bin]$ export PATH=`pwd`:$PATH
[david@bin]$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Linaro GCC 4.9-2015.01-3) 4.9.3 20150113 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

2下载lrzsz源码
官方主页下载lrzsz软件包 lrzsz-0.12.20.tar.gz 。解压缩。

[david@Code]$ tar -zxvf lrzsz-0.12.20.tar.gz

3./configure:

[david@lrzsz-0.12.20]$ ./configure --host=arm-linux
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... gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking how to run the C preprocessor... gcc -E
checking whether 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 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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值