现在的位置: 首页 > 综合 > 正文

在Ubuntu下,建立下载image文件到Mini2440或者TQ2440开发板的环境

2013年08月10日 ⁄ 综合 ⁄ 共 8606字 ⁄ 字号 评论关闭

如果需要转载本文,就注明本文出处,谢谢。


众所周知,在做这类嵌入式开发,尤其是我们自己在玩开发板的时候,一般,都需要建立起一个下载的环境。


通常,串口工具软件会使用标准的COMx端口与目标开发板进行通信,控制与显示,而下载image文件到目标开发板,通常用并口或者USB口。


很遗憾的是,随着电子技术,通信技术的发展,并口,串口这类接口正在退出舞台,逐渐成为历史。


今天,我们就针对于笔记本或者台式机上没有COM口和并口的计算机,介绍一个可用的方法,建立起下载image文件到目标开发板的一个通道。


下面所介绍的内容,都是基于Linux OS的,我使用的是Ubuntu。信息如下。

shawn@shawn-ThinkPad-T410:~$ uname -a
Linux shawn-ThinkPad-T410 3.0.0-16-generic-pae #28-Ubuntu SMP Fri Jan 27 19:24:01 UTC 2012 i686 i686 i386 GNU/Linux


首先,我们说下串口通道。

这里会用到一个USB转RS232的转换接口,从计算机出来是USB信号,经过该转换接口之后,转换为RS232信号到达目标开发板的9-pin COM口。

