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

来源:互联网 发布:淘宝店铺售假扣26分 编辑:程序博客网 时间:2024/05/22 10:45

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


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


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


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


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


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

shawn@shawn-ThinkPad-T410:~$ uname -aLinux 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 ttycrw--w---- 1 root tty       4,  0 2012-02-19 13:03 tty0crw------- 1 root root      4,  1 2012-02-19 13:03 tty1crw--w---- 1 root tty       4, 10 2012-02-19 13:03 tty10crw--w---- 1 root tty       4, 11 2012-02-19 13:03 tty11crw--w---- 1 root tty       4, 12 2012-02-19 13:03 tty12crw--w---- 1 root tty       4, 13 2012-02-19 13:03 tty13crw--w---- 1 root tty       4, 14 2012-02-19 13:03 tty14crw--w---- 1 root tty       4, 15 2012-02-19 13:03 tty15crw--w---- 1 root tty       4, 16 2012-02-19 13:03 tty16crw--w---- 1 root tty       4, 17 2012-02-19 13:03 tty17crw--w---- 1 root tty       4, 18 2012-02-19 13:03 tty18crw--w---- 1 root tty       4, 19 2012-02-19 13:03 tty19crw------- 1 root root      4,  2 2012-02-19 13:03 tty2crw--w---- 1 root tty       4, 20 2012-02-19 13:03 tty20crw--w---- 1 root tty       4, 21 2012-02-19 13:03 tty21crw--w---- 1 root tty       4, 22 2012-02-19 13:03 tty22crw--w---- 1 root tty       4, 23 2012-02-19 13:03 tty23crw--w---- 1 root tty       4, 24 2012-02-19 13:03 tty24crw--w---- 1 root tty       4, 25 2012-02-19 13:03 tty25crw--w---- 1 root tty       4, 26 2012-02-19 13:03 tty26crw--w---- 1 root tty       4, 27 2012-02-19 13:03 tty27crw--w---- 1 root tty       4, 28 2012-02-19 13:03 tty28crw--w---- 1 root tty       4, 29 2012-02-19 13:03 tty29crw------- 1 root root      4,  3 2012-02-19 13:03 tty3crw--w---- 1 root tty       4, 30 2012-02-19 13:03 tty30crw--w---- 1 root tty       4, 31 2012-02-19 13:03 tty31crw--w---- 1 root tty       4, 32 2012-02-19 13:03 tty32crw--w---- 1 root tty       4, 33 2012-02-19 13:03 tty33crw--w---- 1 root tty       4, 34 2012-02-19 13:03 tty34crw--w---- 1 root tty       4, 35 2012-02-19 13:03 tty35crw--w---- 1 root tty       4, 36 2012-02-19 13:03 tty36crw--w---- 1 root tty       4, 37 2012-02-19 13:03 tty37crw--w---- 1 root tty       4, 38 2012-02-19 13:03 tty38crw--w---- 1 root tty       4, 39 2012-02-19 13:03 tty39crw------- 1 root root      4,  4 2012-02-19 13:03 tty4crw--w---- 1 root tty       4, 40 2012-02-19 13:03 tty40crw--w---- 1 root tty       4, 41 2012-02-19 13:03 tty41crw--w---- 1 root tty       4, 42 2012-02-19 13:03 tty42crw--w---- 1 root tty       4, 43 2012-02-19 13:03 tty43crw--w---- 1 root tty       4, 44 2012-02-19 13:03 tty44crw--w---- 1 root tty       4, 45 2012-02-19 13:03 tty45crw--w---- 1 root tty       4, 46 2012-02-19 13:03 tty46crw--w---- 1 root tty       4, 47 2012-02-19 13:03 tty47crw--w---- 1 root tty       4, 48 2012-02-19 13:03 tty48crw--w---- 1 root tty       4, 49 2012-02-19 13:03 tty49crw------- 1 root root      4,  5 2012-02-19 13:03 tty5crw--w---- 1 root tty       4, 50 2012-02-19 13:03 tty50crw--w---- 1 root tty       4, 51 2012-02-19 13:03 tty51crw--w---- 1 root tty       4, 52 2012-02-19 13:03 tty52crw--w---- 1 root tty       4, 53 2012-02-19 13:03 tty53crw--w---- 1 root tty       4, 54 2012-02-19 13:03 tty54crw--w---- 1 root tty       4, 55 2012-02-19 13:03 tty55crw--w---- 1 root tty       4, 56 2012-02-19 13:03 tty56crw--w---- 1 root tty       4, 57 2012-02-19 13:03 tty57crw--w---- 1 root tty       4, 58 2012-02-19 13:03 tty58crw--w---- 1 root tty       4, 59 2012-02-19 13:03 tty59crw------- 1 root root      4,  6 2012-02-19 13:03 tty6crw--w---- 1 root tty       4, 60 2012-02-19 13:03 tty60crw--w---- 1 root tty       4, 61 2012-02-19 13:03 tty61crw--w---- 1 root tty       4, 62 2012-02-19 13:03 tty62crw--w---- 1 root tty       4, 63 2012-02-19 13:03 tty63crw--w---- 1 root tty       4,  7 2012-02-19 13:03 tty7crw--w---- 1 root tty       4,  8 2012-02-19 22:00 tty8crw--w---- 1 root tty       4,  9 2012-02-19 13:03 tty9crw------- 1 root root      5,  3 2012-02-19 13:03 ttyprintkcrw-rw---- 1 root dialout   4, 64 2012-02-19 13:03 ttyS0crw-rw---- 1 root dialout   4, 65 2012-02-19 13:03 ttyS1crw-rw---- 1 root dialout   4, 74 2012-02-19 13:03 ttyS10crw-rw---- 1 root dialout   4, 75 2012-02-19 13:03 ttyS11crw-rw---- 1 root dialout   4, 76 2012-02-19 13:03 ttyS12crw-rw---- 1 root dialout   4, 77 2012-02-19 13:03 ttyS13crw-rw---- 1 root dialout   4, 78 2012-02-19 13:03 ttyS14crw-rw---- 1 root dialout   4, 79 2012-02-19 13:03 ttyS15crw-rw---- 1 root dialout   4, 80 2012-02-19 13:03 ttyS16crw-rw---- 1 root dialout   4, 81 2012-02-19 13:03 ttyS17crw-rw---- 1 root dialout   4, 82 2012-02-19 13:03 ttyS18crw-rw---- 1 root dialout   4, 83 2012-02-19 13:03 ttyS19crw-rw---- 1 root dialout   4, 66 2012-02-19 13:03 ttyS2crw-rw---- 1 root dialout   4, 84 2012-02-19 13:03 ttyS20crw-rw---- 1 root dialout   4, 85 2012-02-19 13:03 ttyS21crw-rw---- 1 root dialout   4, 86 2012-02-19 13:03 ttyS22crw-rw---- 1 root dialout   4, 87 2012-02-19 13:03 ttyS23crw-rw---- 1 root dialout   4, 88 2012-02-19 13:03 ttyS24crw-rw---- 1 root dialout   4, 89 2012-02-19 13:03 ttyS25crw-rw---- 1 root dialout   4, 90 2012-02-19 13:03 ttyS26crw-rw---- 1 root dialout   4, 91 2012-02-19 13:03 ttyS27crw-rw---- 1 root dialout   4, 92 2012-02-19 13:03 ttyS28crw-rw---- 1 root dialout   4, 93 2012-02-19 13:03 ttyS29crw-rw---- 1 root dialout   4, 67 2012-02-19 13:03 ttyS3crw-rw---- 1 root dialout   4, 94 2012-02-19 13:03 ttyS30crw-rw---- 1 root dialout   4, 95 2012-02-19 13:03 ttyS31crw-rw---- 1 root dialout   4, 68 2012-02-19 13:03 ttyS4crw-rw---- 1 root dialout   4, 69 2012-02-19 13:03 ttyS5crw-rw---- 1 root dialout   4, 70 2012-02-19 13:03 ttyS6crw-rw---- 1 root dialout   4, 71 2012-02-19 13:03 ttyS7crw-rw---- 1 root dialout   4, 72 2012-02-19 13:03 ttyS8crw-rw---- 1 root dialout   4, 73 2012-02-19 13:03 ttyS9crw-rw---- 1 root dialout 188,  0 2012-02-19 23:50 ttyUSB0shawn@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$ lsboot_usb.c  lsusb.txt  Makefile  READMEshawn@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 -vUsing built-in specs.COLLECT_GCC=gccCOLLECT_LTO_WRAPPER=/usr/lib/gcc/i686-linux-gnu/4.6.1/lto-wrapperTarget: i686-linux-gnuConfigured 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-gnuThread model: posixgcc 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$ makecc -o s3c2410_boot_usb boot_usb.o -lusbshawn@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 = 0x5b9dsend_file: addr = 0x33f80000, len = 0x002003e4Error downloading programshawn@shawn-ThinkPad-T410:~/Downloads/s3c2410_boot_usb$ 
令人觉得奇怪的是,虽然上面提示了Error,但是,MInicom 却显示下载完毕,并“Uncompressing Linux . . "成功,"booting the kernel."了。






原创粉丝点击