tgy2013
Posts: 3
Joined: Fri Feb 28, 2014 9:29 am

Re: No missing packets

Fri Mar 14, 2014 5:02 pm

tz1 wrote:I just pushed an update to my github.

I am no longer missing packets at 250KBaud (as far as I can tell, ISO15765 at full speed for a long packet).

First, I'm overclocked to 1GHz. See the Tested Values section at http://elinux.org/RPiconfig since I've set the other parameters too including force_turbo.

I've tweaked the mcp2515.c a bit, and the canpi.sh script to add the spi-dma and checked it in.

I'm not sure if it is an either or both fix.
I've installed your modified drivers. At 250 KBaud and 800 kHz clock speed the changes are not by themselves able to resolve the frame overrun. At 900 kHz (the fastest my Pi will run stably) data loss is avoided provided the force_turbo flag is set, and direct screen output is avoided (e.g. by piping candump output to a separate analysis/display process).

I've slightly modified canboat's (https://github.com/canboat/canboat.git) candump2analyzer so that it takes the current version of candump output and forwards it to analyzer.

tgy2013
Posts: 3
Joined: Fri Feb 28, 2014 9:29 am

Candump2analyzer

Fri Mar 14, 2014 7:21 pm

candump2analyzer.zip
From canboat archive
(5.47 KiB) Downloaded 345 times
This is slightly revised version of the process to take output from the latest version of the candump utility and pipe it to analyzer.

Example of use : $ candump -d can0,0:0,#FFFFFFFF | ./candump2analyzer | ./analyzer

tz1
Posts: 22
Joined: Tue Jan 07, 2014 10:09 pm

Re: CAN controller

Fri Mar 14, 2014 11:16 pm

I've noticed the same thing - if there is something else keeping the PI busy (sd card i/o) it will drop frames. I don't know if anything more can be done - I think the latency of the interrupt to the spi transfer of the data won't be that easy to reduce. I think we need a chip with a deeper FIFO, or go back to something like an Arduino between. I may play with a scope a bit this weekend.

chuck90
Posts: 3
Joined: Tue Feb 25, 2014 2:35 pm

Re: CAN controller

Tue Mar 18, 2014 10:10 am

Hey Guys,

great post! But im still fighting, connecting the MCP 2551 and MCP2515 with the RPI. I followed the instructions from martin and betr2d2 on page 12 but it still doesnt work :(
it seems that there is a problem with the interrups because there is alwas 0 at 195............
i read something about, that there can be a problem by using a HDMI-Screenn is that corect? do i have to do it with SSH?
i use a 16Mhz crystal too.
I try it with mcp2515 driver. when i use mcp251x it always say: cannot find device can0 after trying to start loopback mode. i know that loopback is not possible with mcp2515 driver. "I used Zetas auto start up config"
Here the output form dmesg ((only mcp2515 active) and the output from cat /proc/interrupts
i attached my cuircit. sorry for that lousy quality!
is it nessecary to reset the mcp2515 manually on startup? (i read that on the datasheet). or is it included in the package from martin and bertr2d2?
i hope this is all you need for helping me :)

Code: Select all

4.943158] bcm2708_spi bcm2708_spi.0: DMA channel 0 at address 0xf2007000 with irq 16
[    5.207695] bcm2708_spi bcm2708_spi.0: DMA channel 4 at address 0xf2007400 with irq 20
[    5.382662] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80)
[    5.465276] bcm2708_spi bcm2708_spi.0: SPI Controller running in dma mode
[    5.572331] Registered led device: led0
[    9.269022] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[    9.721188] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[   10.492773] 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
[   10.518360]  spi_config_match_cs: SPI0: check CS=0 to be 0
[   10.529313]  spi_config_match_cs: SPI0.0: Found a device with modinfo spidev
[   10.542415] spi_config_register:spi0.0:mcp2515: found already registered device
[   10.555212]  spi_config_register:spi0.0:mcp2515: forcefully-releasing already registered device taints kernel
[   10.570558] Disabling lock debugging due to kernel taint
[   10.584283] spi_config_register:spi0.0: registering modalias=mcp2515 with max_speed_hz=10000000 mode=0 and gpio/irq=25/195
[   10.619765] spi_config_register:spi0.0:platform data:daa1a2e0: 00 24 f4 00 02 20 00 00 00 00 00 00 00 00 00 00  .$... ..........
[   10.637174] spi_config_register:spi0.0:platform data:daa1a2f0: 00 00 00 00                                      ....
[   10.738238] CAN device driver interface
[   10.758111] mcp2515 spi0.0: can0: device registered (cs=0, irq=195)
[   10.926670] can: controller area network core (rev 20120528 abi 9)
[   10.957754] NET: Registered protocol family 29
[   11.214186] can: raw protocol (rev 20120528)
[   11.296802] can: broadcast manager protocol (rev 20120528 t)
[   18.580525] mcp2515 spi0.0: can0: writing CNF: 0x00 0xb5 0x01
[   20.004828] smsc95xx 1-1.1:1.0: eth0: link up, 100Mbps, full-duplex, lpa 0x41E1
[   24.432169] Adding 102396k swap on /var/swap.  Priority:-1 extents:1 across:102396k SS
[  224.849980] fuse init (API version 7.20)
root@raspberrypi:/home/pi# cat /proc/interrupts
           CPU0       
  3:      31242   ARMCTRL  BCM2708 Timer Tick
 16:          0   ARMCTRL  bcm2708_spi.0
 32:     767653   ARMCTRL  dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
 52:          0   ARMCTRL  BCM2708 GPIO catchall handler
 65:       1937   ARMCTRL  ARM Mailbox IRQ
 66:          1   ARMCTRL  VCHIQ doorbell
 75:          1   ARMCTRL
 77:      13573   ARMCTRL  bcm2708_sdhci (dma)
 80:          6   ARMCTRL  bcm2708_spi.0
 83:         19   ARMCTRL  uart-pl011
 84:      22158   ARMCTRL  mmc0