shawn@shawn-ThinkPad-T410:/dev$ ls -al tty*
crw-rw-rw- 1 root tty       5,  0 2012-02-19 23:42 tty
crw--w---- 1 root tty       4,  0 2012-02-19 13:03 tty0
crw------- 1 root root      4,  1 2012-02-19 13:03 tty1
crw--w---- 1 root tty       4, 10 2012-02-19 13:03 tty10
crw--w---- 1 root tty       4, 11 2012-02-19 13:03 tty11
crw--w---- 1 root tty       4, 12 2012-02-19 13:03 tty12
crw--w---- 1 root tty       4, 13 2012-02-19 13:03 tty13
crw--w---- 1 root tty       4, 14 2012-02-19 13:03 tty14
crw--w---- 1 root tty       4, 15 2012-02-19 13:03 tty15
crw--w---- 1 root tty       4, 16 2012-02-19 13:03 tty16
crw--w---- 1 root tty       4, 17 2012-02-19 13:03 tty17
crw--w---- 1 root tty       4, 18 2012-02-19 13:03 tty18
crw--w---- 1 root tty       4, 19 2012-02-19 13:03 tty19
crw------- 1 root root      4,  2 2012-02-19 13:03 tty2
crw--w---- 1 root tty       4, 20 2012-02-19 13:03 tty20
crw--w---- 1 root tty       4, 21 2012-02-19 13:03 tty21
crw--w---- 1 root tty       4, 22 2012-02-19 13:03 tty22
crw--w---- 1 root tty       4, 23 2012-02-19 13:03 tty23
crw--w---- 1 root tty       4, 24 2012-02-19 13:03 tty24
crw--w---- 1 root tty       4, 25 2012-02-19 13:03 tty25
crw--w---- 1 root tty       4, 26 2012-02-19 13:03 tty26
crw--w---- 1 root tty       4, 27 2012-02-19 13:03 tty27
crw--w---- 1 root tty       4, 28 2012-02-19 13:03 tty28
crw--w---- 1 root tty       4, 29 2012-02-19 13:03 tty29
crw------- 1 root root      4,  3 2012-02-19 13:03 tty3
crw--w---- 1 root tty       4, 30 2012-02-19 13:03 tty30
crw--w---- 1 root tty       4, 31 2012-02-19 13:03 tty31
crw--w---- 1 root tty       4, 32 2012-02-19 13:03 tty32
crw--w---- 1 root tty       4, 33 2012-02-19 13:03 tty33
crw--w---- 1 root tty       4, 34 2012-02-19 13:03 tty34
crw--w---- 1 root tty       4, 35 2012-02-19 13:03 tty35
crw--w---- 1 root tty       4, 36 2012-02-19 13:03 tty36
crw--w---- 1 root tty       4, 37 2012-02-19 13:03 tty37
crw--w---- 1 root tty       4, 38 2012-02-19 13:03 tty38
crw--w---- 1 root tty       4, 39 2012-02-19 13:03 tty39
crw------- 1 root root      4,  4 2012-02-19 13:03 tty4
crw--w---- 1 root tty       4, 40 2012-02-19 13:03 tty40
crw--w---- 1 root tty       4, 41 2012-02-19 13:03 tty41
crw--w---- 1 root tty       4, 42 2012-02-19 13:03 tty42
crw--w---- 1 root tty       4, 43 2012-02-19 13:03 tty43
crw--w---- 1 root tty       4, 44 2012-02-19 13:03 tty44
crw--w---- 1 root tty       4, 45 2012-02-19 13:03 tty45
crw--w---- 1 root tty       4, 46 2012-02-19 13:03 tty46
crw--w---- 1 root tty       4, 47 2012-02-19 13:03 tty47
crw--w---- 1 root tty       4, 48 2012-02-19 13:03 tty48
crw--w---- 1 root tty       4, 49 2012-02-19 13:03 tty49
crw------- 1 root root      4,  5 2012-02-19 13:03 tty5
crw--w---- 1 root tty       4, 50 2012-02-19 13:03 tty50
crw--w---- 1 root tty       4, 51 2012-02-19 13:03 tty51
crw--w---- 1 root tty       4, 52 2012-02-19 13:03 tty52
crw--w---- 1 root tty       4, 53 2012-02-19 13:03 tty53
crw--w---- 1 root tty       4, 54 2012-02-19 13:03 tty54
crw--w---- 1 root tty       4, 55 2012-02-19 13:03 tty55
crw--w---- 1 root tty       4, 56 2012-02-19 13:03 tty56
crw--w---- 1 root tty       4, 57 2012-02-19 13:03 tty57
crw--w---- 1 root tty       4, 58 2012-02-19 13:03 tty58
crw--w---- 1 root tty       4, 59 2012-02-19 13:03 tty59
crw------- 1 root root      4,  6 2012-02-19 13:03 tty6
crw--w---- 1 root tty       4, 60 2012-02-19 13:03 tty60
crw--w---- 1 root tty       4, 61 2012-02-19 13:03 tty61
crw--w---- 1 root tty       4, 62 2012-02-19 13:03 tty62
crw--w---- 1 root tty       4, 63 2012-02-19 13:03 tty63
crw--w---- 1 root tty       4,  7 2012-02-19 13:03 tty7
crw--w---- 1 root tty       4,  8 2012-02-19 22:00 tty8
crw--w---- 1 root tty       4,  9 2012-02-19 13:03 tty9
crw------- 1 root root      5,  3 2012-02-19 13:03 ttyprintk
crw-rw---- 1 root dialout   4, 64 2012-02-19 13:03 ttyS0
crw-rw---- 1 root dialout   4, 65 2012-02-19 13:03 ttyS1
crw-rw---- 1 root dialout   4, 74 2012-02-19 13:03 ttyS10
crw-rw---- 1 root dialout   4, 75 2012-02-19 13:03 ttyS11
crw-rw---- 1 root dialout   4, 76 2012-02-19 13:03 ttyS12
crw-rw---- 1 root dialout   4, 77 2012-02-19 13:03 ttyS13
crw-rw---- 1 root dialout   4, 78 2012-02-19 13:03 ttyS14
crw-rw---- 1 root dialout   4, 79 2012-02-19 13:03 ttyS15
crw-rw---- 1 root dialout   4, 80 2012-02-19 13:03 ttyS16
crw-rw---- 1 root dialout   4, 81 2012-02-19 13:03 ttyS17
crw-rw---- 1 root dialout   4, 82 2012-02-19 13:03 ttyS18
crw-rw---- 1 root dialout   4, 83 2012-02-19 13:03 ttyS19
crw-rw---- 1 root dialout   4, 66 2012-02-19 13:03 ttyS2
crw-rw---- 1 root dialout   4, 84 2012-02-19 13:03 ttyS20
crw-rw---- 1 root dialout   4, 85 2012-02-19 13:03 ttyS21
crw-rw---- 1 root dialout   4, 86 2012-02-19 13:03 ttyS22
crw-rw---- 1 root dialout   4, 87 2012-02-19 13:03 ttyS23
crw-rw---- 1 root dialout   4, 88 2012-02-19 13:03 ttyS24
crw-rw---- 1 root dialout   4, 89 2012-02-19 13:03 ttyS25
crw-rw---- 1 root dialout   4, 90 2012-02-19 13:03 ttyS26
crw-rw---- 1 root dialout   4, 91 2012-02-19 13:03 ttyS27
crw-rw---- 1 root dialout   4, 92 2012-02-19 13:03 ttyS28
crw-rw---- 1 root dialout   4, 93 2012-02-19 13:03 ttyS29
crw-rw---- 1 root dialout   4, 67 2012-02-19 13:03 ttyS3
crw-rw---- 1 root dialout   4, 94 2012-02-19 13:03 ttyS30
crw-rw---- 1 root dialout   4, 95 2012-02-19 13:03 ttyS31
crw-rw---- 1 root dialout   4, 68 2012-02-19 13:03 ttyS4
crw-rw---- 1 root dialout   4, 69 2012-02-19 13:03 ttyS5
crw-rw---- 1 root dialout   4, 70 2012-02-19 13:03 ttyS6
crw-rw---- 1 root dialout   4, 71 2012-02-19 13:03 ttyS7
crw-rw---- 1 root dialout   4, 72 2012-02-19 13:03 ttyS8
crw-rw---- 1 root dialout   4, 73 2012-02-19 13:03 ttyS9
crw-rw---- 1 root dialout 188,  0 2012-02-19 23:50 ttyUSB0
shawn@shawn-ThinkPad-T410:/dev$ 

 

