Terry
I loaded the Segger OpenSDA and then it works (with P&E OpenSDA it doesn't) - I didn't realise that it was possible to have code that only works when a certain debugger is loaded but maybe it is because the semi-hosting requires a corresponding debugger to be available to handle the breakpoints (?).
Also, it only works when debuging with KDS and not when the board is just powered by itself.
Your problem is that when the host sends a SetConfiguration (interface 1) your device is responding with a zero data paket (correct) but is it responding with a DATA0 packet, rather than a DATA1 packet and the host rejects this because it is incorrect.
After 5s or so of waiting (the device doesn't send anything else) the host restets the connection and tries again. The same repeats after the reset but sometimes also the SetAddress fails with the device returning malformed frames back - this again causes reset and it goes on forever like this (randomly failing on the SetAddress or the SetInterface).
This is also seen at the semi-hosting output:
SEGGER J-Link GDB Server V4.98b - Terminal output channel
USB_DEV_EVENT_BUS_RESET
USB_DEV_EVENT_BUS_RESET
USB_DEV_EVENT_ENUM_COMPLETE
USB_DEV_EVENT_BUS_RESET
USB_DEV_EVENT_DATA_RECEIVED
USB_DEV_EVENT_SEND_COMPLETE
got one raw packet
USB_DEV_EVENT_BUS_RESET
USB_DEV_EVENT_DATA_RECEIVED
USB_DEV_EVENT_BUS_RESET
USB_DEV_EVENT_BUS_RESET
USB_DEV_EVENT_BUS_RESET
USB_DEV_EVENT_ENUM_COMPLETE
got one raw packet
USB_DEV_EVENT_BUS_RESET
I have no explanation as to why it works with the analyser operating, unless it puts the interface into a promiscuous mode of some sort that allows receiving incorrect DATA packets (?)
Unfortunately these are fairly low-level driver problems - unless you broke something you may have uncovered latent bugs by changing the enumeration sequence length, for example.
Regards
Mark