Hello, JuroV.
The description of the problems follows bellow.
I am trying to use the Serial CDC Host example to connect to a GPRS Modem by USB using the MC52259DEMO board. I tried it with several modems including the Motorola H24, G24 and my CellPhone.
The attachment proccess starts and goes smoothly until "usb_class_cdc_get_acm_line_coding" is called in "usb_host_cdc_data_event".
After a lot of debugging I was able to pinpoint the motive.
USB requests are proccessed by "_usb_khci_task" in my board. This task reads a task queue, processes the current task if the queue is not empty and calls "_usb_khci_process_tr_complete" when the task is completed.
"_usb_khci_process_tr_complete" in turn calls back the task callback function.
The deadlock is created as follows:
- "_usb_khci_process_tr_complete" is called and executes "usb_host_cdc_data_event" with the event code <USB_INTF_EVENT>.
- "usb_host_cdc_data_event" calls "usb_class_cdc_get_acm_line_coding"
- "usb_class_cdc_get_acm_line_coding" enqueues a new USB task and waits for it to callback "usb_class_cdc_cntrl_callback" through the following line of code: <_lwevent_wait_ticks(event, USB_ACM_CTRL_PIPE_FREE | USB_ACM_DETACH, FALSE, 0);>
- Unfortunately the callback would be called by "_usb_khci_task" which is blocked by its execution of "usb_class_cdc_get_acm_line_coding", so it will never happen, thus the deadlock.
Well, I fixed the problem above by not waiting the event and thus releasing the flow. Apparently it was enough to conclude the device initialization (the complete DEBUG_LOG_TRACE goes as attachment). But as soon as I open the USB with fopen it starts to continuously receive data packages of 192 bytes with are interpreted as NAK by the driver and discarded generating am error 151(USBERR_TR_FAILED ).
At this point I am unable to send ot receive any information from the device.