TQ2440移植u-boot-2010.06-rc1---6usb下载
扫描二维码
随时随地手机看文章
以前做过usb下载的东东,现在把它搞到u-boot-2010.06-rc1上去.
网上有usb下载的代码,可以在这儿下载:
http://blogimg.chinaunix.net/blog/upfile2/100109001526.bz2
一. 先编译过再说
1.下载后,解压到u-boot-2010.06-rc1/drivers/usb/slave目录
并在顶层Makefile中添加:LIBS += drivers/usb/slave/libusb_slave.a
2. 将driver/usb/slave/目录下所有C文件所个替换
a.
#ifdefined(CONFIG_S3C2400)
#include
#elif defined(CONFIG_S3C2410)||defined(CONFIG_S3C2440)
#include
#endif
#include
替换为
#include
b. 删除driver/usb/slave/interrupt.c
c. 修改driver/usb/slave/Makefile中的 COBJS, 去掉interrupt.o
3.u-boot-2010.06-rc1中结构体都是小写,跟下载的代码中结构体名字是大写的,需要将大写的名字改成小写的,这样才可以编译过去.
a.将usbin.c中
L21
/*
extern S3C24X0_USB_DEVICE*usbdevregs;
extern S3C24X0_DMAS*dmaregs;
*/
extern struct s3c24x0_usb_device * usbdevregs;
extern struct s3c24x0_dmas * dmaregs;
L32解决: warning: suggest parentheses around arithmetic in operand of |
#define SET_EP1_IN_PKT_READY() usbdevregs->EP0_CSR_IN_CSR1_REG= ((in_csr1 &(~ EPI_WR_BITS))
| EPI_IN_PKT_READY )
#define SET_EP1_SEND_STALL() usbdevregs->EP0_CSR_IN_CSR1_REG= ((in_csr1 & (~EPI_WR_BITS))
| EPI_SEND_STALL) )
#define CLR_EP1_SENT_STALL() usbdevregs->EP0_CSR_IN_CSR1_REG= ( (in_csr1 & (~EPI_WR_BITS))
&(~EPI_SENT_STALL) )
#define FLUSH_EP1_FIFO() usbdevregs->EP0_CSR_IN_CSR1_REG= ( (in_csr1 & (~EPI_WR_BITS))
|(EPI_FIFO_FLUSH) )
b.将usblib.c中
L23
/*
extern S3C24X0_INTERRUPT*intregs;
extern S3C24X0_USB_DEVICE*usbdevregs;
extern S3C24X0_DMAS*dmaregs;
*/
extern struct s3c24x0_interrupt * intregs;
extern struct s3c24x0_usb_device *usbdevregs;
extern struct s3c24x0_dmas * dmaregs;
c.usbinit.c 中
L22
/*
extern S3C24X0_INTERRUPT*intregs;
S3C24X0_USB_DEVICE*usbdevregs;
S3C24X0_DMAS*dmaregs;
S3C24X0_CLOCK_POWER*clk_powerregs;
S3C24X0_GPIO*gpioregs;
*/
extern struct s3c24x0_interrupt * intregs;
struct s3c24x0_usb_device * usbdevregs;
struct s3c24x0_dmas * dmaregs;
struct s3c24x0_clock_power * clk_powerregs;
struct s3c24x0_gpio * gpioregs;
L122:
//gpioregs=S3C24X0_GetBase_GPIO();
gpioregs = s3c24x0_get_base_gpio();
L222
/*
clk_powerregs=S3C24X0_GetBase_CLOCK_POWER();
usbdevregs=S3C24X0_GetBase_USB_DEVICE();
dmaregs=S3C24X0_GetBase_DMAS();
*/
clk_powerregs = s3c24x0_get_base_clock_power();
usbdevregs = s3c24x0_get_base_usb_device();
dmaregs = s3c24x0_get_base_dmas();
L297
//S3C24X0_INTERRUPT*intregs;
struct s3c24x0_interrupt * intregs;
//intregs=S3C24X0_GetBase_INTERRUPT();
intregs = s3c24x0_get_base_interrupt();
d.usbmain.c 中
L20
/*
extern S3C24X0_USB_DEVICE*usbdevregs;
extern S3C24X0_DMAS*dmaregs;
*/
extern struct s3c24x0_usb_device * usbdevregs;
extern struct s3c24x0_dmas * dmaregs;
L444 解决: warning: suggest parentheses around arithmetic in operand of |
444 gpioregs->MISCCR =(gpioregs->MISCCR&~(7<<4))| (clock_sel<<4);
445 gpioregs->GPHCON =(gpioregs->GPHCON&~(3<<18))| (2<<18);
e.usbout.c中
L28
/*
extern S3C24X0_INTERRUPT*intregs;
extern S3C24X0_USB_DEVICE*usbdevregs;
extern S3C24X0_DMAS*dmaregs;
*/
extern struct s3c24x0_interrupt * intregs;
extern struct s3c24x0_usb_device * usbdevregs;
extern struct s3c24x0_dmas * dmaregs;
L188
//ClearPending_my(BIT_DMA2);
ClearPending(BIT_DMA2);
f.usbsetup.c中
L19
/*
extern S3C24X0_INTERRUPT*intregs;
extern S3C24X0_USB_DEVICE*usbdevregs;
extern S3C24X0_DMAS*dmaregs;
*/
extern struct s3c24x0_interrupt * intregs;
extern struct s3c24x0_usb_device * usbdevregs;
extern struct s3c24x0_dmas * dmaregs;
L46 解决: warning: suggest parentheses around arithmetic in operand of |
#define CLR_EP0_OUT_PKT_RDY() usbdevregs->EP0_CSR_IN_CSR1_REG=((ep0_csr & (~EP0_WR_BITS))|
EP0_SERVICED_OUT_PKT_RDY )
#define CLR_EP0_OUTPKTRDY_DATAEND() usbdevregs->EP0_CSR_IN_CSR1_REG=( (ep0_csr & (~EP0_WR_BITS) )|
(EP0_SERVICED_OUT_PKT_RDY|EP0_DATA_END) )
#define SET_EP0_IN_PKT_RDY() usbdevregs->EP0_CSR_IN_CSR1_REG=( (ep0_csr & (~EP0_WR_BITS) ) |
(EP0_IN_PKT_READY) )
#define SET_EP0_INPKTRDY_DATAEND() usbdevregs->EP0_CSR_IN_CSR1_REG=( (ep0_csr & (~EP0_WR_BITS))|
(EP0_IN_PKT_READY|EP0_DATA_END) )
#define CLR_EP0_SETUP_END() usbdevregs->EP0_CSR_IN_CSR1_REG=( (ep0_csr & (~EP0_WR_BITS)) |
(EP0_SERVICED_SETUP_END) )
#define CLR_EP0_SENT_STALL() usbdevregs->EP0_CSR_IN_CSR1_REG=( (ep0_csr & (~EP0_WR_BITS) )&
(~EP0_SENT_STALL) )
#define FLUSH_EP0_FIFO() {while(usbdevregs->OUT_FIFO_CNT1_REG)usbdevregs->fifo[0].EP_FIFO_REG;}
4.arch/arm/include/asm/arch/s3c24x0.h中
a.添加两个宏定义
#define BIT_DMA2 (0x1<<19)
#define BIT_USBD (0x1<<25)
b.修改s3c24x0_usb_device结构体
//u8 res10[7]
u8 res10[3];
//u8 res12[3]
u8 res12[7];
//u8 res13[7]
u8 res13[3];
/*
struct s3c24x0_usb_dev_fifos fifo[5];
struct s3c24x0_usb_dev_dmas dma[5];
*/
u32 res17[8];
struct s3c24x0_usb_dev_fifos fifo[5];
u32 res18[11];
struct s3c24x0_usb_dev_dmas ep1;
struct s3c24x0_usb_dev_dmas ep2;
u8 res19[16];
struct s3c24x0_usb_dev_dmas ep3;
struct s3c24x0_usb_dev_dmas ep4;
c.修改 struct s3c24x0_gpio
L481 添加:
/*s3c2440*/
u32 res9[4];
u32 GPJCON;
u32 GPJDAT;
u32 GPJUP;
5.usbmain.c中void IsrUsbd(void)调用了ClearPending,其实现如下:
arch/arm/cpu/arm920t/interrupt.c
//添加 ClearPending的实现:
void ClearPending(int bit)
{
intregs->SRCPND = bit;
intregs->INTPND = bit;
}
并修改driver/usb/slave/usbmain.c
//ClearPending_my(BIT_USBD);
ClearPending(BIT_USBD);
6. usbmain.c的usb_init_slave(void)调用了Isr_Init(),其实现如下
arch/arm/cpu/arm920t/interrupt.c中添加
#include
struct s3c24x0_interrupt*intregs;
void(*isr_handle_array[50])(void);
extern void IsrUsbd(void);
extern void IsrDma2(void);
void Dummy_isr(void)
{
printf("Dummy_isr error, interrupt number: %d, INTMSK = 0x%xn",intregs->INTOFFSET,intregs->INTMSK);
while(1);
}
//初始化irq的中断向量表
void Isr_Init(void)
{
inti=0;
intregs=s3c24x0_get_base_interrupt();
for(i=0;i
{
isr_handle_array[i]=Dummy_isr;
}
intregs->INTMOD=0x0;//All=IRQ mode
intregs->INTMSK=BIT_ALLMSK;//All interruptismasked.
#ifdef CONFIG_USB_DEVICE
isr_handle_array[ISR_USBD_OFT]=IsrUsbd;
isr_handle_array[ISR_DMA2_OFT] = IsrDma2;