7 7
amauri

CAN BUS support orange pi zero

Recommended Posts

5 hours ago, BertHav said:

The overlay does not load because the device tree path does not contain the necessary path for the OPi3 and OPLite2

Try it without the "clocks" subpath :

target-path = "/";

 

Share this post


Link to post
Share on other sites
On 9/22/2019 at 3:53 PM, martinayotte said:

Try it without the "clocks" subpath :

Thank for replying. 

That was exactly the adjustment I made that successfully loaded the overlay.
This modification ensures that can0 is created with some duplicate error.

pi@orangepi3:~$ dmesg | grep spi||mcp
[    2.332200] sun6i-spi 5011000.spi: chipselect 0 already in use
[    2.332207] spi_master spi1: spi_device register error /soc/spi@5011000/spidev@0
[    2.332216] spi_master spi1: Failed to create SPI device for /soc/spi@5011000/spidev@0
[    6.059773] mcp251x spi1.0 can0: MCP2515 successfully initialized.
[  263.483858] mcp251x spi1.0: failed to acquire irq 0

The last log line is created with the command below: 

pi@orangepi3:~$ sudo ip link set can0 up type can bitrate 250000

replies with error message  

RTNETLINK answers: Invalid argument

My armbianEnv.txt

verbosity=1
console=both
overlay_prefix=sun50i-h6
rootdev=UUID=31a66c72-3b09-4222-a0f2-0f02de01b719
rootfstype=ext4
overlays=spi-spidev1
user_overlays=spi-mcp2515
usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

My overlay:

/dts-v1/;
/plugin/;

/ {
        compatible = "allwinner,sun50i-h6";

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

        fragment@1 {
                target = <&pio>;
                __overlay__ {
                        can0_pin_irq: can0_pin_irq {
                                pins = "PD21";
                                function = "irq";
                                bias-pull-up;
                        };
                };
        };

        fragment@2 {
                target = <&spi1>;
                __overlay__ {
                        status = "okay";
                        #address-cells = <1>;
                        #size-cells = <0>;
                        can0:mcp2515@0 {
                                reg = <0>;
                                compatible = "microchip,mcp2515";
                                pinctrl-names = "default";
                                pinctrl-0 = <&can0_pin_irq>;
                                spi-max-frequency = <10000000>;
                                interrupt-parent = <&pio>;
                                interrupts = <3 21 2>; /* PD21 -> 0 7 2 = PA7 IRQ_TYPE_EDGE_FALLING */
                                clocks = <&can0_osc_fixed>;
                                status = "okay";
                        };
                };
        };
};

Update: For Opi3 read:

 

Edited by BertHav
pointer to solution added

Share this post


Link to post
Share on other sites

Thanks for the tip @martinayotte! This also helped me to deploy successfully the mcp25xxfd CAN_FD driver on the oPi R1.

 

If anyone else decides to move from CAN "classic" to CAN FD, look at:

 

Share this post


Link to post
Share on other sites

Orange pi zero H2 + MCP2515

Connections:

MCP2515 Opi Zero H2
INT PA2
SCK PA14
SI PA15
SO PA16
CS PA13
GND GND
VCC 3.3v and for TJA1050 5v

OPi pinouts:

Spoiler

1483990620622-orange-pi-zero-description

My overlay:

Spoiler

 


/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  = <8000000>;
                        };
                };
        };

        fragment@1 {
                target = <&pio>;
                __overlay__ {
                        can0_pin_irq: can0_pin_irq {
                                pins = "PA2";
                                function = "irq";
                                bias-pull-up;
                        };
                };
        };

        fragment@2 {
                target = <&spi1>;
                __overlay__ {
                        #address-cells = <1>;
                        #size-cells = <0>;
                        status = "okay";
                        mcp2515 {
                                reg = <0>;
                                compatible = "microchip,mcp2515";
                                pinctrl-names = "default";
                                pinctrl-0 = <&can0_pin_irq>;
                                spi-max-frequency = <10000000>;
                                interrupt-parent = <&pio>;
                                interrupts = <0 2 2>; /* PA7 IRQ_TYPE_EDGE_FALLING */
                                clocks = <&can0_osc_fixed>;
                                status = "okay";
                        };
                };
        };
};

dmesg:

Spoiler

[    9.660689] mcp251x spi1.0: Cannot initialize MCP2515. Wrong wiring?
[    9.661233] mcp251x spi1.0: Probe failed, err=19

 

Please, help. What's wrong?

Edited by ism
Opi Pinouts

Share this post


Link to post
Share on other sites

Hi to all. 

I have Orange Pi PC+ and trying to use MCP2515. It worked well before, but some colleagues use my Orange and now I have "cannot find device can0" error

Board and bootenv:

Spoiler

78814    BOARD=orangepipcplus
 78815    BOARD_NAME="Orange Pi PC +"
 78816    BOARDFAMILY=sun8i
 78817    VERSION=5.73
 78818    LINUXFAMILY=sunxi
 78819    BRANCH=next
 78820    ARCH=arm
 78821    IMAGE_TYPE=stable
 78822    BOARD_TYPE=conf
 78823    INITRD_ARCH=arm
 78824    KERNEL_IMAGE_TYPE=zImage

 

78826    ### boot environment:
 78827    
 78828    verbosity=0
 78829    logo=/boot/boot.bmp
 78830    console=custom
 78831    stdout=both
 78832    disp_mode=1920x1080p60
 78833    overlay_prefix=sun8i-h3
 78834    rootdev=UUID=b674c5a6-e4bc-49c7-a23c-9ae6c54f55e0
 78835    rootfstype=ext4
 78836    overlays=spi0-mcp2515 spi-spidev
 78837    rootfstype=ext4
 78838    extraargs=vt.global_cursor_default=0 quiet splash plymouth.ignore-serial-consoles
 78839    usbstoragequirks=0x2537:0x1066:u,0x2537:0x1068:u

 

 

I found that there is no sun8i-h3-spi0-mcp2515.dtbo file in overlay folders. I tried to compile this file  from https://github.com/armbian/sunxi-DT-overlays but I am receiving this error

 

sudo armbian-add-overlay spi-mcp251x.dts
Compiling the overlay
dtc: livetree.c:521: get_node_by_phandle: Assertion `(phandle != 0) && (phandle != -1)' failed.
/usr/sbin/armbian-add-overlay: line 81:  2323 Aborted                 dtc -@ -q -I dts -O dtb -o ${temp_dir}/${fname}.dtbo $1
Error compiling the overlay

 

Sadly I am noob in this, what does it mean?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
7 7