Allwinner A10-A20 CAN bus is working and with mainline drivers!


58_can_bus_2

CAN (controlled area network) bus is communication protocol bus standard widely used in Automotive industry. It uses only two wires for communication and is very robust and noise immune. This is why it also is used in industrial robotics and other areas where reliable communication for small amounts of data is needed.

A10 and A20 SoCs are known to have CAN bus controller inside but few years ago when we started the A10/A20 OLinuXino design nobody knew what is this CAN driver neither how to use it.

This is why when I read message on Twitter –

can1

I reply: “indeed, but on purpose, as no one has used this CAN or know how to use it, this would be just waste of components ”

Obviously things changed for the last couple of years as we have been feed with info about A20 CAN driver!

There is mainline CAN driver for A10/A20: https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/net/can/sun4i_can.c?id=refs/tags/v4.4-rc8

CAN is documented http://linux-sunxi.org/images/f/f5/Sun7i-CANbus.pdf in fact it’s same as NXP SJA1000.

Sunxi-Can-Driver is on Github: https://github.com/btolfa/sunxi-can-driver

Linux-Sunxi mainlining efforts: http://linux-sunxi.org/Linux_mainlining_effort#Merged_into_4.4

Can4Linux is available also.

We quickly setup test with CAN transciever from AM3352-SOM-EVB and A20-OLinuXino-MICRO and build kernel with CAN support. Everything works!

Now we work on small board with CAN transciever on it which will enable CAN to be used on A20-OLinuXino-MICRO, A20-SOM-EVB, A10/20-OLinuXino-LIME and A20-OLinuXino-LIME2.

Fortunately when we made the board we kept same GPIO pin numbering on all boards so the CAN signals are on same places on all these boards and this makes the extension CAN board easy to route.

This will allow all our A10/A20 OLinuXinos to be used in CAN applications.

18 Comments (+add yours?)

  1. Gergely Imreh
    Jan 19, 2016 @ 16:34:03

    Well done, very thoughtful development methods!

    Reply

  2. eduardo
    Jan 19, 2016 @ 16:35:27

    Please bring one to Fosdem. We want to support it by our icoBoard.

    Reply

  3. Christian
    Jan 19, 2016 @ 17:32:35

    Great News – is there already a release date for the CAN extension board?

    Reply

  4. Kees Zagers
    Jan 19, 2016 @ 18:40:55

    Nice. Already used the Olimex Duinomite (also PIC-T795) products very succesfully in CAN projects. It would be very nice to have also the Linux platforms with CAN from Olimex.

    Reply

  5. Heinz
    Jan 20, 2016 @ 00:45:46

    @Kees, hope you will use can4linux🙂 it’s much more performing and easier to use

    Reply

    • Gerd
      Jan 25, 2016 @ 00:57:57

      How did you measure the performance can4linux vs SocketCAN on A10/A20 ?
      Why is can4linux easier than SocketCAN ?

      Reply

      • Heinz
        Jan 26, 2016 @ 11:42:13

        Measuring the processor usage time when receiving messages with high speed and high bus load.
        “easier to use”? look at the simple example at https://en.wikipedia.org/wiki/Can4linux or the examples directory at the SourceForge project page. can4linux is a so-called character driver, with handling like a UART.

      • Heinz
        Jan 26, 2016 @ 11:59:21

        Additional to the default C API, using the LInux standard calls open(), read(), write(), Phyton and Tcl bindings are available.

  6. Stupido
    Jan 25, 2016 @ 09:53:04

    Very good news – still can’t remove the grin out of my face!

    Reply

  7. Bghes
    Feb 02, 2016 @ 22:13:05

    Could you give the DTS can device definition ?

    Reply

  8. Тенгиз Шарафиев
    Feb 25, 2016 @ 16:43:24

    Patch for A10-OLinuXino-LIME dts that add binding for canbus

    Reply

  9. Christian
    Mar 26, 2016 @ 16:21:12

    Have you made any progress or an ETA?

    Reply

  10. Jussi Saarijoki
    May 17, 2016 @ 09:59:04

    Any news on this?

    Reply

  11. vvk
    Nov 09, 2016 @ 07:31:55

    can you please provide guide to use can4linux c drivers with banana pro?
    can you please include all steps from compiling to execution

    Reply

  12. Stephan
    Nov 23, 2016 @ 13:43:50

    We experienced some problems regarding the A20s CAN interface getting out of step after receiving huger amounts of CAN frames. It was reproducibly appearing after several minutes. First some false frames appeared (candump), then none were received anymore. (I also double checked, that they are still on the bus). Though, the controller still acked them. Turning the controller down and up again brought it back to live.
    I could trace this back to the frequency scaling. Setting the governor from ondemand to performance made the problem disappear completely until heat protection kicked in.
    We didn’t find a final solution yet – just telling in case anyone might run into similar problems.

    Reply

  13. Heinz (@heinz_hjo)
    Nov 24, 2016 @ 20:45:41

    @Stephan we need to get your complete code. pleas provide an download-able example for testing the hardware.
    Thanks

    Reply

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: