Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

MCP2518FD not working with OrangePI

Featured Replies

Hi,

we are trying to make our Orange PI zero with custom shield working with an MCP2518FD on board with SN65HVD23 tranceiver.
We started from the normal kernel already built, but according to this thread we found that it must be activated at compile time.

 

So we downloaded the repo and built the Armbian image with this CAN configuration:

 

CONFIG_CAN=y
CONFIG_CAN_RAW=y
CONFIG_CAN_BCM=y
CONFIG_CAN_GW=y
CONFIG_CAN_J1939=y

#
# CAN Device Drivers
#
CONFIG_CAN_VCAN=y
CONFIG_CAN_VXCAN=y
CONFIG_CAN_SLCAN=y
CONFIG_CAN_DEV=y
CONFIG_CAN_CALC_BITTIMING=y
CONFIG_CAN_FLEXCAN=y
CONFIG_CAN_GRCAN=y
CONFIG_CAN_SUN4I=y
CONFIG_CAN_TI_HECC=y
CONFIG_CAN_C_CAN=y
CONFIG_CAN_C_CAN_PLATFORM=m
CONFIG_CAN_CC770=y
CONFIG_CAN_CC770_ISA=m
CONFIG_CAN_CC770_PLATFORM=m
CONFIG_CAN_IFI_CANFD=y
CONFIG_CAN_M_CAN=y
CONFIG_CAN_M_CAN_PLATFORM=y
CONFIG_CAN_M_CAN_TCAN4X5X=y
CONFIG_CAN_RCAR=y
CONFIG_CAN_RCAR_CANFD=y
CONFIG_CAN_SJA1000=y
CONFIG_CAN_SJA1000_ISA=m
CONFIG_CAN_SJA1000_PLATFORM=m
CONFIG_CAN_SOFTING=y

#
# CAN SPI interfaces
#
CONFIG_CAN_HI311X=y
CONFIG_CAN_MCP251X=y
# end of CAN SPI interfaces

#
# CAN USB interfaces
#
CONFIG_CAN_8DEV_USB=y
CONFIG_CAN_EMS_USB=y
CONFIG_CAN_ESD_USB2=y
CONFIG_CAN_GS_USB=y
CONFIG_CAN_KVASER_USB=y
CONFIG_CAN_MCBA_USB=y
CONFIG_CAN_PEAK_USB=y
CONFIG_CAN_UCAN=y
# end of CAN USB interfaces

CONFIG_CAN_DEBUG_DEVICES=y
# end of CAN Device Drivers

 

we currently have two problems:

1. At the physical interface level, the driver in this kernel version works only with MCP2515, but not with our MCP2518FD.

 

After reading the following tread we found the original repository from which we copied the folder with the MCP2518FD drivers, but we can't compile them and include them in our kernel (because we don't know how to do it).

 

2. We cannot activate the CanBus interface with these commands (we get Cannot find device "can0"):

ip link set can0 type can bitrate 2000000 fd off
ip link can0 set can0 up

 

 

Is there a guide on how to build and include the drivers we need?

Once the driver has been loaded we could test the .dtbo and see if the MCP initializes correctly.

 

Solved by garinus

  • Author
  • Solution

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

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.