Re: CAN controller
Gerd,
My Kernel is currently 3.10.25+.
I used the rpi_can_310x_spi_dma.tar.xz from your site and as far as I can see it includes the modules for this kernel too. Did I missunderstand that?
Thanks for your help!
Regards,
Marco
My Kernel is currently 3.10.25+.
I used the rpi_can_310x_spi_dma.tar.xz from your site and as far as I can see it includes the modules for this kernel too. Did I missunderstand that?
Thanks for your help!
Regards,
Marco
Re: CAN controller
Hi Marco,
Regards
Gerd
So, you already upgraded the kernel.Xanatos wrote:Gerd,
My Kernel is currently 3.10.25+
Yes, it should have both versions - the original 3.10.24+ and 310.25+. But I didn't test it myself. Do you get the same error as before ?I used the rpi_can_310x_spi_dma.tar.xz from your site and as far as I can see it includes the modules for this kernel too. Did I missunderstand that?
Regards
Gerd
Easy to build CAN-Bus interface:
http://lnxpps.de/rpie
http://lnxpps.de/rpie
Re: CAN controller
Gerd,
I only tested with 3.10.25+. I will do a fresh img to an SD and don't do rpi-update and test again.
Did you tested youself with 3.10.24+?
Regards,
Marco
I only tested with 3.10.25+. I will do a fresh img to an SD and don't do rpi-update and test again.
Did you tested youself with 3.10.24+?
Regards,
Marco
Re: CAN controller
Gerd,
I repeated my steps without rpi-update and I get rid of the module problem. Thanks!
After extracting the archive and depmod -a I did:
But my dmesg don't look good.
cat /sys/bus/spi/devices/*/modalias
cat /proc/interrupts
ip -s -d link show can0
You know what could be wrong?
Regards,
Marco
I repeated my steps without rpi-update and I get rid of the module problem. Thanks!
After extracting the archive and depmod -a I did:
Code: Select all
modprobe spi-bcm2708
modprobe can
modprobe can-dev
modprobe can-raw
modprobe can-bcm
modprobe spi-config devices=\ bus=0:cs=0:modalias=mcp2515:speed=10000000:gpioirq=25:pd=20:pds32-0=16000000:pdu32-4=0x2002:force_release
Code: Select all
[ 117.903868] bcm2708_spi bcm2708_spi.0: master is unqueued, this is deprecated
[ 117.904799] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80)
[ 117.965216] can: controller area network core (rev 20120528 abi 9)
[ 117.965383] NET: Registered protocol family 29
[ 118.033730] CAN device driver interface
[ 118.074337] can: raw protocol (rev 20120528)
[ 118.115628] can: broadcast manager protocol (rev 20120528 t)
[ 118.299031] spi_config_register: device description: bus=0:cs=0:modalias=mcp 2515:speed=10000000:gpioirq=25:pd=20:pds32-0=16000000:pdu32-4=0x2002:force_relea se
[ 118.300056] spi_config_register: unsupported argument bus - ignoring config
Code: Select all
spi:spidev
spi:spidev
Code: Select all
CPU0
3: 9294 ARMCTRL BCM2708 Timer Tick
32: 114742 ARMCTRL dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
52: 0 ARMCTRL BCM2708 GPIO catchall handler
65: 7 ARMCTRL ARM Mailbox IRQ
66: 1 ARMCTRL VCHIQ doorbell
75: 1 ARMCTRL
77: 8097 ARMCTRL bcm2708_sdhci (dma)
80: 0 ARMCTRL bcm2708_spi.0
83: 19 ARMCTRL uart-pl011
84: 11347 ARMCTRL mmc0
FIQ: usb_fiq
Err: 0
Code: Select all
Device "can0" does not exist.
Regards,
Marco
Re: CAN controller
There seems to be a leading space before the bus argument.Xanatos wrote:Code: Select all
[ 117.903868] bcm2708_spi bcm2708_spi.0: master is unqueued, this is deprecated [ 117.904799] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80) [ 117.965216] can: controller area network core (rev 20120528 abi 9) [ 117.965383] NET: Registered protocol family 29 [ 118.033730] CAN device driver interface [ 118.074337] can: raw protocol (rev 20120528) [ 118.115628] can: broadcast manager protocol (rev 20120528 t) [ 118.299031] spi_config_register: device description: bus=0:cs=0:modalias=mcp 2515:speed=10000000:gpioirq=25:pd=20:pds32-0=16000000:pdu32-4=0x2002:force_relea se [ 118.300056] spi_config_register: unsupported argument bus - ignoring config
Easy to build CAN-Bus interface:
http://lnxpps.de/rpie
http://lnxpps.de/rpie
Re: CAN controller
Thanks Gerd! That did the trick
CAN0 is now online. Will try with a real can device now to see if I can receive something
Regards,
Marco


Regards,
Marco
Re: CAN controller
Hi all =)
first of all i want to thank all the guys here. you did a great work and without you i would not start using RPI^^
i have a problem: my RPI with skpang extension board works only in loopback mode, but not with the real devices. After "candump can0" nothing happens. I tried to use it with http://www.peak-system.com/PCAN-USB.199.0.html.
dmesg:
ifconfig can0:
list of loaded modules:
cat /proc/interrupts
cat /sys/bus/spi/devices/*/modalias
You know what could be wrong?
Regards, Roman
first of all i want to thank all the guys here. you did a great work and without you i would not start using RPI^^
i have a problem: my RPI with skpang extension board works only in loopback mode, but not with the real devices. After "candump can0" nothing happens. I tried to use it with http://www.peak-system.com/PCAN-USB.199.0.html.
dmesg:
Code: Select all
can: controller area network core (rev 20120528 abi 9)
NET: Registered protocoll family 29
CAN device driver interface
can: raw protocol (rev 20120528)
can: broadcast manager protocol (rev 20120528 t)
spi_config_register: device description: bus=0:cs=0:modalias=mcp2515:speed=10000000:gpioirq=25:pd=20:pds32-0=16000000:pdu32-4=0x002:force_release
spi_config_match_cs: SPI0: check CS=0 to be 0
spi_config_match_cs: SPI0.0: Found a device with modinfo spidev
spi_config_register:spi0.0:mcp2515: found already registered device
spi_config_register:spi0.0:mcp2515: forcefully releasing already registered device taints kernel
mcp251x spi0.0: CANSTAT 0x80 CANCTRL 0x07
mcp251x spi0.0: probed
spi_config_register:spi0.0: registering modalias=mcp2515 with max_speed_hz=10000000 mode =0 and gpio/irq=25/195
spi_config_register:spi0.0:platform data: daadbd60: 00 25 f4 00 02 20 00 00 00 00 00 00 00 00 00 00 .$... ..........
spi_config_register:spi0.0:platform data: daadbd70: 00 00 00 00 ....
mcp251x spi 0.0 can0: bit-timing not yet defined
mcp251x spi 0.0: unable to set initial baudrate!
...
a lot of this messages
...
mcp251x spi0.0: CNF: 0x00 0xb5 0x01
Code: Select all
can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP RUNNING NOARP MTU:16 METRIC:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:10
RX bytes:0 (0.0B) TX bytes:0 (0.0B)
Code: Select all
Module Size Used by
fuse 76145 1
spi_config 9367 0
mcp251x 9557 0
can_bcm 11476 0
can_raw 6183 0
can_dev 9884 1 mcp251x
can 23591 2 can_bcm,can_raw
snd_bcm2835 16165 0
snd_soc_bcm2708_i2s 5474 0
regmap_mmio 2806 1 snd_soc_bcm2708_i2s
snd_soc_core 131268 1 snd_soc_bcm2708_i2s
snd_compress 8076 1 snd_soc_core
regmap_i2c 1645 1 snd_soc_core
regmap_spi 1897 1 snd_soc_core
snd_pcm 81593 2 snd_bcm2835,snd_soc_core
snd_page_alloc 5156 1 snd_pcm
snd_seq 53769 0
snd_seq_device 6473 1 snd_seq
snd_timer 20133 2 snd_pcm,snd_seq
evdev 9419 2
leds_gpio 2059 0
led_class 3688 1 leds_gpio
snd 61291 7 snd_bcm2835,snd_soc_core,snd_timer,snd_pcm,snd_seq,snd_seq_device,snd_compress
spi_bcm2708 4728 0
Code: Select all
CPU0
3: 74359 ARMCTRL BCM2708 Timer Tick
32: 2774379 ARMCTRL dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
52: 0 ARMCTRL BCM2708 GPIO catchall handler
65: 8 ARMCTRL ARM Mailbox IRQ
66: 1 ARMCTRL VCHIQ doorbell
75: 1 ARMCTRL
77: 10794 ARMCTRL bcm2708_sdhci (dma)
80: 36 ARMCTRL bcm2708_spi.0
83: 19 ARMCTRL uart-pl011
84: 19964 ARMCTRL mmc0
195: 0 GPIO mcp251x
FIQ: usb_fiq
Err: 0
Code: Select all
spi:mcp2515
spi:spidev
Regards, Roman
Re: CAN controller
Hello everyone! I just joined this forum because it seems to be such a great resource with tons of great information. Thanks to everyone for all of the information that has been posted!
I'd like to try contribute a bit on my first post. I recently purchased the PICAN CAN-bus board (http://skpang.co.uk/catalog/pican-canbu ... -1196.html). This might be the same board that Mayco and st1g have. Mine was purchased from SK Pang Electronics and the schematic that's provided from them shows three solder jumpers near the DB9 connector. These jumpers are used to connect the CAN H, CAN L and GND signals to the DB9 pins. The way my board was shipped, these jumpers were not connected. This might be why you're not receiving any data when connecting to your car's OBDII system.
I'd like to try contribute a bit on my first post. I recently purchased the PICAN CAN-bus board (http://skpang.co.uk/catalog/pican-canbu ... -1196.html). This might be the same board that Mayco and st1g have. Mine was purchased from SK Pang Electronics and the schematic that's provided from them shows three solder jumpers near the DB9 connector. These jumpers are used to connect the CAN H, CAN L and GND signals to the DB9 pins. The way my board was shipped, these jumpers were not connected. This might be why you're not receiving any data when connecting to your car's OBDII system.
Re: CAN controller
Hi at all
with an indispensable help of this post chain I was able to setup my pican board
http://skpang.co.uk/catalog/pican-canbu ... -1196.html
and get CAN going without patching the kernel (spi-config is really pretty cool!).
I had to recompile the kernel though to include all the necessary modules.
I run into an issue and I'm completely stuck:
After going deeper I noticed that it looks like the select() in candump is hanging.
Any ideas gentleman how to bite into it and figure out why it is happening?
I tried it with 3.10.y and 3.12.y kernels - the same result.
This is the info after running and stopping candump:
with an indispensable help of this post chain I was able to setup my pican board
http://skpang.co.uk/catalog/pican-canbu ... -1196.html
and get CAN going without patching the kernel (spi-config is really pretty cool!).
I had to recompile the kernel though to include all the necessary modules.
I run into an issue and I'm completely stuck:
- The interface is started with following options: set can0 type can bitrate 125000 restart-ms 100 triple-sampling on
- After starting can interface I start candump: candump -ta -c can0
- I have an external hardware generating traffic on canbus and sending message every 10ms.
- After starting message generation - candump starts capturing messages but after a while it stops and hangs.
- The only way to get the interface back and running is to restart the hardware: ifconfig can0 down; ifconfig can0 up
After going deeper I noticed that it looks like the select() in candump is hanging.
Any ideas gentleman how to bite into it and figure out why it is happening?
I tried it with 3.10.y and 3.12.y kernels - the same result.
Code: Select all
pi@raspberrypi ~ $ dmesg | egrep -i "can|spi|mcp"
[ 5.483414] bcm2708_spi bcm2708_spi.0: master is unqueued, this is deprecated
[ 5.591924] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80)
[ 11.306202] spi_config_register: device description: bus=0:cs=0:modalias=mcp2515:speed=10000000:gpioirq=25:pd=20:pds32-0=16000000:pdu32-4=0x2002:force_release
[ 11.328815] spi_config_register:spi0.0: registering modalias=mcp2515 with max_speed_hz=10000000 mode=0 and gpio/irq=25/195
[ 11.358623] spi_config_register:spi0.0:platform data:da0963c0: 00 24 f4 00 02 20 00 00 00 00 00 00 00 00 00 00 .$... ..........
[ 11.385710] spi_config_register:spi0.0:platform data:da0963d0: 00 00 00 00 ....
[ 11.407797] CAN device driver interface
[ 11.460230] mcp251x spi0.0: probed
[ 19.236877] mcp251x spi0.0: CNF: 0x03 0xf5 0x01
[ 161.444663] can: controller area network core (rev 20120528 abi 9)
[ 161.464498] can: raw protocol (rev 20120528)
Code: Select all
pi@raspberrypi ~ $ ip -details -statistics link show can0
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT qlen 10
link/can
can <TRIPLE-SAMPLING> state ERROR-ACTIVE restart-ms 100
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
2401 343 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
Re: CAN controller
Hi everybody,
I have another question as I'm still not able to read any packets from my CAN Device.
I think it has to do with the bitrate. In the docs it say 20kBit/s should be used for my device and when I test with my USB to CAN it works. But what is the correct parameter I need to use on the rpi?
Regards,
Marco
I have another question as I'm still not able to read any packets from my CAN Device.
I think it has to do with the bitrate. In the docs it say 20kBit/s should be used for my device and when I test with my USB to CAN it works. But what is the correct parameter I need to use on the rpi?
Code: Select all
ip link set can0 up type can restart-ms 100 bitrate 20000
Marco
Re: CAN controller
Hey Marco,Xanatos wrote: I have another question as I'm still not able to read any packets from my CAN Device.
I think it has to do with the bitrate. In the docs it say 20kBit/s should be used for my device and when I test with my USB to CAN it works. But what is the correct parameter I need to use on the rpi?Code: Select all
ip link set can0 up type can restart-ms 100 bitrate 20000
I got my skpang board working just few days ago. The bitrate refers to CAN bus bitrate so if you are shooting for 20kbit/s bus speed - it should work. The typical series of values for busrates are: 10k, 20k, 50k, 125k, 250k, 500k, 1M. I tested the board 125k and 1M - works fine but is not stable.
I configure mine as follows and it works for some time (see my other post):
Code: Select all
sudo modprobe spi-config devices=bus=0:cs=0:modalias=mcp2515:speed=10000000:gpioirq=25:pd=20:pds32-0=16000000:pdu32-4=0x2002:force_release
sudo ip link set can0 type can bitrate 125000
sudo ifconfig can0 up
Code: Select all
candump can0
Code: Select all
cansend can0 123#deadbeef
Re: CAN controller
Greetings,
I am having trouble getting my PiCan board from http://skpang.co.uk/catalog/pican-canbu ... -1196.html to work. Skpang has instructions on there website for a pre-compiled kernel image but it is out of date. Can someone please help me.
These are the steps I have taken so far:
1: Download fresh 2013-12-20-wheezy-raspbian.img
2: RPI: uname -a : Kernel verison 3.10.24+
3. Download rpi_can_310x_spi_dma.tar.xz
4. Copied it onto a usb stick from my mac
5. RPI: mkdir /media/usbstick
6. RPI: mount -t vfat -o uid=pi,gid=pi /dev/sda1 /media/usbstick
7. RPI: cd /media/usbstick
8. RPI: ls -l (Shows rpi_can_310x_spi_dma.tar.xz)
I'm new to Linux and would really appreciate it if some one could please walk me thought the next steps.
I am having trouble getting my PiCan board from http://skpang.co.uk/catalog/pican-canbu ... -1196.html to work. Skpang has instructions on there website for a pre-compiled kernel image but it is out of date. Can someone please help me.
These are the steps I have taken so far:
1: Download fresh 2013-12-20-wheezy-raspbian.img
2: RPI: uname -a : Kernel verison 3.10.24+
3. Download rpi_can_310x_spi_dma.tar.xz
4. Copied it onto a usb stick from my mac
5. RPI: mkdir /media/usbstick
6. RPI: mount -t vfat -o uid=pi,gid=pi /dev/sda1 /media/usbstick
7. RPI: cd /media/usbstick
8. RPI: ls -l (Shows rpi_can_310x_spi_dma.tar.xz)
I'm new to Linux and would really appreciate it if some one could please walk me thought the next steps.
Re: CAN controller
Current, updated instructions can be found here:Cky_2k wrote:Greetings,
I am having trouble getting my PiCan board from http://skpang.co.uk/catalog/pican-canbu ... -1196.html to work. Skpang has instructions on there website for a pre-compiled kernel image but it is out of date. Can someone please help me.
http://lnxpps.de/rpie/
Re: CAN controller
I have Raspbian 2013-12-20 and rpi_can_310x_spi.tar.xz downloaded. I just don't know how to transfer over the rpi_can_310x_spi.tar.xz onto the pi.radman wrote:Current, updated instructions can be found here:Cky_2k wrote:Greetings,
I am having trouble getting my PiCan board from http://skpang.co.uk/catalog/pican-canbu ... -1196.html to work. Skpang has instructions on there website for a pre-compiled kernel image but it is out of date. Can someone please help me.
http://lnxpps.de/rpie/
Copied it onto a usb stick from my mac
5. RPI: mkdir /media/usbstick
6. RPI: mount -t vfat -o uid=pi,gid=pi /dev/sda1 /media/usbstick
7. RPI: cd /media/usbstick
8. RPI: ls -l (Shows rpi_can_310x_spi_dma.tar.xz)
How do I transfer it over and where?
Re: CAN controller
Everything should be clear after reading posts in this thread and http://lnxpps.de/rpie/
Re: CAN controller
I just tested the update posted on http://lnxpps.de/rpie/ (Update: Just use Raspbian 2013-12-20 with this update).radman wrote: After going deeper I noticed that it looks like the select() in candump is hanging.
Any ideas gentleman how to bite into it and figure out why it is happening?
I tried it with 3.10.y and 3.12.y kernels - the same result.
I see the same issue with candump hanging upon heavy traffic.
Has anybody noticed it or there is something wrong with my hardware?
I also have performed following test.
- Terminal #1: candump -ta -c can0
- Terminal #2: cangen can0 -g 10
- Komodo CAN analizer also monitoring traffic on the bus.
As soon as I started generating additonal bus messages with komodo:
candump stopped receiving messages
cangen crashed with a message: write: No buffer space available
Ideas?
-
- Posts: 29
- Joined: Wed Sep 25, 2013 11:09 am
Re: CAN controller
danjperron wrote:I prefer to have it more automatic,
This is the best method I found so far,
P.S. I'm log as root. If you are not , use the sudo command.
1- from a stock raspbian we need to change the kernelrebootCode: Select all
cd /tmp wget http://lnxpps.de/rpie/rpi_can_3611_spi_dma.tar.xz cd / tar Jxvf /tmp/rpi_can_3611_spi_dma.tar.xz depmod -a
2- We need to update the /etc/modprobe.d/raspi-blacklist.conf file
Enable the spi-bcm2708 driver and blacklist the mcp251x driver3- Let's add the spi-config and the new mcp2515 modules in file /etc/modulesCode: Select all
#blacklist spi-bcm2708 blacklist mcp251x
4- And now the network can0 auto connect. Add these in the /etc/network/interfacesCode: Select all
# MCP2515 configuration with /INT on GPIO25 and 16MHz clock spi-config devices=\ bus=0:cs=0:modalias=mcp2515:speed=10000000:gpioirq=25:pd=20:pds32-0=16000000:pdu32-4=0x2002:force_release #and of course the mcp2515 driver mcp2515
and reboot!Code: Select all
auto can0 iface can0 inet manual pre-up /sbin/ip link set can0 type can bitrate 125000 up /sbin/ifconfig can0 up down /sbin/ifconfig can0 down
if everything is ok , the command ifconfig should report something like
I don't know if this is the best method but it is working fine for me.Code: Select all
root@RpiTest:~# ifconfig can0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 UP RUNNING NOARP MTU:16 Metric:1 RX packets:6674 errors:0 dropped:0 overruns:0 frame:0 TX packets:58915 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 lg file transmission:10 RX bytes:6695 (6.5 KiB) TX bytes:176745 (172.6 KiB)
Daniel
Hi Daniel,
I followed your post.Its really great.
I need to know what is loop back and how to enable loopback on, triple-sampling on..
-
- Posts: 29
- Joined: Wed Sep 25, 2013 11:09 am
Re: CAN controller
Hi Daniel,danjperron wrote:Hi cadsenthilkumar,
I did check the method and didn't find any problem.
I changed the crystal to 8Mhz and everything was ok.
Maybe the best way to check is to use two MCP2515 on the raspberry pi and see if you can send from one to the other.
On the First MCP2515 I use the schematic from this site.
http://skpang.co.uk/catalog/pican-canbu ... -1196.html
And for the second MCP2515 I use CE1 instead of CE0 and GPIO24 instead of GPIO25
I add the second device into the /etc/modules
ith /INT on GPIO25 and 16MHz clockCode: Select all
root@RpiTest:~# cat /etc/modules # /etc/modules: kernel modules to load at boot time. # # This file contains the names of kernel modules that should be loaded # at boot time, one per line. Lines beginning with "#" are ignored. # Parameters can be specified after the module name. snd-bcm2835 # MCP2515 configuration w[code]
spi-config devices=\
bus=0:cs=0:modalias=mcp2515:speed=10000000:gpioirq=25:pd=20:pds32-0=16000000:pdu32-4=0x2002:force_release,bus=0:cs=1:modalias=mcp2515:speed=10000000:gpioirq=24:pd=20:pds32-0=8000000:pdu32-4=0x2002:force_release
#and of course the mcp2515 driver
mcp2515
root@RpiTest:~#[/code]
B.T.W. The second MCP2515 run with a 8Mhz crystal.
and into /etc/network/interfacesI open 2 ssh consolesCode: Select all
root@RpiTest:~# cat /etc/network/interfaces auto lo iface lo inet loopback #iface eth0 inet dhcp allow-hotplug wlan0 #iface wlan0 inet manual #wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface wlan0 inet dhcp wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf #pre-up ifdown eth0; echo -n '1-1.1:1.0' >/sys/bus/usb/drivers/smsc95xx/unbind #post-down echo -n '1-1.1:1.0' >/sys/bus/usb/drivers/smsc95xx/bind iface default inet dhcp auto can0 iface can0 inet manual pre-up /sbin/ip link set can0 type can bitrate 125000 up /sbin/ifconfig can0 up down /sbin/ifconfig can0 down auto can1 iface can1 inet manual pre-up /sbin/ip link set can1 type can bitrate 125000 up /sbin/ifconfig can1 up down /sbin/ifconfig can1 down root@RpiTest:~#
On the first one I typeOn the second console I typeCode: Select all
root@RpiTest:~# candump can0
And I got a respond on the first consoleCode: Select all
root@RpiTest:~# cansend can1 7ef#0101050000000000
This is a neat trick to check if the canbus is working on the Rpi side.Code: Select all
can0 7EF [8] 01 01 05 00 00 00 00 00
Daniel
followed the same connection as given in http://skpang.co.uk/catalog/images/rasp ... _rev_B.pdf
and still candump is not showing anything,can you tell whats the problem
and follwed the same steps as your post in page 14 of this forum.
the virtual can is working.
Thanks.
Re: CAN controller
I am following the tutorial on "How to Build the Modules for adding an mcp251x to a Raspberry Pi" http://lnxpps.de/rpie/raspi-anleitung.txt but I keep receiving this message when I get to git checkout.
paul@KoolKat:~/raspi/linux$ git checkout 16eb921a96db3dc3555a65b53b99c15753e6b770
fatal: reference is not a tree: 16eb921a96db3dc3555a65b53b99c15753e6b770
Any help would be appreciated!
paul@KoolKat:~/raspi/linux$ git checkout 16eb921a96db3dc3555a65b53b99c15753e6b770
fatal: reference is not a tree: 16eb921a96db3dc3555a65b53b99c15753e6b770
Any help would be appreciated!
Re: CAN controller
Hi,
based on notros SPI driver improves the behaviour.
The MCP2515 looks easy to connect to the RPi, but the SPI driver latency is the bottleneck for high speed CAN.
If you need full speed CAN you should considering using a Beaglebone Black. The CAN controller is integrated
- you only need a tranceiver (eg MCP2551 or ISO1050).
Don't know if Martin is still working on the SPI driver.
Regards
Gerd
the "crash" under heavy load is a known issue since 3.10.x. The DMA SPI driver from Martin Sperl using DMAradman wrote: I just tested the update posted on http://lnxpps.de/rpie/ (Update: Just use Raspbian 2013-12-20 with this update).
I see the same issue with candump hanging upon heavy traffic.
Has anybody noticed it or there is something wrong with my hardware?
I also have performed following test.As long as cangen was running candump and komodo were only listening on the bus everything was great.
- Terminal #1: candump -ta -c can0
- Terminal #2: cangen can0 -g 10
- Komodo CAN analizer also monitoring traffic on the bus.
As soon as I started generating additonal bus messages with komodo:
candump stopped receiving messages
cangen crashed with a message: write: No buffer space available
Ideas?
based on notros SPI driver improves the behaviour.
The MCP2515 looks easy to connect to the RPi, but the SPI driver latency is the bottleneck for high speed CAN.
If you need full speed CAN you should considering using a Beaglebone Black. The CAN controller is integrated
- you only need a tranceiver (eg MCP2551 or ISO1050).
Don't know if Martin is still working on the SPI driver.
Regards
Gerd
Easy to build CAN-Bus interface:
http://lnxpps.de/rpie
http://lnxpps.de/rpie
Re: CAN controller
Hi Gerd,
thank you for the pointer. I found this SPI driver but when I tried it with 3.12.y it turned out to be even less stable than the default driver from the rpi branch. I used following driver for the test:
https://github.com/notro/spi-bcm2708
As next steps I tried 3.9.y kernel version (default and DMA driver) - also less stable than the 3.12.y.
In a meantime I got it to work stable enough with default 3.12.y to play with it at 250kbit. The beagle bone black is on order.
If anybody has a recommendation for a kernel driver version along with SPI driver version (git links please), I'm willing to give it a quick test and feedback results to this forum. I put together small script on ubuntu for automated kernel cross-compilation and deployment for very quick turnaround.
thank you for the pointer. I found this SPI driver but when I tried it with 3.12.y it turned out to be even less stable than the default driver from the rpi branch. I used following driver for the test:
https://github.com/notro/spi-bcm2708
As next steps I tried 3.9.y kernel version (default and DMA driver) - also less stable than the 3.12.y.
In a meantime I got it to work stable enough with default 3.12.y to play with it at 250kbit. The beagle bone black is on order.
If anybody has a recommendation for a kernel driver version along with SPI driver version (git links please), I'm willing to give it a quick test and feedback results to this forum. I put together small script on ubuntu for automated kernel cross-compilation and deployment for very quick turnaround.
Re: CAN controller
Hi radman,
As far as i can remember the Raspbian dists based on 3.2.x+ didn't had the problem.
Gerd
AFAIK the problem began with the kernel developer decision, that all drivers need to set IRQF_ONESHOT if you don't have a hardirq function call. Due to the architecture of the MCP2515 driver a hardirq function doesn't make any sense.radman wrote:Hi Gerd,
thank you for the pointer. I found this SPI driver but when I tried it with 3.12.y it turned out to be even less stable than the default driver from the rpi branch. I used following driver for the test:
https://github.com/notro/spi-bcm2708
As next steps I tried 3.9.y kernel version (default and DMA driver) - also less stable than the 3.12.y.
In a meantime I got it to work stable enough with default 3.12.y to play with it at 250kbit.
As far as i can remember the Raspbian dists based on 3.2.x+ didn't had the problem.
A good decision. BTW: If you give up cape management you are getting 2 CAN interfaces.The beagle bone black is on order.
RegardsIf anybody has a recommendation for a kernel driver version along with SPI driver version (git links please), I'm willing to give it a quick test and feedback results to this forum. I put together small script on ubuntu for automated kernel cross-compilation and deployment for very quick turnaround.
Gerd
Easy to build CAN-Bus interface:
http://lnxpps.de/rpie
http://lnxpps.de/rpie
Re: CAN controller
Hi Gerd,
After some more testing I have to say that for my testing methodology, I haven't found a stable enough SPI driver (regardless of distro version). It is probably related to the way how the driver has been tested. My current test which I perform goes as follows:
I think it is good to know current limitations in CAN bus area while playing with raspberry pi.
After some more testing I have to say that for my testing methodology, I haven't found a stable enough SPI driver (regardless of distro version). It is probably related to the way how the driver has been tested. My current test which I perform goes as follows:
- Bus analizer/exerciser, one external device and raspberry pi with skpang cape connected together.
- SkPang board has a JP3 shorted to provide bus termination. http://skpang.co.uk/catalog/pican-canbu ... -1196.html
- Bus is configured at 250kbit.
- There is a can dump running on raspberry pi: candump -ta -c can0
- Bus exerciser generates a 7 byte message every 50ms and external device reponds to it with 7 byte a message. Response time of external device is ~2ms.
- After a short period of time (<1min) the candump stops and does not resume capture after restarting. The only recovery method is ifconfig can0 down/ifconfig can0 up.
I think it is good to know current limitations in CAN bus area while playing with raspberry pi.
Re: CAN controller
Hi radman,
- USB2CAN interface from 8devices (BTW: my reference, a good catch) on can0
- PiCAN as can1 using async mcp2515 module
running at 1Mbps with this test code http://lnxpps.de/rpie/pican_test.c
Result:Roughly 500 sent and 500 received packets per second.
To get things worse the MCP2515 must be read via SPI three times to get a single frame. Have a look at the interrupts:
The MCP2515 interrupts (GPIO can1) generates a 4 time fold number of interrupts at the SPI (bcm2708_spi.0).
Every interrupt means a context switch which generates additional latency.
Linux isn't a realtime OS and the RPi does the rest. Don't get me wrong, I like my RPi, but it's not designed to be
a good performer in regard to devices. For example the network interfaces generates 8000 FIQ which isn't shown
interrupt statistics.
Notro and Martin did a good job improving the SPI driver (which is the key factor), but it isn't perfect.
The problem you are facing today (hang in candump) might be, that the kernel missed the interrupts from the CAN controller. Have a look a the MCP interrupt pin - I'm quite sure that it is at 0V. The kernel missed some edge interrupts from the controller and the buffer from the controller is full. The MCP2515 is still waiting for the host (RPi) to get the interrupt cleared. This is normally done by reading RXB0 or RXB1 thru SPI.
Nevertheless check your cabling - I didn't saw this kind of problem at the rate you are using CAN before.
Gerd
That's 40 packets per second, right ? I wouldn't call this a high rate.radman wrote:Hi Gerd,
After some more testing I have to say that for my testing methodology, I haven't found a stable enough SPI driver (regardless of distro version). It is probably related to the way how the driver has been tested. My current test which I perform goes as follows:
- Bus analizer/exerciser, one external device and raspberry pi with skpang cape connected together.
- SkPang board has a JP3 shorted to provide bus termination. http://skpang.co.uk/catalog/pican-canbu ... -1196.html
- Bus is configured at 250kbit.
- There is a can dump running on raspberry pi: candump -ta -c can0
- Bus exerciser generates a 7 byte message every 50ms and external device reponds to it with 7 byte a message. Response time of external device is ~2ms.
Here is my setup (old Raspbian 2013-09-25 Kernel 3.6.11+):[*]After a short period of time (<1min) the candump stops and does not resume capture after restarting. The only recovery method is ifconfig can0 down/ifconfig can0 up.[/list]
- USB2CAN interface from 8devices (BTW: my reference, a good catch) on can0
- PiCAN as can1 using async mcp2515 module
running at 1Mbps with this test code http://lnxpps.de/rpie/pican_test.c
Result:
Code: Select all
root@raspberrypi ~ # ./pican_test
CAN Socket can0 opened
CAN Socket can1 opened
Send 100000 in 101.656 sec (0.984 tpackets/sec 0.078 Mbit)
./can_bounce 1.39s user 15.05s system 16% cpu 1:41.67 total
Yeah, I took a long time to get the point. At the beginning of the adventure connecting the mcp2515 to the RPi I was standing at the same point as you: The RPi should have enough power to get a good and reliable CAN interface with the simple MCP2515. Days later after spending hours in front of my oscilloscope and digging into the code I must admit that the combination of Linux, RPi, the SPI and MCP2515 driver isn't a good combination: the problem is the latency - see many posts before. There are some oscilloscope pictures, which might get your an idea.I assume that this behavior indicates crash or malfunction of the driver. The instability increases with increasing the bitrate of the bus: 10kbit is the most stable and 1Mbit is almost unusable. Correct me if I'm wrong but shouldn't 700MHz cpu with 10MHz SPI bus and MCP2515 with 16MHz quartz be sufficient to get 1Mbit out of CAN bus?
To get things worse the MCP2515 must be read via SPI three times to get a single frame. Have a look at the interrupts:
Code: Select all
root@raspberrypi ~ # cat /proc/interrupts
CPU0
3: 57529 ARMCTRL BCM2708 Timer Tick
16: 449173 ARMCTRL bcm2708_spi.0
32: 19745859 ARMCTRL dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
52: 99984 ARMCTRL BCM2708 GPIO catchall handler
65: 5673 ARMCTRL ARM Mailbox IRQ
66: 1 ARMCTRL VCHIQ doorbell
75: 1 ARM CTRL
77: 7240 ARMCTRL bcm2708_sdhci (dma)
80: 27 ARMCTRL bcm2708_spi.0
83: 19 ARMCTRL uart-pl011
84: 13719 ARMCTRL mmc0
195: 99984 GPIO can1
FIQ: usb_fiq
Err: 0
Every interrupt means a context switch which generates additional latency.
Linux isn't a realtime OS and the RPi does the rest. Don't get me wrong, I like my RPi, but it's not designed to be
a good performer in regard to devices. For example the network interfaces generates 8000 FIQ which isn't shown
interrupt statistics.
Notro and Martin did a good job improving the SPI driver (which is the key factor), but it isn't perfect.
The problem you are facing today (hang in candump) might be, that the kernel missed the interrupts from the CAN controller. Have a look a the MCP interrupt pin - I'm quite sure that it is at 0V. The kernel missed some edge interrupts from the controller and the buffer from the controller is full. The MCP2515 is still waiting for the host (RPi) to get the interrupt cleared. This is normally done by reading RXB0 or RXB1 thru SPI.
Nevertheless check your cabling - I didn't saw this kind of problem at the rate you are using CAN before.
RegardsI think it is good to know current limitations in CAN bus area while playing with raspberry pi.
Gerd
Last edited by bertr2d2 on Mon Jan 20, 2014 12:12 pm, edited 1 time in total.
Easy to build CAN-Bus interface:
http://lnxpps.de/rpie
http://lnxpps.de/rpie
-
- Posts: 29
- Joined: Wed Sep 25, 2013 11:09 am
Re: CAN controller
Hi Daniel,cadsenthilkumar wrote:Hi Daniel,danjperron wrote:Hi cadsenthilkumar,
I did check the method and didn't find any problem.
I changed the crystal to 8Mhz and everything was ok.
Maybe the best way to check is to use two MCP2515 on the raspberry pi and see if you can send from one to the other.
On the First MCP2515 I use the schematic from this site.
http://skpang.co.uk/catalog/pican-canbu ... -1196.html
And for the second MCP2515 I use CE1 instead of CE0 and GPIO24 instead of GPIO25
I add the second device into the /etc/modules
ith /INT on GPIO25 and 16MHz clockCode: Select all
root@RpiTest:~# cat /etc/modules # /etc/modules: kernel modules to load at boot time. # # This file contains the names of kernel modules that should be loaded # at boot time, one per line. Lines beginning with "#" are ignored. # Parameters can be specified after the module name. snd-bcm2835 # MCP2515 configuration w[code]
spi-config devices=\
bus=0:cs=0:modalias=mcp2515:speed=10000000:gpioirq=25:pd=20:pds32-0=16000000:pdu32-4=0x2002:force_release,bus=0:cs=1:modalias=mcp2515:speed=10000000:gpioirq=24:pd=20:pds32-0=8000000:pdu32-4=0x2002:force_release
#and of course the mcp2515 driver
mcp2515
root@RpiTest:~#[/code]
B.T.W. The second MCP2515 run with a 8Mhz crystal.
and into /etc/network/interfacesI open 2 ssh consolesCode: Select all
root@RpiTest:~# cat /etc/network/interfaces auto lo iface lo inet loopback #iface eth0 inet dhcp allow-hotplug wlan0 #iface wlan0 inet manual #wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface wlan0 inet dhcp wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf #pre-up ifdown eth0; echo -n '1-1.1:1.0' >/sys/bus/usb/drivers/smsc95xx/unbind #post-down echo -n '1-1.1:1.0' >/sys/bus/usb/drivers/smsc95xx/bind iface default inet dhcp auto can0 iface can0 inet manual pre-up /sbin/ip link set can0 type can bitrate 125000 up /sbin/ifconfig can0 up down /sbin/ifconfig can0 down auto can1 iface can1 inet manual pre-up /sbin/ip link set can1 type can bitrate 125000 up /sbin/ifconfig can1 up down /sbin/ifconfig can1 down root@RpiTest:~#
On the first one I typeOn the second console I typeCode: Select all
root@RpiTest:~# candump can0
And I got a respond on the first consoleCode: Select all
root@RpiTest:~# cansend can1 7ef#0101050000000000
This is a neat trick to check if the canbus is working on the Rpi side.Code: Select all
can0 7EF [8] 01 01 05 00 00 00 00 00
Daniel
followed the same connection as given in http://skpang.co.uk/catalog/images/rasp ... _rev_B.pdf
and still candump is not showing anything,can you tell whats the problem
and follwed the same steps as your post in page 14 of this forum.
the virtual can is working.
Thanks.
for cansend can0 123#deadbeef
output using above circuit i got as,
candump can0
can0 1FFFFFFF [8] remote request
whats wrong?how to get dataframe output
Thanks.