Coder Social home page Coder Social logo

usb's Introduction

Microchip logo Harmony logo small

MPLAB® Harmony 3 USB Module

MPLAB® Harmony 3 is an extension of the MPLAB® ecosystem for creating embedded firmware solutions for Microchip 32-bit SAM and PIC® microcontroller and microprocessor devices. Refer to the following links for more information.

This repository contains the USB module for the MPLAB® Harmony 3 Embedded Software Development Framework. The USB module components provide USB middleware and drivers. Refer to the following links for release notes, training materials, and interface reference information.

Contents Summary

Folder Description
apps Example applications for USB library components
config USB module configuration scripts
docs USB module library help documentation
driver USB module driver source files
middleware USB middleware source files
templates Application and system file templates

License Latest release Latest release date Contributors


Follow us on Youtube Follow us on LinkedIn Follow us on Facebook Follow us on Twitter

usb's People

Contributors

aethaniel avatar djsaz avatar jcbuda avatar sandeep2081 avatar shijas-mayan avatar sunil-fernandes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

usb's Issues

USB_HOST_HID_RESULT_FAILURE When using USB_HOST_HID_ReportSend

Hi I'm struggling to get the HID host working on pic32mx470 and I can't find any documentation on USB HID host.

I have modified the keyboard HID host example and the basic HID device example.
The host sends a report and the HID device does echo back.

I have it working but it will only allow me to send same number of commands as the transfer objects (max number of transfers) set in configurator before the USB_HOST_HID_ReportSend returns with USB_HOST_HID_RESULT_FAILURE .

I tried to debug and it seems like USB_HOST_DeviceTransfer always returns USB_HOST_RESULT_REQUEST_BUSY
because the gUSBHostTransferObj are inUse.

When I send a single report I can see the transfer handle (gUSBHostTransferObj ) set to inUse

Then the _USB_HOST_DataTransferIRPCallback sets it back to false. For each sendReprort command the call back triggers 2 times but the USB_HOST_DeviceTransfer is called 3 times causing extra handle to be used each time so after sending a few reports all the handles get used up and don't clear.

Why are there multiple calls to USB_HOST_DeviceTransfer and why does the transfer object not get freed up ?

Additional info:
_USB_HOST_HID_InterfaceTasks is set to USB_HOST_HID_STATE_READY when attached device is detected, in this state IN transfer is done and state is changed to USB_HOST_HID_STATE_WAIT where it waits for incoming report,

if I send the report the second transfer request is done and state is changed to USB_HOST_HID_STATE_WAITING_SET_REPORT when the report is sent the state is changed back to ready not back to USB_HOST_HID_STATE_WAIT and this causes a 2nd transfer IN request to be done.

The state is back in USB_HOST_HID_STATE_WAIT and any incoming data triggers the state change back to hidInstanceInfo->state = USB_HOST_HID_STATE_READY;
Causing another read request to be done. So each time I use SEND report it queue additional transfer IN requests which never get completed because any incoming data also triggers transfer IN request.

if I change the state back to USB_HOST_HID_STATE_WAIT after the report is sent it does work but If I try to send data at higher frequency than 50-60 packets per second the application crashes.

Is there a way to work around this how can I increase throughput and ensure USB host is stable?

Interface description generated in the wrong order

I found an small issue with the ConfigurationDescriptor generated by MCC.

I defined 2 interfaces:

  • 0: HID
  • 1: Vendor

But MCC generates the descriptor in the wrong order (in usb_device_init_data.c):

  • 1: Vendor
  • 0: HID

This works for USB 2.0 just fine.
But I was trying to use BOS + WinUSB so Windows loads the driver without the need for user driver installation. So I had to set bcdUSB to USB >2.0 (I set it to 2.1 .bcdUSB = 0x0210) and it seems that Windows 10 won't enumerate the device if the interfaces are in the wrong order.
After swapping the interface descriptors manually the device would successfully enumerate as a WinUSB device.

I tested this on Windows 10 with a PIC32MX270F256D on a custom board.

PIC32 MZ DA using USB composite device( Vendor & MSD) and FreeRTOS problem

Update:

Found that I passed the wrong parameter to the USB_Device_EventHandlerSet func. Now it works fine, so issue closed.

I found this problem when connect the device to PC the second time, the device will be halted

I tested different combinations, there is this only combination which will cause the problem:
USB Vendor(winusb) with FreeRTOS works fine
USB MSD with FreeRTOS works fine
USB Composite device (Vendor & MSD) without FreeRTOS works fine
USB Composite device (Vendor & MSD) with FreeRTOS, if it is the first time connecting to PC, works fine. When disconnect, then connect again, the device halts, and the PC OS report getting device descriptor fail.

Does anybody know how to fix this problem?

USB Device Vendor

Dear,

Let me check with you one thing (please forgive me if my question is misplaced).

The package for investigation is attached. I'm trying to get USB Device Vendor going on my SAME70-XPLD board. It connects fine to windows looking in Windows Device Manager, WinUSB driver is loaded. However, when I try to communicate from PC to the SAME70Q21B nothing happens (also SAM->PC doesn't work), e.g. by using the PC demo application "WinUSB_PnP_Demo.exe".

What I did was to use Harmony Configurator 3 to setup USB Device Vendor (starting from scratch), selecting BSP for my board, among others. Then the contents of app.c and .h I took from the vendor demo app (HarmonyFramework\usb\apps\device\vendor\firmware\src). From here compiled, flashed the micro SAME70Q21B and started to execute the code.

Me trying to do some sort of investigation I was looking into app.c and found that the "Place a new read request." USB_DEVICE_EndpointRead(...) under APP_STATE_WAIT_FOR_CONFIGURATION returns USB_DEVICE_RESULT_ERROR_TRANSFER_QUEUE_FULL instead of USB_DEVICE_RESULT_OK. This is the first Read Request made after the configuration.

