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上的移植詳解 (八)