USB-HID working with IIO but now with hidraw subsystem

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
aicastell
Posts: 12
Joined: Tue Sep 04, 2018 11:03 am
Has thanked: 6 times

USB-HID working with IIO but now with hidraw subsystem

Postby aicastell » Thu Nov 29, 2018 8:44 am

Hello forum.

My uC is connected to a Linux kernel through a USB interface. It is running Chibios 16.1.0 firmware to send data collected from HID sensors to the Linux kernel. Running on a Linux kernel 4.x, the application can receive data through Industrial I/O subsystem (IIO) and consume them. That works really nice.

I have tryied to use this Chibios firmware with an older Linux kernel 3.x. The problem I found is kernel 3.x doesn't provide that IIO subsystem.

To fix this I tried enabling hidraw subsystem in that 3.x kernel to consume data. But any data is received though /dev/hidrawX.

Is there something missing on Chibios side that must be implemented to enable communications with that hidraw subsystem?

I can provide any relevant source code details you need to review this.

Thanks a lot in advance!

User avatar
Giovanni
Site Admin
Posts: 11480
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 454 times
Been thanked: 375 times
Contact:

Re: USB-HID working with IIO but now with hidraw subsystem

Postby Giovanni » Thu Nov 29, 2018 9:10 am

Hi,

Are you using USB CDC? ChibiOS Serial_USB driver does not implement all CDC messages, if it gets an unsupported message it stops the communication. You need to implement the messages you need in your application code.

Anyway, 16.1.0 is way out of maintenance, you better update to new versions.

Giovanni

aicastell
Posts: 12
Joined: Tue Sep 04, 2018 11:03 am
Has thanked: 6 times

Re: USB-HID working with IIO but now with hidraw subsystem

Postby aicastell » Thu Nov 29, 2018 10:18 am

The firmware is implemented as a composite USB-device with diferent configurations, and in some configurations we use the CDC serial driver. But the active configuration we are talking about doesn't use Serial_USB driver, just HID sensors.

Using wireshark to check the traffic through the USB, we can see a single GET_REPORT request/response when we read the /sys/bus/iio/devices/X sensor. However, there is no traffic on the USB bus when reading the /dev/hidrawX device.

icastell
Posts: 10
Joined: Wed Jun 08, 2016 11:43 am
Has thanked: 1 time
Been thanked: 1 time

Re: USB-HID working with IIO but now with hidraw subsystem

Postby icastell » Mon Dec 03, 2018 2:02 pm

Sniffing USB traffic with tcpdump we captured an INTERRUPT SUBMIT packet from host to uC device when we execute:

# cat /dev/hidrawX

The capture was done with this command:

# tcpdump -XX -v -i 10

08:41:00.765323 INTERRUPT SUBMIT from 3:21:5
0x0000: 0071 51ee 0000 0000 5301 8515 0300 2d3c .qQ.....S.....-<
0x0010: 0cde 045c 0000 0000 8bad 0b00 8dff ffff ...\............
0x0020: 0d00 0000 0000 0000 0000 0000 0000 0000 ................
0x0030: 0800 0000 0000 0000 0402 0000 0000 0000 ................

As you can see, there is no response from the uC to the host.

To debug that I have tried to switch on a led on different RSI, USBConfig and EndPoint callbacks. But none callback seems to switch on the led when I execute the "cat" command. So I don't know what code receives that packet in order to manage the response properly.

In general it's being really hard to debug this problem...

sabdulqadir
Posts: 12
Joined: Fri Mar 23, 2018 7:29 pm
Has thanked: 6 times
Been thanked: 2 times

Re: USB-HID working with IIO but now with hidraw subsystem

Postby sabdulqadir » Mon Dec 10, 2018 8:18 pm

Hi,
I do not have much experience with HID, but my two cents, try placing your led turn-on in:

Code: Select all

static void usb_lld_serve_interrupt(USBDriver *usbp) {
  ...
  /* IN/OUT endpoints event handling.*/
  src = otgp->DAINT;

}

in os/hal/ports/STM32/.....hal_usb_lld.c

You should be able to trace from there if you may...

Thanks,
AQ

skute
Posts: 64
Joined: Wed Aug 29, 2012 10:17 pm

Re: USB-HID working with IIO but now with hidraw subsystem

Postby skute » Mon Jan 07, 2019 8:17 pm

The difference seems to be that using /sys/bus/iio/devices/X sensor results in a GET_REPORT which is a control request and using /dev/hidrawX results in an interrupt read request. For the device to respond to the interrupt read request your software needs to send something on that endpoint (otherwise it will NAK).


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 2 guests