Copy binary文件到开发板

来源:互联网 发布:ubuntu查看系统存储 编辑:程序博客网 时间:2024/05/17 22:49

简介:

有多种方式可以把binary文件从开发机copy到开发板, 但各种方式都有自己的优缺点。

一. U盘

1. 在开发机上把binary文件copy到U盘, 然后把U盘插到开发板的USB-Host接口。
2. 串口线连接开发板和开发机。
3. minicom中使用cp /udisk/yourbinaryfile /bin(or any other places).

优点:
copy速度非常快。

缺点:
操作较为麻烦


二. tftp

1.安装
$ sudo apt-get install xinetd tftpd tftp

2. 配置
a. 在/etc/xinetd.d下建立一个tftp文件:
$ sudo vim tftp
输入如下内容:
service tftp{protocol        = udpport            = 69socket_type     = dgramwait            = yesuser            = nobodyserver          = /usr/sbin/in.tftpdserver_args     = /var/lib/tftpbootdisable         = no}
b. 创建/var/lib/tftpboot,并修改属性
$ sudo mkdir /var/lib/tftpboot
$ sudo chown -R nobody /var/lib/tftpboot
$ sudo chmod -R 777 /var/lib/tftpboot
c. 开启xinetd服务:
$sudo service xinetd stop
$sudo service xinetd start
d. 测试
在/var/lib/tftpboot下面建立一个文件a.txt (文件内容: Hello TFTP!),然后换一个目录比如~/Projects(换目录只是为了方便验证).
$ sudo tftp localhost
$tftp > get a.txt
如果出现:
> Received 13 bytes in 0.0 seconds
则表示配置成功。

3.使用。
a. 首先在sever端开启tftp服务:
$ sudo tftp localhost
b. 在client端, 也就是开发板端使用minicom:
$ tftp 192.168.1.100 -g -r a.txt
其中192.168.1.100是server端的ip, a.txt是需要传输的文件。运行该命令会产生如下让人误解的信息:
> tftp: server only supports blocksize of 512
但是事实上,文件已经传输成功。详见: http://lists.busybox.net/pipermail/busybox-cvs/2010-June/031335.html
Client端的tftp的使用帮助如下:
BusyBox v1.16.0 (2010-04-17 19:14:08 CST) multi-call binary.                    
                                                                                
Usage: tftp [OPTIONS] HOST [PORT]                                               
                                                                                
Transfer a file from/to tftp server                                             
                                                                                
Options:                                                                        
        -l FILE Local FILE                                                      
        -r FILE Remote FILE                                                     
        -g      Get file                                                        
        -p      Put file                                                        
        -b SIZE Transfer blocks of SIZE octets

优点:
方便, 传输速度快,现在是我的首选。

缺点:

需要安装tftp服务器,安装不那么方便。