Following a successful deployment of an MCP2515 SPI to CAN device with the great help of https://forum.armbian.com/topic/3588-can-bus-support-orange-pi-zero/ I’ve been looking into using an SPI to CANFD device with the orangePi R1 (H2+ based). (CANFD allows greater bitrate than the “regular” CAN)
I am looking into using the driver made for the mcp2517fd/mcp2518fd, which has been submitted but not yet linux mainlined: https://github.com/msperl/linux-rpi/tree/upstream-v5.0-rc3-mcp25xxfd-v6.11/drivers/net/can/spi/mcp25xxfd
This driver seems to be functional with the raspberry pi, and an example of PCB and associated overlay can be seen here: https://github.com/Seeed-Studio/pi-hats/tree/master/CAN-HAT
I’ve been able to compile the drivers successfully (on kernel 4.19.72) and insmod/modprobe them. I also managed to compile the overlays into a dtbo (with dtc v1.4.7 and using -@ argument), but uBoot seems to find some errors in it:
Applying kernel provided DT overlay sun8i-h3-spi1-mcp25xxfd.dtbo
failed on fdt_overlay_apply(): FDT_ERR_BADOVERLAY
Error applying DT overlays, restoring original DT
29943 bytes read in 4 ms (7.1 MiB/s)
Any ideas as to how I could look into debugging this? libfdt (https://github.com/qemu/dtc/blob/master/libfdt/fdt_overlay.c) shows 14 different ways that the dtbo file can fail loading and have FDT_ERR_BADOVERLAY thrown
This is my dts:
/dts-v1/;
/plugin/;
//#include <dt-bindings/interrupt-controller/irq.h>
/ {
compatible = "allwinner,sun8i-h3";
fragment@0 {
target-path = "/aliases";
__overlay__ {
spi1 = "/soc/spi@01c69000";
};
};
/* the interrupt pin of the can-controller */
fragment@1 {
target = <&pio>;
__overlay__ {
can0_pin_irq: can0_pin_irq {
allwinner,pins = "PA2";
allwinner,function = "irq";
allwinner,drive = <0x0>;
allwinner,pull = <0x1>;
linux,phandle = <0x1>;
phandle = <0x1>;
};
};
};
/* the clock/oscillator of the can-controller */
fragment@2 {
target-path = "/clocks";
__overlay__ {
/* external 20M oscillator of mcp2517fd on SPI0.0 */
mcp2517fd_osc: mcp2517fd_osc {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <0x400000>;
linux,phandle = <0x2>;
phandle = <0x2>;
};
};
};
/* the spi config of the can-controller itself binding everything together */
fragment@3 {
//target = <0xffffffff>;
target = <&spi1>;
can_overlay:__overlay__ {
status = "okay";
/* needed to avoid dtc warning */
#address-cells = <1>;
#size-cells = <0>;
mcp2517fd: mcp2517fd@0 {
reg = <0>;
compatible = "microchip,mcp2517fd";
pinctrl-names = "default";
pinctrl-0 = <&can0_pin_irq>;
spi-max-frequency = <10000000>;
interrupt-parent = <&pio>;
interrupts = <0 2 8>; /* PA2 / IRQ_TYPE_LEVEL_LOW */
clocks = <&mcp2517fd_osc>;
};
};
};
};