For Colibri, the kernel needs to be configured to include the
CAN subsystem plus the used driver.
For V2.x Images
http://git.toradex.com/gitweb/linux-toradex.git/commitdiff/d4be58791a6358e85fa1bf139d46f7e80c65eec4
As on Apalis the CAN chips have dedicated SPI interfaces we provide
our standard image with a kernel configured for CAN.
For V1.x Images
The relevant platform data must be back ported.
First install the CAN utilities plus the native (e.g. not BusyBox
based) IP route 2 as follows:
For V2.x Images:
The required ipk packages be built with openembedded or can be
found here:
http://developer.toradex.com/files/toradex-dev/uploads/media/Colibri/Linux/Extra/
For V1.x Images:
root@colibri_t20:~# opkg install canutils iproute2
Installing canutils (4.0.6-r1.0.5) to root...
Downloading http://www.angstrom-distribution.org/feeds/unstable/ipk/glibc/armv5t
e/base/canutils_4.0.6-r1.0.5_armv5te.ipk.
Installing libsocketcan2 (0.0.8-r0.0.5) to root...
Downloading http://www.angstrom-distribution.org/feeds/unstable/ipk/glibc/armv5t
e/base/libsocketcan2_0.0.8-r0.0.5_armv5te.ipk.
Installing iproute2 (2.6.38-r4.0.9) to root...
Downloading http://www.angstrom-distribution.org/feeds/next/ipk/eglibc/armv5te/b
ase/iproute2_2.6.38-r4.0.9_armv5te.ipk.
Configuring iproute2.
update-alternatives: Linking //bin/ip to /sbin/ip.iproute2
Configuring libsocketcan2.
Configuring canutils.
Colibri EvalBoard V3.1a with built-in MCP2515 SPI CAN
Controller
The following shows the bring-up of a Colibri EvalBoard V3.1a
with its built-in MCP2515 SPI CAN controller connected to the
Colibri T20's SPI bus:
[ 4.904898] CAN device driver interface
[ 4.932793] Colibri EvalBoard V3.1a/MECS Tellurium xPOD CAN Initialisation
[ 4.979119] mcp251x spi3.0: probed
[ 5.340662] can: controller area network core (rev 20090105 abi 8)
[ 5.424355] can: raw protocol (rev 20090105)
[ 5.434325] can: broadcast manager protocol (rev 20090105 t)
root@colibri-t20:~# ip link set can0 type can bitrate 125000
root@colibri-t20:~# ifconfig can0 up
[ 2616.560726] Wake5 for irq=192
[ 2616.579120] mcp251x spi3.0: CNF: 0x03 0xb5 0x01
root@colibri-t20:~# cat /proc/interrupts | grep mcp251x
192: 0 0 GPIO mcp251x
root@colibri-t20:~# candump can0
interface = can0, family = 29, type = 3, proto = 1
<0x001> [1] 01
<0x001> [1] 01
^C
root@colibri-t20:~# cansend can0 1F334455#1122334455667788
interface = can0, family = 29, type = 3, proto = 1
root@colibri-t20:~# cansend can0 1F334455#1122334455667788
interface = can0, family = 29, type = 3, proto = 1
root@colibri-t20:~# cat /proc/interrupts | grep mcp251x
192: 4 0 GPIO mcp251x
root@colibri-t20:~# ip -details -statistics link show can0
2: can0: mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
link/can
can state ERROR-ACTIVE restart-ms 0
bitrate 125000 sample-point 0.875
tq 500 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
mcp251x: tseg1 3..16 tseg2 2..8 sjw 1..4 brp 1..64 brp-inc 1
clock 8000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 0 0 0
RX: bytes packets errors dropped overrun mcast
2 2 0 0 0 0
TX: bytes packets errors dropped carrier collsns
2 2 0 0 0 0
Colibri EvalBoard V2.1c with built-in SJA1000 CAN Controller
on GMI Bus
The following shows the bring-up of a Colibri EvalBoard V2.1c
with its built-in SJA1000 CAN controller connected to the Colibri
T20's GMI bus:
[ 4.317941] CAN device driver interface
[ 4.343046] sja1000 CAN netdevice driver
[ 4.369867] sja1000_platform sja1000_platform.0: sja1000_platform device registered (reg_base=97800000, irq=192)
[ 5.340662] can: controller area network core (rev 20090105 abi 8)
[ 5.424355] can: raw protocol (rev 20090105)
[ 5.434325] can: broadcast manager protocol (rev 20090105 t)
root@colibri_t20:~# ip link set can0 type can bitrate 125000
[ 909.720112909.720112] sja1000_platform sja1000_platform.0: setting BTR0=0x05 BTR1=0x1c
root@colibri_t20:~# ifconfig can0 up
[ 938.335586938.335586] Wake5 for irq=192
root@colibri_t20:~# cat /proc/interrupts | grep can
192: 0 0 GPIO can0
root@colibri_t20:~# candump can0
interface = can0, family = 29, type = 3, proto = 1
<0x001> [1] 01
<0x001> [1] 01
^C
root@colibri_t20:~# cansend can0 1F334455#1122334455667788
interface = can0, family = 29, type = 3, proto = 1
root@colibri_t20:~# cansend can0 1F334455#1122334455667788
interface = can0, family = 29, type = 3, proto = 1
root@colibri_t20:~# cat /proc/interrupts | grep can
192: 4 0 GPIO can0
root@colibri_t20:~# ip -details -statistics link show can0
2: can0: mtu 16 qdisc pfifo_fast state UNKNOWN qlen 10
link/can
can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0
bitrate 125000 sample-point 0.875
tq 500 prop-seg 6 phase-seg1 7 phase-seg2 2 sjw 1
sja1000: tseg1 1..16 tseg2 1..8 sjw 1..4 brp 1..64 brp-inc 1
clock 12000000
re-started bus-errors arbit-lost error-warn error-pass bus-off
0 0 0 0 0 0
RX: bytes packets errors dropped overrun mcast
2 2 0 0 0 0
TX: bytes packets errors dropped carrier collsns
2 2 0 0 0 0
You'll need Skype CreditFree via
Skype
You'll need Skype
CreditFree via
Skype