* 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
* RE: SocketCAN on Intel Edison with MCP 2515
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
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Rost, Martin @ 2015-05-28 5:22 UTC (permalink / raw)
To: linux-can@vger.kernel.org
Hi,
> However, can0 is not recognized:
>
> 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?
>
Well, I don't know about Yocto or the RPI, but on our Tegra t30 we have a
board file arch/arm/mach_tegra/board-colibri_t30.c which contains:
static struct mcp251x_platform_data mcp251x_pdata = {
.board_specific_setup = colibri_t20_mcp2515_setup,
.oscillator_frequency = 16000000,
.power_enable = NULL,
.transceiver_enable = NULL
};
static struct spi_board_info mcp251x_board_info[] = {
{
.bus_num = 0,
.chip_select = 0,
.max_speed_hz = 10000000,
.modalias = "mcp2515",
.platform_data = &mcp251x_pdata,
},
};
You probably want to use .bus_num=4 or 5.
> #SSP5_RXD
> #SSP5_CLK
> #SSP5_TXD
> #SSP5_CS
For us, these are configured in arch/arm/mach_tegra/board-colibri_t30-pinmux.c
> 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.
Maybe that's how it works in Yocto, too?
Regards,
M.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: SocketCAN on Intel Edison with MCP 2515
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
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Tom Evans @ 2015-05-28 8:19 UTC (permalink / raw)
To: Michael Gallagher, linux-can
On 28/05/15 01:18, Michael Gallagher wrote:
> 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)
That's pretty new. Newer linux versions rely more and more on the Device Tree.
If the devices aren't enumerated in the Device Tree (meaning that you have an
MCP2515 and it is at a specific address/chip-select on a particular SPI bus)
then it won't enable it.
Linux used to be "Plug and Play", but they've fixed that bug...
Device Tree problems are really hard. The "language" and its "keywords" depend
on every driver and every driver-writer, and they make different choices, and
then change them when a new kernel comes out.
Check in the Documentation/devicetree/Bindings to see if it says what to do.
Tom
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: SocketCAN on Intel Edison with MCP 2515
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-23 12:32 ` Chris
2015-07-26 10:54 ` John Whitmore
2015-08-25 14:49 ` Rosemarie Sheehy
4 siblings, 0 replies; 9+ messages in thread
From: Chris @ 2015-07-23 12:32 UTC (permalink / raw)
To: linux-can
Hey,
unfortunately I really can not help you, because I'm very new to SocketCan
myself, but I wanted to ask if you could share your recompiled Yocto so we
could try to figure something out. We also trying to get the MCP2515 to
work with the Edison.
Kind regards Chris
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: SocketCAN on Intel Edison with MCP 2515
2015-05-28 8:19 ` Tom Evans
@ 2015-07-26 10:05 ` John Whitmore
0 siblings, 0 replies; 9+ messages in thread
From: John Whitmore @ 2015-07-26 10:05 UTC (permalink / raw)
To: Tom Evans; +Cc: Michael Gallagher, linux-can
On Thu, May 28, 2015 at 06:19:40PM +1000, Tom Evans wrote:
> On 28/05/15 01:18, Michael Gallagher wrote:
> >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)
>
> That's pretty new. Newer linux versions rely more and more on the
> Device Tree. If the devices aren't enumerated in the Device Tree
> (meaning that you have an MCP2515 and it is at a specific
> address/chip-select on a particular SPI bus) then it won't enable
> it.
>
> Linux used to be "Plug and Play", but they've fixed that bug...
>
> Device Tree problems are really hard. The "language" and its
> "keywords" depend on every driver and every driver-writer, and they
> make different choices, and then change them when a new kernel comes
> out.
>
I'm certainly no expert but have to say that the Device Tree stuff is great,
from my point of view. I'm using RPi so previously had to edit a "C" board
file for my hardware and create structures to explain to the kernel what SPI
interface the MCP2515 was connected to, What SPI Clock Freq to use, and what
Chip Select pin to use. Then rebuild the kernel with that board file. Not
really Plug and Play.
With the later RPi kernels all I have to do is make sure MCP2515 driver is
included in the build and edit NO C files at all. Basically I then have a
device tree file that tells the RPi kernel you've got an MCP2515 connected on
Chip Select 1 and a RTC on Chip select 2. It does the rest.
One point on the original question is that when you executed "dmesg | grep
can" there was no mention of "can0" at all. It looked like the kernel didn't
recognise the chip was there. I'll try to check this for you but I think when
my system boots it recognises the device and instantiates can0 device.
I might be wrong but I'll check.
John
> Check in the Documentation/devicetree/Bindings to see if it says what to do.
>
> 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
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: SocketCAN on Intel Edison with MCP 2515
2015-05-27 15:18 SocketCAN on Intel Edison with MCP 2515 Michael Gallagher
` (2 preceding siblings ...)
2015-07-23 12:32 ` Chris
@ 2015-07-26 10:54 ` John Whitmore
2015-08-25 14:49 ` Rosemarie Sheehy
4 siblings, 0 replies; 9+ messages in thread
From: John Whitmore @ 2015-07-26 10:54 UTC (permalink / raw)
To: Michael Gallagher; +Cc: linux-can
On Wed, May 27, 2015 at 11:18:54AM -0400, Michael Gallagher wrote:
> 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
>
Hi Mike,
Just looked at my RPi system and dmesg | grep can does mention can0
interface. That interface is brought up during power up by the kernel on my
system so that it's there ready for me to do ifconfig can0 up
I do have to have baud rate settings in place ready to go before I bring it
up.
Looks like your kernel is never bringing up that interface. Have you edited
the Board file for your device to add the Hardware, or used Device Tree if
your bootloader and Kernel can use Device Tree?
John
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: SocketCAN on Intel Edison with MCP 2515
2015-05-27 15:18 SocketCAN on Intel Edison with MCP 2515 Michael Gallagher
` (3 preceding siblings ...)
2015-07-26 10:54 ` John Whitmore
@ 2015-08-25 14:49 ` Rosemarie Sheehy
2015-08-26 4:54 ` Tom Evans
4 siblings, 1 reply; 9+ messages in thread
From: Rosemarie Sheehy @ 2015-08-25 14:49 UTC (permalink / raw)
To: linux-can
Michael Gallagher <mjg <at> isomorphdevelopment.com> writes:
>
> 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:
>
Hi Michael
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)
Can you tell me how you installed the SocketCAN module as well as the
drivers for the MCP2515 please?
Thanks
Rosemarie
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: SocketCAN on Intel Edison with MCP 2515
2015-08-25 14:49 ` Rosemarie Sheehy
@ 2015-08-26 4:54 ` Tom Evans
0 siblings, 0 replies; 9+ messages in thread
From: Tom Evans @ 2015-08-26 4:54 UTC (permalink / raw)
To: Rosemarie Sheehy, linux-can
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/microchip,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
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: SocketCAN on Intel Edison with MCP 2515
2015-08-26 10:31 AW: " Michael Luxen
@ 2015-08-26 10:36 ` Rosemarie Sheehy
0 siblings, 0 replies; 9+ messages in thread
From: Rosemarie Sheehy @ 2015-08-26 10:36 UTC (permalink / raw)
To: Michael Luxen, linux-can@vger.kernel.org,
tom_usenet@optusnet.com.au
Hi
Thanks Tom and Michael for the comments.
They are helpful, I am currently trying to work my way through it.
Rosemarie
-----Original Message-----
From: Michael Luxen [mailto:mluxen@gmx.net]
Sent: 26 August 2015 11:31
To: linux-can@vger.kernel.org; Rosemarie Sheehy <rsheehy@dairymaster.com>; tom_usenet@optusnet.com.au
Subject: AW: SocketCAN on Intel Edison with MCP 2515
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
>
^ 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.