2015-04-29 01:39 AM
Hi,
I'm trying to interface an USB barcode with discovery board F407. I'm using CubeMX 4.7 and keyboard example as starting point from Cube USB HOST library. With some keyboards and usb wireless presenters (logitech) everything works, but with other keyboards and with barcode readers the USB library recognizes the device but then enter in stall. In particular in the case CTRL_DATA_IN_WAIT of function USBH_HandleControl in file usbh_ctlreq.c: case CTRL_DATA_IN_WAIT: URB_Status = USBH_LL_GetURBState(phost , phost->Control.pipe_in); /* check is DATA packet transferred successfully */ if (URB_Status == USBH_URB_DONE) { phost->Control.state = CTRL_STATUS_OUT; } /* manage error cases*/ if (URB_Status == USBH_URB_STALL) { /* In stall case, return to previous machine state*/ status = USBH_NOT_SUPPORTED; /* HERE THE CODE ENTER LOOP */ } else if (URB_Status == USBH_URB_ERROR) { /* Device error */ phost->Control.state = CTRL_ERROR; Seems that the code, in case of stall, does not return to previous machine state as stated in the above comment (and so skip the URB packet not recognized) but remains in this loop forever. This is the same situation from this old post: https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/USB%20state%20machine%20hangs%20with%20some%20usb%20keys¤tviews=667 but the suggested modification does not work for me. I'm open to advice to move on Thanks in advance #host #usb #stall #barcode2015-05-16 07:15 AM
So,
I've tested same devices (keyboards, USB barcode scanners, Wireless USB barcode) with VNC2 (Vinculum II) from FTDI and Tiva microcontroller: their libraries works well.Therefore I must conclude that the problem stems from the STM32 USB library.2015-07-23 01:27 AM
*bump*
I have the exact same problem. The barcode reader is stuck in USBH_URB_STALL state.In case CTRL_DATA_IN_WAIT it is checking the IN pipe while looking at the pipes it seems that the OUT pipe is in state USBH_URB_DONE. Can it be that this hid 'keyboard' acts differently and those states don't work for all hid devices ?PS: I've worked with mouses and two mouses that seem the same act differently and to make one of them work I had to change the code in USBH_CtlReq to skip CTRL_SETUP state .. it seemed like a temporary fix at the time.2015-09-01 07:21 AM
Hi,
I have same problem. Temporary i have a solution. In the usbh_hid.c file in the USBH_HID_Process function I leave out the HID_IDLE case. I tested it with two keyboard and two type barcode reader. All of them work for me. Please check it out.static USBH_StatusTypeDef USBH_HID_Process(USBH_HandleTypeDef *phost){ USBH_StatusTypeDef status = USBH_OK; HID_HandleTypeDef *HID_Handle = (HID_HandleTypeDef *) phost->pActiveClass->pData; switch (HID_Handle->state) { case HID_INIT: HID_Handle->Init(phost); HID_Handle->state = HID_SYNC; /*leave out HID_IDLE state, stuck in stall some device*/ break; case HID_IDLE: if(USBH_HID_GetReport (phost, 0x01, 0, HID_Handle->pData, HID_Handle->length) == USBH_OK) { fifo_write(&HID_Handle->fifo, HID_Handle->pData, HID_Handle->length); HID_Handle->state = HID_SYNC; } break;2015-11-12 10:02 AM
I bought a discoveryF4 to use it as HID host.
I used latest cubeMX, and thus HAL and USB Host libraries. I tried three keyboards and a mouse, all of them in boot protocol. Only one of the keyboards returns reports (this one works flawlessly). I tried the modification that fulop.zsolt shared, but nothing changed. It's very strange that a mature product as this MCU is, isn't able to work with standard boot HID devices. I spent so many hours trying to find where the problem is, unsucessfuly. I hope someone more experienced can give some clue to where to aim. The code is so simple, but here are the main points of interest: main.c ------ while (1) { MX_USB_HOST_Process(); } usb_host.c ----------------------- void USBH_HID_EventCallback(USBH_HandleTypeDef *phost) { printf(''Event''); } ----------------------- Microsoft comfort 2000 ----------------------- This keyboard fails in: usbh_hid.c ---------- After calling USBH_InterruptReceiveData, code reaches: case HID_POLL: if(USBH_LL_GetURBState(phost , HID_Handle->InPipe) == USBH_URB_DONE) USBH_LL_GetURBState always returns USBH_URB_IDLE, and no report is ever received. ----------------------- Razer BlackWidow Ultimate 2014 ----------------------- This keyboard fails in: usbh_ctlreq.c ------------- static USBH_StatusTypeDef USBH_HandleControl (USBH_HandleTypeDef *phost) in CTRL_DATA_IN_WAIT state USBH_LL_GetURBState returns USBH_URB_STALL. Any ideas? Thank you so much.2017-05-16 05:13 AM
Its working.
Thank you