U-Boot使用loadb下载程序(附测试代码) --基于Linux下Kermit工具

 

U-Boot使用loadb下载程序

                                                          --基于LinuxKermit工具

                                                                                                                                      初步移植好U-Boot,还没有研究网络、USB等高级功能,想试试通过串口下载程序的功能。经过一番倒腾之后,终于实现,现将笔记整理如下。

实验环境:Linux ubuntu 9.10(来自韦东山老师光盘自带虚拟机)

开发板:  Jz2440ARM9     S3C2440

                                   NAND     K9F2G08

                                   SDRAM   K4S561632 * 2

U-Boot    u-boot-1.1.6

烧写工具:   OpenJtag

串口工具:kermit


一、Linux下串口工具kermit安装使用

    由于光盘自带的ubuntu中已经安装好串口工具kermit,在此就不安装了。可以在Linux控制台运行命令kermit,如果输出

C-Kermit>

kermit已经安装。

       Kermit安装使用方法,请查看附件参考资料。


二、实验步骤

1.准备工作

    A.启动虚拟机中的Linux系统 Ubuntu 9.10


    B.开发板Jz2440上电


    C.插上OpenJtag

    使用OpenJtag时,确定已经在Linux环境下安装了OpenJtag驱动。

    为确保Linux能比WindowXP先识别OpenJtag,请全屏Ubuntu虚拟机,然后在命令行输入

         ls /dev/

    出现的设备中除了ttytty0tty1外应该能看到设备ttyUSB0或者ttyUSB1

    否则就是OpenJtag没有识别,请拔下重新插入,或者检查OpenJtag驱动是否安装。


   D.OpenJtag线插入Jz2440开发板Jtag插槽


   E.使用串口线连接OpenJtagJz2440开发板


    至此,准备工作完成。


2.烧写U-Boot

   使用OpenJtag烧写u-boot.binJz2440开发板。操作过程(红色为输入):

root@book-desktop:/home/book/workspace/U-Boot/Jz_u-boot-1.1.6# oflash

+---------------------------------------------------------+

|Flash Programmer v1.3 for OpenJTAG ofwww.100ask.net|

|OpenJTAG is a USB to JTAG & RS232 tool based FT2232|

|This programmer supports both of S3C2410X & S3C2440|

|Author: Email/MSN([email protected]), QQ(17653039)|

+---------------------------------------------------------+

Usage:

1. oflash, run with cfg.txt or prompt

2. oflash [file], write [file] to flash with prompt

3. oflash [-f config_file]

4. oflash [jtag_type] [cpu_type] [flash_type] [read_or_write] [offset] [file]

Can't open cfg.txt, you should follow the prompt

Select the JTAG type:

0. OpenJTAG

1. Dongle JTAG(parallel port)

Enter the number: 0

Select the CPU:

1. S3C2410X

2. S3C2440X

Enter the number:2

'ft2232' interface using libftdi with 'USB<=>JTAG&RS232' layout (1457:5118)

current latency timer: 2

FTDI chip type: 2 "2232C"

S3C24X0 detected, cpuID = 0x0032409d

[Main Menu]


0:Nand Flash prog
1:Nor Flash prog
2:Memory Rd/Wr
3:Exit

Select the function to test:0

Enter the file name:u-boot.bin

[NAND Flash JTAG Programmer]

Scan nand flash:

Device 0: NAND 256MiB 3,3V 8-bit, sector size 128 KiB

Total size: 256 MiB


0:Nand Flash Program
1:Nand Flash Print BlkPage
2:Exit

Select the function to test :0

[NAND Flash Writing Program]

Source size: 0x17df4

Available target block number: 0~2047

Input target block number:0

target start block number
=0

target size
(0x20000*1) =0x20000

STATUS:

Epppppppppppppppppppppppppppppppppppppppppppppppp

 
3.设置Linux串口工具kermit
在Linux命令行输入kermit,然后按照以下过程输入kermit命令,初始化kermit(红色字体为输入)。

root@book-desktop:/home/book# kermit
C-Kermit 8.0.211, 10 Apr 2004, for Linux
Copyright (C) 1985, 2004,
  Trustees of Columbia University in the City of New York.
