hhh321
Posts: 17
Joined: Fri Apr 22, 2016 12:41 pm

No can0 interface RPi 3

Fri Apr 22, 2016 12:55 pm

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".
Last edited by hhh321 on Fri Apr 22, 2016 2:55 pm, edited 1 time in total.

Aydan
Posts: 713
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: No can0 interface RPi 3

Fri Apr 22, 2016 1:49 pm

Try swapping the lines in your config.txt
SPI first, then CAN

Regards
Aydan

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

hhh321
Posts: 17
Joined: Fri Apr 22, 2016 12:41 pm

Re: No can0 interface RPi 3

Fri Apr 22, 2016 1:53 pm

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.

Aydan
Posts: 713
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: No can0 interface RPi 3

Fri Apr 22, 2016 2:41 pm

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

hhh321
Posts: 17
Joined: Fri Apr 22, 2016 12:41 pm

Re: No can0 interface RPi 3

Fri Apr 22, 2016 2:46 pm

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.

Aydan
Posts: 713
Joined: Fri Apr 13, 2012 11:48 am
Location: Germany, near Lake Constance

Re: No can0 interface RPi 3

Fri Apr 22, 2016 5:52 pm

what are the outputs of the following commands?

Code: Select all

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

hhh321
Posts: 17
Joined: Fri Apr 22, 2016 12:41 pm

Re: No can0 interface RPi 3

Mon Apr 25, 2016 7:01 am

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

iotope
Posts: 1
Joined: Fri Apr 29, 2016 8:12 pm

Re: No can0 interface RPi 3

Fri Apr 29, 2016 8:23 pm

Is socketcan installed?

hhh321
Posts: 17
Joined: Fri Apr 22, 2016 12:41 pm

Re: No can0 interface RPi 3

Mon May 02, 2016 9:07 am

Yes, I have installed libsocketcan-dev + can-utils.

hhh321
Posts: 17
Joined: Fri Apr 22, 2016 12:41 pm

Re: No can0 interface RPi 3

Mon May 16, 2016 3:00 pm

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?

laalex
Posts: 20
Joined: Fri May 27, 2016 7:29 pm

Re: No can0 interface RPi 3

Sat May 28, 2016 2:28 pm

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 :(

Return to “Troubleshooting”