CAN over SPI using MCP2515 and Beaglebone

Hey! Just like the title says, I’m interested in doing this. I know I can use the CAN bus on the Beaglebone, but I want to be able to do it over SPI. Anyone ever tried this before?

I have a feeling that you will have to change the low level driver code to include the SPI mechanism. Can is not just a protocol but there is a lot of bus arbitration type of actions at low level.
I wonder if it would not be easier to look for a high level protocol that can be piped to any comms driver or even roll your own.

BlueArcCNC email signature_pdf conversion.jpg

e943ecc8-5be2-4768-a17e-1b829b908afe.gif

The last time I looked, the there was already a kernel driver for this CAN device. http://lxr.free-electrons.com/source/drivers/net/can/mcp251x.c?v=3.14 is just one such example for the 3.14.x kernel, but that does not mean you need 3.14.x kernel for it to work.

Anyway, I know several people have gotten this chip to work on the rPI - Since I googled this chip a couple months ago to see what all was done with it in Linux. At minimum you should have many things to go by from the rPI camp. Most of the setup / usage should be similar.

BlueArcCNC email signature_pdf conversion.jpg

e943ecc8-5be2-4768-a17e-1b829b908afe.gif

Thanks for that William. Very handy information. Do you know if anyone made it work on BBB yet?
I will try that soon I hoop.

BlueArcCNC email signature_pdf conversion.jpg

e943ecc8-5be2-4768-a17e-1b829b908afe.gif

Thanks for that William. Very handy information. Do you know if anyone made it work on BBB yet?

I will try that soon I hoop.

No idea, but I’d imagine it shouldn’t be too much to get working.

What I’d really like to see is someone using a PRU with this device. Just because I think it’d be interesting.

e943ecc8-5be2-4768-a17e-1b829b908afe.gif

BlueArcCNC email signature_pdf conversion.jpg

Related question: I’m using the towertech CAN cape (mcp2515) and seeing a lot of CPU usage by the spi process. For example, just connecting one interface to an active bus gives 30-50% CPU usage, and that doesn’t include actually doing anything with the data! I’m running debian with kernel 3.8.13-bone70 and using the driver source they provide (mcp2515). Is this a known issue? Has it been addressed in more recent kernels? Thanks!

Could you please provide us with your working device tree overlay?

onsdag 17. februar 2016 15.39.41 UTC+1 skrev paulda...@gmail.com følgende:

Related question: I’m using the towertech CAN cape (mcp2515) and seeing a lot of CPU usage by the spi process. For example, just connecting one interface to an active bus gives 30-50% CPU usage, and that doesn’t include actually doing anything with the data! I’m running debian with kernel 3.8.13-bone70 and using the driver source they provide (mcp2515). Is this a known issue? Has it been addressed in more recent kernels? Thanks!

Sounds like there is no DMA “happening” with those SPI transactions. But if DMA is a problem, using a PRU to bitbang SPI should probably offload that CPU.

If you are using a devicetree overlay, then SPI DMA won’t work. You have to build the driver into the base devicetree using dtb-rebuilder to get DMA to work with your SPI driver.

Regards,
John