上面,黑色字体一行,即是我的USB转串口的设备

下面配置minicom,串口通信工具

shawn@shawn-ThinkPad-T410:~$ 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/ttyUSB0                              |
    | 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?                                              |
    +-----------------------------------------------------------------------+
            | Screen and keyboard      |
            | Save setup as dfl        |
            | Save setup as..          |
            | Exit                     |
            | Exit from Minicom        |
            +--------------------------+

设置好之后,输入回车,退回到如下界面。

注意,上面的设置中,默认值通常是开启硬件流控的,也就是Hardware flow control。请取消该选项,也就是设置成NO。

serial device 要选择正确,可以通过点击A,进行serial deviece的配置。配置好之后,点击Enter回车退出serial setup 建立界面。


                                                                             
            +-----[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        |
            +--------------------------+


选择Save setup as dfl,保存为默认配置,或者 Save setup as .. 另存为


经过配置,配置发生了变化,为了让配置生效,我们选择Exit from Minicom,退出Minicom。


之后,输入MInicom就会以默认配置启动了。

shawn@shawn-ThinkPad-T410:~$ minicom

 

上面配置好了串口,这时,如果给板子上电的话,

U-boot的菜单就会显示在Minicom的界面上了。


之后,让我们来看看,如何使用另一个USB口将image文件上载到目标开发板上。

这里会用到一个工具,名为 s3c2410_boot_usb,其sources的下载地址是

http://code.google.com/p/mini2440/downloads/detail?name=s3c2410_boot_usb-20060807.tar.bz2&can=2&q

下载保存到你希望的路径下。解压,有4个文件,如下面的黑色字体描述

shawn@shawn-ThinkPad-T410:~/Downloads$ tar xjf s3c2410_boot_usb-20060807.tar.bz2 
shawn@shawn-ThinkPad-T410:~/Downloads/s3c2410_boot_usb$ ls
boot_usb.c  lsusb.txt  Makefile  README
shawn@shawn-ThinkPad-T410:~/Downloads/s3c2410_boot_usb$ 


但是,不要着急,在利用该sources构建s3c2410_boot_usb这么一个通过USB口upload文件到目标开发板的工具之前,

需要做2件事,

1.  确认安装libusb-dev,这个package里应该包含了一些操作USB接口的APIs。

shawn@shawn-ThinkPad-T410:~/Downloads/s3c2410_boot_usb$ sudo apt-get install libusb-dev

 

2. 如果你的Ubuntu安装的GCC版本是4.6,或者以上的,

shawn@shawn-ThinkPad-T410:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6.1/lto-wrapper
Target: i686-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.1-9ubuntu3' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i686 --with-tune=generic --enable-checking=release --build=i686-linux-gnu --host=i686-linux-gnu --target=i686-linux-gnu
Thread model: posix
gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3) 
shawn@shawn-ThinkPad-T410:~$ 
那么,需要修改 s3c2410_boot_usb 目录中的Makefile中的2行

 

s3c2410_boot_usb: boot_usb.o
	$(CC) $(LDFLAGS) -o $@ $<


修改为

s3c2410_boot_usb: boot_usb.o
	$(CC) -o $@ $< $(LDFLAGS)

做完上面的2件事,之后就可以在 s3c2410_boot_usb 目录下输入make 命令,构建s3c2410_boot_usb工具了

shawn@shawn-ThinkPad-T410:~/Downloads/s3c2410_boot_usb$ make
cc -o s3c2410_boot_usb boot_usb.o -lusb
shawn@shawn-ThinkPad-T410:~/Downloads/s3c2410_boot_usb$ 


构建成功, 可以将该工具放在path的路径下,这样,就不需要在 s3c2410_boot_usb 目录下使用该命令了。

该工具的使用命令是,第一个是上载工具,第二个参数是要上载到目标开发板的zImage镜像文件,注意两个参数间的空格

shawn@shawn-ThinkPad-T410:~/Downloads/s3c2410_boot_usb$ sudo ./s3c2410_boot_usb ~/test/build-linux-2.6.33/arch/arm/boot/zImage 
csum = 0x5b9d
send_file: addr = 0x33f80000, len = 0x002003e4
Error downloading program
shawn@shawn-ThinkPad-T410:~/Downloads/s3c2410_boot_usb$ 

令人觉得奇怪的是,虽然上面提示了Error,但是,MInicom 却显示下载完毕,并“Uncompressing Linux . . "成功,"booting the kernel."了。





抱歉!评论已关闭.