Hello there Beaglebone community,
I am trying to connect two microchip MCP2515 CAN controller over SPI to a beaglebone, one on SPI0 and another one on SPI1. I used the following procedure as a base:
Right now, I have both working, but not at the same time. I need to add one overlay for SPI0, and it works:
debian@beaglebone:~$ dmesg | grep mcp
[ 26.036544] mcp251x spi0.0 can0: MCP2515 successfully initialized.
Then add another overlay for SPI1 and it also works. See output:
debian@beaglebone:~$ dmesg | grep mcp
[ 26.301898] mcp251x spi1.1 can0: MCP2515 successfully initialized.
But whenever I try to add both overlays at the same time, one works but the other doesn’t:
debian@beaglebone:~$ dmesg | grep mcp
[ 25.343504] mcp251x spi0.0: prop pinctrl-0 index 0 invalid phandle
[ 25.786343] mcp251x: probe of spi0.0 failed with error -22
[ 26.301898] mcp251x spi1.1 can0: MCP2515 successfully initialized.
What am I doing wrong?
Here is my dts for SPI0:
/dts-v1/;
/plugin/;
/ {
compatible = “ti,beaglebone”, “ti,beaglebone-black”, “ti,beaglebone-green”;
exclusive-use = "P8.6", "gpio1_3";
/*
* Helper to show loaded overlays under: /proc/device-tree/chosen/overlays/
*/
fragment@0 {
target-path="/";
__overlay__ {
chosen {
overlays {
MCP2515-SPI0 = __TIMESTAMP__;
};
};
};
};
fragment@1{
target = <&ocp>;
__overlay__ {
P9_17_pinmux { status = "disabled"; }; /* P9_17 (A16) spi0_cs0.spi0_cs0 */
P9_18_pinmux { status = "disabled"; }; /* P9_18 (B16) spi0_d1.spi0_d1 */
P9_21_pinmux { status = "disabled"; }; /* P9_21 (B17) spi0_d0.spi0_d0 */
P9_22_pinmux { status = "disabled"; }; /* P9_22 (A17) spi0_sclk.spi0_sclk */ };
};
fragment@2 {
target = <&am33xx_pinmux>;
__overlay__ {
bb_spi0_pins: pinmux_bb_spi0_pins {
pinctrl-single,pins = <
0x150 0x30 /* configure sck0 */
0x154 0x30 /* configure d0 */
0x158 0x10 /* configure d1 */
0x15C 0x10 /* configure cs0 */
>;
};
mcp2515_int1: mcp2515_int {
pinctrl-single,pins = < 0x00c 0x37 >;
};
};
};
fragment@3 {
target = <&spi0>;
__overlay__ {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&bb_spi0_pins>;
//channel@0{ status = "disabled"; };
//channel@1{ status = "disabled"; };
};
};
fragment@4 {
target-path = "/";
__overlay__ {
mcp2515_clock: mcp2515_clock {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <8000000>;
};
};
};
fragment@5 {
target = <&spi0>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
can0: mcp2515@0 {
status = "okay";
reg = <0>;
compatible = "microchip,mcp2515";
pinctrl-names = "default";
pinctrl-0 = <&mcp2515_int1>;
spi-max-frequency = <10000000>;
interrupt-parent = <&gpio1>;
interrupts = <3 2>;
clocks = <&mcp2515_clock>;
mcp251x,oscillator-frequency = <8000000>;
mcp251x,irq-gpios = <&gpio1 3 0>;
mcp251x,stay-awake = <1>;
mcp251x,enable-clkout = <1>;
};
};
};
__overrides__ {
oscillator = <&mcp2515_clock>,"clock-frequency:0";
spimaxfrequency = <&can0>,"spi-max-frequency:0";
interrupt = <&mcp2515_int1>,"pinctrl-single,pins:0",<&can0>,"interrupts:0";
};
};
Here is my dts for SPI1:
/dts-v1/;
/plugin/;
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/pinctrl/am33xx.h>
#include <dt-bindings/interrupt-controller/irq.h>
/ {
compatible = "ti,beaglebone", "ti,beaglebone-black", "ti,beaglebone-green";
exclusive-use = "P9.12", "gpio1_28";
fragment@0 {
target = <&ocp>;
__overlay__ {
P9_29_pinmux { status = "disabled"; }; /* SPI1 MOSI - gpio1_9 */
P9_30_pinmux { status = "disabled"; }; /* SPI1 MISO - gpio1_8 */
P9_31_pinmux { status = "disabled"; }; /* SPI1 CLK - gpio0_7 */
P9_28_pinmux { status = "disabled"; }; /* SPI1 CS0 - gpio3_17 */
//P9_19_pinmux { status = "disabled"; }; /* SPI1 CS1 - gpio0_19 */
P9_12_pinmux { status = "disabled"; }; /* SWC nINT */
//P8_18_pinmux { status = "disabled"; }; /* SWC nRESET */
//P8_16_pinmux { status = "disabled"; }; /* SWC M0 */
//P8_14_pinmux { status = "disabled"; }; /* SWC M1 */
};
};
fragment@1 {
target = <&am33xx_pinmux>;
__overlay__ {
bb_spi1_pins: pinmux_bb_spi1_pins {
pinctrl-single,pins = <
0x190 0x33
0x194 0x33
0x198 0x13
//0x19c 0x13
0x164 0x12
>;
};
mcp2515_int: mcp2515_int {
pinctrl-single,pins = < 0x087 0x37 >;
};
};
};
fragment@2 {
target = <&spi1>;
__overlay__ {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&bb_spi1_pins>;
//channel@0{ status = "disabled"; };
//channel@1{ status = "disabled"; };
};
};
fragment@3 {
target-path = "/";
__overlay__ {
mcp2515_clock1: mcp2515_clock {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <8000000>;
};
};
};
fragment@4 {
target = <&spi1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
can1: mcp2515@1 {
status = "okay";
reg = <1>;
compatible = "microchip,mcp2515";
pinctrl-names = "default";
pinctrl-0 = <&mcp2515_int>;
spi-max-frequency = <10000000>;
interrupt-parent = <&gpio1>;
interrupts = <28 2>;
clocks = <&mcp2515_clock1>;
mcp251x,oscillator-frequency = <8000000>;
mcp251x,irq-gpios = <&gpio1 28 0>;
mcp251x,stay-awake = <1>;
mcp251x,enable-clkout = <1>;
};
};
};
__overrides__ {
oscillator = <&mcp2515_clock1>,"clock-frequency:0";
spimaxfrequency = <&can1>,"spi-max-frequency:0";
interrupt = <&mcp2515_int>,"pinctrl-single,pins:0",<&can1>,"interrupts:0";
};
};
Output of /opt/scripts/tools/version.sh:
git:/opt/scripts/:[b39ec679648a6be8f25f48bd1c9784c1fc5a0c46]
eeprom:[A335BNLTEIA02118SBB08756]
model:[TI_AM335x_BeagleBone_Black]
dogtag:[BeagleBoard.org Debian Buster IoT Image 2020-04-06]
bootloader:[microSD-(push-button)]:[/dev/mmcblk0]:[U-Boot 2019.04-00002-g07d5700e21]:[location: dd MBR]
/opt/scripts/tools/version.sh: line 137: warning: command substitution: ignored null byte in input
UBOOT: Booted Device-Tree:[am335x-boneblack-uboot.dts]
UBOOT: Loaded Overlay:[MCP2515-SPI0]
kernel:[4.19.94-ti-r42]
nodejs:[v10.15.2]
/boot/uEnv.txt Settings:
uboot_overlay_options:[enable_uboot_overlays=1]
uboot_overlay_options:[uboot_overlay_addr0=/lib/firmware/MCP2515-SPI0.dtbo]
uboot_overlay_options:[uboot_overlay_addr1=/lib/firmware/MCP2515-SPI1.dtbo]
uboot_overlay_options:[disable_uboot_overlay_emmc=1]
uboot_overlay_options:[disable_uboot_overlay_video=1]
uboot_overlay_options:[disable_uboot_overlay_audio=1]
uboot_overlay_options:[disable_uboot_overlay_wireless=1]
uboot_overlay_options:[disable_uboot_overlay_adc=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade ]
pkg:[bb-cape-overlays]:[4.14.20200403.0-0rcnee0~buster+20200403]
pkg:[bb-wl18xx-firmware]:[1.20200322.0-0rcnee0~buster+20200322]
pkg:[kmod]:[26-1]
pkg:[librobotcontrol]:[1.0.4-git20190227.1-0rcnee0~buster+20190327]
pkg:[firmware-ti-connectivity]:[20190717-2rcnee1~buster+20200305]
groups:[debian : debian adm kmem dialout cdrom floppy audio dip video plugdev users systemd-journal bluetooth netdev i2c gpio pwm eqep remoteproc admin spi iio docker tisdk weston-launch xenomai cloud9ide]
cmdline:[console=ttyO0,115200n8 bone_capemgr.uboot_capemgr_enabled=1 root=/dev/mmcblk0p1 ro rootfstype=ext4 rootwait coherent_pool=1M net.ifnames=0 quiet]
dmesg | grep remote
[ 32.293028] remoteproc remoteproc0: wkup_m3 is available
[ 33.993496] remoteproc remoteproc0: powering up wkup_m3
[ 33.993530] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
[ 33.993825] remoteproc remoteproc0: remote processor wkup_m3 is now up
dmesg | grep pru
dmesg | grep pinctrl-single
[ 0.948957] pinctrl-single 44e10800.pinmux: 142 pins, size 568
dmesg | grep gpio-of-helper
[ 0.950662] gpio-of-helper ocp:cape-universal: ready
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END
Thanks!!