1.开启usb host功能
【1】打开/include/configs/mini2440.h,定位到112行附近:加入下面代码:
/*
* Command line configuration.
*/
#include <config_cmd_default.h>
#define CONFIG_CMD_ASKENV
#define CONFIG_CMD_CACHE
#define CONFIG_CMD_DATE
#define CONFIG_CMD_ELF
#define CONFIG_CMD_NAND
#define CONFIG_CMD_JFFS2 /* JFFS2 Support*/
#define CONFIG_CMD_PING /*ping command support*/
#define CONFIG_CMD_USB
#define CONFIG_CMD_FAT
#define CONFIG_BOOTDELAY 3
其中相关宏定义的作用:
CONFIG_CMD_USB :使能USB相关命令的支持
CONFIG_CMD_FAT :使能FAT文件系统相关命令的支持
定位到194行附近加入下面代码:
/*
USB device support
*/
#define CONFIG_USB_DEVICE 1
#ifdef CONFIG_USB_DEVICE
#define CONFIG_USE_IRQ 1
#endif
#if 1
#define CONFIG_USB_OHCI
#define CONFIG_USB_STORAGE
#define CONFIG_DOS_PARTITION
#define CONFIG_SYS_DEVICE_DEREGISTER
#define CONFIG_SUPPORT_VFAT
#define LITTLEENDIAN
//#define CONFIG_USB_TTY
//#define CONFIG_USB_KEYBOARD
#endif
相关宏定义的作用:
CONFIG_USB_OHCI :使能USB_OHCI协议的支持
CONFIG_USB_STORAGE:使能USB存储设备的支持
CONFIG_DOS_PARTITION : 使能FAT文件系统分区的支持
CONFIG_SUPPORT_VFAT : 使能FAT32文件系统的支持
LITTLEENDIAN : 定义数据为小端模式
CONFIG_USB_TTY:使能USB终端(本次未使用)
CONFIG_USB_KEYBOARD是对USB键盘的支持(本次未使用)
【2】打开/cpu/arm920t/s3c24x0/usb_ohci.c,定位到43行附近,加入下面代码:
#ifdef CONFIG_USB_OHCI
#if defined(CONFIG_S3C2400)
#include <s3c2400.h>
#elif defined(CONFIG_S3C2410) || defined (CONFIG_S3C2440)
#include <s3c2410.h>
#endif
2. usb host 功能编译测试:
【1】先看下USB 操作指令
指令 功能
usb reset 初始化USB 控制器
usb stop [f] 关闭USB 控制器
usb tree 已连接的USB 设备树
usb info [dev] 显示USB 设备[dev]的信息
usb storage 显示已连接的USB 存储设备
usb dev [dev] 显示和设置当前USB 存储设备
usb part [dev] 显示USB 存储设备[dev]的分区信息
usb read addr blk# cnt 读取USB 存储设备数据
【2】准备一个fat32格式的U盘
【3】在编译完成后,nor 档下载nand 档启动,操作如下:
[u-boot@MINI2440]# usb help
USB is stopped. Please issue 'usb start' first.
[u-boot@MINI2440]# usb start
(Re)start USB...
USB: scanning bus for devices... cannot reset port 2!?
2 USB Device(s) found
scanning bus for storage devices... 1 Storage Device(s) found
[u-boot@MINI2440]# usb storage
Device 0: Vendor: USB 2.0 Rev: 5.00 Prod: Flash Drive
Type: Removable Hard Disk
Capacity: 1012.5 MB = 0.9 GB (2073600 x 512)
[u-boot@MINI2440]# usb part 0
print_part of 0
Partition Map for USB device 0 -- Partition Type: DOS
Partition Start Sector Num Sectors Type
1 32 2073568 b
[u-boot@MINI2440]# fatload usb 0:1 0x30008000 uImage_T35
reading uImage_T35
................................................................................
................................................................................
.....................................
2022412 bytes read
[u-boot@MINI2440]# bootm 0x30008000
## Booting kernel from Legacy Image at 30008000 ...
Image Name: mini2440_linux
Created: 2011-05-12 3:37:00 UTC
Image Type: ARM Linux Kernel Image (uncompressed)