Difference between revisions of "CAN Bus"

From eLinux.org
Jump to: navigation, search
(SocketCAN Supported Controllers: add TI SoCs and ASCII protocol based devices)
m (hint to can4linux-examples)
 
(35 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
=== Overview ===
 
=== Overview ===
  
The CAN bus is an ISO standard bus for vehicles. It manages the Chassis Electrical System Control
+
The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control
 
and is responsible for critical activities like engine electrical, and skid control. This system is also used
 
and is responsible for critical activities like engine electrical, and skid control. This system is also used
 
to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of
 
to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of
Line 8: Line 8:
 
for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m.
 
for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m.
 
Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s).
 
Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s).
 
 
(Jeremiah J. Flerchinger [[media:avc-lan.pdf|Source]])
 
(Jeremiah J. Flerchinger [[media:avc-lan.pdf|Source]])
 +
Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s,
 +
will be available in the second half of 2014. A can4linux version supportig CAN FD on a [http://www.ifi-pld.de/IP/CANFD/canfd.html IFI CAN] is ready to be used.
  
additional information can be found at:
+
Although developed as car communication network CAN is used in many other areas, industrial, medical, maritime laboratory and more.
 +
Most often with a CAN based higher layer protocol like [http://en.wikipedia.org/wiki/CANopen CANopen] on top of it.
  
http://en.wikipedia.org/wiki/CAN_bus
 
  
 +
Additional information can be found at:
 +
:
 +
:http://en.wikipedia.org/wiki/CAN_bus
 +
:
 +
:[https://plus.google.com/u/0/117660856159215855502 SocketCAN News]
 +
:
 +
:CiA [http://www.can-cia.org CAN in Automation] CAN user association
 +
:[http://www.can-wiki.info CAN Wiki]
 +
:[http://www.bosch-semiconductors.de/media/pdf_1/canliteratur/can_fd_spec.pdf CAN FD Specification Version 1.0]
 
=== CAN Support in Linux ===
 
=== CAN Support in Linux ===
  
The Linux kernel supports CAN with the SocketCAN framework.
+
CAN is supported by Linux device drivers. Mainly two types exist. Character device based drivers and network socket based drivers. The Linux kernel supports CAN with the SocketCAN framework.
  
 
* [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob_plain;f=Documentation/networking/can.txt SocketCAN Documentation]
 
* [http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob_plain;f=Documentation/networking/can.txt SocketCAN Documentation]
Line 24: Line 34:
 
* [http://developer.berlios.de/projects/socketcan/ Berlios Project Page (obsolete)]
 
* [http://developer.berlios.de/projects/socketcan/ Berlios Project Page (obsolete)]
  
=== SocketCAN Supported Controllers ===
+
One of the character based drivers is can4linux.
 +
 
 +
* [http://sourceforge.net/projects/can4linux/ SourceForge project page]
 +
* [http://de.wikipedia.org/wiki/Can4linux German Wikipedia article]
 +
* [http://en.wikipedia.org/wiki/Can4linux English Wikipedia article]
 +
 
 +
==== SocketCAN Supported Protocols ====
 +
* RAW: send & receive raw CAN frames
 +
* BCM: Broadcast manager, offload repetitive work to the Linux kernel
 +
* ISOTP ...
 +
* SAE [[J1939]]
 +
 
 +
==== SocketCAN Supported Controllers ====
 
* Microchip MCP251x
 
* Microchip MCP251x
 
* Atmel AT91 SoCs
 
* Atmel AT91 SoCs
 
* ESD 331 CAN Cards
 
* ESD 331 CAN Cards
* Philips SJA1000
+
* NXP (Philips) SJA1000
 
* Freescale MPC52xx SoCs
 
* Freescale MPC52xx SoCs
 
* Bosch CC770
 
* Bosch CC770
Line 34: Line 56:
 
* TIs SoCs
 
* TIs SoCs
 
* Serial/network devices utilizing ASCII protocol (slcan driver)
 
* Serial/network devices utilizing ASCII protocol (slcan driver)
 +
 +
{| class="wikitable sortable"
 +
|-
 +
!Vendor !! Device Name !! Driver Module Name !! Controller !! Kconfig Option !! Linux Mainline !! Remarks
 +
|-
 +
|[http://vscom.de VScom] || [http://vscom.de/1_1_05_3.htm NET-CAN] || slcan || (unknown) || CONFIG_CAN_SLCAN || 2.6.38 || needs slcand and socat
 +
|-
 +
|[http://vscom.de VScom] || [http://vscom.de/1_1_05_4.htm PCI-2CAN] || slcan || (unknown) || CONFIG_CAN_SLCAN || 2.6.38 || needs slcand
 +
|-
 +
|[http://vscom.de VScom] || [http://vscom.de/1_1_05_1.htm SER-CAN] || slcan || (unknown) || CONFIG_CAN_SLCAN || 2.6.38 || needs slcand
 +
|-
 +
|[http://vscom.de VScom] || [http://vscom.de/1_1_05_2.htm USB-CAN] || slcan || (unknown) || CONFIG_CAN_SLCAN || 2.6.38 || needs slcand
 +
|-
 +
|[http://www.lawicel-shop.se LAWICEL] || [http://www.can232.com/?page_id=14 CAN232] || slcan || (unknown)  || CONFIG_CAN_SLCAN || 2.6.38 || needs slcand
 +
|-
 +
|[http://www.lawicel-shop.se‎ LAWICEL] || [http://www.can232.com/?page_id=16 CANUSB] || slcan || (unknown)  || CONFIG_CAN_SLCAN || 2.6.38 || needs slcand
 +
|-
 +
|[http://www.peak-system.com PEAK] || [http://www.peak-system.com/PCAN-PCI.207.0.html PCAN-PCI] || peak_pci || sja1000 || CONFIG_CAN_PEAK_PCI || 3.2 || supports all PCAN-[mini]PCI[e][104] variants
 +
|-
 +
|[http://www.peak-system.com PEAK] || [http://www.peak-system.com/PCAN-USB.199.0.html PCAN-USB] || peak_usb || (unknown) || CONFIG_CAN_PEAK_USB || 3.4 || supports PCAN-USB[pro][hub] (no LIN support)
 +
|-
 +
|[http://www.kvaser.com/ Kvaser] || [http://www.kvaser.com/products-services/our-products/#?interfaces=mini-pci-express,pci104,pci,pci-express PCIcanx] || kvaser_pci || sja1000 || CONFIG_CAN_KVASER_PCI || 2.6.31 || supports all PCI-[mini]PCI[e][104] variants
 +
|-
 +
|[http://www.kvaser.com/ Kvaser] || [http://www.kvaser.com/products-services/our-products/#?interfaces=usb Leaf] || kvaser_usb || (unknown) || CONFIG_CAN_KVASER_USB || 3.8 || supports USB Leaf / Memorator / Blackbird / R (see detailed USB device IDs in kvaser_usb.c)
 +
 +
|-
 +
|[http://www.ems-wuensche.com EMS Wünsche] || [http://www.ems-wuensche.com/product/datasheet/html/can-pccard-laptop-notebook-adapter-cpccard.html CPC-Card] || ems_pcmcia || sja1000 || CONFIG_CAN_EMS_PCMCIA || 3.2 || discontinued
 +
 +
|-
 +
|[http://www.ems-wuensche.com EMS Wünsche] || [http://www.ems-wuensche.com/product/datasheet/html/can-usb-adapter-converter-interface-cpcusb.html CPC-USB/ARM7] || ems_usb || (unknown) || CONFIG_CAN_EMS_USB || 3.2 ||
 +
 +
|-
 +
|[http://www.ems-wuensche.com EMS Wünsche] || [http://www.ems-wuensche.com/product/datasheet/html/can-pci-plugincard-multiple-channels-cpcpci.html CPC-PCI/PCIe] || ems_pci || sja1000 || CONFIG_CAN_EMS_PCI || 3.2 || up to four channel
 +
 +
|-
 +
|[http://www.ems-wuensche.com EMS Wünsche] || [http://www.ems-wuensche.com/product/datasheet/html/can-pci-104-passive-plugincard-cpc104p.html CPC-PC104P] || ems_pci || sja1000 || CONFIG_CAN_EMS_PCI || 3.2 || up to four channel on a PC104+ board
 +
 +
|-
 +
|[http://8devices.com 8devices] || [http://8devices.com/usb2can USB2CAN] || usb_8dev || (STR750FV2) || CONFIG_CAN_8DEV_USB || 3.9 || [https://github.com/krumboeck/usb2can STR750FV2 Firmware]
 +
 +
|-
 +
|[http://www.softing.com Softing] || [http://automotive.softing.com/en/products/communication-interfaces-can.html CANcard2] || softing_cs || sja1000 or NEC-005(?) || CONFIG_CAN_SOFTING_CS || 2.6.38 || Supports {CAN,EDIC}card{,SJA,2} PCMCIA cards
 +
Needs firmware [http://www.gitorious.org/linux-can/can-misc softing-fw-4.6-binaries.tar.gz]
 +
|}
 +
 +
==== SocketCAN Support in Programming Languages/Environments ====
 +
* [[Android]]
 +
* [[Java]]
 +
* [[Python_Can | Python]]
 +
 +
==== can4linux Supported Controllers ====
 +
 +
* [http://linux-sunxi.org/A20 Allwinner A20] with integrated CAN (on the popular [http://www.lemaker.org/ BananaPi] single-board computer.)
 +
* Analog Devices BlackFin BF537
 +
* Atmel AT91 SoCs
 +
* [http://www.freescale.com/ Freescale] FlexCAN (ColdFire 5282, i.MX25, i.MX28, i.MX35)
 +
* Microchip Stand Alone CAN MCP2515
 +
* NXP Stand Alone CAN  [http://www.nxp.com/documents/data_sheet/SJA1000.pdf SJA1000] (on different ISA or PCI/PCIe boards)
 +
* [http://www.xilinx.com/products/intellectual-property/DO-DI-CAN.htm Xilinx] Zynq with XCAN
 +
* 'virtual' CAN mode without CAN hardware
 +
* 'virtual' CAN mode supporting [http://www.can-wiki.info/doku.php?id=can_fd CAN FD]
 +
* [http://www.ifi-pld.de/IP/CANFD/canfd.html IFI CAN] FPGA IP, in classic CAN mode and CAN FD mode
 +
 +
==== can4linux Support in Programming Languages/Environments ====
 +
* C - many examples and useful applications are provided with the package, check can4linux-examples/
 +
* [[Tcl/Tk]] also in can4linux-examples/
 +
* [[Python]] also in can4linux-examples/
 +
 +
==== CAN Controllers Emulation (WIP/experimental) ====
 +
* SJA1000 CAN controller based PCI board emulation for QEMU
 +
** Cards models provided:
 +
*** Simple memory mapped SJA1000 in the first PCI BAR with ad-hoc PCI ID
 +
*** Kvaser PCIcan-S single I/O mapped SJA1000 model compatible with kvaser_pci Linux driver on guest side
 +
** The emulated CAN buses can be connected to virtual or physical SocketCAN interface if Linux is used as host system
 +
** Project repository: [https://github.com/CTU-IIG/qemu https://github.com/CTU-IIG/qemu]
 +
** Work started by 2013 GSoC project when RTEMS project donated its slot to work on QEMU CAN support - see [http://www.rtems.org/wiki/index.php/QEMU_CAN_Bus_Emulation RTEMS related page] for more info and use instructions
 +
 +
==== SocketCAN Bechmarking ====
 +
* [http://rtime.felk.cvut.cz/can/benchmark/3.0/ CAN gateway timing analysis] and [http://rtime.felk.cvut.cz/gitweb/can-benchmark.git repository with benchmark infrastructure]
 +
 +
==== SocketCAN Tutorials ====
 +
* [[Bringing CAN interface up]]
 +
* [[can-utils]]
 +
* [[libsocketcan]]
 +
* [[libnl]]
 +
 
[[Category:Networking]]
 
[[Category:Networking]]

Latest revision as of 19:42, 15 August 2014

Overview

The CAN bus is an ISO standard bus originally developed for vehicles. It manages the Chassis Electrical System Control and is responsible for critical activities like engine electrical, and skid control. This system is also used to provide vehicle diagnostic information for maintenance. A multi-star configuration seems typical of this bus with a primary bus line that branches into sub bus lines at its extremities then attaches to multiple device nodes. Differential voltage is applied over twisted pair at 1.5 to 2.5V and 2.5 to 3.5V for noise resistant signaling. Bit rates up to 1 Mbit/s are possible at network lengths below 40 m. Decreasing the bit rate allows longer network distances (e.g., 500 m at 125 kbit/s). (Jeremiah J. Flerchinger Source) Controllers supporting CAN FD, an enhanced CAN version with frames up to 64 byte and bit rates up to 4 Mbit/s, will be available in the second half of 2014. A can4linux version supportig CAN FD on a IFI CAN is ready to be used.

Although developed as car communication network CAN is used in many other areas, industrial, medical, maritime laboratory and more. Most often with a CAN based higher layer protocol like CANopen on top of it.


Additional information can be found at:

http://en.wikipedia.org/wiki/CAN_bus
SocketCAN News
CiA CAN in Automation CAN user association
CAN Wiki
CAN FD Specification Version 1.0

CAN Support in Linux

CAN is supported by Linux device drivers. Mainly two types exist. Character device based drivers and network socket based drivers. The Linux kernel supports CAN with the SocketCAN framework.

One of the character based drivers is can4linux.

SocketCAN Supported Protocols

  • RAW: send & receive raw CAN frames
  • BCM: Broadcast manager, offload repetitive work to the Linux kernel
  • ISOTP ...
  • SAE J1939

SocketCAN Supported Controllers

  • Microchip MCP251x
  • Atmel AT91 SoCs
  • ESD 331 CAN Cards
  • NXP (Philips) SJA1000
  • Freescale MPC52xx SoCs
  • Bosch CC770
  • Intel AN82527
  • TIs SoCs
  • Serial/network devices utilizing ASCII protocol (slcan driver)
Vendor Device Name Driver Module Name Controller Kconfig Option Linux Mainline Remarks
VScom NET-CAN slcan (unknown) CONFIG_CAN_SLCAN 2.6.38 needs slcand and socat
VScom PCI-2CAN slcan (unknown) CONFIG_CAN_SLCAN 2.6.38 needs slcand
VScom SER-CAN slcan (unknown) CONFIG_CAN_SLCAN 2.6.38 needs slcand
VScom USB-CAN slcan (unknown) CONFIG_CAN_SLCAN 2.6.38 needs slcand
LAWICEL CAN232 slcan (unknown) CONFIG_CAN_SLCAN 2.6.38 needs slcand
LAWICEL CANUSB slcan (unknown) CONFIG_CAN_SLCAN 2.6.38 needs slcand
PEAK PCAN-PCI peak_pci sja1000 CONFIG_CAN_PEAK_PCI 3.2 supports all PCAN-[mini]PCI[e][104] variants
PEAK PCAN-USB peak_usb (unknown) CONFIG_CAN_PEAK_USB 3.4 supports PCAN-USB[pro][hub] (no LIN support)
Kvaser PCIcanx kvaser_pci sja1000 CONFIG_CAN_KVASER_PCI 2.6.31 supports all PCI-[mini]PCI[e][104] variants
Kvaser Leaf kvaser_usb (unknown) CONFIG_CAN_KVASER_USB 3.8 supports USB Leaf / Memorator / Blackbird / R (see detailed USB device IDs in kvaser_usb.c)
EMS Wünsche CPC-Card ems_pcmcia sja1000 CONFIG_CAN_EMS_PCMCIA 3.2 discontinued
EMS Wünsche CPC-USB/ARM7 ems_usb (unknown) CONFIG_CAN_EMS_USB 3.2
EMS Wünsche CPC-PCI/PCIe ems_pci sja1000 CONFIG_CAN_EMS_PCI 3.2 up to four channel
EMS Wünsche CPC-PC104P ems_pci sja1000 CONFIG_CAN_EMS_PCI 3.2 up to four channel on a PC104+ board
8devices USB2CAN usb_8dev (STR750FV2) CONFIG_CAN_8DEV_USB 3.9 STR750FV2 Firmware
Softing CANcard2 softing_cs sja1000 or NEC-005(?) CONFIG_CAN_SOFTING_CS 2.6.38 Supports {CAN,EDIC}card{,SJA,2} PCMCIA cards

Needs firmware softing-fw-4.6-binaries.tar.gz

SocketCAN Support in Programming Languages/Environments

can4linux Supported Controllers

  • Allwinner A20 with integrated CAN (on the popular BananaPi single-board computer.)
  • Analog Devices BlackFin BF537
  • Atmel AT91 SoCs
  • Freescale FlexCAN (ColdFire 5282, i.MX25, i.MX28, i.MX35)
  • Microchip Stand Alone CAN MCP2515
  • NXP Stand Alone CAN SJA1000 (on different ISA or PCI/PCIe boards)
  • Xilinx Zynq with XCAN
  • 'virtual' CAN mode without CAN hardware
  • 'virtual' CAN mode supporting CAN FD
  • IFI CAN FPGA IP, in classic CAN mode and CAN FD mode

can4linux Support in Programming Languages/Environments

  • C - many examples and useful applications are provided with the package, check can4linux-examples/
  • Tcl/Tk also in can4linux-examples/
  • Python also in can4linux-examples/

CAN Controllers Emulation (WIP/experimental)

  • SJA1000 CAN controller based PCI board emulation for QEMU
    • Cards models provided:
      • Simple memory mapped SJA1000 in the first PCI BAR with ad-hoc PCI ID
      • Kvaser PCIcan-S single I/O mapped SJA1000 model compatible with kvaser_pci Linux driver on guest side
    • The emulated CAN buses can be connected to virtual or physical SocketCAN interface if Linux is used as host system
    • Project repository: https://github.com/CTU-IIG/qemu
    • Work started by 2013 GSoC project when RTEMS project donated its slot to work on QEMU CAN support - see RTEMS related page for more info and use instructions

SocketCAN Bechmarking

SocketCAN Tutorials