u-boot-2010.03在LT2440上的移植详解 (七)
郑重声明,这系列文章改写自博客园 黄刚先生的《嵌入式Linux之我行——u-boot-2009.08在2440上的移植详解》
转载时请注明出处
文章出处:http://www.lt-net.cn
编译系统 | Ubuntu10.04 |
交叉编译器 | arm-linux-gcc 4.3.3 |
硬件设备 | LT2440开发板 |
测试软件 | u-boot-2010.03 |
依赖库 | 无 |
本次移植在u-boot-2010.03原有功能的基础上增加如下特性:
1.支持2KB page Nand Flash读写
2.支持Nand/Nor Flash启动自动识别
3.支持DM9000AEP 10M/100M自适应网卡
4.支持yaffs文件系统烧写
5.支持USB下载功能
6.支持一键式菜单
7.支持启动Logo
8.支持ubifs(待续)
上接:u-boot-2010.03在LT2440上的移植详解 (六)
USB 驱动的移植比较麻烦,它涉及到S3C2440的中断,还有 S3C2440 USB device的驱动
首先我们增加USB device的驱动,驱动有19个文件,
请到下面的链接下载
http://blogimg.chinaunix.net/blog/upfile2/101209120345.bz2
解压之后会有一个device目录,请将这个目录放到 drivers/usb目录下
修改根目录下Makefile ,加入USB device 驱动的编译支持
#gedit Makefile //根目录下Makefile |
LIBS += drivers/usb/phy/libusb_phy.a LIBS += drivers/usb/device/libusb_device.a //大约244行 LIBS += drivers/video/libvideo.a LIBS += drivers/watchdog/libwatchdog.a |
- #ifndef __DEF_H__
- #define __DEF_H__
- #ifndef U32
- #define U32 unsigned int
- #endif
- #ifndef U16
- #define U16 unsigned short
- #endif
- #ifndef S32
- #define S32 int
- #endif
- #ifndef S16
- #define S16 short int
- #endif
- #ifndef U8
- #define U8 unsigned char
- #endif
- #ifndef S8
- #define S8 char
- #endif
- typedef unsigned char BOOL;
- typedef unsigned char UCHAR;
- typedef UCHAR *PUCHAR;
- typedef unsigned long DWORD;
- typedef DWORD *PDWORD;
- typedef unsigned long LDWORD;
- typedef DWORD *LPDWORD;
- typedef unsigned char BYTE;
- typedef unsigned short WORD;
- typedef unsigned long ULONG;
- typedef ULONG *PULONG;
- typedef unsigned short USHORT;
- typedef USHORT *PUSHORT;
- typedef BYTE *LPBYTE;
- typedef void *PVOID;
- typedef char* LPSTR;
- #ifndef NULL
- #define NULL 0
- #endif
- #define TRUE 1
- #define FALSE 0
- #endif /*__DEF_H__*/
现在 include/configs/lt2440.h 添加一个使能USB设备的宏定义并且使能中断。
#gedit |
#define USE_920T_MMU 1 #define CONFIG_USB_DEVICE 1 |
修改u-boot关于s3c2440的中断的文件,使其适应LT2440板子要求
gedit cpu/arm920t/s3c24x0/interrupts.c
#gedit cpu/arm920t/s3c24x0/interrupts.c |
#if 0 |
#gedit lib_arm/interrupts.c |
int interrupt_init (void) |
上面有两个宏没有声明也没有定义FREE_RAM_END , FREE_RAM_SIZE 下面给出声明和定义
#gedit include/asm-arm/u-boot-arm.h |
extern ulong IRQ_STACK_START; /* top of IRQ stack */ |
#gedit cpu/arm920t/start.S /* .globl _bss_end .globl FREE_RAM_END .globl FREE_RAM_SIZE |
#gedit lib_arm/bootm.c |
#ifdef CONFIG_USB_DEVICE |
#gedit lib_arm/board.c |
/* enable exceptions */ // 约388行 |
这些做好了之后,USB驱动已经可以正常加载了,下面加入USB下载的命令
#gedit common/cmd_usbslave.c |
#include <common.h> #ifdef CONFIG_USB_DEVICE int g_bUSBWait = 1; int do_usbslave (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) case 3: dwUSBBufBase = load_addr; g_dwDownloadLen = usb_receive(dwUSBBufBase, len, g_bUSBWait); U_BOOT_CMD( #endif |
修改common目录下Makefile
#gedit common/Makefile |
//在约155行加入下面一句 COBJS-y += cmd_usbslave.o |
s3c2440 USB控制器与s3c2410有区别,还有多了一个GPIO口 J 口,安装下面修改,增加支持
#gedit include/asm-arm/arch-s3c24x0/s3c24x0.h |
struct s3c24x0_usb_device { //增加J口支持 /* I/O PORT (see manual chapter 9) */ u32 PBCON; u32 PCCON; u32 PDCON; u32 PECON; u32 PFCON; u32 PGCON; u32 OPENCR; u32 MISCCR; u32 MISCCR; #if defined (CONFIG_S3C2440) #endif |
#gedit include/asm-arm/arch-s3c24x0/s3c24x0.h |
//在文件末尾增加下面定义 #define _ISR_STARTADDRESS ((unsigned)isr_handle_array) #define ISR_EINT0_OFT 0 #define ISR_EINT1_OFT 1 #define ISR_EINT2_OFT 2 #define ISR_EINT3_OFT 3 #define ISR_EINT4_7_OFT 4 #define ISR_EINT8_23_OFT 5 #define ISR_NOTUSED6_OFT 6 #define ISR_BAT_FLT_OFT 7 #define ISR_TICK_OFT 8 #define ISR_WDT_OFT 9 #define ISR_TIMER0_OFT 10 #define ISR_TIMER1_OFT 11 #define ISR_TIMER2_OFT 12 #define ISR_TIMER3_OFT 13 #define ISR_TIMER4_OFT 14 #define ISR_UART2_OFT 15 #define ISR_LCD_OFT 16 #define ISR_DMA0_OFT 17 #define ISR_DMA1_OFT 18 #define ISR_DMA2_OFT 19 #define ISR_DMA3_OFT 20 #define ISR_SDI_OFT 21 #define ISR_SPI0_OFT 22 #define ISR_UART1_OFT 23 #define ISR_NOTUSED24_OFT 24 #define ISR_USBD_OFT 25 #define ISR_USBH_OFT 26 #define ISR_IIC_OFT 27 #define ISR_UART0_OFT 28 #define ISR_SPI1_OFT 29 #define ISR_RTC_OFT 30 #define ISR_ADC_OFT 31 #endif /*__S3C2410_H__*/ |
#gedit cpu/arm920t/s3c24x0/Makefile |
//注释掉如下两行,它与USB device 驱动冲突 COBJS-y += speed.o COBJS-y += timer.o #COBJS-y += usb.o #COBJS-y += usb_ohci.o |
重新编译,重新烧写u-boot。重启LT2440开发板,可以使用 usbslave 命令传输文件了
有两个格式:
# usbslave //下载到板子内存的地址由DNW决定
# usbslave 1 0x30000000 //下载到板子内存的地址由后面的地址参数决定
打开DNW,可以发现USB已经OK了
下面使用usbslave命令做测试,下载Linux内核
LT2440 # usbslave 1 0x30000000
USB host is connected. Waiting a download.
Now, Downloading [ADDRESS:30000000h,TOTAL:2223646]
RECEIVED FILE SIZE: 2223646 (723KB/S, 3S)
LT2440 #
说明USB功能调试成功,可以使用USB device传输数据了
下接:u-boot-2010.03在LT2440上的移植详解 (八)