Hi there,
i'm trying to get my Pi ( REV 1 )connected to an arduino using a self made can Interface with the mcp2515 and mcp2551.
The interfaces itself work, I can connect two arduinos without a any Problems.
But when I connect one of it to the Pi the sending arduino just lights up the leds connected on can-txd and can-rxd of the 2515.
This normaly only happens if the sending arduino is not connected to the bus or is the only device.
On the Pi side I crosscompiled a 3.12.26+ and got all modules compiled and they all load without any error.
lsmod
Code: Select all
root@raspi:~# uname -a
Linux raspi 3.12.26+ #1 Sun Aug 31 00:40:21 CEST 2014 armv6l GNU/Linux
root@raspi:~# lsmod
Module Size Used by
mcp251x 7248 0
spi_config 8568 0
can_bcm 9732 0
can_raw 4972 0
can_dev 5560 1 mcp251x
can 18228 2 can_bcm,can_raw
spi_bcm2708 3728 0
snd_bcm2835 13596 0
snd_pcm 52180 1 snd_bcm2835
snd_page_alloc 2708 1 snd_pcm
snd_seq 34932 0
snd_seq_device 3640 1 snd_seq
snd_timer 13584 2 snd_pcm,snd_seq
snd 35796 5 snd_bcm2835,snd_timer,snd_pcm,snd_seq,snd_seq_device
dmesg:
Code: Select all
bcm2708_spi bcm2708_spi.0: master is unqueued, this is deprecated
bcm2708_spi bcm2708_spi.0: SPI Controller at 0x20204000 (irq 80)
can: controller area network core (rev 20120528 abi 9)
NET: Registered protocol 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=0x2002:force_release
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:cea64c40: 00 24 f4 00 02 20 00 00 00 00 00 00 00 00 00 00 .$... ..........
spi_config_register:spi0.0:platform data:cea64c50: 00 00 00 00 ....
mcp251x spi0.0: probed
mcp251x spi0.0: CNF: 0x03 0xb5 0x01
The interupt is also registered but never gets a hit:
Code: Select all
root@raspi:~# cat /proc/interrupts
CPU0
3: 43921 ARMCTRL BCM2708 Timer Tick
16: 0 ARMCTRL bcm2708_fb dma
32: 694934 ARMCTRL dwc_otg, dwc_otg_pcd, dwc_otg_hcd:usb1
52: 0 ARMCTRL BCM2708 GPIO catchall handler
65: 3 ARMCTRL ARM Mailbox IRQ
66: 1 ARMCTRL VCHIQ doorbell
75: 1 ARMCTRL
77: 5762 ARMCTRL bcm2708_sdhci (dma)
80: 36 ARMCTRL bcm2708_spi.0
83: 20 ARMCTRL uart-pl011
84: 7767 ARMCTRL mmc0
195: 0 GPIO mcp251x
FIQ: usb_fiq
Err: 0
The Interface is up:
Code: Select all
root@raspi:~# ip -s -d link show can0
3: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc pfifo_fast state UNKNOWN mode DEFAULT 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
0 0 0 0 0 0
TX: bytes packets errors dropped carrier collsns
0 0 0 0 0 0
When I set the interface up with the loopback option I can send and receive frames localy, but candump never gets anything from the arduino nor does a listening arduino ever get something from the Pi.
I use this bash-script to load the module and set up the can0 device:
Code: Select all
root@raspi:~# cat loadcan.sh
#!/bin/bash
modprobe can
modprobe can-dev
modprobe can-raw
modprobe can-bcm
modprobe spi-bcm2708
insmod spi-config/spi-config.ko devices=bus=0:cs=0:modalias=mcp2515:speed=10000000:gpioirq=25:pd=20:pds32-0=16000000:pdu32-4=0x2002:force_release
modprobe mcp251x
/sbin/ip link set can0 up type can bitrate 125000
ifconfig can0 up
I guess the last ifconfig isn't necessary but I found it in some howtos.
The only Thing I noticed is that the arduino uses this for the cfg Registers of the mcp2515:
Code: Select all
#define MCP_16MHz_125kBPS_CFG1 (0x03)
#define MCP_16MHz_125kBPS_CFG2 (0xF0)
#define MCP_16MHz_125kBPS_CFG3 (0x86)
whereas the mcp251x module uses other values:
Code: Select all
mcp251x spi0.0: CNF: 0x03 0xb5 0x01
Is there anything special about the REV 1 that I missed out? The GPIO Header layout should be the same on the pins used, right?
Any ideas where the problem is or what I can try to make it work?
I'm realy out of ideas now.
Thank you
Ingo