* usb_8dev: USB Protocoll available?
@ 2012-12-14 16:52 Uwe Bonnes
2012-12-14 18:33 ` Marc Kleine-Budde
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Uwe Bonnes @ 2012-12-14 16:52 UTC (permalink / raw)
To: linux-can
Hello,
is there some document describing the protocoll used for the usb_8dev? I
have STM32 hardware with USB and CAN connected and think about writing some
firmware compatible with some existing adapter.
Otherwise, are the github projects
saeugetier / usb2can
shackspace / usb2can
for usb to can hardware related to this driver??
Thanks
--
Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: usb_8dev: USB Protocoll available?
2012-12-14 16:52 usb_8dev: USB Protocoll available? Uwe Bonnes
@ 2012-12-14 18:33 ` Marc Kleine-Budde
2012-12-14 19:25 ` Bernd Krumboeck
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Marc Kleine-Budde @ 2012-12-14 18:33 UTC (permalink / raw)
To: Uwe Bonnes; +Cc: linux-can
[-- Attachment #1: Type: text/plain, Size: 818 bytes --]
On 12/14/2012 05:52 PM, Uwe Bonnes wrote:
> is there some document describing the protocoll used for the usb_8dev? I
> have STM32 hardware with USB and CAN connected and think about writing some
> firmware compatible with some existing adapter.
>
> Otherwise, are the github projects
>
> saeugetier / usb2can
>
> shackspace / usb2can
>
> for usb to can hardware related to this driver??
Have a look at the driver from Bernd Krumboeck on the list here [1].
Marc
[1] http://www.spinics.net/lists/linux-usb/msg76025.html
--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 261 bytes --]
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: usb_8dev: USB Protocoll available?
2012-12-14 16:52 usb_8dev: USB Protocoll available? Uwe Bonnes
2012-12-14 18:33 ` Marc Kleine-Budde
@ 2012-12-14 19:25 ` Bernd Krumboeck
2012-12-15 6:31 ` Bernd Krumboeck
2012-12-15 7:09 ` Bernd Krumboeck
3 siblings, 0 replies; 8+ messages in thread
From: Bernd Krumboeck @ 2012-12-14 19:25 UTC (permalink / raw)
To: Uwe Bonnes; +Cc: linux-can
Hi!
Sorry, there is no document at the moment. The mentioned github projects are not related.
But I'll try to explain the protocol:
The controller use big endian for all values.
/* urb endpoints */
enum usb_8dev_endpoint {
USB_8DEV_ENDP_DATA_RX = 1,
USB_8DEV_ENDP_DATA_TX,
USB_8DEV_ENDP_CMD_RX,
USB_8DEV_ENDP_CMD_TX
};
-------------------------------------------------------------------------
The command frame for endpoint 3 and 4:
struct __packed usb_8dev_cmd_msg {
u8 begin; /* always 0x11 */
u8 channel; /* unkown - always 0 */
u8 command; /* command to execute */
u8 opt1; /* optional parameter / return value */
u8 opt2; /* optional parameter 2 */
u8 data[10]; /* optional parameter and data */
u8 end; /* always 0x22 */
};
After executing a command the return value (opt1) will be set to 0 (= success) or 255 (= error).
/* available commands */
enum usb_8dev_cmd {
USB_8DEV_RESET = 1,
USB_8DEV_OPEN,
USB_8DEV_CLOSE,
USB_8DEV_SET_SPEED,
USB_8DEV_SET_MASK_FILTER,
USB_8DEV_GET_STATUS,
USB_8DEV_GET_STATISTICS,
USB_8DEV_GET_SERIAL,
USB_8DEV_GET_SOFTW_VER,
USB_8DEV_GET_HARDW_VER,
USB_8DEV_RESET_TIMESTAMP,
USB_8DEV_GET_SOFTW_HARDW_VER
};
Command RESET:
Reset the microcontroller on the board.
Not used by the driver.
Command OPEN:
Open can bus
outmsg.command = USB_8DEV_OPEN
outmsg.opt1 = USB_8DEV_BAUD_MANUAL
outmsg.data[0] = prop_seg + phase_seg1
outmsg.data[1] = phase_seg2
outmsg.data[2] = sjw
outmsg.data[3-4] = brp
outmsg.data[5-8] = flags
opt1:
1000 kb/s - 0x00
800 kb/s - 0x01
500 kb/s - 0x02
250 kb/s - 0x03
125 kb/s - 0x04
100 kb/s - 0x05
50 kb/s - 0x06
20 kb/s - 0x07
10 kb/s - 0x08
manual - 0x09
flags:
SILENT 0x01
LOOPBACK 0x02
DISABLE_AUTO_RESTRANSMISSION 0x04
STATUS_FRAME 0x08
Command CLOSE:
Close can bus
Command SET_SPEED:
Set can bus speed.
Same parameters like open command, but without flags.
Not fully implemented by the firmware.
Is not used by the driver.
Command SET_MASK_FILTER:
Not fully implemented by the firmware.
Is not used by the driver.
Command GET_STATUS:
Return value in data[0-3]:
STATUS_NONE 0x00000000
STATUS_BUS_OFF 0x80000000
STATUS_PASSIVE 0x40000000
STATUS_BUS_WARN 0x20000000
STATUS_ACTIVE 0x10000000
STATUS_PHY_FAULT 0x08000000
STATUS_PHY_H 0x04000000
STATUS_PHY_L 0x02000000
STATUS_SLEEPING 0x01000000
STATUS_STOPPED 0x00800000
Is not used by the driver.
Command GET_STATISTICS:
Value in opt1 selects statistic:
RX_FRAMES 0
RX_BYTES 1
TX_FRAMES 2
TX_BYTES 3
OVERRUNS 4
WARNINGS 5
BUS_OFF 6
RESET_STAT 7 /* will set all stats to 0 */
Return value in data[0-3]
Is not used by the driver.
Command GET_SERIAL:
Return value in data[0-7]
Same value as in iSerial (lsusb -v)
Is not used by the driver.
Command GET_SOFTW_VER:
Firmware version:
Return value in data[0-1]
Is not used by the driver.
Command GET_HARDW_VER:
Hardware version:
Return value in data[0-1]
Is not used by the driver.
Command RESET_TIMESTAMP:
Resets the timestamp for rx can frame
Is not used by the driver.
Command GET_SOFTW_HARDW_VER:
Firmware version:
Return value in data[0-1]
Hardware version:
Return value in data[2-3]
-------------------------------------------------------------------------
Sending can frames (endpoint 2):
struct __packed usb_8dev_tx_msg {
u8 begin; /* alway 0x55 */
u8 flags; /* RTR and EXT_ID flag */
__be32 id; /* upper 3 bits not used */
u8 dlc; /* data length code 0-8 bytes */
u8 data[8]; /* 64-bit data */
u8 end; /* alway 0xAA */
};
Flags:
EXTID 0x01
RTR 0x02
-------------------------------------------------------------------------
Receiving can frames (endpoint 1):
struct __packed usb_8dev_rx_msg {
u8 begin; /* alway 0x55 */
u8 type; /* frame type */
u8 flags; /* RTR and EXT_ID flag */
__be32 id; /* upper 3 bits not used */
u8 dlc; /* data length code 0-8 bytes */
u8 data[8]; /* 64-bit data */
__be32 timestamp; /* 32-bit timestamp */
u8 end; /* alway 0xAA */
};
frame type:
CAN_FRAME 0
STATUS_FRAME 3 (always set ERR_FLAG)
flags:
EXTID 0x01
RTR 0x02
ERR_FLAG 0x04
timestamp:
I don't know which format is used, but I assume its simple a register value from the microcontroller
Is not used by the driver (but may change later).
regards,
Bernd
Am 2012-12-14 17:52, schrieb Uwe Bonnes:
>
> Hello,
>
> is there some document describing the protocoll used for the usb_8dev? I
> have STM32 hardware with USB and CAN connected and think about writing some
> firmware compatible with some existing adapter.
>
> Otherwise, are the github projects
>
> saeugetier / usb2can
>
> shackspace / usb2can
>
> for usb to can hardware related to this driver??
>
> Thanks
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: usb_8dev: USB Protocoll available?
2012-12-14 16:52 usb_8dev: USB Protocoll available? Uwe Bonnes
2012-12-14 18:33 ` Marc Kleine-Budde
2012-12-14 19:25 ` Bernd Krumboeck
@ 2012-12-15 6:31 ` Bernd Krumboeck
2012-12-15 7:09 ` Bernd Krumboeck
3 siblings, 0 replies; 8+ messages in thread
From: Bernd Krumboeck @ 2012-12-15 6:31 UTC (permalink / raw)
To: Uwe Bonnes; +Cc: linux-can
Error handling:
Error occured when frame type = 3 and ERR_FLAG = 0x04.
Error message:
byte 0: Status
byte 1: bit 7: Receive Passive
byte 1: bit 0-6: Receive Error Counter
byte 2: Transmit Error Counter
byte 3: Always 0 (maybe reserved for future use)
(byte 1-2 seems to be the value from CAN->ERR register in the microcontroller)
driver source:
u8 state = msg->data[0];
u8 rxerr = msg->data[1] & 0x7F;
u8 txerr = msg->data[2];
Status:
OK 0x00 /* Normal condition. */
OVERRUN 0x01 /* Overrun occured when sending */
BUSLIGHT 0x02 /* Error counter has reached 96 */
BUSHEAVY 0x03 /* Error count. has reached 128 */
BUSOFF 0x04 /* Device is in BUSOFF */
STUFF 0x20 /* Stuff Error */
FORM 0x21 /* Form Error */
ACK 0x23 /* Ack Error */
BIT0 0x24 /* Bit1 Error */
BIT1 0x25 /* Bit0 Error */
CRC 0x26 /* CRC Error */
regards,
Bernd
Am 2012-12-14 17:52, schrieb Uwe Bonnes:
>
> Hello,
>
> is there some document describing the protocoll used for the usb_8dev? I
> have STM32 hardware with USB and CAN connected and think about writing some
> firmware compatible with some existing adapter.
>
> Otherwise, are the github projects
>
> saeugetier / usb2can
>
> shackspace / usb2can
>
> for usb to can hardware related to this driver??
>
> Thanks
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: usb_8dev: USB Protocoll available?
2012-12-14 16:52 usb_8dev: USB Protocoll available? Uwe Bonnes
` (2 preceding siblings ...)
2012-12-15 6:31 ` Bernd Krumboeck
@ 2012-12-15 7:09 ` Bernd Krumboeck
2012-12-16 16:54 ` USB CAN Scripts - was " Oliver Hartkopp
3 siblings, 1 reply; 8+ messages in thread
From: Bernd Krumboeck @ 2012-12-15 7:09 UTC (permalink / raw)
To: Uwe Bonnes; +Cc: linux-can
Hello Uwe!
Maybe this will help you (lsusb -v):
Bus 006 Device 006: ID 0483:1234 SGS Thomson Microelectronics
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 255 Vendor Specific Class
bDeviceSubClass 255 Vendor Specific Subclass
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x0483 SGS Thomson Microelectronics
idProduct 0x1234
bcdDevice 1.00
iManufacturer 1 edevices
iProduct 2 USB2CAN converter
iSerial 3 ED000202
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 46
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 4
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0019 1x 25 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x04 EP 4 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0019 1x 25 bytes
bInterval 0
Device Status: 0x0000
(Bus Powered)
regards,
Bernd
Am 2012-12-14 17:52, schrieb Uwe Bonnes:
>
> Hello,
>
> is there some document describing the protocoll used for the usb_8dev? I
> have STM32 hardware with USB and CAN connected and think about writing some
> firmware compatible with some existing adapter.
>
> Otherwise, are the github projects
>
> saeugetier / usb2can
>
> shackspace / usb2can
>
> for usb to can hardware related to this driver??
>
> Thanks
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* USB CAN Scripts - was Re: usb_8dev: USB Protocoll available?
2012-12-15 7:09 ` Bernd Krumboeck
@ 2012-12-16 16:54 ` Oliver Hartkopp
2012-12-16 17:17 ` Uwe Bonnes
2012-12-17 8:06 ` Bernd Krumboeck
0 siblings, 2 replies; 8+ messages in thread
From: Oliver Hartkopp @ 2012-12-16 16:54 UTC (permalink / raw)
To: Bernd Krumboeck, Kurt Van Dijck, Stephane Grosjean; +Cc: linux-can
Hello Bernd,
thanks for sending the [v9] version of the 8devices USB2CAN.
I'm looking forward to get my own devices (hopefully) the next days to test
your driver too. When it's applied to Daves net-next we have additional two
month to test ;-)
Btw. you mentioned the need for some scripting support ...
To me the problem is when attaching some USB CAN adapter the enumeration of
these adapters is arbitrarily.
E.g. if i wanted to set the bitrate according to the specific adapter, i need
some kind of reference, let's say a unique device identifier.
When i would be able to identify the USB CAN adapters device ID i could add
some udev scripts to set the bitrate - even if i change the plug-in order.
The PEAK USB adapters have this info:
peak_usb 2-1.3:1.0: PEAK-System PCAN-USB adapter hwrev 28 serial FFFFFFFF (1 channel)
peak_usb 2-1.3:1.0 can2: attached to PCAN-USB channel 0 (device 67)
This device number "67" can be set by the user to identify the adapter.
In your mail ...
On 15.12.2012 08:09, Bernd Krumboeck wrote:
> Maybe this will help you (lsusb -v):
>
> Bus 006 Device 006: ID 0483:1234 SGS Thomson Microelectronics
> Device Descriptor:
(..)
> iManufacturer 1 edevices
> iProduct 2 USB2CAN converter
> iSerial 3 ED000202
(..)
... there's a serial number "ED000202" available.
Maybe we should discuss about having that kind of unique identifier available
in the sysfs (as we do not have a MAC address like USB ethernet adapters) for
udev scripts as discussed above.
I wonder if we could/should re-use the already existing
/sys/class/net/canX/addr
/sys/class/net/canX/addr_len
for this purpose ?!?
Regards,
Oliver
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: USB CAN Scripts - was Re: usb_8dev: USB Protocoll available?
2012-12-16 16:54 ` USB CAN Scripts - was " Oliver Hartkopp
@ 2012-12-16 17:17 ` Uwe Bonnes
2012-12-17 8:06 ` Bernd Krumboeck
1 sibling, 0 replies; 8+ messages in thread
From: Uwe Bonnes @ 2012-12-16 17:17 UTC (permalink / raw)
To: Oliver Hartkopp
Cc: Bernd Krumboeck, Kurt Van Dijck, Stephane Grosjean, linux-can
>>>>> "Oliver" == Oliver Hartkopp <socketcan@hartkopp.net> writes:
Oliver> Hello Bernd, thanks for sending the [v9] version of the 8devices
Oliver> USB2CAN.
Oliver> I'm looking forward to get my own devices (hopefully) the next
Oliver> days to test your driver too. When it's applied to Daves
Oliver> net-next we have additional two month to test ;-)
Oliver> Btw. you mentioned the need for some scripting support ...
Oliver> To me the problem is when attaching some USB CAN adapter the
Oliver> enumeration of these adapters is arbitrarily.
Oliver> E.g. if i wanted to set the bitrate according to the specific
Oliver> adapter, i need some kind of reference, let's say a unique
Oliver> device identifier.
Oliver> When i would be able to identify the USB CAN adapters device ID
Oliver> i could add some udev scripts to set the bitrate - even if i
Oliver> change the plug-in order.
Hello,
I have a lot of FTDI USB adapter related boards here. For manufacturer, I
programmed "IKDA", product is the board name and each board has a unique
number, here enumeratad beginning with 0000, 0001 etc.
To construct a unique /dev/ entry for each of them, I have a line
SUBSYSTEMS=="usb", KERNEL=="ttyUSB*", ATTRS{../manufacturer}=="IKDA", \
SYMLINK="%s{../product}_%s{../serial}_%s{bInterfaceNumber}"
in my udev rules. When plugged in, e.g. /dev/FTDITAG_0002_01 is created.
Network devices behave different, but maybe above gives you an idea.
Bye
--
Uwe Bonnes bon@elektron.ikp.physik.tu-darmstadt.de
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: USB CAN Scripts - was Re: usb_8dev: USB Protocoll available?
2012-12-16 16:54 ` USB CAN Scripts - was " Oliver Hartkopp
2012-12-16 17:17 ` Uwe Bonnes
@ 2012-12-17 8:06 ` Bernd Krumboeck
1 sibling, 0 replies; 8+ messages in thread
From: Bernd Krumboeck @ 2012-12-17 8:06 UTC (permalink / raw)
To: Oliver Hartkopp; +Cc: Kurt Van Dijck, Stephane Grosjean, linux-can
Hello Oliver!
Am 2012-12-16 17:54, schrieb Oliver Hartkopp:
>
> ... there's a serial number "ED000202" available.
>
> Maybe we should discuss about having that kind of unique identifier available
> in the sysfs (as we do not have a MAC address like USB ethernet adapters) for
> udev scripts as discussed above.
Simply a great idea. :-)
Some questions:
* How should it look like? ("<vendorId><productId><serial><...>")
* What should we do if the device does not have any useful number? (A PCI device can simply use the slot-id. USB???)
* How a driver should set the address? (priv->can.addr?)
regards,
Bernd
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2012-12-17 7:06 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-14 16:52 usb_8dev: USB Protocoll available? Uwe Bonnes
2012-12-14 18:33 ` Marc Kleine-Budde
2012-12-14 19:25 ` Bernd Krumboeck
2012-12-15 6:31 ` Bernd Krumboeck
2012-12-15 7:09 ` Bernd Krumboeck
2012-12-16 16:54 ` USB CAN Scripts - was " Oliver Hartkopp
2012-12-16 17:17 ` Uwe Bonnes
2012-12-17 8:06 ` Bernd Krumboeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.