dlizewski commented on code in PR #18815:
URL: https://github.com/apache/nuttx/pull/18815#discussion_r3156711847


##########
include/nuttx/usb/usbhost.h:
##########
@@ -1326,6 +1326,32 @@ int usbhost_waiter_initialize(FAR struct 
usbhost_connection_s *conn);
 void usbhost_drivers_initialize(void);
 #endif
 
+#ifdef CONFIG_USBHOST_CONFIGURATION_SELECTION
+
+/****************************************************************************
+ * Name: usbhost_select_configuration
+ *
+ * Description:
+ *   Board specific function to select the correct USB configuration
+ *   for a given device. The function may use the device descriptor
+ *   or make additional requests using the hport to decide which
+ *   configuration to use.
+ *
+ * Input Parameters:
+ *   hport - The port for the USB device
+ *   devdesc - The device descriptor of the USB device
+ *   id - device identification
+ *
+ * Returned Value:
+ *   USB configuration index to use.
+ *
+ ****************************************************************************/
+
+int usbhost_select_configuration(FAR struct usbhost_hubport_s *hport,

Review Comment:
   done



##########
boards/arm/stm32h5/nucleo-h563zi/src/stm32_usb.c:
##########
@@ -226,11 +226,32 @@ void stm32h5_usbhost_vbusdrive(int port, bool enable)
   /* The Nucleo-h563zi doesn't have hardware for a vbus drive.
    * Instead to get host working, you need to put an extra jumper
    * on the "PWR SEL" to jump "STLK" and "USB USER".
-   * This effectively supplies 5V power form the STLink to the USB device.
-   * The power output is limited so only relatively low power
+   * This effectively supplies 5V power from the STLink to the USB device.
+   * The power output is limited, so only relatively low power
    * devices can work.
    */
 }
 #endif
 
+#ifdef CONFIG_USBHOST_CONFIGURATION_SELECTION
+int usbhost_select_configuration(FAR struct usbhost_hubport_s *hport,
+                                 FAR const struct usb_devdesc_s *devdesc,
+                                 FAR const struct usbhost_id_s *id)
+{
+  if (id->vid == 0x0bda && id->pid == 0x8153)

Review Comment:
   The problem is that the configuration needs to be selected before the host 
drivers are called.
   
   Right now the code is:
   ```
   set config X
   for each host driver {
     if(host matches){
       break
     }
   }
   ```
   
   The other approach I tried is to cycle the configs until we find a host 
driver that matches.
   Something like:
   
   ```
   for each config c {
     set config c
     for each host driver {
       if(host matches){
         goto exit
       }
     }
   }
   
   ```
   
   But I ran into some problems with certain host class drivers failing the 2nd 
time it was iniitalized for a given device. Likely a bug that could be solved 
if we think that is a better approach.
   
   The other thing to note is that I dont really need this configuration 
selection. I added CDC-ECM since certain modems I need support ECM. On the 
modems they are configuration 0.
   
   I added this configuration selection because the CDC-ECM USB-Ethernet 
adapters that I have present ECM as the 2nd interface and I wanted to provide 
testing logs using a standard off the shelf product.
   
   But if we can accept logs from a custom board with modems (or a build where 
I temporarily hard-code it to 1 instead of 0) then I could revert the 
configuration selection portion until it is actually needed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to