USBHS other speed

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

USBHS other speed

1,910 Views
michaelbrudevol
Contributor II

Has anyone implemented the USBHS other speed device descriptor properly in MQX?  I am using the USB MSC device code on a K20, and while it implements g_device_qualifier_descriptor and g_other_speed_config_descriptor, it's statically configured for the high-speed case.  For full-speed, the device descriptors need to be swapped.  I saw no reference in the usbd code to USBHS_PORTSC1, which I'm assuming is the best place to figure out the port speed.

0 Kudos
Reply
8 Replies

1,577 Views
DavidS
NXP Employee
NXP Employee

Hi Michael,

I do not have a K20-120MHz tower.

I have used the TWR-K70F120M and the TWR-SER2 card that has a HS ULPI USB PHY on it.

I tested with MQX4.1 mfs_usb_twrk70f120m example application.

I did have to play around a bit to disable the PTA GPIO pins used for TWR-K70F120M LED's as they conflict with ULPI interface.

In twrk70f120m I made the following changes to enable using ULPI PHY and the mini-AB USB connector (yes have to find adapter to USB stick):

#ifndef BSP_USB_TWR_SER2 //DES added

#define BSP_USB_TWR_SER2 (1) //set to 1 if TWR-SER2 (2 eth) board used (only host)

#if BSP_USB_TWR_SER2

   /* If the TWR-SER2 board is used, the default USB host controller is EHCI. This gives the applicatio 

   #define USBCFG_DEFAULT_HOST_CONTROLLER (&_bsp_usb_host_ehci0_if)

#else //BSP_USB_TWR_SER2

   /* Use KHCI host controller as default controller for other configurations. */

   #define USBCFG_DEFAULT_HOST_CONTROLLER (&_bsp_usb_host_khci0_if)

#endif //BSP_USB_TWR_SER2

In init_hmi.c I modified it to disable using PORTA GPIO that conflict with ULPI interface:

/* LWGPIO buttons and LEDS

*  interrupt not used - HMI_LWGPIO_FLAG_INT_ON is not set for buttons

*/

static const HMI_LWGPIO_INIT_STRUCT hmi_init_table_lwgpio[]={   

        /* UID, PIN ID, FUNCTIONALITY, FLAGS */

#ifndef BSP_USB_TWR_SER2   //DES added...PTA pins conflicts with USB ULPI interface when using TWR-SER2 so LED's cannot be used.

        {HMI_LED_1, BSP_LED1, BSP_LED1_MUX_GPIO, HMI_LWGPIO_FLAG_DIRECTION_OUT|HMI_LWGPIO_FLAG_ACTIVE_STATE_0},    /* LED 1 */

        {HMI_LED_2, BSP_LED2, BSP_LED2_MUX_GPIO, HMI_LWGPIO_FLAG_DIRECTION_OUT|HMI_LWGPIO_FLAG_ACTIVE_STATE_0},    /* LED 2 */

        {HMI_LED_3, BSP_LED3, BSP_LED3_MUX_GPIO, HMI_LWGPIO_FLAG_DIRECTION_OUT|HMI_LWGPIO_FLAG_ACTIVE_STATE_0},    /* LED 3 */

        {HMI_LED_4, BSP_LED4, BSP_LED4_MUX_GPIO, HMI_LWGPIO_FLAG_DIRECTION_OUT|HMI_LWGPIO_FLAG_ACTIVE_STATE_0},    /* LED 4 */

#endif

        {HMI_BUTTON_5, BSP_SW1, BSP_BUTTON1_MUX_GPIO, HMI_LWGPIO_FLAG_DIRECTION_IN|HMI_LWGPIO_FLAG_ACTIVE_STATE_0|HMI_LWGPIO_FLAG_PULL_UP_ON},    /* BUTTON 1 */

        {HMI_BUTTON_6, BSP_SW2, BSP_BUTTON2_MUX_GPIO, HMI_LWGPIO_FLAG_DIRECTION_IN|HMI_LWGPIO_FLAG_ACTIVE_STATE_0|HMI_LWGPIO_FLAG_PULL_UP_ON},    /* BUTTON 2 */

        {0,0,0},

};

Regards,

David

0 Kudos
Reply

1,577 Views
michaelbrudevol
Contributor II

Hi David,

I am not having issues connecting as a USB HS device and using ULPI to my PHY.  I am having issues connecting my device to Full-Speed ports (so non-high speed capable ports).  The issue is that the code is providing the device descriptor as if it was connected at high speed, which allow transfers of 512 bytes.  Full-speed only allows up to 64.  The code needs to be intelligent enough to notice if it was connected at full or high speed and provide the correct device descriptor.  My query is whether or not someone has already done that, which may save me time.

0 Kudos
Reply

1,577 Views
DavidS
NXP Employee
NXP Employee

Hi Michael,

My apologize for not understanding the issue (and still a bit foggy).  The K20 you reference is a K20F120M (120/150MHz) MCU?

I think you are saying your K20 using MQX is being setup to operate with a ULPI phy in the device mode and when it connects to a USB FS Host it is using the wrong device descriptor.  Is that understanding correct?

What MQX example are you running?

Regards,

David

0 Kudos
Reply

1,577 Views
michaelbrudevol
Contributor II

That's correct.  I am using the mass storage example.

0 Kudos
Reply

1,577 Views
DavidS
NXP Employee
NXP Employee

Hi Michael,

Thanks for clarification.

I did find one reference in the twrk70f120m.h header that says interface only for host mode.

#define BSP_USB_TWR_SER2 (1) //set to 1 if TWR-SER2 (2 eth) board used (only host)

I'll ask around to see why that is the case.

Regards,

David

0 Kudos
Reply

1,577 Views
simonraybould
Contributor I

Hi David,

Did you ever find out if this should also work in "DEVICE" mode?

This question still seems to be open and this comment is still in the latest code along with the BSP_USB_TWR_SER2 precompile switch only changing USBCFG_DEFAULT_HOST_CONTROLLER to ehci mode.

Regards,
Simon

0 Kudos
Reply

1,577 Views
michaelbrudevol
Contributor II

Just to make sure you're not tracking down the wrong thing...  The function USB_Desc_Get_Descriptor returns the descriptor as an index into g_std_descriptors.  "g_std_descriptors" is one of them and "g_other_speed_config_descriptor" is another.  These are correct when connecting to a High-Speed host.  However, when connecting to a Full-Speed host, the two need to change places (and USB_OTHER_SPEED_DESCRIPTOR vs USB_CONFIG_DESCRIPTOR still need to be correct, so they need to swap places as well).

0 Kudos
Reply

1,577 Views
lh_dan
Contributor III

Hi Michael,

I would like to know if you ever received an answer to your question.  I have just implemented a USB HS device with MQX and it seems like the other speed function was never implemented in a way that works.  The config descriptors and other speed descriptors are not dependent upon the actual speed configured by the port.  My bulk endpoints work at both full and high speed as long as I keep my packet size below the full speed max of 64.  If I use a packet size greater than 64 (but less than the high speed max of 512)  everything works at high speed but not at full speed.

Thanks,

Dan

0 Kudos
Reply