How to use A20 CAN interface with the A20 universal Armbian image for OLinuXino


CAN-Network-Diagram

To use A20 CAN interface you need A20-OLinuXino board and A20-CAN board.

Then you have to install the armbian A20 CAN overlay:

 

$ sudo armbian-add-overlay <path_to_the_dts_file>

 

  • connect A20-CAN to your OLinuXino and reboot.

You can see if CAN is available now:

$ ifconfig -a

   can0     Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 
            NOARP MTU:16 Metric:1
            RX packets:0 errors:0 dropped:0 overruns:0 frame:0
            TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:10
            RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
            Interrupt:51

 

To use CAN interface you can install can-utils and setup the CAN interface:

$ sudo apt-get install can-utils 
$ ip link set can0 down
$ ip link set can0 type can bitrate 100000 triple-sampling on loopback off
$ ip link set can0 up

 

Now conect A20-CAN to the CAN network two wire interface.

To send a packet over CAN use :

cansend <can_interface> <packet>

 

For instance:

$ cansend can0 5AA#10.10.10

 

To sniff for CAN network messages you can use candump :

$ candump can0

 

Now you can log your car CAN networking messages and interpret them. There is plenty of info on the web about the different CAN messages which are exchanged on car CAN bus.

3 Comments (+add yours?)

  1. rreignier
    Feb 22, 2019 @ 21:15:23

    Thank you for the tutorial. But did you tried it on your latest image “Armbian_5.72.1_Olinuxino-a20_Ubuntu_bionic_next_4.19.17_desktop.7z”?
    First, the provided dtc do not support overlays, then ifconfig is not installed, ip commands should be run as root and then, the cansend command do not send anything on the ping. After a couple of commands, a buffer full error message appear:
    write: No buffer space available

    Reply

    • Lub Olimex
      Feb 25, 2019 @ 11:07:10

      Checked your report today. For sure, there is ifconfig in the image out-of-the-box and I’m not sure what “provided dtc do not support overlays” but the CAN dts loads fine.I’m not exactly sure what have you done, but drop an e-mail at support@olimex.com if you wish to discuss it.

      Reply

      • rreignier
        Feb 26, 2019 @ 23:06:34

        Thanks you for your reply.
        I have tested it again with the latest image from your FTP and it remains the same, no ifconfig and the device tree compiler does not support overlay:

        lime@olinuxino:~$ sudo armbian-add-overlay sun7i-a20-can.dts
        Error: dtc does not support compiling overlays

        Image used : ftp://staging.olimex.com/Allwinner_Images/A20-OLinuXino/1.latest_mainline_images/stretch/images/Armbian_5.72.1_Olinuxino-a20_Debian_stretch_next_4.19.17.7z

        BUT with the bionic version, there is indeed ifconfig and the dtc supports overlays.
        So your instructions are working, unless the missing “sudo” in the ip commands.

        But now I have an issue with the A20-CAN board. I cannot receive any data or send some while the data are coming on the CAN transceiver (checked with logic analyzer).
        Is there any instructions on how to connect the A20-CAN to a Lime2 with the ribbon cable?

        Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: