嵌入式 网口以及串口操作小结
来源:互联网 发布:明略数据校园招聘 编辑:程序博客网 时间:2024/04/28 05:04
loadb - load binary file over serial line (kermit mode)
loadx - load binary file over serial line (xmodem mode)
loady - load binary file over serial line (ymodem mode)
格式基本都为:
load [ off ] [ baud ]
第1个参数是下载到SDRAM的地址,如果不填,就是用默认配置:CONFIG_SYS_LOAD_ADDR
第2个参数是波特率,一般不填,用默认的115200.
[u-boot@apple_guet]# loadb
## Ready for binary (kermit) download to 0x30008000 at 115200 bps...
[u-boot@apple_guet]# loadb
## Ready for binary (kermit) download to 0x30008000 at 115200 bps...
(Back at MAGI-Linux)
----------------------------------------------------
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/tekkaman/桌面/) C-Kermit>send /home/tekkaman/development/share/zImage.img
C-kermit就开始传送,并且显示一个传送界面,并动态显示传送进度。
C-Kermit 8.0.211, 10 Apr 2004, MAGI-Linux
Current Directory: /home/tekkaman/��~L�~]�
Communication Device: /dev/ttyUSB0
Communication Speed: 115200
Parity: none
RTT/Timeout: 01 / 02
SENDING: /home/tekkaman/development/share/zImage.img => zImage.img
File Type: BINARY
File Size: 2277540
Percent Done: 19 /////////-
...10...20...30...40...50...60...70...80...90..100
Estimated Time Left: 00:03:35
Transfer Rate, CPS: 8536
Window Slots: 1 of 1
Packet Type: D
Packet Count: 557
Packet Length: 1000
Error Count: 0
Last Error:
Last Message:
X to cancel file, Z to cancel group, <CR> to resend last packet,
E to send Error packet, ^C to quit immediately, ^L to refresh screen.
传送完毕后,输入c ,回到U-boot的串口界面。
[u-boot@apple_guet]# loadb
## Ready for binary (kermit) download to 0x30008000 at 115200 bps...
(Back at MAGI-Linux)
----------------------------------------------------
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/apple_guet/桌面/) C-Kermit>send /opt/gsc3280/zImage.img
(/home/apple_guet/桌面/) 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 = 0x0022c0a4 = 2277540 Bytes
## Start Addr = 0x30008000
二、网络命令
只要你的网卡驱动没问题,那么你就可以通过网络来传输文件到开发板,这可比串口快多了。你可以直接用交叉网线连接开发板和电脑,也可以用普通直连网线连接路由器,再连到电脑,不过记得配置好网络,关闭防火墙。
先测试网络是否通了,现在开发板使用ping 命令,看看是否可以ping通电脑:
[u-boot@apple_guet]# ping 192.168.1.122
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
host 192.168.1.122 is alive
如果出现:
[u-boot@apple_guet]# ping 192.168.1.122
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
ping failed; host 192.168.1.122 is not alive
这样无法ping通的事,可能是:
1、U-boot网卡驱动有问题
2、U-boot网络协议延时配置有问题
3、网络参数配置问题,比如IP等,Host和Target都有可能有问题。Host最好关闭IPv6。
实在找不到原因,用Wireshark抓包看看。
如果网络畅通,下面就可以使用下面的命令从tftp目录或者nfs目录下载文件到SDRAM了。
命令:
dhcp - boot image via network using DHCP/TFTP protocol
rarpboot- boot image via network using RARP/TFTP protocol
nfs - boot image via network using NFS protocol
tftpboot- boot image via network using TFTP protocol
bootp - boot image via network using BOOTP/TFTP protocol
这几个命令的格式都是:<指令> [目的SDRAM地址] [[主机IP:]文件名]
注意:
要使用dhcp、rarpboot或 bootp 等功能要路由器或Host的支持。
如果没有输入[目的SDRAM地址],系统就是用编译时定义的CONFIG_SYS_LOAD_ADDR作为目的SDRAM地址
如果tftpboot和nfs命令没有定义[主机IP:],则使用ENV中的serverip
其它命令必需定义[主机IP:],否则会使用提供动态IP服务的主机IP作为[主机IP:]。
使用范例:
[u-boot@apple_guet]# nfs 0x30008000 192.168.1.100:/opt/gsc3280/u-boot.bin
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
File transfer via NFS from server 192.168.1.100; our IP address is 192.168.1.101
Filename '/opt/gsc3280/u-boot.bin'.
Load address: 0x30008000
Loading: ###################################################
done
Bytes transferred = 256220 (3e8dc hex)
[u-boot@apple_guet]# tftp u-boot.bin
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.122; our IP address is 192.168.1.101
Filename 'u-boot.bin'.
Load address: 0x30008000
Loading: T ##################
done
Bytes transferred = 256220 (3e8dc hex)
[u-boot@apple_guet]# dhcp 192.168.1.122:u-boot.bin
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.1.101
Using dm9000 device
TFTP from server 192.168.1.100; our IP address is 192.168.1.101
Filename 'u-boot.bin'.
Load address: 0x30008000
Loading: ##################
done
Bytes transferred = 256220 (3e8dc hex)
[u-boot@apple_guet]# bootp 192.168.1.122:u-boot.bin
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
BOOTP broadcast 1
BOOTP broadcast 2
DHCP client bound to address 192.168.1.101
Using dm9000 device
TFTP from server 192.168.1.100; our IP address is 192.168.1.101
Filename 'u-boot.bin'.
Load address: 0x30008000
Loading: ##################
done
Bytes transferred = 256220 (3e8dc hex)
[u-boot@apple_guet]# rarpboot 192.168.1.100:u-boot.bin
我的路由器没有开rarp协议,所以rarpboot 无法使用,要使用dhcp或 bootp 也是要路由或Host支持的。
3、Nand Flash操作指令
常用的Nand Flash指令如下:
指令
功能
nand info
显示可使用的Nand Flash
nand device [dev]
显示或设定当前使用的Nand Flash
nand read addr off size
Nand Flash读取命令,从Nand的 off 偏移地址处读取size 字节的数据到SDRAM的 addr地址。
nand write addr off size
Nand Flash烧写命令,将SDRAM的 addr地址处的size 字节的数据烧写到Nand的 off 偏移地址。
nand write[.yaffs[1]] addr off size
烧写yaffs 映像专用的命令,.yaffs1 for 512+16 NAND
nand erase [clean] [off size]
Nand Flash檫除命令,擦除Nand Flash的 off 偏移地址处的size 字节的数据
nand bad
显示Nand Flash的坏块
nand dump[.oob] off
显示Nand Flash中的数据(16进制)
nand scrub
彻底擦除整块Nand Flash中的数据,包括OOB。可以擦除软件坏块标志。
nand markbad off
标示 Nand的 off 偏移地址处的块为坏块
使用范例:
[u-boot@apple_guet]# nand info
Device 0: NAND 128MiB 3,3V 8-bit, sector size 128 KiB
[u-boot@apple_guet]# nand device 0
Device 0: NAND 128MiB 3,3V 8-bit... is now current device
[u-boot@apple_guet]# nand read 0x30008000 0x60000 200000
NAND read: device 0 offset 0x60000, size 0x200000
2097152 bytes read: OK
[u-boot@apple_guet]# nand bad
Device 0 bad blocks:
030a0000
030c0000
030e0000
07ee0000
[u-boot@apple_guet]# nand markbad 0x500000
block 0x00500000 successfully marked as bad
[u-boot@apple_guet]# nand bad
Device 0 bad blocks:
00500000
030a0000
030c0000
030e0000
07ee0000
[u-boot@apple_guet]# nand scrub
NAND scrub: device 0 whole chip
Warning: scrub option will erase all factory set bad
There is no reliable way to recover them.
Use this command only for testing purposes if you
are sure of what you are
Really scrub this NAND flash? <y/N>
Erasing at 0x2f4000008000000 -- 0% complete.
NAND 128MiB 3,3V 8-bit: MTD Erase failure: -5
NAND 128MiB 3,3V 8-bit: MTD Erase failure: -5
NAND 128MiB 3,3V 8-bit: MTD Erase failure: -5
Erasing at 0x7ea000008000000 -- 0% complete.
NAND 128MiB 3,3V 8-bit: MTD Erase failure: -5
Erasing at 0x7fe000008000000 -- 0% complete.
OK
[u-boot@apple_guet]# nand bad
Device 0 bad blocks:
030a0000
030c0000
030e0000
07ee0000
[u-boot@MINI2440]# nand dump 0x8000
Page 00008000 dump:
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
(略)
OOB:
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
[u-boot@MINI2440]# tftp u-boot.bin
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.100; our IP address is 192.168.1.101
Filename 'u-boot.bin'.
Load address: 0x30008000
Loading: T ##################
done
Bytes transferred = 256220 (3e8dc hex)
[u-boot@apple_guet]# nand write 0x30008000 0 40000
NAND write: device 0 offset 0x0, size 0x40000
Writing at 0x2000000020000 -- 100% is complete. 262144 bytes written: OK
[u-boot@apple_guet]# nand dump 0x8000
Page 00008000 dump:
00 00 53 e1 01 00 00 2a 15 40 e0 e3 19 00 00 ea
(略)
60 30 97 e5 03 00 54 e1 f6 ff ff ba 00 40 a0 e3
OOB:
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
ff ff ff ff ff ff ff ff
65 a9 6b f3 ff 33 fc 30
f3 33 cf 33 0f f0 ff 00
cc 0f 59 55 57 96 a5 5b
nboot 指令也是一条Nand Flash 读取指令,它是将Nand Flash 的 offset 偏移地址的内核映像读取到SDRAM的loadAddr位置。它会自动读取到内核映像(使用mkimage处理过的)的结束,所以不用给出读取大小。
格式:nboot loadAddr dev offset
使用范例:
[u-boot@apple_guet]# tftp 192.168.1.122:zImage.img
dm9000 i/o: 0x20000300, id: 0x90000a46
DM9000: running in 16 bit mode
MAC: 08:08:11:18:12:27
operating at 100M full duplex mode
Using dm9000 device
TFTP from server 192.168.1.122; our IP address is 192.168.1.212
Filename 'zImage.img'.
Load address: 0x30008000
Loading: T #################################################################
#################################################################
##########################
done
Bytes transferred = 2277540 (22c0a4 hex)
[u-boot@apple_guet]# nand erase 0x100000 300000
NAND erase: device 0 offset 0x100000, size 0x300000
Erasing at 0x3e000001800000 -- 0% complete.
OK
[u-boot@apple_guet]# nand write 0x30008000 0x100000 300000
NAND write: device 0 offset 0x100000, size 0x300000
Writing at 0x3e000000020000 -- 100% is complete. 3145728 bytes written: OK
[u-boot@MINI2440]# nand device 0
Device 0: NAND 128MiB 3,3V 8-bit... is now current device
[u-boot@MINI2440]# nboot 30008000 0 0x100000
Loading from NAND 128MiB 3,3V 8-bit, offset 0x100000
Image Name: tekkaman
Created: 2010-03-29 12:59:51 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2277476 Bytes = 2.2 MB
Load Address: 30008000
Entry Point: 30008040
[u-boot@apple_guet]# bootm 30008000
## Booting kernel from Legacy Image at 30008000 ...
Image Name: tekkaman
Created: 2010-03-29 12:59:51 UTC
Image Type: ARM Linux Kernel Image (uncompressed)
Data Size: 2277476 Bytes = 2.2 MB
Load Address: 30008000
Entry Point: 30008040
Verifying Checksum ... OK
XIP Kernel Image ... OK
OK
Starting kernel ...
Uncompressing Linux... done, booting the kernel.
Linux version 2.6.33.1 (tekkaman@MAGI-Linux) (gcc version 4.3.2 (crosstool-NG-1.6.1-tekkaman) ) #5 Mon Mar 29 20:58:50 CST 2010
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=c0007177
CPU: VIVT data cache, VIVT instruction cache
Machine: MINI2440
- 嵌入式 网口以及串口操作小结
- 嵌入式串口操作
- 嵌入式Linux串口操作接口
- C++串口操作以及串口模拟测试
- 嵌入式 uboot裁剪方向以及思路小结
- 嵌入式 sqlite3中事务操作小结
- 嵌入式串口
- 串口小结
- 串口操作包括 java上位机 嵌入式c下位机
- 串口操作包括 java上位机 嵌入式c下位机
- 嵌入式 修改u-boot与Linux调试串口以及文件系统显示终端串口
- 嵌入式 iptables参数说明以及使用示例小结
- 嵌入式线程函数中如何对CEdit控件操作小结
- linux操作串口的代码,linux串口通信以及串口初始化代码,linux串口读写方法和代码
- 串口、USB口和网口在嵌入式系统开…
- MFC下对串口的操作以及定时器的调用
- 嵌入式 获取网卡设备以及IP和MAC地址示例以及网络编程之ioctl小结
- 嵌入式linux串口编程
- WCF小问题
- for循环和递归算法的运行效率比较(c语言)
- Python的安装与Python第三方模块的安装(在没有ROOT权限的情况下)
- HTML小结
- 11
- 嵌入式 网口以及串口操作小结
- Morris Traversal 遍历二叉树
- 用json获取服务器端的数据
- 嵌入式 uboot的nand flash常用命令
- OCP 1Z0 052 123
- 自由职业,我的半年总结
- linux 文件链接
- IOS7 隐藏状态栏 (电池栏 )
- 6.Swift教程翻译系列——Swift集合类型