Page 1 of 1

No can0 interface RPi 3

Posted: Fri Apr 22, 2016 12:55 pm
by hhh321
Hello,
I'm trying to connect my RPi3 to CAN bus with MCP2515 controller using SPI. I have ready module with MCP2515 and TJA1050 on board. Here is link to scheme http://elty.pl/pl/p/file/e6f9cc8afd8b6b ... module.pdf.I added this 2 lines to my /boot/config.txt .

Code: Select all

dtoverlay=mcp2515-can0,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835
Previously i enabled spi so dtparam=spi=on was already there. After setting my config.txt i run sudo reboot. After rebooting my result for

Code: Select all

ls /dev/spi*
is :

Code: Select all

/dev/spidev0.1
Same is happening while i connect to mcp2515-can1 then my

Code: Select all

ls /dev/spi*
result is:

Code: Select all

/dev/spidev0.0
In both situations can0 or can1 is not visible in ifconfig and trying to access it returns

Code: Select all

No such device
.
Can anyone guide me how can i configure my RPi so can0 interface is visible in ifconfig ?
[EDIT]
Following this: viewtopic.php?f=44&t=141052&p=933920&hilit=can0#p933920 I don't have 'net' directory for "sys/bus/spi/devices/spi0.0".

Re: No can0 interface RPi 3

Posted: Fri Apr 22, 2016 1:49 pm
by Aydan
Try swapping the lines in your config.txt
SPI first, then CAN

Regards
Aydan

Edit: Where does the MCP2515 get it's clock from?

Re: No can0 interface RPi 3

Posted: Fri Apr 22, 2016 1:53 pm
by hhh321
Aydan : nothing changes if I swap bcm2835 with mcp2515 overlays in config.txt.
[EDIT]
I have connected SPI CLK(SCLK) to SCK pin on my board with mcp2515.

Re: No can0 interface RPi 3

Posted: Fri Apr 22, 2016 2:41 pm
by Aydan
I meant pins 8 & 9 of the MCP2515. Are they connected to a crystal?
You did not state if this is something you built yourself or if it is a ready made module.

Regards
Aydan

Re: No can0 interface RPi 3

Posted: Fri Apr 22, 2016 2:46 pm
by hhh321
I'm using ready module. Here is link to scheme http://elty.pl/pl/p/file/e6f9cc8afd8b6b ... module.pdf. It is connected to 16MHz crystal.

Re: No can0 interface RPi 3

Posted: Fri Apr 22, 2016 5:52 pm
by Aydan
what are the outputs of the following commands?

Code: Select all

lsmod | grep mcp25
dmesg | grep mcp25
dmesg | grep spi
Regards
Aydan

Re: No can0 interface RPi 3

Posted: Mon Apr 25, 2016 7:01 am
by hhh321

Code: Select all

lsmod | grep mcp25
mcp251x                 8438  0 
can_dev                 9381  1 mcp251x

Code: Select all

dmesg | grep mcp25
[    9.537230] Modules linked in: mcp251x can_dev brcmfmac brcmutil cfg80211 rfkill snd_bcm2835 bcm2835_rng bcm2835_gpiomem spi_bcm2835 snd_pcm snd_timer snd uio_pdrv_genirq uio i2c_dev fuse ipv6

Code: Select all

dmesg | grep spi
[    6.355722] spi spi0.0: setting up native-CS0 as GPIO 8
[    6.355871] spi spi0.1: setting up native-CS1 as GPIO 7
[    9.537230] Modules linked in: mcp251x can_dev brcmfmac brcmutil cfg80211 rfkill snd_bcm2835 bcm2835_rng bcm2835_gpiomem spi_bcm2835 snd_pcm snd_timer snd uio_pdrv_genirq uio i2c_dev fuse ipv6

Re: No can0 interface RPi 3

Posted: Fri Apr 29, 2016 8:23 pm
by iotope
Is socketcan installed?

Re: No can0 interface RPi 3

Posted: Mon May 02, 2016 9:07 am
by hhh321
Yes, I have installed libsocketcan-dev + can-utils.

Re: No can0 interface RPi 3

Posted: Mon May 16, 2016 3:00 pm
by hhh321
As mentioned in: viewtopic.php?f=44&t=7027&sid=501d5932c ... &start=625, I run test posted by msperl , my output without any parameter is :

Code: Select all

Resetting MCP2515
RESET                  0 0x00
Read MCP2515 registers
CMD-READ               0 0x00
REG-CNF3               0 0x00
CNF3                   0 0x00
CNF2                   0 0x00
CNF1                   0 0x00
INTE                   0 0x00
INTF                   0 0x00
EFLG                   0 0x00
CANSTAT                0 0x00
CANCTRL                0 0x00
Then i did same as Romey-Rome(connected gpio7 to gpio9) and I got exactly the same result as him. With argument "7" I get :

Code: Select all

Resetting MCP2515
RESET                  0 0x00
Read MCP2515 registers
CMD-READ               0 0x00
REG-CNF3               0 0x00
CNF3                   0 0x00
CNF2                   0 0x00
CNF1                   0 0x00
INTE                   0 0x00
INTF                   0 0x00
EFLG                   0 0x00
CANSTAT                0 0x00
CANCTRL                0 0x00
And without it i get:

Code: Select all

Resetting MCP2515
RESET                  255 0xff
Read MCP2515 registers
CMD-READ               255 0xff
REG-CNF3               255 0xff
CNF3                   255 0xff
CNF2                   255 0xff
CNF1                   255 0xff
INTE                   255 0xff
INTF                   255 0xff
EFLG                   255 0xff
CANSTAT                255 0xff
CANCTRL                255 0xff
I also tested my SPI pins at RPi using script from wiringPi. Results were good(every pin returned OK). So i guess i didn't broke my RPi pins.
Can somebody give other solution than buying new CAN controller?

Re: No can0 interface RPi 3

Posted: Sat May 28, 2016 2:28 pm
by laalex
I have the same problem but the commands above return for me:

Code: Select all

[email protected]:~ $ lsmod | grep mcp25
mcp251x                 8502  0
can_dev                 9561  1 mcp251x

Code: Select all

[email protected]:~ $ dmesg | grep mcp25
-> returns nothing

Code: Select all

[email protected]:~ $ dmesg | grep spip
-> returns nothing

GPIO test:

Code: Select all

Resetting MCP2515
RESET                255 0xff
Read MCP2515 registers
CMD-READ             255 0xff
REG-CNF3             255 0xff
CNF3                 255 0xff
CNF2                 255 0xff
CNF1                 255 0xff
INTE                 255 0xff
INTF                 255 0xff
EFLG                 255 0xff
CANSTAT              255 0xff
CANCTRL              255 0xff

I can't set up in any way can0 to show up :(