Linux Odrive USB protocol problem

Hello there

I am currently in the process of developing a native Linux driver for the ODrive, because I want to learn to develop drivers and this seems like a great device to do so for.
But I’m not getting an response from the ODrive. I’ve flashed the V3.6 firmware to the device.

When I analyze the traffic in wireshark I can see that the packets match. But when I open an debug session via the ST Link to the Odrive I noticed that the packet that is processed only contains NULL.

The following hex dump is a working packet from the odrivetool

USB URB
[Source: host]
[Destination: 2.5.3]
URB id: 0xffff9925fbe7c6c0
URB type: URB_SUBMIT (‘S’)
URB transfer type: URB_BULK (0x03)
Endpoint: 0x03, Direction: OUT
Device: 5
URB bus id: 2
Device setup request: not relevant (’-’)
Data: present (0)
URB sec: 1564506936
URB usec: 66928
URB status: Operation now in progress (-EINPROGRESS) (-115)
URB length [bytes]: 12
Data length [bytes]: 12
[Response in: 41]
[bInterfaceClass: Device (0x00)]
Unused Setup Header
Interval: 0
Start frame: 0
Copy of Transfer Flags: 0x00000000
Number of ISO descriptors: 0

0000 c0 c6 e7 fb 25 99 ff ff 53 03 03 05 02 00 2d 00
0010 38 7b 40 5d 00 00 00 00 70 05 01 00 8d ff ff ff
0020 0c 00 00 00 0c 00 00 00 00 00 00 00 00 00 00 00
0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0040 81 00 00 80 00 02 00 00 00 00 01 00

This is my packet

USB URB
[Source: host]
[Destination: 2.8.3]
URB id: 0xffff96daaf3efbc0
URB type: URB_SUBMIT (‘S’)
URB transfer type: URB_BULK (0x03)
Endpoint: 0x03, Direction: OUT
Device: 8
URB bus id: 2
Device setup request: not relevant (’-’)
Data: present (0)
URB sec: 1564653447
URB usec: 377160
URB status: Operation now in progress (-EINPROGRESS) (-115)
URB length [bytes]: 12
Data length [bytes]: 12
[Response in: 6]
[bInterfaceClass: Unknown (0xffff)]
Unused Setup Header
Interval: 0
Start frame: 0
Copy of Transfer Flags: 0x00000000
Number of ISO descriptors: 0

0000 c0 fb 3e af da 96 ff ff 53 03 03 08 02 00 2d 00
0010 87 b7 42 5d 00 00 00 00 48 c1 05 00 8d ff ff ff
0020 0c 00 00 00 0c 00 00 00 00 00 00 00 00 00 00 00
0030 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0040 81 00 00 80 40 00 00 00 00 00 01 00

The destination is different because I disconnected and reconnected the device between captures.
As you can see the packets are identical and I get an URB_Complete right after it.

To submit the packet from my driver I use the usb_bulk_msg call.
Anybody got any suggestions or ideas?

Kind regards

It looks like you are requesting a different return size in your packet than the Odrivetool is. 8100 0080 4000 instead of 8100 0080 0002. Take a look at my thread about connecting to the Odrive using Java. It might help.

Thanks for the suggestion. I just tried to increase the packetsize to 512 but still the buffer on the odrive contains no data. I will check out your thread to see if it can help me.
Thanks :smile:

The return size you are requesting should match the size in bytes that correspond with the endpoint you are accessing. If the value is not correct, the Odrive will not respond.

I found my error. My out buffer was created on the stack, but it should have been created on the heap with an kmalloc call.
The only weird part is that wireshark reported the correct packet.
Thanks for your help either way.
@Riewert I am going to use your post as an reference for the protocol. It is an great write up. Maybe an suggestion to reference that in the protocol description of the Odrive.

1 Like

Glad to help, good luck!