Fabio Utzig
2012-09-14 00:35:46 UTC
Hi,
Today when trying to run mspdebug with and EZ430-F2013 dev board on a Mac I found an interesting problem. When mspdebug runs on this specific board, it first checks the number of configurations (bNumConfigurations) and if it has only 1, it will download a .hex file to the board I try to restart the board which should now have 2 configurations. When trying to switch to the second configuration it always gets in error and dies.
While debugging this I found that after downloading the FW on the board it does an usb_reset. On the Darwin backend the usb_reset turns into this call (libusb/os/darwin_usb.c:1215):
kresult = (*(dpriv->device))->ResetDevice (dpriv->device);
Checking Apple's documentation here:
https://developer.apple.com/library/mac/#documentation/IOKit/Reference/IOUSBDeviceInterface_reference/translated_content/IOUSBDeviceInterface.html
It states:
"It will not reenumerate the device, which means that the cached device descriptor values will not be updated after the reset. (If you want the IOUSBFamily to reload the cached values, use the call USBDeviceReEnumerate)."
So I add the new call to USBDeviceReEnumerate just after the call to ResetDevice and now it seems to be working fine.
I never used libusb before and I'm not very much into USB internals so I'm not really sure if this fix will not have side effects or if there's another way of fixing this without this modification. Anyway I'm sending a patch attached with the proposed fix.
Best Regards,
Today when trying to run mspdebug with and EZ430-F2013 dev board on a Mac I found an interesting problem. When mspdebug runs on this specific board, it first checks the number of configurations (bNumConfigurations) and if it has only 1, it will download a .hex file to the board I try to restart the board which should now have 2 configurations. When trying to switch to the second configuration it always gets in error and dies.
While debugging this I found that after downloading the FW on the board it does an usb_reset. On the Darwin backend the usb_reset turns into this call (libusb/os/darwin_usb.c:1215):
kresult = (*(dpriv->device))->ResetDevice (dpriv->device);
Checking Apple's documentation here:
https://developer.apple.com/library/mac/#documentation/IOKit/Reference/IOUSBDeviceInterface_reference/translated_content/IOUSBDeviceInterface.html
It states:
"It will not reenumerate the device, which means that the cached device descriptor values will not be updated after the reset. (If you want the IOUSBFamily to reload the cached values, use the call USBDeviceReEnumerate)."
So I add the new call to USBDeviceReEnumerate just after the call to ResetDevice and now it seems to be working fine.
I never used libusb before and I'm not very much into USB internals so I'm not really sure if this fix will not have side effects or if there's another way of fixing this without this modification. Anyway I'm sending a patch attached with the proposed fix.
Best Regards,
--
Fabio Utzig
Fabio Utzig