I'm not sure if this helps to understand the problem that I see, but I wanted to check with you if only me seeing this problem on SAME70Q21B micro or more people out there.

I've been using the Vendor application with PIC32MZ and I'm very happy how well it works. Having a SAME70-XPLD board and discovering you're developing same framework for the E70 made me glad.

Thanks!

The following is some background data:

  • Windows 10
  • MPLABX v5.20
  • XC32 v2.15
  • Harmony Configurator 3.3.0.1
  • Harmony Framework USB Release v3.2.2 (all framework modules picked May 31)
  • SAME70-XPLD board with micro SAME70Q21B (I'm using the built-in debugger EDBG, breakpoints work fine but not yet learnt how to read variables -all showing zeroes)

myUSB4.zip

void APP_Initialize(void) wrong init?

at usb/apps/device/cdc_com_port_single/firmware/src/app.c file

/* Initial get line coding state */
appData.getLineCodingData.dwDTERate = 9600;
appData.getLineCodingData.bParityType = 0;
appData.getLineCodingData.bParityType = 0;
appData.getLineCodingData.bDataBits = 8;

`

Is it right ?
i think that fix like this

/* Initial get line coding state */
appData.getLineCodingData.dwDTERate = 9600;
appData.getLineCodingData.bParityType = 0;
appData.getLineCodingData.bCharFormat= 0;
appData.getLineCodingData.bDataBits = 8;

`

am i wrong?

  • sry, my bad english

Help file Documentation issue

image
On page 2 of the usb help file, it mentions EHCI complaint instead of compliant.
See attached picture above.

Thanks

`CONFIG_USB_DEVICE_INTERFACES_NUMBER` set to erroneous value.

I've configured my project graph as such:

image

The code generated in usb_device_init_data.c that describes the configuration erroneously was set to the number 75, rather than 2, as expected.

In my project's mc3 file, I see the following setting:

      <entry>
         <key class="com.microchip.mcc.core.tokenManager.CustomKey" moduleName="usb_device" name="CONFIG_USB_DEVICE_INTERFACES_NUMBER"/>
         <value>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;usb_device&gt;
  &lt;usb_device dnOrder=&quot;0&quot; id=&quot;CONFIG_USB_DEVICE_INTERFACES_NUMBER&quot;&gt;
    &lt;Values dnOrder=&quot;0&quot;&gt;
      &lt;Dynamic dnOrder=&quot;0&quot; id=&quot;usb_device&quot; value=&quot;75&quot;/&gt;
    &lt;/Values&gt;
  &lt;/usb_device&gt;
&lt;/usb_device&gt;
</value>
      </entry>

The value specifies it's a dynamic one (and thus should be calculated), but that value is not displayed anywhere in the configuration Options for the USB Device layer, (where as Number of Functions and Number of Endpoints does seem to generate correct):

image

I removed and re-added the "USB Device Layer" component, but that caused the generated code to instead think it has 0 configurations/functions/endpoints.

image

Upon removing and re-adding the CDC Function driver, the values seem to have all been correctly re-calculated.

I've not yet been able to reproduce how that value of "75" was generated.

MPLAB Code Configurator version: v5.1.4
Target device: ATSAMD21G18A (DFP 3.6.144)
Target toolchain: XC32 4.00.

Let me know if there's any other info I could provide for potentially tracking down this issue.

Edit to add:

Upon further exploration, since re-creating the configuration, the number of bytes to describe the configuration generated as '58' instead of the 67 it should have been. Deleting both the USB Device Layer and the CDC Function Driver, and then re-adding them in that order seems to have resolved that particular issue.

USB HID Vendor Descriptor fails in windows.

I am working on a USB project where I want to use the USB HID Vendor method communicate with the host PC (windows)

My project consists of the following 3 USB functions

  • HID Joystick - Working normally.
  • HID Vendor - Windows error code 10. Insufficient resources to allocate needed memory
  • MSD SPI Flash - Works normally.

I configured everything with the harmony configuration.
for the HID Vendor descriptor I looked in to the example apps and copied the descriptor to my project but it doesn't work.

Example HID descriptor,

0x06, 0x00, 0xFF,     // Usage Page = 0xFF00 (Vendor Defined Page 1)
0x09, 0x01,             // Usage (Vendor Usage 1)
0xA1, 0x01,             // Colsslection (Application)
0x19, 0x01,             // Usage Minimum
0x29, 0x40,             // Usage Maximum 	//64 input usages total (0x01 to 0x40)
0x15, 0x01,             // Logical Minimum (data bytes in the report may have minimum value = 0x00)
0x25, 0x40,             // Logical Maximum (data bytes in the report may have maximum value = 0x00FF = unsigned 255)
0x75, 0x08,             // Report Size: 8-bit field size
0x95, 0x40,             // Report Count: Make sixty-four 8-bit fields (the next time the parser hits an "Input", "Output", or "Feature" item)
0x81, 0x00,             // Input (Data, Array, Abs): Instantiates input packet fields based on the above report size, count, logical min/max, and usage.
0x19, 0x01,             // Usage Minimum
0x29, 0x40,             // Usage Maximum 	//64 output usages total (0x01 to 0x40)
0x91, 0x00,             // Output (Data, Array, Abs): Instantiates output packet fields.  Uses same report size and count as "Input" fields, since nothing new/different was specified to the parser since the "Input" item.
0xC0 

But it fails with: Windows error code 10. Insufficient resources to allocate needed memory

After searching the microchip forums I found the following descriptor

    0x06, 0x00, 0xff,              // USAGE_PAGE (Generic Desktop)
    0x09, 0x01,                    // USAGE (Vendor Usage 1)
    0xa1, 0x01,                    // COLLECTION (Application)
    
    0x85, 0x01,                    //   Report ID (1) 
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x95, 0x3F,                    //   REPORT_COUNT (64-1)
    0x19, 0x01,                    //   USAGE_MINIMUM (Vendor Usage 1)
    0x29, 0x40,                    //   USAGE_MAXIMUM (Vendor Usage 64)
    0x81, 0x02,                    //   INPUT (Data,Var,Abs)

    0x85, 0x02,                    //   Report ID (2) 
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x95, 0x3F,                    //   REPORT_COUNT (64-1)
    0x19, 0x01,                    //   USAGE_MINIMUM (Vendor Usage 1)
    0x29, 0x40,                    //   USAGE_MAXIMUM (Vendor Usage 64)
    0x91, 0x02,                    //   OUTPUT (Data,Var,Abs)
    
    0x85, 0x03,                    //   Report ID (3) 
    0x95, 0x3F,                    //   REPORT_COUNT (64-1)
    0x09, 0x01,                    //   USAGE (Vendor Usage 1)
    0xB1, 0x02,                    //   Feature (Data,Var,Abs)
    
    0xC0                           // END_COLLECTION

But it fails with: Extra end collection found or end collection not found.

It feels like I am missing something obvious but after a couple of days of struggling I cant seem to figure it out.

IN (to host pc) control transfers not working

In my testing I have not been able to get control transfers to send data from the MCU (SAM V71, on ultra xplained eval board) back to host PC. I am using libusb on the host side. On the MCU side, I am starting with the provided 'vendor' example, and just adding the bare minimum code to service a specific control transfer (mainly to APP_USBDeviceEventHandler()) - see app.c.txt attached.
app.c.txt

Expected behaviour:
Host PC application will be able to use libusb_control_transfer() to receive data from MCU without issue.

Observed behaviour:
The first libusb_control_transfer() appears to work correctly, then hangs on the next transaction. When I add the 'CONSOLE' and 'DEBUG' components via Harmony, I can see the following error message via EDBG COM port (the last message occurs on the second control transfer):
image

The MCU seems to fail other control endpoint requests after the first control transfer as well. For example if I only do one control transfer, then try to query the device descriptors, these requests also timeout/hang; it appears that the MCU is in some bad state.

Hopefully there is something wrong with my example.
Other things I've tried:

  • receiving data from PC via vendor control transfers : works just fine
  • performing vendor control requests with no data stage : also seems to work fine
  • changing amount of data to be sent by MCU for control transfer to host : does not seem to have any effect.

Issue when using stalls in vendor-defined control transfers outside of the interrupt context

This was seen in a vendor-defined application on an ATSAME51G19A running FreeRTOS.

USB transfers stop working when a bus stall is used to indicate an error in vendor-defined control transfers and is called outside of the interrupt context (deferred handling.) I traced this to the following reasons:

  1. DRV_USBFSV1_DEVICE_EndpointStall() calls _DRV_USBFSV1_DEVICE_IRPQueueFlush(), but when called outside of the interrupt context a new read IRP does not get submitted for endpoint 0, so new control transfers are never received. I was able to work around this by not calling _DRV_USBFSV1_DEVICE_IRPQueueFlush() if hDriver->isInInterruptContext is true.
  2. _USB_DEVICE_Ep0ReceiveCompleteCallback() is called on completion of the stall, which subsequently calls the application callback function. This calls driver functions which attempt to make nested calls to lock hDriver->mutexID resulting in a deadlock. This may work if recursive mutexes are enabled, but I worked around by returning immediately from _USB_DEVICE_Ep0ReceiveCompleteCallback() if (irpHandle->status == USB_DEVICE_IRP_STATUS_ABORTED) || (irpHandle->status == USB_DEVICE_IRP_STATUS_ABORTED_ENDPOINT_HALT).

Wrong size calculation of fullSpeedConfigurationDescriptor

Hello,

in my project iam trying to create a usb device with two CDC instances. So as suggested i'am using the Interface Association Desciptor
The size field in Configuration Descriptor is calculated wrong, when using Interface Association Descriptor

grafik

grafik
grafik

For the configuration this struct will be generated:

/*******************************************
 *  USB Full Speed Configuration Descriptor
 *******************************************/
const uint8_t fullSpeedConfigurationDescriptor[]=
{
	/* Configuration Descriptor */

    0x09,                                                   // Size of this descriptor in bytes
    USB_DESCRIPTOR_CONFIGURATION,                           // Descriptor Type
    USB_DEVICE_16bitTo8bitArrange(133),                      //(133 Bytes)Size of the Configuration descriptor
    4,                                                      // Number of interfaces in this configuration
    0x01,                                                   // Index value of this configuration
    0x00,                                                   // Configuration string index
    USB_ATTRIBUTE_DEFAULT | USB_ATTRIBUTE_SELF_POWERED, // Attributes
    50,
	
	
	/* Descriptor for Function - CDC     */ 
    /* Interface Association Descriptor: CDC Function*/
    0x08,   // Size of this descriptor in bytes
    0x0B,   // Interface association descriptor type
    0,   // The first associated interface
    0x02,   // Number of contiguous associated interface
    0x02,   // bInterfaceClass of the first interface
    0x02,   // bInterfaceSubclass of the first interface
    0x01,   // bInterfaceProtocol of the first interface
    0x00,   // Interface string index
	/* Interface Descriptor */

    0x09,                                                   // Size of this descriptor in bytes
    USB_DESCRIPTOR_INTERFACE,                               // Descriptor Type is Interface descriptor
    0,                                                      // Interface Number
    0x00,                                                   // Alternate Setting Number
    0x01,                                                   // Number of endpoints in this interface
    USB_CDC_COMMUNICATIONS_INTERFACE_CLASS_CODE,            // Class code
    USB_CDC_SUBCLASS_ABSTRACT_CONTROL_MODEL,                // Subclass code
    USB_CDC_PROTOCOL_AT_V250,                               // Protocol code
    0x00,                                                   // Interface string index

    /* CDC Class-Specific Descriptors */

    sizeof(USB_CDC_HEADER_FUNCTIONAL_DESCRIPTOR),                   // Size of the descriptor
    USB_CDC_DESC_CS_INTERFACE,                                      // CS_INTERFACE
    USB_CDC_FUNCTIONAL_HEADER,                                      // Type of functional descriptor
    0x20,0x01,                                                      // CDC spec version

    sizeof(USB_CDC_ACM_FUNCTIONAL_DESCRIPTOR),                      // Size of the descriptor
    USB_CDC_DESC_CS_INTERFACE,                                      // CS_INTERFACE
    USB_CDC_FUNCTIONAL_ABSTRACT_CONTROL_MANAGEMENT,                 // Type of functional descriptor
    USB_CDC_ACM_SUPPORT_LINE_CODING_LINE_STATE_AND_NOTIFICATION,    // bmCapabilities of ACM

    sizeof(USB_CDC_UNION_FUNCTIONAL_DESCRIPTOR_HEADER) + 1,         // Size of the descriptor
    USB_CDC_DESC_CS_INTERFACE,                                      // CS_INTERFACE
    USB_CDC_FUNCTIONAL_UNION,                                       // Type of functional descriptor
    0,                                                              // com interface number
    1,

    sizeof(USB_CDC_CALL_MANAGEMENT_DESCRIPTOR),                     // Size of the descriptor
    USB_CDC_DESC_CS_INTERFACE,                                      // CS_INTERFACE
    USB_CDC_FUNCTIONAL_CALL_MANAGEMENT,                             // Type of functional descriptor
    0x00,                                                           // bmCapabilities of CallManagement
    1,                                                              // Data interface number

    /* Interrupt Endpoint (IN) Descriptor */

    0x07,                                                   // Size of this descriptor
    USB_DESCRIPTOR_ENDPOINT,                                // Endpoint Descriptor
    1 | USB_EP_DIRECTION_IN,                                // EndpointAddress ( EP1 IN INTERRUPT)
    USB_TRANSFER_TYPE_INTERRUPT,                            // Attributes type of EP (INTERRUPT)
    0x10,0x00,                                              // Max packet size of this EP
    0x02,                                                   // Interval (in ms)

    /* Interface Descriptor */

    0x09,                                                   // Size of this descriptor in bytes
    USB_DESCRIPTOR_INTERFACE,                               // INTERFACE descriptor type
    1,                                                      // Interface Number
    0x00,                                                   // Alternate Setting Number
    0x02,                                                   // Number of endpoints in this interface
    USB_CDC_DATA_INTERFACE_CLASS_CODE,                      // Class code
    0x00,                                                   // Subclass code
    USB_CDC_PROTOCOL_NO_CLASS_SPECIFIC,                     // Protocol code
    0x00,                                                   // Interface string index

    /* Bulk Endpoint (OUT) Descriptor */

    0x07,                                                   // Size of this descriptor
    USB_DESCRIPTOR_ENDPOINT,                                // Endpoint Descriptor
    2 | USB_EP_DIRECTION_OUT,                               // EndpointAddress ( EP2 OUT )
    USB_TRANSFER_TYPE_BULK,                                 // Attributes type of EP (BULK)
    0x40, 0x00,                                             // Max packet size of this EP
    0x00,                                                   // Interval (in ms)

     /* Bulk Endpoint (IN)Descriptor */

    0x07,                                                   // Size of this descriptor
    USB_DESCRIPTOR_ENDPOINT,                                // Endpoint Descriptor
    2 | USB_EP_DIRECTION_IN,                                // EndpointAddress ( EP2 IN )
    0x02,                                                   // Attributes type of EP (BULK)
    0x40, 0x00,                                             // Max packet size of this EP
    0x00,                                                   // Interval (in ms)


	
	/* Descriptor for Function - CDC     */ 
    /* Interface Association Descriptor: CDC Function*/
    0x08,   // Size of this descriptor in bytes
    0x0B,   // Interface association descriptor type
    2,   // The first associated interface
    0x02,   // Number of contiguous associated interface
    0x02,   // bInterfaceClass of the first interface
    0x02,   // bInterfaceSubclass of the first interface
    0x01,   // bInterfaceProtocol of the first interface
    0x00,   // Interface string index
	/* Interface Descriptor */

    0x09,                                                   // Size of this descriptor in bytes
    USB_DESCRIPTOR_INTERFACE,                               // Descriptor Type is Interface descriptor
    2,                                                      // Interface Number
    0x00,                                                   // Alternate Setting Number
    0x01,                                                   // Number of endpoints in this interface
    USB_CDC_COMMUNICATIONS_INTERFACE_CLASS_CODE,            // Class code
    USB_CDC_SUBCLASS_ABSTRACT_CONTROL_MODEL,                // Subclass code
    USB_CDC_PROTOCOL_AT_V250,                               // Protocol code
    0x00,                                                   // Interface string index

    /* CDC Class-Specific Descriptors */

    sizeof(USB_CDC_HEADER_FUNCTIONAL_DESCRIPTOR),                   // Size of the descriptor
    USB_CDC_DESC_CS_INTERFACE,                                      // CS_INTERFACE
    USB_CDC_FUNCTIONAL_HEADER,                                      // Type of functional descriptor
    0x20,0x01,                                                      // CDC spec version

    sizeof(USB_CDC_ACM_FUNCTIONAL_DESCRIPTOR),                      // Size of the descriptor
    USB_CDC_DESC_CS_INTERFACE,                                      // CS_INTERFACE
    USB_CDC_FUNCTIONAL_ABSTRACT_CONTROL_MANAGEMENT,                 // Type of functional descriptor
    USB_CDC_ACM_SUPPORT_LINE_CODING_LINE_STATE_AND_NOTIFICATION,    // bmCapabilities of ACM

    sizeof(USB_CDC_UNION_FUNCTIONAL_DESCRIPTOR_HEADER) + 1,         // Size of the descriptor
    USB_CDC_DESC_CS_INTERFACE,                                      // CS_INTERFACE
    USB_CDC_FUNCTIONAL_UNION,                                       // Type of functional descriptor
    2,                                                              // com interface number
    3,

    sizeof(USB_CDC_CALL_MANAGEMENT_DESCRIPTOR),                     // Size of the descriptor
    USB_CDC_DESC_CS_INTERFACE,                                      // CS_INTERFACE
    USB_CDC_FUNCTIONAL_CALL_MANAGEMENT,                             // Type of functional descriptor
    0x00,                                                           // bmCapabilities of CallManagement
    3,                                                              // Data interface number

    /* Interrupt Endpoint (IN) Descriptor */

    0x07,                                                   // Size of this descriptor
    USB_DESCRIPTOR_ENDPOINT,                                // Endpoint Descriptor
    3 | USB_EP_DIRECTION_IN,                                // EndpointAddress ( EP3 IN INTERRUPT)
    USB_TRANSFER_TYPE_INTERRUPT,                            // Attributes type of EP (INTERRUPT)
    0x10,0x00,                                              // Max packet size of this EP
    0x02,                                                   // Interval (in ms)

    /* Interface Descriptor */

    0x09,                                                   // Size of this descriptor in bytes
    USB_DESCRIPTOR_INTERFACE,                               // INTERFACE descriptor type
    3,                                                      // Interface Number
    0x00,                                                   // Alternate Setting Number
    0x02,                                                   // Number of endpoints in this interface
    USB_CDC_DATA_INTERFACE_CLASS_CODE,                      // Class code
    0x00,                                                   // Subclass code
    USB_CDC_PROTOCOL_NO_CLASS_SPECIFIC,                     // Protocol code
    0x00,                                                   // Interface string index

    /* Bulk Endpoint (OUT) Descriptor */

    0x07,                                                   // Size of this descriptor
    USB_DESCRIPTOR_ENDPOINT,                                // Endpoint Descriptor
    4 | USB_EP_DIRECTION_OUT,                               // EndpointAddress ( EP4 OUT )
    USB_TRANSFER_TYPE_BULK,                                 // Attributes type of EP (BULK)
    0x40, 0x00,                                             // Max packet size of this EP
    0x00,                                                   // Interval (in ms)

     /* Bulk Endpoint (IN)Descriptor */

    0x07,                                                   // Size of this descriptor
    USB_DESCRIPTOR_ENDPOINT,                                // Endpoint Descriptor
    4 | USB_EP_DIRECTION_IN,                                // EndpointAddress ( EP4 IN )
    0x02,                                                   // Attributes type of EP (BULK)
    0x40, 0x00,                                             // Max packet size of this EP
    0x00,                                                   // Interval (in ms)



};

But the length of the whole field is 141 instead of 133.
so wTotalLength of Configuration Descriptors should be USB_DEVICE_16bitTo8bitArrange(141)

in a new project the size of 141 is correct.

Harmony USB 3.7.0

SDCard USB MSD crash

I have configured the following in the harmony configurator:
472fd75271

But after adding the MSD Function Driver to the configuration the device crashes after 1 à 2 minutes.
Before it crashes the windows machine times out on the SD Card. Windows recognizes the USB drive but when trying to access the windows machine hangs untill the device crashes or when i remove the SD card.

After debugging the system I found the following:
184685a13e

I coded some simple filesystem commands that I can manual execute to see if the SD Card works and I can success fully view the SD Card contents through the File System driver, but I can not get the MSD function driver to properly work.

I assume File System & MSD Function driver concurrently is a supported configuration as harmony lets me configure it, so I guess I ran in to a bug which I don't know you to debug further.

Also in the exception code thrown in exceptions.c has no enum defined for error code '2'. And I have not been able to find it in the datasheets yet (must be overlooking something cant seem to find it)

USB Host Hub Generated Code Doesn't Build

Please disregard the first edit of this ticket, as I was barking up the completely wrong tree. Following the USB Host tutorial, I'm able to build after generating code from Harmony. However, upon heading back into the configurator, and enabling hub support, the generated code fails to build, with undefined symbols. (Output below)

As well, adding a HID client driver, and enabling mouse and keyboard driver checkboxes causes build errors too. (This seems to be because the number of TPL entries is a read-only field in the configurator, based on the number of client drivers I have. Trying to enable both HID Keyboard and HID mouse adds two entries, which will cause the array to always be 1 larger than it's sized for. Playing around with it, I was actually able to get the entry number to go to 0, despite still having a client, so the generated code was always bad until I removed and re-added the Host Layer component) I can open a separate issue for that, if it's not just the case of me doing something wrong! 🙂

My build output looks like:

CLEAN SUCCESSFUL (total time: 11ms)
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'Y:/Users/cmd/Hardware/UsbTest/UsbHostTest/firmware/UsbHostTest.X'
make  -f nbproject/Makefile-default.mk dist/default/production/UsbHostTest.X.production.hex
make[2]: Entering directory 'Y:/Users/cmd/Hardware/UsbTest/UsbHostTest/firmware/UsbHostTest.X'
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/1171490990/usb_host_init_data.o.d" -o build/default/production/_ext/1171490990/usb_host_init_data.o ../src/config/default/usb_host_init_data.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/308758920/usb_host.o.d" -o build/default/production/_ext/308758920/usb_host.o ../src/config/default/usb/src/usb_host.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/308758920/usb_host_hub.o.d" -o build/default/production/_ext/308758920/usb_host_hub.o ../src/config/default/usb/src/usb_host_hub.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/1434821282/bsp.o.d" -o build/default/production/_ext/1434821282/bsp.o ../src/config/default/bsp/bsp.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/308758920/usb_host_msd.o.d" -o build/default/production/_ext/308758920/usb_host_msd.o ../src/config/default/usb/src/usb_host_msd.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/308758920/usb_host_scsi.o.d" -o build/default/production/_ext/308758920/usb_host_scsi.o ../src/config/default/usb/src/usb_host_scsi.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/60181895/plib_tmr2.o.d" -o build/default/production/_ext/60181895/plib_tmr2.o ../src/config/default/peripheral/tmr/plib_tmr2.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/1269487135/sys_fs.o.d" -o build/default/production/_ext/1269487135/sys_fs.o ../src/config/default/system/fs/src/sys_fs.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/1269487135/sys_fs_media_manager.o.d" -o build/default/production/_ext/1269487135/sys_fs_media_manager.o ../src/config/default/system/fs/src/sys_fs_media_manager.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/1269487135/sys_fs_fat_interface.o.d" -o build/default/production/_ext/1269487135/sys_fs_fat_interface.o ../src/config/default/system/fs/src/sys_fs_fat_interface.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/411819097/ff.o.d" -o build/default/production/_ext/411819097/ff.o ../src/config/default/system/fs/fat_fs/file_system/ff.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/411819097/ffunicode.o.d" -o build/default/production/_ext/411819097/ffunicode.o ../src/config/default/system/fs/fat_fs/file_system/ffunicode.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/565198302/diskio.o.d" -o build/default/production/_ext/565198302/diskio.o ../src/config/default/system/fs/fat_fs/hardware_access/diskio.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/1171490990/initialization.o.d" -o build/default/production/_ext/1171490990/initialization.o ../src/config/default/initialization.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/1360937237/main.o.d" -o build/default/production/_ext/1360937237/main.o ../src/main.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/1171490990/interrupts.o.d" -o build/default/production/_ext/1171490990/interrupts.o ../src/config/default/interrupts.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/1171490990/exceptions.o.d" -o build/default/production/_ext/1171490990/exceptions.o ../src/config/default/exceptions.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/163028504/xc32_monitor.o.d" -o build/default/production/_ext/163028504/xc32_monitor.o ../src/config/default/stdio/xc32_monitor.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/60165520/plib_clk.o.d" -o build/default/production/_ext/60165520/plib_clk.o ../src/config/default/peripheral/clk/plib_clk.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/2128569739/drv_usbfs.o.d" -o build/default/production/_ext/2128569739/drv_usbfs.o ../src/config/default/driver/usb/usbfs/src/drv_usbfs.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/1865254177/plib_gpio.o.d" -o build/default/production/_ext/1865254177/plib_gpio.o ../src/config/default/peripheral/gpio/plib_gpio.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/2128569739/drv_usbfs_host.o.d" -o build/default/production/_ext/2128569739/drv_usbfs_host.o ../src/config/default/driver/usb/usbfs/src/drv_usbfs_host.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/1865200349/plib_evic.o.d" -o build/default/production/_ext/1865200349/plib_evic.o ../src/config/default/peripheral/evic/plib_evic.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/1360937237/app.o.d" -o build/default/production/_ext/1360937237/app.o ../src/app.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/1171490990/tasks.o.d" -o build/default/production/_ext/1171490990/tasks.o ../src/config/default/tasks.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/101884895/sys_time.o.d" -o build/default/production/_ext/101884895/sys_time.o ../src/config/default/system/time/src/sys_time.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  
"C:\Program Files\Microchip\xc32\v2.41\bin\xc32-gcc.exe"    -g -x c -c -mprocessor=32MX470F512L  -ffunction-sections -O1 -I"../src/config/default/system/fs/fat_fs/file_system" -I"../src/config/default/system/fs/fat_fs/hardware_access" -I"../src" -I"../src/config/default" -I"../src/packs/PIC32MX470F512L_DFP" -Werror -Wall -MMD -MF "build/default/production/_ext/1881668453/sys_int.o.d" -o build/default/production/_ext/1881668453/sys_int.o ../src/config/default/system/int/src/sys_int.c    -DXPRJ_default=default  -no-legacy-libc    -mdfp="C:/Program Files (x86)/Microchip/MPLABX/v5.40/packs/Microchip/PIC32MX_DFP/1.3.231"  

In file included from ../src/config/default/definitions.h:53:0,
                 from ../src/config/default/usb_host_init_data.c:39:
../src/config/default/usb/usb_host_hub.h:76:21: error: unknown type name 'USB_HOST_CLIENT_DRIVER'
 /*DOM-IGNORE-BEGIN*/extern USB_HOST_CLIENT_DRIVER gUSBHostHUBClientDriver; /*DOM-IGNORE-END*/
                     ^
In file included from ../src/config/default/definitions.h:53:0,
                 from ../src/main.c:28:
../src/config/default/usb/usb_host_hub.h:76:21: error: unknown type name 'USB_HOST_CLIENT_DRIVER'
 /*DOM-IGNORE-BEGIN*/extern USB_HOST_CLIENT_DRIVER gUSBHostHUBClientDriver; /*DOM-IGNORE-END*/
                     ^
In file included from ../src/config/default/definitions.h:53:0,
                 from ../src/config/default/initialization.c:47:
../src/config/default/usb/usb_host_hub.h:76:21: error: unknown type name 'USB_HOST_CLIENT_DRIVER'
 /*DOM-IGNORE-BEGIN*/extern USB_HOST_CLIENT_DRIVER gUSBHostHUBClientDriver; /*DOM-IGNORE-END*/
                     ^
nbproject/Makefile-default.mk:301: recipe for target 'build/default/production/_ext/1171490990/usb_host_init_data.o' failed
nbproject/Makefile-default.mk:392: recipe for target 'build/default/production/_ext/1360937237/main.o' failed
make[2]: *** [build/default/production/_ext/1171490990/usb_host_init_data.o] Error 255
make[2]: *** Waiting for unfinished jobs....
In file included from ../src/config/default/usb/src/usb_host_hub.c:54:0:
../src/config/default/usb/src/usb_host_hub_local.h:243:5: error: unknown type name 'SYS_TMR_HANDLE'
     SYS_TMR_HANDLE timerHandle;
     ^
../src/config/default/usb/src/usb_host_hub.c: In function '_USB_HOST_HUB_DeviceAssign':
../src/config/default/usb/src/usb_host_hub.c:309:37: error: 'SYS_TMR_HANDLE_INVALID' undeclared (first use in this function)
             portInfo->timerHandle = SYS_TMR_HANDLE_INVALID;
                                     ^
../src/config/default/usb/src/usb_host_hub.c:309:37: note: each undeclared identifier is reported only once for each function it appears in
../src/config/default/usb/src/usb_host_hub.c: In function '_USB_HOST_HUB_PortTasks':
../src/config/default/usb/src/usb_host_hub.c:1092:13: error: pointer targets in passing argument 2 of 'SYS_TIME_DelayMS' differ in signedness [-Werror=pointer-sign]
             SYS_TIME_DelayMS(2 * hubInstance->hubDescriptor.bPwrOn2PwrGood , &portInfo->timerHandle  );
             ^
In file included from ../src/config/default/definitions.h:72:0,
                 from ../src/config/default/driver/usb/drv_usb_external_dependencies.h:48,
                 from ../src/config/default/usb/src/usb_host_hub_local.h:53,
                 from ../src/config/default/usb/src/usb_host_hub.c:54:
../src/config/default/system/time/sys_time.h:494:17: note: expected 'SYS_TIME_HANDLE *' but argument is of type 'int *'
 SYS_TIME_RESULT SYS_TIME_DelayMS ( uint32_t ms, SYS_TIME_HANDLE* handle );
                 ^
../src/config/default/usb/src/usb_host_hub.c:1093:17: error: 'SYS_TMR_HANDLE_INVALID' undeclared (first use in this function)
             if( SYS_TMR_HANDLE_INVALID != portInfo->timerHandle )
                 ^
make[2]: *** [build/default/production/_ext/1360937237/main.o] Error 255
nbproject/Makefile-default.mk:315: recipe for target 'build/default/production/_ext/308758920/usb_host_hub.o' failed
nbproject/Makefile-default.mk:399: recipe for target 'build/default/production/_ext/1171490990/initialization.o' failed
cc1.exe: all warnings being treated as errors
make[2]: *** [build/default/production/_ext/308758920/usb_host_hub.o] Error 255
In file included from ../src/config/default/definitions.h:53:0,
                 from ../src/config/default/tasks.c:54:
../src/config/default/usb/usb_host_hub.h:76:21: error: unknown type name 'USB_HOST_CLIENT_DRIVER'
 /*DOM-IGNORE-BEGIN*/extern USB_HOST_CLIENT_DRIVER gUSBHostHUBClientDriver; /*DOM-IGNORE-END*/
                     ^
In file included from ../src/config/default/definitions.h:53:0,
                 from ../src/config/default/interrupts.c:53:
../src/config/default/usb/usb_host_hub.h:76:21: error: unknown type name 'USB_HOST_CLIENT_DRIVER'
 /*DOM-IGNORE-BEGIN*/extern USB_HOST_CLIENT_DRIVER gUSBHostHUBClientDriver; /*DOM-IGNORE-END*/
                     ^
make[2]: *** [build/default/production/_ext/1171490990/initialization.o] Error 255
In file included from ../src/config/default/definitions.h:53:0,
                 from ../src/config/default/exceptions.c:50:
../src/config/default/usb/usb_host_hub.h:76:21: error: unknown type name 'USB_HOST_CLIENT_DRIVER'
 /*DOM-IGNORE-BEGIN*/extern USB_HOST_CLIENT_DRIVER gUSBHostHUBClientDriver; /*DOM-IGNORE-END*/
                     ^
In file included from ../src/config/default/definitions.h:53:0,
                 from ../src/config/default/driver/usb/drv_usb_external_dependencies.h:48,
                 from ../src/config/default/driver/usb/usbfs/src/drv_usbfs_local.h:57,
                 from ../src/config/default/driver/usb/usbfs/src/drv_usbfs.c:53:
../src/config/default/usb/usb_host_hub.h:76:21: error: unknown type name 'USB_HOST_CLIENT_DRIVER'
 /*DOM-IGNORE-BEGIN*/extern USB_HOST_CLIENT_DRIVER gUSBHostHUBClientDriver; /*DOM-IGNORE-END*/
                     ^
nbproject/Makefile-default.mk:476: recipe for target 'build/default/production/_ext/1171490990/tasks.o' failed
nbproject/Makefile-default.mk:406: recipe for target 'build/default/production/_ext/1171490990/interrupts.o' failed
make[2]: *** [build/default/production/_ext/1171490990/tasks.o] Error 255
make[2]: *** [build/default/production/_ext/1171490990/interrupts.o] Error 255
nbproject/Makefile-default.mk:413: recipe for target 'build/default/production/_ext/1171490990/exceptions.o' failed
nbproject/Makefile-default.mk:448: recipe for target 'build/default/production/_ext/2128569739/drv_usbfs.o' failed
make[2]: *** [build/default/production/_ext/1171490990/exceptions.o] Error 255
make[2]: *** [build/default/production/_ext/2128569739/drv_usbfs.o] Error 255
make[2]: Leaving directory 'Y:/Users/cmd/Hardware/UsbTest/UsbHostTest/firmware/UsbHostTest.X'
nbproject/Makefile-default.mk:91: recipe for target '.build-conf' failed
make[1]: Leaving directory 'Y:/Users/cmd/Hardware/UsbTest/UsbHostTest/firmware/UsbHostTest.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 1s)

C++ compatibility

\usb\driver\usbfs\src\templates\usb_LastTransactionDetails_Default.h is not c++ compatible
Missing casts

PLIB_TEMPLATE void USB_LastTransactionDetailsGet_Default( USB_MODULE_ID index , USB_BUFFER_DIRECTION * direction , USB_PING_PONG_STATE * pingpong , uint8_t * endpoint )
{
    volatile usb_registers_t   * usb = ((usb_registers_t *)(index));
    *direction = usb->UxSTAT.DIR;
    *pingpong = usb->UxSTAT.PPBI;
    *endpoint = usb->UxSTAT.ENDPT;
}

Need to cast to specific types

PLIB_TEMPLATE void USB_LastTransactionDetailsGet_Default( USB_MODULE_ID index , USB_BUFFER_DIRECTION * direction , USB_PING_PONG_STATE * pingpong , uint8_t * endpoint )
{
    volatile usb_registers_t   * usb = ((usb_registers_t *)(index));
    *direction = (USB_BUFFER_DIRECTION)(usb->UxSTAT.DIR);
    *pingpong = (USB_PING_PONG_STATE)(usb->UxSTAT.PPBI);
    *endpoint = (uint8_t)(usb->UxSTAT.ENDPT);
}

there a maybe some more files without c++ compatiblity.

Harmony Core Console Service takes the only USB Device instances

How do I combine the multiple USB devices functions that required their own event handling?

I tried the following two test:

  1. 2x CDC instances:
    • CDC 1 using the Console Service + Command Service.
    • CDC 2 connected through to a UART peripheral to create a USB CDC UART bridge (following the cdc_com_port_single example project).
  2. 1x CDC Instance & 1x HID Instance.
    • CDC instance using the Console Service
    • HID instance following the hid_joystick example project.

While trying this I ran in to a problem that I couldn't open the USB Device.
After some time i found that the Console Service already calls the USB_DEVICE_Open( USB_DEVICE_INDEX_0) and attaches the USBDeviceEventHandler and the necessary USBDeviceCDCEventHandler.
Because the USB Device is already opened I have no way to set:

  • CDC event handler for the UART Bridge code.
  • HID event handler for the joystick code.

It seems to me that I need a unified USBDeviceEventHandler . But the Console Service doesn't seem to expose any way of adding the other necessary CDC/HID event handlers to its USBDeviceEventHandler.
Some old Harmony 1.1 documentation that talked about multiple USB Device Instances but that doesn't seem to exists in Harmony 3, or at least not in the configurator.

Is there some API part that I missed that would allow me to set all the event handlers that I need. Or is this some limitation form the USB frame work/Console Service?

For these small test I can remove the Console Service and do without.
But for my actual project this is not really option because other Harmony libraries use the Console Service like the TCP/IP stack that provides some command line utilities.

USB MSD-base example compile failed on linux machine

USB example usb_host_msd_bootloader/test_app/firmware/sam_e54_xpro.X/ shows compile error as bellow:

make[2]: *** No rule to make target '..\src\config\sam_e54_xpro\ATSAME54P20A.ld', needed by 'dist/sam_e54_xpro/production/sam_e54_xpro.X.production.hex'. Stop.
make[2]: *** Waiting for unfinished jobs....


harmony is updated to latest version:
USB : v3.7.0
BSP: v3.8.2
CORE: v3.8.1

XC32: V2.41
Product Version: MPLAB X IDE v5.40
Java: 1.8.0_202; OpenJDK 64-Bit Server VM 25.202-b05
Runtime: OpenJDK Runtime Environment 1.8.0_202-b05
System: Linux version 4.15.0-72-generic running on amd64; UTF-8; en_US (mplab)

USB Driver - Function Missing in Header

The DRV_USBFSV1_Deinitialize() function is defined in the .c files but never in the header file drv_usbfsv1.h.

Using the latest release on the SAME53 with the CDC Function driver, USB device layer, and USB Full speed driver blocks in the MCC.

Deadlock in `USB_DEVICE_Detach()`

There's a deadlock when calling USB_DEVICE_Detach()

Cause of the deadlock

If USB_DEVICE_Detach() is called from a non-interrupt context, a mutex is locked:

if(OSAL_MUTEX_Lock((OSAL_MUTEX_HANDLE_TYPE *)&hDriver->mutexID, OSAL_WAIT_FOREVER) == OSAL_RESULT_TRUE)

USB_DEVICE_Detach() then calls DRV_USBDP_EndpointDisable()...

DRV_USBDP_EndpointDisable((DRV_HANDLE)hDriver, DRV_USB_DEVICE_ENDPOINT_ALL);

... which then proceeds to try to lock the same mutex, with a timeout of OSAL_WAIT_FOREVER:

if(OSAL_MUTEX_Lock((OSAL_MUTEX_HANDLE_TYPE *)&hDriver->mutexID, OSAL_WAIT_FOREVER) == OSAL_RESULT_TRUE)

This sequence is guaranteed to cause a deadlock (assuming USB_DEVICE_Detach() is not called from an interrupt context).

Steps leading to the deadlock

I encountered this problem when trying to use both FreeRTOS and the default USB stack on a SAM G55 XPlained Pro board.

The docs say to call USB_DEVICE_Detach() in response to the USB_DEVICE_EVENT_POWER_REMOVED (1).

But the VBUS monitoring occurrs in DRV_USBDP_Tasks(), which is called in a task context (not an interrupt context) when using FreeRTOS. This means that when the USB_DEVICE_EVENT_POWER_REMOVED event is passed into the task event handler, the task is not running in an interrupt context

Why does the demo project work?

Calling USB_DEVICE_Detach() in the G55 cdc_com_port_single demo project works, because the OSAL implementation used is osal_implementation_basic.h. In this implementation, the mutex locking doesn't take the timeout into account, so the deadlock doesn't occur:
https://github.com/Microchip-MPLAB-Harmony/usb_apps_device/blob/e8089912b07a7c4eaec5d5ee81c6929badfc9a9f/apps/cdc_com_port_single/firmware/src/config/sam_g55_xpro/osal/osal_impl_basic.h#L274-L282

I've not got the hardware to test one of the FreeRTOS demo projects, so I can't say if they work

Thanks,
-Jon

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.