WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: MCP2515 CAN interface  (Read 17232 times)

Offline johand

  • Newbie
  • *
  • Posts: 19
MCP2515 CAN interface
« on: September 17, 2015, 05:35:00 AM »
I am completely new to TinyCore. Installed my first system yesterday. So far I am very impressed! I try to enable a CAN interface on Raspberry Pi 2. I use the PICAN board based on MCP2515 (http://skpang.co.uk/catalog/pican-canbus-board-for-raspberry-pi-p-1196.html) and follows the instructions here: http://skpang.co.uk/blog/archives/1165

The problem I found is that the ip-command is not available. Any idea on how to set up the interface without ip? Doesn´t look like it is available in any extension.

Maybe something else is missing making this project “impossible”, but I would like to give it a try.

Johan

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: MCP2515 CAN interface
« Reply #1 on: September 17, 2015, 05:46:08 AM »
Hi Johan,

welcome on board. piCore by default contains only the basic kernel modules. For CAN you need to install CAN modules from the repository. It is not there yet, but will add it, please be patient a while. Same for ip command which is part of iproute2.

Are you using piCore 6.x or 7.x?
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline johand

  • Newbie
  • *
  • Posts: 19
Re: MCP2515 CAN interface
« Reply #2 on: September 17, 2015, 05:55:54 AM »
Thank you for your very quick reply! I use 6.1 right now. Should I change to 7.0? Any timeframe for when they will be added to the repository?

Johan

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: MCP2515 CAN interface
« Reply #3 on: September 17, 2015, 06:07:07 AM »
6.1 is fine. When it works, would appreciate to try on 7.0 also for testing.

Will try to do it today.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: MCP2515 CAN interface
« Reply #4 on: September 17, 2015, 06:57:21 AM »
iproute2 and can modules added to 6.x / armv7 repo. To install them, as tc user use the following command in the terminal

Code: [Select]
tce-load -iw iproute2 can-3.18.10_v7-piCore+
or use the tce browser in the gui. Let us know the result or if something still missing.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline johand

  • Newbie
  • *
  • Posts: 19
Re: MCP2515 CAN interface
« Reply #5 on: September 17, 2015, 10:42:35 AM »
That was quick, thanks!

Noticed that the description for the CAN extension is ” Kernel modules and drivers for Bluetooth”, too much copy-paste?

Unfortunately I cannot get this running (I got it running under Raspbian).

Added to config.txt:
dtoverlay=mcp2515-can0-overlay,oscillator=16000000,interrupt=25
dtoverlay=spi-bcm2835-overlay

rebooted

tc@box:~$ sudo ip link set can0 up type can bitrate 250000
Cannot find device "can0"

I guess I am missing something really simple. Can you see what is missing?

(this is 6.1, maybe I should try 7.0?)

Johan

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: MCP2515 CAN interface
« Reply #6 on: September 17, 2015, 10:49:20 AM »
Yes, it is a copy paste bug, thanks for reporting.

First lets work with 6.1, it must work and there were user feedbacks on working can.

Probably you must load the kernel modules manually. Check with lsmod command whether can modules are loaded and also /dev dir. If not loaded, load them manually:

Code: [Select]
sudo modprobe can
Probably you must load the driver also not only tha can system itself.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline johand

  • Newbie
  • *
  • Posts: 19
Re: MCP2515 CAN interface
« Reply #7 on: September 17, 2015, 11:31:36 AM »
I loaded the can module manually and it shows up with lsmod. But it doesn´t show up under /dev. Where can I find the name of the driver to load?

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: MCP2515 CAN interface
« Reply #8 on: September 17, 2015, 11:54:23 AM »
Well, just checked and the mcp251x driver module is not in the 3.18 kernel (piCore 6.x), only in the 4.1 kernel (piCore 7.x)

I'm adding the can kernel modules to the 7.x /armv7 repo within an hour. It looks like you need 7.0alpha5
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline gavinmc42

  • Sr. Member
  • ****
  • Posts: 301
Re: MCP2515 CAN interface
« Reply #9 on: September 17, 2015, 09:42:22 PM »
Wow now CAN Bela?

Had the chips and microchip Lin/Can tools for a few years, waiting, waiting....
RPi OBD display, Can bus robotics controller.....
Lots of new projects just popped into my head.
You have just blown open the industrial automation field, piCore rules.

Regards
Gavin

Offline johand

  • Newbie
  • *
  • Posts: 19
Re: MCP2515 CAN interface
« Reply #10 on: September 18, 2015, 02:24:17 AM »
Sorry to bother you again. Installed 7.0alpha5. But I cannot figure out how to load the driver, where should it be located? Nothing shows up from dmesg. Can also not load the can module any more.

tc@box:~$ sudo modprobe can
modprobe: module can not found in modules.dep
tc@box:~$ lsmod
Module                  Size  Used by    Not tainted
ipv6                  342679 18 [permanent]
i2c_dev                 6027  0
regmap_i2c              2714  0
bcm2835_gpiomem         2987  0
spi_bcm2835             7280  0
i2c_bcm2708             4950  0
regmap_mmio             2969  0
uio_pdrv_genirq         2966  0
uio                     8347  1 uio_pdrv_genirq
tc@box:~$

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: MCP2515 CAN interface
« Reply #11 on: September 18, 2015, 02:34:51 AM »
Did you install the can-modules-4.1.7-piCore_v7+.tcz package?
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline johand

  • Newbie
  • *
  • Posts: 19
Re: MCP2515 CAN interface
« Reply #12 on: September 18, 2015, 02:38:01 AM »
Yes

tc@box:~$ ls /mnt/mmcblk0p2/tce/optional/
bash.tcz                                  iproute2.tcz.dep                          mc.tcz
bash.tcz.dep                              iproute2.tcz.md5.txt                      mc.tcz.dep
bash.tcz.md5.txt                          iptables.tcz                              mc.tcz.md5.txt
bzip2-lib.tcz                             iptables.tcz.dep                          nano.tcz
bzip2-lib.tcz.md5.txt                     iptables.tcz.md5.txt                      nano.tcz.dep
can-modules-4.1.7-piCore_v7+.tcz          ipv6-4.1.7-piCore_v7+.tcz                 nano.tcz.md5.txt
can-modules-4.1.7-piCore_v7+.tcz.md5.txt  ipv6-4.1.7-piCore_v7+.tcz.md5.txt         ncurses.tcz
db.tcz                                    libelf.tcz                                ncurses.tcz.md5.txt
db.tcz.md5.txt                            libelf.tcz.md5.txt                        netfilter-4.1.7-piCore_v7+.tcz
file.tcz                                  libffi.tcz                                netfilter-4.1.7-piCore_v7+.tcz.md5.txt
file.tcz.md5.txt                          libffi.tcz.md5.txt                        openssh.tcz
findutils.tcz                             libgcrypt.tcz                             openssh.tcz.dep
findutils.tcz.md5.txt                     libgcrypt.tcz.dep                         openssh.tcz.md5.txt
gamin.tcz                                 libgcrypt.tcz.md5.txt                     openssl.tcz
gamin.tcz.md5.txt                         libgpg-error.tcz                          openssl.tcz.md5.txt
glib2.tcz                                 libgpg-error.tcz.md5.txt                  pcre.tcz
glib2.tcz.dep                             libssh2.tcz                               pcre.tcz.dep
glib2.tcz.md5.txt                         libssh2.tcz.dep                           pcre.tcz.md5.txt
iproute2.tcz                              libssh2.tcz.md5.txt
tc@box:~$ more /mnt/mmcblk0p2/tce/onboot.lst
mc.tcz
openssh.tcz
nano.tcz
iproute2.tcz
can-modules-4.1.7-piCore_v7+.tcz
findutils.tcz
tc@box:~$

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: MCP2515 CAN interface
« Reply #13 on: September 18, 2015, 02:56:01 AM »
can-modules-4.1.7-piCore_v7+.tcz was buggy. Fixed, please update your system.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline johand

  • Newbie
  • *
  • Posts: 19
Re: MCP2515 CAN interface
« Reply #14 on: September 18, 2015, 06:16:44 AM »
Seems to be working perfect now! Thanks for your support!

I it possible to add these extensions to armv6 as well? I have a plan using MCP2515 with the Raspberry Pi Compute Module in near future.

Johan