Hi,
after having performed some tests I managed to have the mcp2518fd working with Armbian and Orange PI zero.
In attachment there is a patch that works with the current version.
The driver is the same as in the main kernel version:
https://github.com/torvalds/linux/tree/master/drivers/net/can/spi/mcp251xfd
after compiling the kernel it is necessary to add the following custom overlay in /boot/overlay-user
/dts-v1/;
/plugin/;
/ {
compatible = "allwinner,sun4i-a10", "allwinner,sun7i-a20", "allwinner,sun8i-h3", "allwinner,sun50i-a64", "allwinner,sun50i-h5";
fragment@0 {
target-path = "/clocks";
overlay {
#address-cells = <1>;
#size-cells = <1>;
can0_osc_fixed: can0_osc_fixed {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <20000000>;
};
};
};
fragment@1 {
target = <&pio>;
overlay {
can0_pin_irq: can0_pin_irq {
pins = "PA10";
function = "irq";
bias-pull-up;
};
};
};
fragment@2 {
target = <&spi1>;
overlay {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
mcp2515 {
reg = <0>;
compatible = "microchip,mcp2518fd";
pinctrl-names = "default";
pinctrl-0 = <&can0_pin_irq>;
spi-max-frequency = <10000000>;
interrupt-parent = <&pio>;
interrupts = <0 10 2>; /* PA10 IRQ_TYPE_EDGE_FALLING */
clocks = <&can0_osc_fixed>;
status = "okay";
};
};
};
};
In my case the interrupt pin is on PA10 and the crystal on mcp is 20MHz, change them if necessary.
copile it with armbian-add-overlay, then after the reboot launch the following commands:
ip link set can0 type can bitrate 500000
ip link up can0
where 500000 is the bitrate of your canBus.
It is possible to test the connection with:
cansend can0 123#1122334455667788
or
candump can0
mcp2518fd.patch