All of lore.kernel.org
 help / color / mirror / Atom feed
* SocketCAN on Intel Edison with MCP 2515
@ 2015-05-27 15:18 Michael Gallagher
  2015-05-28  5:22 ` Rost, Martin
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Michael Gallagher @ 2015-05-27 15:18 UTC (permalink / raw)
  To: linux-can

Hello,

I am new to SocketCAN and have some basic questions, I'm hoping that
someone might be able to point me in the right direction.

I have recompiled Yocto (uname - r returns 3.10.17-yocoto standard)
and included the SocketCAN module as well as the drivers for the MCP
2515. I can see that the module has been installed, as dmesg | grep
can returns:

[    0.754296] vcan: Virtual CAN interface driver
[    2.033276] can: controller area network core (rev 20120528 abi 9)
[    2.033429] can: raw protocol (rev 20120528)
[    2.033447] can: broadcast manager protocol (rev 20120528 t)
[    2.033476] can: netlink gateway (rev 20130117) max_hops=1

I believe I am running iproute2 because the which ip command returns /sbin/ip.

cat /proc/net/can/version returns :

rev 20120528 abi 9

I can also load all necessary (I think these are all the necessary
drivers?) drivers by issuing the following modprobe commands:

modprobe can
modprobe can-dev
modprobe can-raw
modprobe mcp251x

However, can0 is not recognized:

ifconfig returns:

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

usb0      Link encap:Ethernet  HWaddr 02:00:86:b6:1c:86
          inet addr:192.168.2.15  Bcast:192.168.2.255  Mask:255.255.255.0
          inet6 addr: fe80::86ff:feb6:1c86/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1485 errors:0 dropped:0 overruns:0 frame:0
          TX packets:56 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:297401 (290.4 KiB)  TX bytes:10210 (9.9 KiB)

wlan0     Link encap:Ethernet  HWaddr fc:c2:de:43:ee:f2
          inet addr:192.168.11.26  Bcast:0.0.0.0  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:12169 errors:0 dropped:84 overruns:0 frame:0
          TX packets:609 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1564033 (1.4 MiB)  TX bytes:60145 (58.7 KiB)

and ifconfig can0 up returns:

can0: ERROR while getting interface flags: No such device

One thing I am confused about is how the socketCAN drivers know which
SPI bus to use? I see that this information is provided in the
bcm2708.c source file for the RPI_CANBUS
(http://www.elinux.org/RPi_CANBus) project in the config_spi function.
Is there something similar I would need to do?

I thought maybe socketCAN would automatically use the SSP driver
provided by Intel, which seems like it might provide a layer of
abstraction that would make the config_spi function unnecessary? For
reference, here is what dmesg | grep -a ssp returns:

[    2.022921] merr_dpcm_dummy merr_dpcm_dummy.0:  snd-soc-dummy-dai
<-> ssp2-codec mapping ok
[    2.039652] intel_mid_ssp_spi_unified 0000:00:07.0: found PCI SSP
controller (ID: 8086h:1194h cfg: 0dh)
[    2.040598] intel_mid_ssp_spi_unified 0000:00:07.0: register with
SPI framework (bus spi3)
[    2.040765] intel_mid_ssp_spi_unified 0000:00:07.0: master is
unqueued, this is deprecated
[    2.040795] intel_mid_ssp_spi_unified 0000:00:07.0: Unbalanced
pm_runtime_enable!
[    2.046297] intel_mid_ssp_spi_unified 0000:00:07.1: found PCI SSP
controller (ID: 8086h:1194h cfg: 15h)
[    2.047172] intel_mid_ssp_spi_unified 0000:00:07.1: register with
SPI framework (bus spi5)
[    2.047338] intel_mid_ssp_spi_unified 0000:00:07.1: master is
unqueued, this is deprecated
[    2.049172] intel_mid_ssp_spi_unified 0000:00:07.1: Unbalanced
pm_runtime_enable!
[    2.056516] intel_mid_ssp_spi_unified 0000:00:07.2: found PCI SSP
controller (ID: 8086h:1194h cfg: 19h)
[    2.057360] intel_mid_ssp_spi_unified 0000:00:07.2: register with
SPI framework (bus spi6)
[    2.057527] intel_mid_ssp_spi_unified 0000:00:07.2: master is
unqueued, this is deprecated
[    2.057556] intel_mid_ssp_spi_unified 0000:00:07.2: Unbalanced
pm_runtime_enable!

Based on the above I chose to use SSP5 to wire my Edison to the
MCP2515 but I have connected a scope and never see any spi traffic.
I've also tried configuring the mux options using the following shell
script:

#SSP5_RXD
echo mode1 > /sys/kernel/debug/gpio_debug/gpio114/current_pinmux

#SSP5_CLK
echo mode1 > /sys/kernel/debug/gpio_debug/gpio109/current_pinmux

#SSP5_TXD
echo mode1 > /sys/kernel/debug/gpio_debug/gpio115/current_pinmux

#SSP5_CS
echo mode1 > /sys/kernel/debug/gpio_debug/gpio111/current_pinmux

So in short I think something is breaking in my SPI communication
configuration but I'm not sure exactly where to start. Anything you
could do to point me in the right direction towards the appropriate
documentation would be appreciated.

Thanks,

Mike

^ permalink raw reply	[flat|nested] 9+ messages in thread
* AW: SocketCAN on Intel Edison with MCP 2515
@ 2015-08-26 10:31 Michael Luxen
  2015-08-26 10:36 ` Rosemarie Sheehy
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Luxen @ 2015-08-26 10:31 UTC (permalink / raw)
  To: linux-can@vger.kernel.org, Rosemarie Sheehy,
	tom_usenet@optusnet.com.au

