Where would be the best place to post a question regarding the USB Bare Metal Library (V4.1.1) to implement a USB MSC on a K60? I can download fine, I'm having problems uploading, dropping every other packet, I believe it's in usb_dci_kinetis.c?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Where would be the best place to post a question regarding the USB Bare Metal Library (V4.1.1) to implement a USB MSC on a K60? I can download fine, I'm having problems uploading, dropping every other packet, I believe it's in usb_dci_kinetis.c?

584 Views
leedimmitt
Contributor I

I'm getting a USBHS_EPCOMPLETE interrupt in USBHS_IRQ, it contains the proper packet, then I get an ERROR interrupt, and the next time I get an USBHS_ECOMPLETE interrupt, I seem to have dropped a 512 byte packet.

Thanks in advance for any help,

Lee Dimmitt

0 Kudos
4 Replies

490 Views
leedimmitt
Contributor I

Looks like I got it working and the problem was with the ZLT's. My predecessor had turned them off by default to get the read portion working (all referenced routines are found in usb_dci_kinetis.c ):

routine: usbd_send_data_ep0 in()

- originally:

    (*(volatile unsigned int *)(dqh_address)) &= ~0x20000000;  // Enabled

- changed to:

    (*(volatile unsigned int *)(dqh_address)) |= 0x20000000;     // Disabled

Indeed, the Setup reads didn't work when it was in its original, Enabled state.

But apparently they're needed for uploading. so in usdb_prime_ep() I changed:

if (direction == IN)
{
    (*(volatile unsigned int *)(dqh_address)) &= ~0x20000000;

}

To: 

if (direction == IN)
{
    (*(volatile unsigned int *)(dqh_address)) |= 0x20000000;
}

I'm not sure that was really necessary because this next change is what really fixed it. In USB_DCI_Init_EndPoint(), I  changed the parameter passed to usbd_ep_qh_init() from "flag" to "1":

From: 

usbd_ep_qh_init(controller_ID, ep_ptr->ep_num, ep_ptr->direction, ep_ptr->size, flag, mult, 0xDEAD0001);

To:

usbd_ep_qh_init(controller_ID, ep_ptr->ep_num, ep_ptr->direction, ep_ptr->size, 1, mult, 0xDEAD0001);

Things started uploading then! I've got some cleanup to do, and more testing, just wanted to share my findings in case anyone else is having similar problems.

Lee

0 Kudos

490 Views
leedimmitt
Contributor I

Since no one's replied, I'll assume this is the place and give a bit more detail.

In V4.1.1 of usb_dci_kinetis.c:

USBHS_EPCOMPLETE in the interrupt routine invokes usbd_ep_complete_handler().

From there, the EPCOMPLETE bits invoke usbd_dtd_complete(event);

The usb_driver.c USB_Device_Call_Service() invokes the usb_msc.c USB_Service_Bulk_Out() routine, eventually getting me to 

USB_DCI_Recv_Data() back in usb_dci_kinetis.c.

Invoking usbd_receive_data_epxout(), it gets the dtd, initializes it then sets it up via usbd_setup_td().

In that routine, I see that the td->status that gets put into dtd_word1 = 0x60, with bits 6 & 5 set. 

Bit 6 indicates the communication is halted, and bit 5 indicates a Data Buffer Error - "the device controller is unable to maintain the reception of
incoming data (overrun)"

Section 51 of the K60P144M150SF3RM datasheet alludes to double buffering so that one endpoint can be filling while the other is processing, but I don't see this happening in the USB Stack firmware. 

Has anyone else had any luck uploading files to a USB MSC using the USB Stack?

Any help would be appreciated,

Lee

0 Kudos

490 Views
mjbcswitzerland
Specialist V

Hi

I don't know whether the USB-MSD is fully functional - there are many posts from people trying to get it working. There were two USB stacks that don't look to be supported any more and possibly you'll have more luck trying USB code in the KSDK: https://community.nxp.com/community/mcuxpresso/kinetis-software-development-kit 

If you don't have to use NXP code there is an industrial quality solution at the following link for almost all Kinetis parts and IDEs: http://www.utasker.com/kinetis.html

Regards

Mark

490 Views
leedimmitt
Contributor I

Thanks Mark,

Not the answer I was hoping to here, but I was beginning to suspect it. I see a few "ToDo: " and "Check" comments, which I guess were never done or checked. I don't necessarily need NXP code, but half of it works, and I guess I'm just holding out so I don't have to start over from scratch. I thought I saw a reference to V4.1.3, but I can't seem to find it, I was hoping it had the necessary clean up. I appreciate your response and will check out the links you provided.

Regards,

Lee

0 Kudos