天嵌 ARM开发社区

 找回密码
 注册
查看: 3678|回复: 6

uboot中usb_receive()函数在什么地方实现的

[复制链接]
lgfsee 发表于 2010-7-20 15:56:35 | 显示全部楼层 |阅读模式
在Cmd_usbslave.c文件中

extern __u32 usb_receive(char *buf, size_t len, U32 wait);
函数在什么地方实现的

g_dwDownloadLen = usb_receive(dwUSBBufBase, len, g_bUSBWait);
 楼主| lgfsee 发表于 2010-7-22 09:15:18 | 显示全部楼层
顶层makefile中发现
LIBS += modules/usb.module
LIBS += modules/wince.module

usb_receive(char *buf, size_t len, U32 wait);
应该是在usb.module实现的
haichang417 发表于 2010-8-11 13:47:56 | 显示全部楼层
居然是库,源码呢?
198944lijing 发表于 2010-12-17 09:15:23 | 显示全部楼层
天嵌的我不知道。这个函数是现成的驱动。是在一个驱动包里定义的,驱动包叫usb_slave,你要想查可以去网上搜索,这个驱动好像和dnw有关,我可以粘贴一些源码,要是下载不了联系我qq:654224414



//void WaitDownload(void)
__u32 usb_receive(char *buf, size_t len, U32 wait)
{
    int first=1;
    U8 tempMem[16];
    U32 j;
    unsigned int dwRecvTimeSec = 0;
        char c;

    dwUSBBufReadPtr = dwUSBBufBase; // USB_BUF_BASE; thiswa.diy, 2006.06.21
    dwUSBBufWritePtr = dwUSBBufBase; // USB_BUF_BASE; thiswa.diy, 2006.06.21
    bDMAPending = 0;

    /* add by thisway.diy */
    tempDownloadAddress = dwUSBBufBase; // USB_BUF_BASE; thiswa.diy, 2006.06.21 // RAM_BASE, changed by thisway.diy for wince, 2006.06.18

    downloadAddress=(U32)tempMem; //_RAM_STARTADDRESS;
    downPt=(unsigned char *)downloadAddress;
        //This address is used for receiving first 8 byte.
    downloadFileSize=0;
   

    /*******************************/
    /*    File download    */
    /*******************************/
    if(isUsbdSetConfiguration==0)
    {
            printf("USB host is not connected yet.\n");
    }

    while(downloadFileSize==0) /* wait until send a file */
    {
        if(first==1 && isUsbdSetConfiguration!=0)
        {
            printf("USB host is connected. Waiting a download.\n");
            first=0;
        }
                c = awaitkey(1, 0);
                if ((c & 0x7f) == INTR)
                {
                        printf("Cancelled by user\n");
                        return 0;
                }
    }

    /* add by thisway.diy */
    if (downloadFileSize - 10 > len)
    {
        printf("Length of file is too big : %d > %d\n", downloadFileSize - 10, len);
        return 0;
    }
   
    Timer_InitEx();
    Timer_StartEx();
        
#if USBDMA   

    intregs->INTMSK&=~(BIT_DMA2);  

    ClearEp3OutPktReady();
            // indicate the first packit is processed.
            // has been delayed for DMA2 cofiguration.

    if(downloadFileSize>EP3_PKT_SIZE)
    {
        if(downloadFileSize - EP3_PKT_SIZE<=(0x80000))
        {
            /* set the source and length */
            dwUSBBufWritePtr = downloadAddress + EP3_PKT_SIZE-8;
            dwWillDMACnt = downloadFileSize - EP3_PKT_SIZE;
            }
              else
              {
            dwUSBBufWritePtr = downloadAddress + EP3_PKT_SIZE - 8;
            // dwWillDMACnt = 0x80000 - EP3_PKT_SIZE;
            
            /* Changed by thisway.diy, 2006.06.22
             * We want When the first DMA interrupt happened,
             * it has received (0x80000 + 8) bytes data from PC
             * The format of data PC send out is: <ADDR(DATA):4>+<SIZE(n+10):4>+<DATA:n>+<CS:2>
             * So, the first 8 bytes isn't the real data we want
             * We want the dwUSBBufWritePtr is always 0x80000 aligin
             */
            dwWillDMACnt = 0x80000 + 8 - EP3_PKT_SIZE;
            }
             totalDmaCount = 0;
              ConfigEp3DmaMode(dwUSBBufWritePtr, dwWillDMACnt);
    }
    else
    {
        dwUSBBufWritePtr = downloadAddress + downloadFileSize - 8;
            totalDmaCount = downloadFileSize;
    }
#endif

    printf("\nNow, Downloading [ADDRESS:%xh,TOTAL:%d]\n",
                    downloadAddress,downloadFileSize);

    if (wait)
    {
        printf("RECEIVED FILE SIZE:%8d",0);

        j = totalDmaCount + 0x10000;
        while (totalDmaCount != downloadFileSize)
        {
            if (totalDmaCount > j)
            {
                    printf("\b\b\b\b\b\b\b\b%8d", j);
                j = totalDmaCount + 0x10000;
            }
        }
            printf("\b\b\b\b\b\b\b\b%8d ", totalDmaCount);
        dwRecvTimeSec = Timer_StopEx();
        if (dwRecvTimeSec == 0)
        {
            dwRecvTimeSec = 1;
        }
        printf("(%dKB/S, %dS)\n", (downloadFileSize/dwRecvTimeSec/1024), dwRecvTimeSec);
    }

    return downloadFileSize - 10;

}
198944lijing 发表于 2010-12-17 09:18:04 | 显示全部楼层
本帖最后由 198944lijing 于 2010-12-17 09:22 编辑

哥们你真是救了我啊,我最近移植一个uboot,但是就是找不到usb_init(),我用si跟踪了也还是找不到有效的定义,哈哈竟然是库。妈的,我当时就是忘记看makefile了,弄了2个星期,奖励你一个小红花,祝你成功
天嵌_support1 发表于 2010-12-17 10:44:48 | 显示全部楼层
:)
fsi159085 发表于 2012-3-1 00:10:34 | 显示全部楼层
终于解开疑点
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号 )

GMT+8, 2024-5-26 05:18 , Processed in 1.046875 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表