USB_DeviceSetSpeed() fix for usb_device_descriptor.c

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

USB_DeviceSetSpeed() fix for usb_device_descriptor.c

907 Views
Don_Adams_HPE
Contributor I

We found a problem in the usb_device_descriptor.c file of the frdmmcxn947_dev_phdc_weighscale_freertos_cm33_core0 sample project for the FRDM-MCXN947 development board.  We used this project as the basis for a new project.  After an upgrade to MacOS version Tahoe 26.4 our USB communication stopped working.  The symptom of the problem was that communication from the Mac to the FRDM-MCXN947 development board worked, but communication from the development board back to the Mac stopped working.  The fix to the problem was the following code changes to the USB_DeviceSetSpeed() function in usb_device_descriptor.c:


-                if (((pDescStart->endpoint.bEndpointAddress & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK) ==
+                if (((pDescStart->endpoint.bmAttributes & USB_DESCRIPTOR_ENDPOINT_ATTRIBUTE_TYPE_MASK) ==
+                     USB_ENDPOINT_INTERRUPT) &&
+                    ((pDescStart->endpoint.bEndpointAddress & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK) ==


-                else if (((pDescStart->endpoint.bEndpointAddress & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK) ==
+                else if (((pDescStart->endpoint.bmAttributes & USB_DESCRIPTOR_ENDPOINT_ATTRIBUTE_TYPE_MASK) ==
+                          USB_ENDPOINT_BULK) &&
+                         ((pDescStart->endpoint.bEndpointAddress & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK) ==


-                else if (((pDescStart->endpoint.bEndpointAddress & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK) ==
+                else if (((pDescStart->endpoint.bmAttributes & USB_DESCRIPTOR_ENDPOINT_ATTRIBUTE_TYPE_MASK) ==
+                          USB_ENDPOINT_BULK) &&
+                         ((pDescStart->endpoint.bEndpointAddress & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK) ==


-                if (((pDescStart->endpoint.bEndpointAddress & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK) ==
+                if (((pDescStart->endpoint.bmAttributes & USB_DESCRIPTOR_ENDPOINT_ATTRIBUTE_TYPE_MASK) ==
+                     USB_ENDPOINT_INTERRUPT) &&
+                    ((pDescStart->endpoint.bEndpointAddress & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK) ==


-                else if (((pDescStart->endpoint.bEndpointAddress & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK) ==
+                else if (((pDescStart->endpoint.bmAttributes & USB_DESCRIPTOR_ENDPOINT_ATTRIBUTE_TYPE_MASK) ==
+                          USB_ENDPOINT_BULK) &&
+                         ((pDescStart->endpoint.bEndpointAddress & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK) ==


-                else if (((pDescStart->endpoint.bEndpointAddress & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK) ==
+                else if (((pDescStart->endpoint.bmAttributes & USB_DESCRIPTOR_ENDPOINT_ATTRIBUTE_TYPE_MASK) ==
+                          USB_ENDPOINT_BULK) &&
+                         ((pDescStart->endpoint.bEndpointAddress & USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK) ==


We no longer have problems with USB communication. I am posting this information in case it solves USB communication problems for others as well.

0 Kudos
Reply
1 Reply

845 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hi @Don_Adams_HPE 

Thank you for your kind sharing.
I will report this to the internal SDK team for further review.
Thank you.
 

BR

Alice

0 Kudos
Reply
%3CLINGO-SUB%20id%3D%22lingo-sub-2350351%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EUSB_DeviceSetSpeed()%20fix%20for%20usb_device_descriptor.c%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2350351%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EWe%20found%20a%20problem%20in%20the%20usb_device_descriptor.c%20file%20of%20the%20frdmmcxn947_dev_phdc_weighscale_freertos_cm33_core0%20sample%20project%20for%20the%20FRDM-MCXN947%20development%20board.%26nbsp%3B%20We%20used%20this%20project%20as%20the%20basis%20for%20a%20new%20project.%26nbsp%3B%20After%20an%20upgrade%20to%20MacOS%20version%20Tahoe%2026.4%20our%20USB%20communication%20stopped%20working.%26nbsp%3B%20The%20symptom%20of%20the%20problem%20was%20that%20communication%20from%20the%20Mac%20to%20the%20FRDM-MCXN947%20development%20board%20worked%2C%20but%20communication%20from%20the%20development%20board%20back%20to%20the%20Mac%20stopped%20working.%26nbsp%3B%20The%20fix%20to%20the%20problem%20was%20the%20following%20code%20changes%20to%20the%20USB_DeviceSetSpeed()%20function%20in%20usb_device_descriptor.c%3A%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E-%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20if%20(((pDescStart-%26gt%3Bendpoint.bEndpointAddress%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK)%20%3D%3D%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20if%20(((pDescStart-%26gt%3Bendpoint.bmAttributes%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ATTRIBUTE_TYPE_MASK)%20%3D%3D%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BUSB_ENDPOINT_INTERRUPT)%20%26amp%3B%26amp%3B%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20((pDescStart-%26gt%3Bendpoint.bEndpointAddress%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK)%20%3D%3D%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E-%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20else%20if%20(((pDescStart-%26gt%3Bendpoint.bEndpointAddress%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK)%20%3D%3D%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20else%20if%20(((pDescStart-%26gt%3Bendpoint.bmAttributes%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ATTRIBUTE_TYPE_MASK)%20%3D%3D%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20USB_ENDPOINT_BULK)%20%26amp%3B%26amp%3B%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B((pDescStart-%26gt%3Bendpoint.bEndpointAddress%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK)%20%3D%3D%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E-%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20else%20if%20(((pDescStart-%26gt%3Bendpoint.bEndpointAddress%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK)%20%3D%3D%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20else%20if%20(((pDescStart-%26gt%3Bendpoint.bmAttributes%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ATTRIBUTE_TYPE_MASK)%20%3D%3D%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20USB_ENDPOINT_BULK)%20%26amp%3B%26amp%3B%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B((pDescStart-%26gt%3Bendpoint.bEndpointAddress%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK)%20%3D%3D%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E-%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20if%20(((pDescStart-%26gt%3Bendpoint.bEndpointAddress%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK)%20%3D%3D%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20if%20(((pDescStart-%26gt%3Bendpoint.bmAttributes%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ATTRIBUTE_TYPE_MASK)%20%3D%3D%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BUSB_ENDPOINT_INTERRUPT)%20%26amp%3B%26amp%3B%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20((pDescStart-%26gt%3Bendpoint.bEndpointAddress%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK)%20%3D%3D%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E-%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20else%20if%20(((pDescStart-%26gt%3Bendpoint.bEndpointAddress%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK)%20%3D%3D%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20else%20if%20(((pDescStart-%26gt%3Bendpoint.bmAttributes%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ATTRIBUTE_TYPE_MASK)%20%3D%3D%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20USB_ENDPOINT_BULK)%20%26amp%3B%26amp%3B%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B((pDescStart-%26gt%3Bendpoint.bEndpointAddress%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK)%20%3D%3D%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E-%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20else%20if%20(((pDescStart-%26gt%3Bendpoint.bEndpointAddress%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK)%20%3D%3D%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20else%20if%20(((pDescStart-%26gt%3Bendpoint.bmAttributes%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ATTRIBUTE_TYPE_MASK)%20%3D%3D%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20USB_ENDPOINT_BULK)%20%26amp%3B%26amp%3B%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B((pDescStart-%26gt%3Bendpoint.bEndpointAddress%20%26amp%3B%20USB_DESCRIPTOR_ENDPOINT_ADDRESS_DIRECTION_MASK)%20%3D%3D%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EWe%20no%20longer%20have%20problems%20with%20USB%20communication.%20I%20am%20posting%20this%20information%20in%20case%20it%20solves%20USB%20communication%20problems%20for%20others%20as%20well.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2350351%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3ECommunication%20%26amp%3B%20Control(I3C%20%7C%20I2C%20%7C%20SPI%20%7C%20FlexCAN%20%7C%20Ethernet%20%7C%20FlexIO)%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2351455%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%20translate%3D%22no%22%3ERe%3A%20USB_DeviceSetSpeed()%20fix%20for%20usb_device_descriptor.c%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2351455%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fcommunity.nxp.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F261582%22%20target%3D%22_blank%22%3E%40Don_Adams_HPE%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3EThank%20you%20for%20your%20kind%20sharing.%3CBR%20%2F%3EI%20will%20report%20this%20to%20the%20internal%20SDK%20team%20for%20further%20review.%3CBR%20%2F%3EThank%20you.%3C%2FDIV%3E%0A%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3EBR%3C%2FP%3E%0A%3CP%3EAlice%3C%2FP%3E%3C%2FLINGO-BODY%3E