[-- Attachment #1: Type: text/plain, Size: 3633 bytes --]

Hi, 

attached you can find a working DeviceTree examples which is working fine for me with 2x MCP2515 CAN devices via socketcan.
The ODROID-W is an BCM2835 SoC based (Raspi like) system running kernel 3.18.x.
Hint: My MCP2515 SPI is running wth 12MHz instead of 16MHz.

On another embedded system (Raspi B) I've some days ago used a fresh Rapbmc installation with kernel 3.18.x!
I've adapted the original DeviceTree from...
https://github.com/raspberrypi/linux/blob/rpi-3.18.y/arch/arm/boot/dts/overlays/mcp2515-can0-overlay.dts
...to my needs (16MHz to 12MHz MCP2515 SPI-clock)

Maybe you can use these background informations to adapt to the Edison platform.

Regards
Michael

-----Ursprüngliche Nachricht-----
Von:	Tom Evans <tom_usenet@optusnet.com.au>
Gesendet:	Mi 26.08.2015 06:56
Betreff:	Re: SocketCAN on Intel Edison with MCP 2515
An:	Rosemarie Sheehy <rsheehy@dairymaster.ie>; linux-can@vger.kernel.org; 
> On 26/08/15 00:49, Rosemarie Sheehy wrote:
> > Michael Gallagher <mjg <at> isomorphdevelopment.com> writes:
> 
> Actually:
> 
> On 28/05/15 01:18, Michael Gallagher wrote:
>  > ...
> 
> He may not be monitoring this list after 3 months.
> 
> > I am trying to trying to set the can bus on the Edison.
> > I have the expansion board and the can-bus shield
> > (https://www.sparkfun.com/products/10039)
> 
> That's an Arduino Shield board on an adaptor on an Intel Edison running (I'm 
> guessing) Yocto Linux. Good luck with that, you may be the first in the world 
> to try that combination.
> 
> Did you read all the other posts in this thread? You may get some clues from 
> them
> 
> Apparently the RPi Linux will automatically detect the CAN chips, but you'll 
> have to consult the Yocto/Edison documentation to see if it has been set up by 
> someone to do that.
> 
> Michael didn't say which hardware he was using.
> 
> As I said in another post "Linux used t be plug-and-play, but they fixed that 
> bug". Devices on an I2C bus can sometimes be automatically identified, but the 
> MCP2515 is on an SPI bus, and it can't autodetect chips. You have to add 
> descriptions in the Device Tree File for your board (or add information to the 
> Bootstrap Configuration so it can edit the Device Tree - more complications 
> and more languages to learn to get a simple job done).
> 
> Check your Linux Source Tree "Documentation/devicetree/bindings/net/can" 
> directory. Mine has documentation for cc770, flexcan, mscan, sj1000 but no 
> mcp251x.
> 
> A more modern version of Linux has this:
> 
> http://lxr.free-electrons.com/source/Documentation/devicetree/bindings/net/can/m
> icrochip,mcp251x.txt
> 
> That doesn't tell you where in the tree to add that section. I assume it has 
> to be under/inside or reference an SPI controller somehow.
> 
> So to try and find a worked example, google for <compatible = 
> "microchip,mcp2515">
> 
> http://www.microchip.com/forums/m828830.aspx
> 
> Also check "Documentation/devicetree/bindings/spi-bus.txt".
> 
> Remember the device doesn't show up as "/dev/can0", but shows up as a network 
> device when you run "/sbin/ifconfig". It might also show up under /sys 
> somewhere too. You then have to control it (to enable and set the baud rate) 
> with "canconfig". If you don't have that software installed you may have to 
> find/configure/build/install it as well.
> 
> Tom
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-can" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

[-- Attachment #2: ODROID-W_mcp2515-can-overlay.zip --]
[-- Type: application/x-zip-compressed, Size: 1549 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-08-26 10:50 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-27 15:18 SocketCAN on Intel Edison with MCP 2515 Michael Gallagher
2015-05-28  5:22 ` Rost, Martin
2015-05-28  8:19 ` Tom Evans
2015-07-26 10:05   ` John Whitmore
2015-07-23 12:32 ` Chris
2015-07-26 10:54 ` John Whitmore
2015-08-25 14:49 ` Rosemarie Sheehy
2015-08-26  4:54   ` Tom Evans
  -- strict thread matches above, loose matches on Subject: below --
2015-08-26 10:31 AW: " Michael Luxen
2015-08-26 10:36 ` Rosemarie Sheehy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.