195:          0      GPIO  can0
FIQ:              usb_fiq
Err:          0
edited:
hi. i added my output "dmesg" with mcp251x:

Code: Select all

[    4.027002] udevd[153]: starting version 175
[    5.018052] bcm2708_spi bcm2708_spi.0: DMA channel 0 at address 0xf2007000 with irq 16
[    5.197594] bcm2708_spi bcm2708_spi.0: DMA channel 4 at address 0xf2007400 with irq 20
[    5.370512] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80)
[    5.469650] bcm2708_spi bcm2708_spi.0: SPI Controller running in dma mode
[    5.677971] Registered led device: led0
[    9.736725] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[   10.209074] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
[   19.884912] smsc95xx 1-1.1:1.0: eth0: link up, 100Mbps, full-duplex, lpa 0x41E1
[   23.164718] Adding 102396k swap on /var/swap.  Priority:-1 extents:1 across:102396k SS
[   51.186856] fuse init (API version 7.20)
[  156.629792] bcm2708_spi bcm2708_spi.0: SPI Bus statistics: 0 poll 0 interrupt and 0 dma driven messages
[  176.324792] bcm2708_spi bcm2708_spi.0: DMA channel 0 at address 0xf2007000 with irq 16
[  176.324893] bcm2708_spi bcm2708_spi.0: DMA channel 4 at address 0xf2007400 with irq 20
[  176.328461] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80)
[  176.328490] bcm2708_spi bcm2708_spi.0: SPI Controller running in dma mode
[  240.561330] bcm2708_spi bcm2708_spi.0: SPI Bus statistics: 0 poll 0 interrupt and 0 dma driven messages
[  262.552284] bcm2708_spi bcm2708_spi.0: DMA channel 0 at address 0xf2007000 with irq 16
[  262.552317] bcm2708_spi bcm2708_spi.0: DMA channel 4 at address 0xf2007400 with irq 20
[  262.556966] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80)
[  262.556995] bcm2708_spi bcm2708_spi.0: SPI Controller running in dma mode
[  283.068463] can: controller area network core (rev 20120528 abi 9)
[  283.068654] NET: Registered protocol family 29
[  283.087814] CAN device driver interface
[  283.115036] can: raw protocol (rev 20120528)
[  283.134592] can: broadcast manager protocol (rev 20120528 t)
[  323.745421] 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
[  323.745504]  spi_config_match_cs: SPI0: check CS=0 to be 0
[  323.745518]  spi_config_match_cs: SPI0.0: Found a device, but no driver...
[  323.745530] spi_config_register:spi0.0:mcp2515: found already registered device
[  323.745541]  spi_config_register:spi0.0:mcp2515: forcefully-releasing already registered device taints kernel
[  323.745550] Disabling lock debugging due to kernel taint
[  323.750525] spi_config_register:spi0.0: registering modalias=mcp2515 with max_speed_hz=10000000 mode=0 and gpio/irq=25/195
[  323.750567] spi_config_register:spi0.0:platform data:daa9db20: 00 24 f4 00 02 20 00 00 00 00 00 00 00 00 00 00  .$... ..........
[  323.750585] spi_config_register:spi0.0:platform data:daa9db30: 00 00 00 00                                      ....
[  324.805344] mcp251x spi0.0: MCP251x didn't enter in conf mode after reset
[  324.805487] mcp251x spi0.0: CANSTAT 0x00 CANCTRL 0x00
[  324.805506] mcp251x spi0.0: Probe failed
[  324.805549] mcp251x spi0.0: probe failed

