battlesnake / beaglebone-spi0-mcp2515

Device-tree overlay for using MCP2515 CAN controller @ SPI0.0 on Beaglebone with older DTS-using kernels (e.g. 4.9)
MIT License
2 stars 0 forks source link

Document pins that the MCP2515 is wired to? #1

Closed pdp7 closed 5 years ago

pdp7 commented 5 years ago

Hello, thank you for sharing this dts file. I am trying to get a MCP2515 working with the BeagleBone Black on SPI0 with the 4.14.78-bone17 kernel.

Would it be possible for to document how you had the MCP2515 wired to the P8/P9 headers on the BeagleBone Black?

Also, I would be curious to know what kernel version you were using with this Device Tree Overlay. I am trying to get this working with u-boot overlays as the cape manager driver has been deprecated.

thanks! drew

battlesnake commented 5 years ago

Hi,

I can't remember. The MCP2515 board was just for demonstration purposes for a small project, I usually use the built-in CAN protocol hardware plus an external bus driver.

You can lookup the pin IDs from my dts against the addresses from the Sitara datasheet (or take the addresses from some community-produced source like here), then adjust the DTS or your wiring as necessary.

You can either merge this into the main DT you're booting the kernel with, or (my preferred way for prototyping) load it dynamically as an overlay at runtime via the Renesas R-car kernel patch, which provides a userspace interface for loading/unloading DT overlays.

battlesnake commented 5 years ago

I've not actually used a BeagleBone for some months now, I have my own custom boards for this kind of work now, in order to reduce the colossal amount of wiring and boards that I had to deal with when using BeagleBone / RPi / Arduinos.

pdp7 commented 5 years ago

@battlesnake thank you for following up.

I'm hoping to get this MCP2515 breakout board working on the BBB SPI0 and then create a pull request on https://github.com/beagleboard/bb.org-overlays/

pdp7 commented 5 years ago

To followup, here is a GitHub gist which shows how I was able to wire the MCP2515 to SPI0 on the BeagleBone Black and successfully observe the mcp251x initialize it and load the can0 interface: https://gist.github.com/pdp7/20dddbeffe83082e3c94ab0903563783

Photos of MCP2515 breakout board wired to SPI0 on the BeagleBone Black: https://photos.app.goo.gl/1UUAHhRngzwiVWha9

add this to /boot/uEnv.txt:

uboot_overlay_addr0=/lib/firmware/BB-SPIDEV0-00A0.dtbo
uboot_overlay_addr1=/lib/firmware/MCP2515.dtbo

grab the MCP2515 overlay and install it:

cd /opt/source/bb.org-overlays/
wget https://github.com/battlesnake/beaglebone-spi0-mcp2515/blob/master/MCP2515.dts
sudo ./install.sh

After rebooting, the mcp251x driver should initialize the MCP2515 device and these commands from the Macchina documentation should work:

sudo ip link set can0 type can bitrate 500000 listen-only on
sudo ifconfig can0 up
pdp7 commented 5 years ago

@battlesnake thanks for creating this dts. I have created pull request https://github.com/beagleboard/bb.org-overlays/pull/101