not able to use USBD mass-storage on LPC1778

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

not able to use USBD mass-storage on LPC1778

2,105件の閲覧回数
walm_nxp
Contributor II

I tried to use USBD Mass-storage on LPC1778 by adapting project-example 'usbd_rom_msc_sdmmc' of lpcopen 2.18, lpcxpresso lpc1837.

Actual read files from SD-Card-Interface on LPC1778 over USB (Host Windows PC) works normal, but any try to write data on SD-Card only generates corrupt data on SD-Card.

Finally I found possible reason at field 'uint8_t BulkStage' (in struct 'USB_MSC_CTRL_T', in file 'mw_usbd/mw_usbd_mscuser.h'), it's only read by user program, but possible never changed by 'usbd_177x_8x_lib'.

Is any documentation available how to use field 'uint8_t BulkStage' here for my application ?

ラベル(2)
タグ(1)
0 件の賞賛
返信
3 返答(返信)

1,703件の閲覧回数
walm_nxp
Contributor II

I found mistake in my program in function app_bulk_out_hdlr(). I didn't check variable 'BulkStage' (Bulk Stage) in correct way.

Now USBD Mass-storage on LPC1778 is working normal for read and write.

Thanks for assistance

Manfred

0 件の賞賛
返信

1,703件の閲覧回数
jmccabe
Contributor II

Manfred, 

I tried the same (well, similar) thing recently, but didn't get as far as writing to the card because I found that every time I right clicked on the mounted drive in Windows Explorer and selected "Eject", I got an error (ported to the Embedded Artists LPC1788 Development Kit). I also found exactly the same using the actual LPC18S37 version on an OM13076 board with OM13082 general purpose board attached (once I'd fixed the wiring on it!).

Have you seen this issue? I couldn't see any obvious solution but I'm quite new to USB and LPC stuff. 

John 

0 件の賞賛
返信

1,703件の閲覧回数
isaacavila
NXP Employee
NXP Employee

Hello Mandred,


Have you registered an endpoint handler for bulk in endpoint? How did you configure mscDisk_init function?

If you checked mscDisk_init function you will notice that callback for writing is already set:

msc_param.MSC_Write = translate_wr;‍

but also, you will need to add an endpoint handler for IN transactions:

 

 if (USBD_API->version > 0x01111101) { /* New ROM stack version */
        default_bulk_in_hdlr = pCtrl->ep_event_hdlr[((((USB_MSC_CTRL_T *) g_pMscCtrl)->epin_num & 0x0F) << 1) + 1];
        default_bulk_out_hdlr = pCtrl->ep_event_hdlr[(((USB_MSC_CTRL_T *) g_pMscCtrl)->epout_num & 0x0F) << 1];
        USBD_API->core->RegisterEpHandler(hUsb,(((USB_MSC_CTRL_T *) g_pMscCtrl)->epout_num & 0x0F) << 1, app_bulk_out_hdlr, g_pMscCtrl);
        USBD_API->core->RegisterEpHandler(hUsb,((((USB_OLD_MSC_CTRL_T *) g_pMscCtrl)->epin_num & 0x0F) << 1) + 1, app_bulk_in_hdlr, g_pMscCtrl);
    } else { /* Old ROM stack version */
        default_bulk_in_hdlr = pCtrl->ep_event_hdlr[((((USB_MSC_CTRL_T *) g_pMscCtrl)->epin_num    & 0x0F) << 1) + 1];
        default_bulk_out_hdlr = pCtrl->ep_event_hdlr[(((USB_OLD_MSC_CTRL_T *) g_pMscCtrl)->epout_num & 0x0F) << 1];
        USBD_API->core->RegisterEpHandler(hUsb,    (((USB_OLD_MSC_CTRL_T *) g_pMscCtrl)->epout_num & 0x0F) << 1, app_bulk_out_hdlr, g_pMscCtrl);
        USBD_API->core->RegisterEpHandler(hUsb, ((((USB_OLD_MSC_CTRL_T *) g_pMscCtrl)->epin_num & 0x0F) << 1) + 1, app_bulk_in_hdlr, g_pMscCtrl);
    }‍‍‍‍‍‍‍‍‍‍‍

And, in app_bulk_in_hdlr, you can replicate what it is done for app_bulk_out_hdlr only replacing the OUT endpoint reference for IN endpoint reference.


How are you handling these callbacks?

Regards,

Isaac

0 件の賞賛
返信