This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DM368 Uboot 无法识别部分U盘的问题求助



我在DM368 Uboot中使用了U盘升级功能, 但发现Uboot对部分U盘的支持不太好, 会出现READ_CAP ERROR, 打印的信息如下:

i=0
i=1


USB Mass Storage device detected
Transport: Bulk/Bulk/Bulk
Endpoints In 1 Out 2 Int 0
Get Max LUN -> len = 1, result = 0
BBB_reset
BBB_reset result 0: status 0 reset
BBB_reset result 0: status 0 clearing IN endpoint
BBB_reset result 0: status 0 clearing OUT endpoint
BBB_reset done
address 2
COMMAND phase
DATA phase
STATUS phase
inquiry returns 0
ISO Vers 6, Response Data 2
COMMAND phase
STATUS phase
FAILED
COMMAND phase
DATA phase
STATUS phase
!CSWSIGNATURE
BBB_reset
BBB_reset result 0: status 0 reset
BBB_reset result 0: status 0 clearing IN endpoint
BBB_reset result 0: status 0 clearing OUT endpoint
BBB_reset done
Request Sense returned 42 01 95
COMMAND phase
STATUS phase
!Tag
BBB_reset
BBB_reset result 0: status 0 reset
BBB_reset result 0: status 0 clearing IN endpoint
BBB_reset result 0: status 0 clearing OUT endpoint
BBB_reset done
COMMAND phase
DATA phase
STATUS phase
Request Sense returned 42 00 6B
COMMAND phase
STATUS phase
COMMAND phase
DATA phase
STATUS phase
!CSWSIGNATURE
BBB_reset
BBB_reset result 0: status 0 reset
BBB_reset result 0: status 0 clearing IN endpoint
BBB_reset result 0: status 0 clearing OUT endpoint
BBB_reset done
COMMAND phase
DATA phase
STATUS phase
!CSWSIGNATURE
BBB_reset
BBB_reset result 0: status 0 reset
BBB_reset result 0: status 0 clearing IN endpoint
BBB_reset result 0: status 0 clearing OUT endpoint
BBB_reset done
COMMAND phase
DATA phase
STATUS phase
!CSWSIGNATURE
BBB_reset
BBB_reset result 0: status 0 reset
BBB_reset result 0: status 0 clearing IN endpoint
BBB_reset result 0: status 0 clearing OUT endpoint
BBB_reset done
COMMAND phase
DATA phase
STATUS phase
!CSWSIGNATURE
BBB_reset
BBB_reset result 0: status 0 reset
BBB_reset result 0: status 0 clearing IN endpoint
BBB_reset result 0: status 0 clearing OUT endpoint
BBB_reset done
READ_CAP ERROR
Read Capacity returns: 0xb40, 0x200
Capacity = 0x400b0001, blocksz = 0x20000
address 2
partype: 0

usb_read: dev 0
COMMAND phase
STATUS phase

usb_read: dev 0 startblk 0, blccnt 1 buffer 87e43b90
read10: start 0 blocks 1
COMMAND phase
DATA phase
DATA:stall
STATUS phase
STATUS:stall
STATUS phase
!CSWSIGNATURE
BBB_reset
BBB_reset result 0: status 0 reset
BBB_reset result 0: status 0 clearing IN endpoint
BBB_reset result 0: status 0 clearing OUT endpoint
BBB_reset done
Read ERROR
COMMAND phase
DATA phase
STATUS phase
!CSWSIGNATURE
BBB_reset
BBB_reset result 0: status 0 reset
BBB_reset result 0: status 0 clearing IN endpoint
BBB_reset result 0: status 0 clearing OUT endpoint
BBB_reset done
Request Sense returned 42 00 0C
read10: start 0 blocks 1
COMMAND phase
DATA phase

对于支持的U盘, 打印信息如下:

i=0
i=1


USB Mass Storage device detected
Transport: Bulk/Bulk/Bulk
Endpoints In 2 Out 1 Int 0
Get Max LUN -> len = 1, result = 0
BBB_reset
BBB_reset result 0: status 0 reset
BBB_reset result 0: status 0 clearing IN endpoint
BBB_reset result 0: status 0 clearing OUT endpoint
BBB_reset done
address 2
COMMAND phase
DATA phase
STATUS phase
inquiry returns 0
ISO Vers 2, Response Data 2
COMMAND phase
STATUS phase
FAILED
COMMAND phase
DATA phase
STATUS phase
Request Sense returned 06 28 00
COMMAND phase
STATUS phase
COMMAND phase
DATA phase
STATUS phase
Read Capacity returns: 0xffbff300, 0x20000
Capacity = 0xf3c000, blocksz = 0x200
address 2
partype: 0

usb_read: dev 0
COMMAND phase
STATUS phase

usb_read: dev 0 startblk 0, blccnt 1 buffer 87e43b90
read10: start 0 blocks 1
COMMAND phase
DATA phase
STATUS phase
usb_read: end startblk 1, blccnt 1 buffer 87e43d90
partype: 2
i=2
1 Storage Device(s) found

到网上查了一下, 但没有找到解决办法, 目前已对Uboot中的musb_hcd.c的MUSB_CSR0_H_DIS_PING进行了屏蔽, 因为DM368没有用到该位, 但U盘识别不到的问题依然存在, 请问一下是什么原因导致READ_CAP ERROR(进入内核后识别同样的U盘是可以的)? 谢谢.

  • 按照网上的一个建议, 可以解决这个问题:

    将Uboot中的usb_storage.c的usb_stor_BBB_transpor函数做如下修改:

    /* COMMAND phase */
    USB_STOR_PRINTF("COMMAND phase\n");
    result = usb_stor_BBB_comdat(srb, us);
    if (result < 0) {
    USB_STOR_PRINTF("failed to send CBW status %ld\n",
    us->pusb_dev->status);
    usb_stor_BBB_reset(us);
    return USB_STOR_TRANSPORT_FAILED;
    }
    //wait_ms(5);
    wait_ms(10);
    pipein = usb_rcvbulkpipe(us->pusb_dev, us->ep_in);
    pipeout = usb_sndbulkpipe(us->pusb_dev, us->ep_out);
    /* DATA phase + error handling */
    data_actlen = 0;
    /* no data, go immediately to the STATUS phase */
    if (srb->datalen == 0)
    goto st;
    USB_STOR_PRINTF("DATA phase\n");
    if (dir_in)
    pipe = pipein;
    else
    pipe = pipeout;
    result = usb_bulk_msg(us->pusb_dev, pipe, srb->pdata, srb->datalen,
    &data_actlen, USB_CNTL_TIMEOUT * 5);

    在发送完COMMAND phase后, 原来是延时5ms, 现在改为10ms, 再发送DATA phase, 就可以解决READ_CAP ERROR问题.

    但这种做法会将U盘识别过程和U盘数据传输过程的时间增大很大, 比串口传输快不了多少了.