Type ? or HELP for help.
(/home/book/) C-Kermit>set line /dev/ttyUSB0 (或者set line /dev/ttyUSB1
(/home/book/) C-Kermit>set speed 115200
/dev/ttyUSB0, 115200 bps
(/home/book/) C-Kermit>set carrier-watch off
(/home/book/) C-Kermit>set handshake none
(/home/book/) C-Kermit>set flow-control none
(/home/book/) C-Kermit>robust
(/home/book/) C-Kermit>set file type bin
(/home/book/) C-Kermit>set file name lit
(/home/book/) C-Kermit>set rec pack 1000
(/home/book/) C-Kermit> set send pack 1000
(/home/book/) C-Kermit> set window 5
(/home/book/) C-Kermit> connect
Connecting to /dev/ttyUSB0, speed 115200
Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
----------------------------------------------------
JZ2440 #

看到有U-Boot提示符“JZ2440 #”出现,说明通过串口工具kermit已经设置OK。

在u-boot界面按下ctrl + \ ,再按c键,就会切换到kermit界面

JZ2440 #                                                       (u-boot界面)
(Back at book-desktop)
----------------------------------------------------
(/home/book/) C-Kermit>                                (kermit界面)


在kermit界面输入c(就是connect的意思),即可切换到u-boot界面
----------------------------------------------------
(/home/book/) C-Kermit>c                                (kermit界面)
Connecting to /dev/ttyUSB0, speed 115200
Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
----------------------------------------------------
JZ2440 #                                                         (u-boot界面)


4.下载程序
由于程序是下载到SDRAM(U-Boot已经初始化了SDRAM)中运行,所以程序的连接地址是0x30000000,这点要特别注意!
附件中leds_0x30000000.rar就是已经修改好的led闪灯程序,其连接地址是0x30000000。
在u-boot界面,输入loadb 0x30000000,就是将程序下载到内存的0x30000000地址。
JZ2440 # loadb 0x30000000
## Ready for binary (kermit) download to 0x30000000 at 115200 bps...

u-boot正在等待程序下载
按ctrl + \ 然后按 c,切换到kermit界面。发送已经编译好的leds.bin(连接地址为0x30000000,特别注意!!!)(红色字体为输入)。
(/home/book/) C-Kermit>send /home/book/leds.bin
下载完毕,输入c切换到u-boot界面
(/home/book/) C-Kermit>c                                       (在kermit界面输入c)
Connecting to /dev/ttyUSB0, speed 115200
Escape character: Ctrl-\ (ASCII 28, FS): enabled
Type the escape character followed by C to get back,
or followed by ? to see other options.
----------------------------------------------------
## Total Size      = 0x000000a8 = 168 Bytes
## Start Addr      = 0x30000000

JZ2440 #                                                                        (切换到了u-boot界面)

绿色字体显示数据已经下载完毕,下载到了0x30000000地址。
使用u-boot  go命令,执行leds程序
JZ2440 # go 0x30000000                                                (u-boot界面)
## Starting application at 0x30000000 ...
此时,Jz2440开发板上的led已经开始闪烁了,使用kermit下载程序OK!

三 、技巧
使用kermit时,每次启动连接都要输入set xxx …命令,很繁琐,直接将命令输入到~/.kermrc里面保存,以后使用kermit命令就直接可以使用了。

root@book-desktop:/home/book# vi ~/.kermrc
set line /dev/ttyUSB0
set speed 115200
set carrier-watch off
set handshake none
set flow-control none
robust
set file type bin
set file name lit
set rec pack 1000
set send pack 1000
set window 5
c


四、为什么不用minicom?
minicom也是Linux下一个很好用的串口工具,为什么u-boot不使用minicom传输文件?u-boot官网说明的很清楚了:
minicom is another popular serial communication program. Unfortunately, many users have reported problems using it with U-Boot and Linux, especially when trying to use it for serial image download. It's use is therefore discouraged.

http://www.denx.de/wiki/view/DUL ... ad#Section_5.9.5.3.

五、附件
移植好的Jz2440简单u-boot
Jz2440_u-boot_bin.rar ( 47.44 K, 下载次数:1)

测试用的连接地址为0x30000000的leds闪灯程序
leds_0x30000000.rar ( 7.11 K, 下载次数:1)

参考资料:
1.《C-Kermit安装和使用及下载内核方法》
http://wenku.baidu.com/view/34378323bcd126fff7050bbc.html

 

声明:本文为个人原创,边移植边写,完全来自实践。本文首先发表在百问网(www.100ask.net)转载请指明出处。

原文地址: http://www.100ask.net/forum/showtopic-3627.aspx

 

免费视频下载地址:

1期共33个视频,免费,下载后可以直接观看,下载地址:
http://115.com/folder/fa55184z#
http://dl.dbank.com/c03o1ebwlo
第一期视频从Linux安装开始,讲解了SDRAMNAND FLASHLCD等硬件操作,U-Boot的移植、内核移植、简单字符驱动的编写,非常详尽。

第二期视频主要是驱动深入讲解,精华啊!

第二期视频需要收费的哦,具体见韦东山老师淘宝店铺:

http://100ask.taobao.com/

 

书籍资料下载:

《嵌入式Linux应用开发完全手册》及相关资源电炉可以下载:

http://www.verycd.com/topics/2828590/

       嵌入式linux应用开发完全手册光盘里的驱动和例子源代码.rar 详情

嵌入式linux应用开发完全手册.pdf 详情

 

如果能买一块韦东山老师的开发板,加上视频讲解,加上书,那学起来就太Easy了!

淘宝店铺上http://100ask.taobao.com/ 全套都有了!!!

 

 

你可能感兴趣的:(u-boot,Linux,移植)