like you see: mcp251x didnt enter in conf mode after reset..
Greetings!
Attachments
rpi_2.jpg
rpi_2.jpg (62.74 KiB) Viewed 8126 times

Joker_90
Posts: 9
Joined: Wed Mar 19, 2014 11:32 am

Re: CAN controller

Wed Mar 19, 2014 12:03 pm

Hello Guys,
Sorry for my bad English...
I have a new Kernel compilated who is shown under this page http://elinux.org/RPi_CANBus.
Its already on my Raspi and it works pretty well.
Now i installed the Software from Microchip (http://www.microchip.com/Developmenttoo ... umentation) on my Laptop.
I have connected my Laptop with one of this Boards. This Board i have connected with the other one and then with my Raspi.
Now i wanna sent some Messages with this Programm of Microchip via my Laptop. And all in all my Raspi shoul recognize it and show the messages on the tft-Monitor.
But there's the Problem, I don't know the commands i have to use for it.
Can somebody help me?
Thanks
Patrick

tz1
Posts: 22
Joined: Tue Jan 07, 2014 10:09 pm

cam CAN modules

Wed Mar 19, 2014 7:00 pm

There was an update for raspicam moving the kernel version to 3.10.33+ and replacing the kernel and binary modules.

So here is a new can module archive attached.

I'm updating http://github.com/tz1/pikernomatic and will do mcp2515 async later.

I have a faster guide to finding the git checkout hash in pikernomatic (HASH-HOWTO).
Attachments
can-33+.tgz
can modules
(59.32 KiB) Downloaded 247 times

Joker_90
Posts: 9
Joined: Wed Mar 19, 2014 11:32 am

Re: CAN controller

Thu Mar 20, 2014 9:25 am

Thanks tz1
but i have a problem with this step
wget http://www.pengutronix.de/software/libs ... .8.tar.bz2
# tar xvjf libsocketcan-0.0.8.tar.bz2
My Raspi says to me that he cant find this "tool"
But i can download it with my Laptop.
When i start the "startx" in su mode i can dl it at the Raspi too but when i want to unzip it i get an error which says that the data file is damaged.
Does anybody have a clue about this issue?

Reagards
Patrick

Joker_90
Posts: 9
Joined: Wed Mar 19, 2014 11:32 am

Re: CAN controller

Thu Mar 20, 2014 11:09 am

Hey,
I got a Problem, I exactly did what Maddin1234 told (http://www.raspberrypi.org/phpBB3/viewt ... &start=275)
But at this step "ip link set can0 up type can bitrate 500000" and after pressing enter nothing happens. I just get the answer "Cannot find device "can0""

Where is the problem?
When i type lsmod on my Pi i get this

Code: Select all

Module                  Size  Used by
can_bcm                 9376  0 
can_raw                 4820  0 
can                    18388  2 can_bcm,can_raw
snd_bcm2835            11484  1 
snd_pcm                52992  1 snd_bcm2835
snd_seq                36936  0 
snd_timer              14664  2 snd_pcm,snd_seq
snd_seq_device          3616  1 snd_seq
snd                    36032  7 snd_bcm2835,snd_timer,snd_pcm,snd_seq,snd_seq_device
snd_page_alloc          2684  1 snd_pcm
mcp251x                 7300  0 
spidev                  3916  0 
can_dev                 5376  1 mcp251x
evdev                   7536  4 
8192cu                411532  0 
leds_gpio               1668  0 
led_class               1788  1 leds_gpio
spi_bcm2708             3904  0 
When i type dmesg | egrep -i "can|spi|mcp" i get this

Code: Select all

BCM2708 mcp251x_init:  got IRQ 195 for MCP2515
bcm2708_spi bcm2708_spi.0: master is unqueued, this is deprecated
bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80)
CAN device driver interface
mcp251x spi0.0: MCP251x didn't enter in conf mode after reset
mcp251x spi0.0: CANSTAT 0x00 CANCTRL 0x00
mcp251x spi0.0: Probe failed
mcp251x spi0.0: probe failed
can: controller area network core (rev 20120528 abi 9)
can: raw protocol (rev 20120528)
can: broadcast manager protocol (rev 20120528 t)

And last but not least cat /proc/interrupts

Code: Select all

          CPU0       
  3:      21469   ARMCTRL  BCM2708 Timer Tick
 32:     307108   ARMCTRL  dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
 52:          0   ARMCTRL  BCM2708 GPIO catchall handler
 65:          2   ARMCTRL  ARM Mailbox IRQ
 66:        789   ARMCTRL  VCHIQ doorbell
 75:          1   ARMCTRL
 77:      14575   ARMCTRL  bcm2708_sdhci (dma)
 80:      40812   ARMCTRL  bcm2708_spi.0
 83:         19   ARMCTRL  uart-pl011
 84:      23034   ARMCTRL  mmc0
FIQ:              usb_fiq
Err:          0
I would be very proud if someone can help me because its my Bachelor"work"
Tanks a lot
Regards

bertr2d2
Posts: 97
Joined: Wed Aug 08, 2012 10:12 pm

Re: CAN controller

Thu Mar 20, 2014 12:37 pm

Joker_90 wrote:Hey,
Hi Joker_90,

just clearifying your setup: You want to use MCP2515DM-BM board with the RPi, right ?
The mcp251x drivers won't work with the MCP2515DM-BM, because they rely on a MCP2515 connected via SPI not USB.
Here is somebody, who used this board with Linux:
http://www.harshbutfair.org/software/canboard.html
but this has nothing to do with SocketCAN (can0 interface using obvious tools like candump).

Regards

Gerd
Easy to build CAN-Bus interface:
http://lnxpps.de/rpie

Joker_90
Posts: 9
Joined: Wed Mar 19, 2014 11:32 am

Re: CAN controller

Thu Mar 20, 2014 1:29 pm

Hi Gerd,
yes i have the MCP2515DM-BM from Microchip.
What i wanna do is this,
I want to connect the Raspi via SPI with one Board and this Board i wanna connect with the second board. This second board is connected with the Laptop via USB.
You get from Microchip a Software where you can send messages. If i send now 500k messages the raspi should be able ,however, to receive this messages and show them on the monitor.
Now you said all the work i've done is wrong. :(
I opend your link but i cant handle this.
Where do i have to start and what must i do then?

Does this help? "http://skpang.co.uk/catalog/pican-canbu ... -1196.html"
When i use my CAN BUS Monitor Demonstration Board MCP2515DM-BM what must i do that this works?:(
Thanks

chuck90
Posts: 3
Joined: Tue Feb 25, 2014 2:35 pm

Re: CAN controller

Thu Mar 20, 2014 1:31 pm

joker90's problems are the same i have... all the outputs are the same.
I try with mcp2515 and mcp2551.

Does anyone knows what am i doing wrong

Chuk

tz1
Posts: 22
Joined: Tue Jan 07, 2014 10:09 pm

Re: CAN controller

Thu Mar 20, 2014 2:30 pm

Joker_90 wrote:Thanks tz1
but i have a problem with this step
wget http://www.pengutronix.de/software/libs ... .8.tar.bz2
# tar xvjf libsocketcan-0.0.8.tar.bz2
My Raspi says to me that he cant find this "tool"
But i can download it with my Laptop.
When i start the "startx" in su mode i can dl it at the Raspi too but when i want to unzip it i get an error which says that the data file is damaged.
Does anybody have a clue about this issue?

Reagards
Patrick
apt-get install wget bzip2

You need to do "tar xvf...", the "j" means bzip2 (z=gzip, but tar can now automatically figure out most compression schemes).
You can decompress it with "bunzip2" as well.
Unzip can only handle zip files.
I'm not sure if there is an "archive manager" for the pi,.

tz1
Posts: 22
Joined: Tue Jan 07, 2014 10:09 pm

Re: CAN controller

Thu Mar 20, 2014 2:41 pm

I have used both of these:

http://microcontrollershop.com/product_ ... ts_id=4618
http://microcontrollershop.com/product_ ... ts_id=4719

One is 10Mhz, the other 16Mhz (Also works with Arduinos, see github.com/tz1/CanBusTriple forked from etx's project). I've made a monitor from an Arduino Micro plus one of the above boards.

I have to power the boards with 5v from the Pi or the messages are garbled. 5v on the 3.3v pin for the one that has the 2x5 connector.

As to the MCP development board, you might try connecting directly to the SPI port on J7 (if you can disable the PIC from reading it).

Joker_90
Posts: 9
Joined: Wed Mar 19, 2014 11:32 am

Re: CAN controller

Thu Mar 20, 2014 5:41 pm

Perhaps you get me wrong
I have this two Boards "http://www.microchip.com/Developmenttoo ... P2515DM-BM"
This Board you can connect with USB or with SPI.
I connect the Raspi with SPI with one board. From this board i go with a can-cable to the second board. From this second board i go with USB to the Laptop.
From the Laptop i want to send some Messages and i wanna "listened" to them with the Raspi.
Hm perhaps now somebody know if the instruction of maddin1234 fits for this or someone knows a other solution.

Thanks!

Regards
Patrick

msperl
Posts: 344
Joined: Thu Sep 20, 2012 3:40 pm

Re: CAN controller

Fri Mar 21, 2014 12:29 pm

Hi!

One thing that I find surprizing is that you do NOT get the interrupt 195 listed in /proc/interrupts.
Joker_90 wrote:And last but not least cat /proc/interrupts

Code: Select all

          CPU0       
  3:      21469   ARMCTRL  BCM2708 Timer Tick
 32:     307108   ARMCTRL  dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
 52:          0   ARMCTRL  BCM2708 GPIO catchall handler
 65:          2   ARMCTRL  ARM Mailbox IRQ
 66:        789   ARMCTRL  VCHIQ doorbell
 75:          1   ARMCTRL
 77:      14575   ARMCTRL  bcm2708_sdhci (dma)
 80:      40812   ARMCTRL  bcm2708_spi.0
 83:         19   ARMCTRL  uart-pl011
 84:      23034   ARMCTRL  mmc0
FIQ:              usb_fiq
Err:          0
The other thing is that you get a "bad" response from the device - as if there is no communication between the rpi and the MCP2515 chip.
Joker_90 wrote: mcp251x spi0.0: MCP251x didn't enter in conf mode after reset
mcp251x spi0.0: CANSTAT 0x00 CANCTRL 0x00
mcp251x spi0.0: Probe failed
mcp251x spi0.0: probe failed
[/code]
With the stock driver you should get some - non-zero values for CANSTAT/CANCTRL.

So I would guess that the cabling is wrong and that is why the driver does not recognize the IC so the interrupt does not register.

Get an oscilloscope/logic analyzer on the SPI lines and check that there is a signal (especially Chip-select and clock) and also verify that you have connected MOSI/MISO correctly - on the diagrams it looks good (besides missing capacitors close to the ICs Power input).

This issue of yours has nothing to do with any communication on the CAN bus talking to other devices - first you need to fix the SPI side of things...

Martin

jtosey
Posts: 1
Joined: Fri Mar 28, 2014 5:49 pm

Re: CAN controller

Sat Mar 29, 2014 7:21 am

I think I'm close to getting the PICAN (http://skpang.co.uk/catalog/pican-canbu ... -1196.html) to work with the mcp2515 driver on the Model B, but cannot get can0 to appear. Any help would be greatly appreciated!
The mc251x kernel on the PICAN page (http://lnxpps.de/rpie/) superficially appears to work, but the kernel is missing a WIFI driver, and has a reputation for instability.

The story thus far:

I started with the 2014-01-03 Raspbian image and did not install any other packages or modules, or even expand the file system.

Code: Select all

$ uname -a
Linux raspberrypi 3.10.25+ #622 PREEMPT Fri Jan 3 18:41:00 GMT 2014 armv6l GNU/Linux
I then:
  • Downloaded canmods-3.10.25+.tgz described in post "by tz1 » Mon Feb 24, 2014 8:47 pm”
    Overlaid mcpupdate.tgz described in post "by tz1 » Tue Mar 11, 2014 6:41 pm”
    Overlaid isotp.zip described in post "by tz1 » Tue Mar 11, 2014 7:44 pm”
Moved these into place, and chmod -R root.root:

Code: Select all

$ ls -l /lib/modules/3.10.25+/extra/
total 180
-rw-r--r-- 1 root root 23731 Feb 24 04:58 can-bcm.ko
-rw-r--r-- 1 root root 18027 Feb 24 04:58 can-dev.ko
-rw-r--r-- 1 root root 16588 Feb 24 04:58 can-gw.ko
-rw-r--r-- 1 root root 14610 Feb 24 04:58 can-raw.ko
-rw-r--r-- 1 root root 28595 Feb 24 04:58 can.ko
-rw-r--r-- 1 root root 18769 Mar 11 12:38 isotp.ko
-rw-r--r-- 1 root root 13091 Mar 11 17:15 mcp2515.ko
-rw-r--r-- 1 root root 16119 Mar 11 17:15 spi-bcm2708.ko
-rw-r--r-- 1 root root 17370 Feb 14 22:11 spi-config.ko
Executed:

Code: Select all

$ sudo depmod -a
Added these to the autoload module list:

Code: Select all

$ 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

spi-bcm2708
spi-config
can
mcp2515
can-bcm
can-dev
can-gw
can-raw
isotp
Before rebooting, to minimize interactions, I removed USB devices so that the board only has fixed Ethernet, HDMI and 5V power from a 10W iPad power supply:

Code: Select all

Mar 29 06:03:14 raspberrypi kernel: [   12.768380] bcm2708_spi bcm2708_spi.0: DMA channel 4 at address 0xf2007400 with irq 20
Mar 29 06:03:14 raspberrypi kernel: [   12.784896] bcm2708_spi bcm2708_spi.0: DMA channel 5 at address 0xf2007500 with irq 21
Mar 29 06:03:14 raspberrypi kernel: [   12.806249] bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80)
Mar 29 06:03:14 raspberrypi kernel: [   12.832938] bcm2708_spi bcm2708_spi.0: SPI Controller running in dma mode
Mar 29 06:03:14 raspberrypi kernel: [   13.099516] can: controller area network core (rev 20120528 abi 9)
Mar 29 06:03:14 raspberrypi kernel: [   13.127241] NET: Registered protocol family 29
Mar 29 06:03:14 raspberrypi kernel: [   13.215359] CAN device driver interface
Mar 29 06:03:14 raspberrypi kernel: [   13.338698] can: broadcast manager protocol (rev 20120528 t)
Mar 29 06:03:14 raspberrypi kernel: [   13.501203] can: netlink gateway (rev 20130117) max_hops=1
Mar 29 06:03:14 raspberrypi kernel: [   13.590164] can: raw protocol (rev 20120528)
Mar 29 06:03:14 raspberrypi kernel: [   13.782641] can: isotp protocol (rev 20120528 alpha)
These appear to have loaded without problem:

Code: Select all

$ lsmod
Module                  Size  Used by
isotp                   8641  0 
can_raw                 6183  0 
can_gw                  8137  0 
can_bcm                11476  0 
mcp2515                 6494  0 
can_dev                 9884  1 mcp2515
can                    23591  4 isotp,can_gw,can_bcm,can_raw
spi_config              9367  0 
spi_bcm2708             7488  0 
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
evdev                   9419  2 
snd_seq                53769  0 
snd_seq_device          6473  1 snd_seq
8192cu                550816  0 
snd_timer              20133  2 snd_pcm,snd_seq
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
And interrupts appear as follows:

Code: Select all

$ cat /proc/interrupts 
           CPU0       
  3:       6098   ARMCTRL  BCM2708 Timer Tick
 16:          0   ARMCTRL  bcm2708_fb dma
 20:          0   ARMCTRL  bcm2708_spi.0
 32:      52080   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:       6216   ARMCTRL  bcm2708_sdhci (dma)
 80:          0   ARMCTRL  bcm2708_spi.0
 83:         20   ARMCTRL  uart-pl011
 84:       9204   ARMCTRL  mmc0
FIQ:              usb_fiq
Err:          0
And FWIW the LED on the PICAN board is on (I don't know who is using it). But can0 is not created:

Code: Select all

$ ip link set can0 up type can bitrate 125000
Cannot find device “can0"
$ ls /dev/*can*
ls: cannot access /dev/*can*: No such file or directory
Thanks in advance!

chuck90
Posts: 3
Joined: Tue Feb 25, 2014 2:35 pm

Re: CAN controller

Sun Mar 30, 2014 2:09 pm

After loading spi_bcm2708
my clock is lost. And Ehen i try to send messages With cansend
the si pin does something at the First message and than nothing happens. Dmesg always Shows "...didnt enter in conf mode"

Is it normal that the flock disappers after loading bcm2708?

andariel
Posts: 3
Joined: Mon Dec 23, 2013 8:20 pm

Re: CAN controller

Sun Mar 30, 2014 2:29 pm

Hi all,
I´m working on my school project. I would like measure some data on my Arduino and send the measured data (floats) via CAN bus to my RPi. In RPi I must get data from measeges to global variables witch I need for my C program. I have already done CAN bus communication betwen Arduinos with this lbr. https://github.com/Seeed-Studio/CAN_BUS_Shield .
But I have big problem get comunicate RPi vith MCP2515 over SPI.
I spend almost two weeks to get it work but without positive result.
My starting point on RPi was port lbr. for Arduino to get work with RPi SPI.
I use RPi SPI bcm2835 lbr. http://www.airspayce.com/mikem/bcm2835/group__spi.html to get communicate with MCP2515
I attached my code when I tried to send one float over CAN bus. My port of lbr. is attached.
Lbr. is now not working and I don't know where is problem.
My Kernel is currently 3.10.25+.
I will be very happy if somebody can help me tell what I'm doing wrong.
Or is possible to store data from messages to global variables for my program in different way?
Please reply.
Thank you
Attachments
CAN bus.zip
My port of MCP2515 lbr.
(31.01 KiB) Downloaded 286 times

tz1
Posts: 22
Joined: Tue Jan 07, 2014 10:09 pm

Re: CAN controller

Sun Mar 30, 2014 4:01 pm

jtosey wrote:I think I'm close to getting the PICAN (http://skpang.co.uk/catalog/pican-canbu ... -1196.html) to work with the mcp2515 driver on the Model B, but cannot get can0 to appear. Any help would be greatly appreciated!
The mc251x kernel on the PICAN page (http://lnxpps.de/rpie/) superficially appears to work, but the kernel is missing a WIFI driver, and has a reputation for instability.
Add the parameters to spi-config
# 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 you should load spi-config after mcp2515. There should be dmesg traffic for this.

you should be able to remove spi-config, add the params or specify them on an ismod or modprobe line, e.g.

rmmod spi_config
modprobe spi-config devices=...

The params to spi-config bind the mcp driver to the spi subsystem. It isn't really active until that happens.

purjo__
Posts: 1
Joined: Tue Apr 01, 2014 9:29 am

Re: CAN controller

Tue Apr 01, 2014 9:33 am

Does anybody know if you can use SK Pangs 'PiTFT Mini Kit - 320x240 2.8" TFT+Touchscreen' at the same time as the 'PICAN CAN-Bus Board'? Does the cards use the same I/O-ports or can the cooperate without problems?

/Tia

Joker_90
Posts: 9
Joined: Wed Mar 19, 2014 11:32 am

Re: CAN controller

Tue Apr 01, 2014 8:29 pm

Hello
I got the 3.10.25+ Kernel on my raspi.
And i followed the instruction of tz1 http://github.com/tz1/pikernomatic, first of all download the zip on the raspi then unzip it and then run ./getsource.sh first. After this i did the secound command ./setupget.sh and after this i do buildall.sh.
After compiling the kernel, aborded after there was an error
make[2]: *** [/home/pat/Desktop/pikernomatic-master/raspibuild/spi-bcm2708/spi-bcm2708.o] Error 127
make[1]: *** [_module_/home/pat/Desktop/pikernomatic-master/raspibuild/spi-bcm2708] Error 2
make[1]: Leaving directory `/home/pat/Desktop/pikernomatic-master/raspibuild/linux'
make: *** [all] Error 2
make: Leaving directory `/home/pat/Desktop/pikernomatic-master/raspibuild/spi-bcm2708'
I check the raspibuild/buildoutput file. The Boot-order was empty just in the lib order are some files.
Is this correct?
If yes what or where do i have to copy this files i would put them into the lib files of the raspi.
But how can i start then the communication with the Can-Board.
Do i also need the Canmods of the User tz1?
Thanks!
Regards
Patrick

whatspi
Posts: 1
Joined: Thu Apr 03, 2014 2:26 pm

Re: CAN controller

Thu Apr 03, 2014 2:33 pm

Hello,
I have follow everything from http://lnxpps.de/rpie/raspi-anleitung.txt
compile the module for 3.10.34+ version


Oops...sorry for a long post it works now (just I can see can0 when I do

Code: Select all

ifconfig
)


But when I try to run

Code: Select all

candump can0
nothing happens

Also when I do

Code: Select all

ip link set can0 up type can bitrate 500000
My Wi-Pi stops working (or maybe the USB port ?)

Please help !

Thank you very much,
Yod

.Webo
Posts: 1
Joined: Fri Apr 04, 2014 2:06 pm

Re: CAN controller

Fri Apr 04, 2014 2:24 pm

Hi everyone,

I've succesfully built my CAN board driven by the Raspberry Pi to monitor the traffic of a bus. After my last performance analysis I've noticed that the frame filtering of SocketCAN is not implemented in the MCP2515 driver and therefore all frames are transferred via SPI and then dropped in the network stack.
This results logically in higher CPU usage. And if the system has additional software with also high usage - it is possible to lost frames in the small receive buffer of the MCP2515 ...

So, do there exist solutions to support the hardware filtering? Or does this require an own implementation/modification :?

Regards,
Fabian

msperl
Posts: 344
Joined: Thu Sep 20, 2012 3:40 pm

Re: CAN controller

Fri Apr 04, 2014 3:48 pm

I have not seen any means to to "driver side filtering" inside the linux kernel - and I have written a new driver implementation, that works very well with a WiP DMA only SPI bus driver...

Even if there was an Interface to HW filtering - changing the Filters requires switching the mcp2515 into config mode which means that you potentially loose some messages while adding filters (and you can only have 2 fully independent filters on the mcp2515, but then you loose the second read buffer, which may be more of a pain as it means more lost frames due to overruns)

The primary overhead is actually the number of interrupts that are necessary to handle the SPI protocol.
And the new drivers mentioned above allow 500khz CAN bus saturated (in listen only mode) to read those 3225 8 byte extended messages/s and still run quite idle - scheduling/filtering the messages inside the kernel is not the problem...
The other part is latencies inside the kernel...

And BTW: I have been able to read 500M of those CAN messages with about 3000 dropped can messages over about 44 hours...

Martin

P.s: here the thread for the SPI-DMA-Bus driver: http://www.raspberrypi.org/forums/viewt ... 44&t=19489

msperl
Posts: 344
Joined: Thu Sep 20, 2012 3:40 pm

Re: CAN controller

Fri Apr 04, 2014 5:50 pm

Just to put into perspective - I did measure how much time the submit a single CAN message to the kernel stack takes: 7us/message.

So to put that into perspective: with 3300 Messages/s this means about 0.023s are spent submitting each second - that is about 2.3% of the overall CPU cycles - so the CPU effort is minimal.

By comparison the same number of messages with the default spi-driver means that only 43% of the CPU is available to userspace.
The DMA driver by comparison leaves about 83% of the CPU available (this includes the scheduling+filtering)

Martin

Return to “Interfacing (DSI, CSI, I2C, etc.)”