Chinaunix首页 | 论坛 | 博客
  • 博客访问: 542802
  • 博文数量: 67
  • 博客积分: 1625
  • 博客等级: 上尉
  • 技术积分: 1053
  • 用 户 组: 普通用户
  • 注册时间: 2012-02-04 14:40
文章分类

全部博文(67)

文章存档

2012年(67)

分类:

2012-12-20 20:08:29

1、复制usb slave驱动源代码
创建drivers/usb/slave 目录,复制usb slave驱动源代码到此目录(详见附件)
 
2、修改uboot根目录下的Makefeils,添加红色部分代码
 

LIBS += drivers/usb/musb/libusb_musb.a

# Apollo +

LIBS += drivers/usb/slave/libusb_slave.a

# Apollo -

LIBS += drivers/video/libvideo.a


3、修改lib_arm/board.c文件,添加红色部分代码

//Apollo +

    Port_Init();
    /* enable exceptions */
    enable_interrupts ();
    usb_init();

//Apollo -

 

4、修改平台头文件,include/configs/utu2440.h,添加红色部分 

#define CONFIG_USB_DEVICE 1

#ifdef CONFIG_USB_DEVICE

#define CONFIG_USE_IRQ 1

#endif

//#undef CONFIG_USE_IRQ /* we don't need IRQ/FIQ stuff */


5、修改cpu/arm920t/s3c24x0/interrupts.c 文件,添加arch_interrupt_init函数定义

    //Apollo +

    int arch_interrupt_init (void)
    {
        return 0;
    }
    //Apollo -


6、修改cpu/arm920t/start.S,文件

    #ifdef CONFIG_USE_IRQ
    
        .align    5
    irq:
    //Apollo +,此处开始修改
    /*
        get_irq_stack
        irq_save_user_regs
        bl    do_irq
        irq_restore_user_regs
    */


    /* use IRQ for USB and DMA */
        sub    lr, lr, #4             @ the return address
        ldr    sp, IRQ_STACK_START     @ the stack for irq
        stmdb  sp!,   { r0-r12,lr }    @ save registers
        
        ldr    lr,    =int_return         @ set the return addr
        ldr    pc, =IRQ_Handle         @ call the isr
    int_return:
        ldmia  sp!,   { r0-r12,pc }^    @ return from interrupt
    //Apollo -,修改结束


 
7、修改include/s3c24x0.h,文件
 

//Apollo +

    S3C24X0_REG8    MAXP_REG;
//    S3C24X0_REG8    res10[7];
    S3C24X0_REG8    res10[3];
    S3C24X0_REG8    EP0_CSR_IN_CSR1_REG;
    S3C24X0_REG8    res11[3];
    S3C24X0_REG8    IN_CSR2_REG;
//    S3C24X0_REG8    res12[3];
    S3C24X0_REG8    res12[7];
    S3C24X0_REG8    OUT_CSR1_REG;
//    S3C24X0_REG8    res13[7];
    S3C24X0_REG8    res13[3];

//Apollo -

 

8、添加usbslave命令

在common目录下创建cmd_usbslave.c
 

#include <common.h>
#include <command.h>
#include <asm/byteorder.h>

#ifdef CONFIG_USB_DEVICE

#ifdef CONFIG_USE_IRQ
    #define IRQ_STACK_START    (_armboot_start - CONFIG_SYS_MALLOC_LEN - CONFIG_SYS_GBL_DATA_SIZE - 4)
    #define FIQ_STACK_START    (IRQ_STACK_START - CONFIG_STACKSIZE_IRQ)
    #define FREE_RAM_END        (FIQ_STACK_START - CONFIG_STACKSIZE_FIQ - CONFIG_STACKSIZE)
    #define FREE_RAM_SIZE        (FREE_RAM_END - PHYS_SDRAM_1)
#else
    #define    FREE_RAM_END    (_armboot_start - CONFIG_SYS_MALLOC_LEN - CONFIG_SYS_GBL_DATA_SIZE - 4 - CONFIG_STACKSIZE)
    #define    FREE_RAM_SIZE    (FREE_RAM_END - PHYS_SDRAM_1)
#endif



int g_bUSBWait = 1;
u32 g_dwDownloadLen = 0;

extern int download_run;
extern volatile unsigned int dwUSBBufBase;
extern volatile unsigned int dwUSBBufSize;

extern __u32 usb_receive(char *buf, size_t len, unsigned int wait);

int do_usbslave (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
    int i;
    size_t len = ~0UL;
    char buf[32];

    /* download_run为1时表示将文件保存在USB Host发送工具dnw指定的位置
     * download_run为0时表示将文件保存在参数argv[2]指定的位置
     * 要下载程序到内存,然后直接运行时,要设置download_run=1,这也是这个参数名字的来由
     */

    download_run = 1;
    switch (argc) {
        case 1:
        {
            break;
        }
        case 2:
        {
            g_bUSBWait = (int)simple_strtoul(argv[1], NULL, 16);
            break;
        }

        case 3:
        {
            g_bUSBWait = (int)simple_strtoul(argv[1], NULL, 16);
            load_addr = simple_strtoul(argv[2], NULL, 16);
            download_run = 0;
            break;
        }
        
        default:
        {
            printf ("Usage:\n%s\n", cmdtp->usage);
            return 1;
        }
    }

    dwUSBBufBase = load_addr;
    dwUSBBufSize = (FREE_RAM_SIZE&(~(0x80000-1)));
    if (g_bUSBWait)
        len = FREE_RAM_SIZE;

    g_dwDownloadLen = usb_receive(dwUSBBufBase, len, g_bUSBWait);
    sprintf(buf, "%X", g_dwDownloadLen);
    setenv("filesize", buf);
    
    return 0;
}

U_BOOT_CMD(
    usbslave,    3,    0,    do_usbslave,
    "usbslave - get file from host(PC)\n",
    "[wait] [loadAddress]\n"
    "\"wait\" is 0 or 1, 0 means for return immediately, not waits for the finish of transferring\n"
);

#endif

 

修改common/Makefile 

COBJS-$(CONFIG_USB_KEYBOARD) += usb_kbd.o

# Apollo +

COBJS-$(CONFIG_USB_DEVICE) += cmd_usbslave.o

# Apollo -


 

文件: uboot-usb_slave.tar.bz2
大小: 17KB
下载: 下载

 

 

原创文章,转载请注明:转载自 风雨无阻博客(http://Apollo5520.cublog.cn

本文链接地址:http://blog.chinaunix.net/u3/105764/showart_2144192.html

 


阅读(3560) | 评论(0) | 转发(0) |
0

上一篇:reading u-boot.bin error found:0010成功解决

下一篇:没有了

给主人留下些什么吧!~~