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.

MCP2515 CAN bus user overlay

Featured Replies

Hereby a tutorial to connect an MCP2515 based CAN bus interface to an OrangePi 3 running successfull with Buster minimal nightly with 5.3 kernel. It uses the attached user overlay only and doesn’t need any other overlay.

 

Connections
CAN module

OPi3

26 pin header

Raspberry

CAN interface

40 pin header
Vcc 3.3 CON12-P01 1
Gnd CON12-P06 6
MOSI CON12-P19 19
MISO CON12-P21 21
CLK CON12-P23 23
CS CON12-P24 24
INT CON12-P26 22

Optional 5V for

Transceiver

on cheap

Chinese modules

CON12-P02

Not used

when

equiped

with a

3.3V transceiver

 

Add the attached overlay with the command:

sudo armbian-add-overlay spi-h6-mcp2515.dts

The file /boot/armbianEnv.txt now contains a line:

user_overlays=spi-h6-mcp2515

Reboot the OrangePi 3

Check if the MCP2515 is recognized:

pi@orangepi3:~$ dmesg | grep mcp

If properly connected it should return a line containing:

mcp251x spi1.0 can0: MCP2515 successfully initialized.

As stated a can0 interface should be generated check it with:

pi@orangepi3:~$ sudo ifconfig -a

 

 

Bring up the network:

sudo ip link set can0 up type can bitrate 250000

Check if the interrupt is hooked:

cat /proc/interrupts

should return a line like this

46:          1          0          0          0  sunxi_pio_edge   8 Edge      mcp251x

 

Check for traffic on the CAN bus with candump from can-utils  (sudo apt-get install can-utils)

candump can0

 

spi-h6-mcp2515.dts

sudo armbian-add-overlay spi-h6-mcp2515.dts

Overlays are supported only on mainline kernel based images

Problem on: Orange Pi 3, 5.3.9-sunxi64, Buster

  • Author

Searching the forum will give an explanation, sometimes Google is your best friend.....

For short, replace  "sudo armbian-add-overlay spi-h6-mcp2515.dts" with the following commands:

 dtc -@ -q -I dts -O dtb -o spi-h6-mcp2515.dtbo spi-h6-mcp2515.dts

 sudo nano /boot/armbianEnv.txt
          insert the line: user_overlays=spi-h6-mcp2515
          write and exit nano

sudo mkdir -p /boot/overlay-user

sudo cp spi-h6-mcp2515.dtbo /boot/overlay-user/spi-h6-mcp2515.dtbo

Reboot the OrangePi 3 and continue with check if the MCP2515 is recognized

Hello, i work on  Lime-a64 board (olimex).

 

Based on this topic and some other around, i wrote the overlay attached.

The module i used is use on this topic for the raspberry : tutorial raspberryi.

 

The pinout:

| Lime-A64  | UEXT Nb |   Function   | Output | Module  |
| --------- | ------- | ------------ | ------ | ------- |
| +3.3      | 1       |              | VCC    | 7       |
| GND       | 2       |              | GND    | 6       |
| PH4       | 3       | UART3TX      |        |         |
| PH5       | 4       | UART3RX      |        |         |
| PH2       | 5       | TWI1-SCK     | INT    | 1       |
| PH3       | 6       | TWI1-SDA     |        |         |
| PC1       | 7       | SPI_MISO     | SO     | 4       |
| PC0       | 8       | SPI_MOSI     | SI     | 3       |
| PC2       | 9       | SPI_CLK      | SCK    | 2       |
| PC3       | 10      | SPI_CS       | CS     | 5       |

 

The mcp seem will initialized and i can up the interfaces. however, i am not sure interrupts works.

This line seem wrong : 

 interrupts = <0 194 2>; /* PH2 IRQ_TYPE_EDGE_FALLING */

 

Someone know how to correctly set the line with the Allwinner A64,  PH2 pin ?

 

 

spi-a64-mcp2515.dts

I get a complete system hang on 'sudo ip link set can0 up type can bitrate 250000'
ifconfig -a shows Can0 and no errors that i can see in dmesg

 

I am using the Waveshare CanHat https://www.waveshare.com/rs485-can-hat.htm

 

dtparam=spi=on dtoverlay=mcp2515-can0,oscillator=12000000,interrupt=25,spimaxfrequency=2000000

so i changed the following lines in the dts file.

 

clock-frequency  = <12000000>;

spi-max-frequency = <20000000>;

nothing else, I am Wired as per directions

 

Orange Pi 3.0.6 Bullseye with Linux 5.16.17-sun50iw6

 

Anybody got any idea's ??
I know im close, but with a complete hang, its hard to see the error.

 

 

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...

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.