Unable to compile DTBO for MCP2515 using CAN over SPI1 bus

Hey 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 followed this procedure: https://gist.github.com/pdp7/20dddbeffe83082e3c94ab0903563783 and make it work for SPI0. Now, I am trying to compile a new dts for SPI1. This is my source:

/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 = "P8.5", "gpio1_2";

	fragment@0 {
		target = <&spi1>;
		__overlay__ {
			status = "okay";
			spidev@1 {
				status = "disabled";
			};
		};
	};

	fragment@1 {
		target = <&am33xx_pinmux>;
		__overlay__ {
			mcp2515-dev1_int: mcp2515_int {
				pinctrl-single,pins = < 0x008 0x37 >;
			};
		};
	};

	fragment@2 {
		target-path = "/";
		__overlay__ {
			mcp2515-dev1_clock: mcp2515_clock {
				compatible = "fixed-clock";
				#clock-cells = <0>;
				clock-frequency = <8000000>;
			};
		};
	};

	fragment@3 {
		target = <&spi1>;
		__overlay__ {
			#address-cells = <1>;
			#size-cells = <0>;
			can1: mcp2515@1 {
				status = "okay";
				reg = <0>;
				compatible = "microchip,mcp2515";
				pinctrl-names = "default";
				pinctrl-0 = <&mcp2515-dev1_int>;
				spi-max-frequency = <10000000>;
				interrupt-parent = <&gpio1>;
				interrupts = <3 2>;
				clocks = <&mcp2515-dev1_clock>;

				mcp251x,oscillator-frequency = <8000000>;
				mcp251x,irq-gpios = <&gpio1 2 0>;
				mcp251x,stay-awake = <1>;
				mcp251x,enable-clkout = <1>;
			};
		};
	};

	__overrides__ {
		oscillator = <&mcp2515-dev1_clock>,"clock-frequency:0";
		spimaxfrequency = <&can1>,"spi-max-frequency:0";
		interrupt = <&mcp2515-dev1_int>,"pinctrl-single,pins:0",<&can1>,"interrupts:0";
	};

};

After trying to compile:

dtc -@ -Hepapr -I dts -O dtb -o MCP2515-dev1.dtbo MCP2515-dev1.dts

or

dtc -O dtb -o MCP2515-dev1.dtbo -b 0 -@ MCP2515-dev1.dts 

or by placing the dts under /opt/source/bb.org-overlays/src/arm and running install.sh under /opt/source/bb.org-overlays

I get the same error:

  DTC     src/arm/MCP2515-dev1.dtbo
Error: src/arm/MCP2515-dev1.dts:26.20-21 syntax error
FATAL ERROR: Unable to parse input tree

What am I doing wrong? Does the dts seems correct for my purposes?

/opt/scripts/tools/version.sh output:
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]
bootloader:[eMMC-(default)]:[/dev/mmcblk1]:[U-Boot 2019.04-00002-g31a8ae0206]:[location: dd MBR]
version.sh: line 137: warning: command substitution: ignored null byte in input
UBOOT: Booted Device-Tree:[am335x-boneblack-uboot-univ.dts]
UBOOT: Loaded Overlay:[AM335X-PRU-RPROC-4-19-TI-00A0]
UBOOT: Loaded Overlay:[BB-ADC-00A0]
UBOOT: Loaded Overlay:[BB-BONE-eMMC1-01-00A0]
UBOOT: Loaded Overlay:[BB-HDMI-TDA998x-00A0]
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_pru=/lib/firmware/AM335X-PRU-RPROC-4-19-TI-00A0.dtbo]
uboot_overlay_options:[enable_uboot_cape_universal=1]
pkg check: to individually upgrade run: [sudo apt install --only-upgrade <pkg>]
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 lpj=1990656 rng_core.default_quality=100 quiet]
dmesg | grep remote
[   57.731246] remoteproc remoteproc0: wkup_m3 is available
[   57.828145] remoteproc remoteproc0: powering up wkup_m3
[   57.828174] remoteproc remoteproc0: Booting fw image am335x-pm-firmware.elf, size 217168
[   57.828428] remoteproc remoteproc0: remote processor wkup_m3 is now up
[   60.180227] remoteproc remoteproc1: 4a334000.pru is available
[   60.194163] remoteproc remoteproc2: 4a338000.pru is available
dmesg | grep pru
[   60.180227] remoteproc remoteproc1: 4a334000.pru is available
[   60.180390] pru-rproc 4a334000.pru: PRU rproc node pru@4a334000 probed successfully
[   60.194163] remoteproc remoteproc2: 4a338000.pru is available
[   60.194341] pru-rproc 4a338000.pru: PRU rproc node pru@4a338000 probed successfully
dmesg | grep pinctrl-single
[    0.921363] pinctrl-single 44e10800.pinmux: 142 pins, size 568
dmesg | grep gpio-of-helper
[    0.934637] gpio-of-helper ocp:cape-universal: ready
lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
END

What I have done is:

Copy the .dts file into the overlays folder for running kernel dtb-* folder.
Ex:
/opt/source/dtb-4.19-ti/src/arm/overlays/

Edit the Make file in the overlays folder to add an entry for the new .dtbo file.
Note: I believe the entries not associated with the board you have can be removed.
Ex:
BONE-UART3.dtbo
BONE-UART4.dtbo
BONE-UART5.dtbo
MCP2515-dev1.dtbo

Back out to the top level folder:
Ex:
/opt/source/dtb-4.19-ti

Run make to build the platform dtb
Ex: For the PocketBeagle
make src/arm/am335x-pocketbeagle.dtb

Run make install to build the new and other .dtbo files:
Ex:
sudo make install

If it compiles without issue, a .dtbo should be located in the overlays folder and under ‘/boot/dtbs’ for the running kernel.

I hope this helps.

Cheers,

Jon

1 Like