How to configure and use CAN bus: Difference between revisions

From RidgeRun Developer Wiki
m (moved Enabling CAN Bus to How to configure and use CAN bus: Added more information beyond just enabling CAN bus.)
mNo edit summary
Line 1: Line 1:
This article explains how to enable the CAN bus using as example the [[:Category:AM35x | AM35x]] [[LogicPD AM35x EVM | EVM]], but can be applied to other platforms as well.
This article explains how to enable the CAN bus using as examples the [[:Category:AM35x | AM35x]] [[LogicPD AM35x EVM | EVM]] and [[:Category:OMAP35x OMAP35x], but can be applied to other platforms as well.  In addition, steps to exchange data with a MCP2515 Bus Monitor board is also documented.


== Build the SDK with socketcan and ip tools ==
== Build the SDK with socketcan and ip tools ==
Working with the CAN buys requires enabling the 'ip' tools from iputils2 package (the 'ip' tool from busybox won't work). The socketcan package is optional and provide you with tools to debug your can bus.


This packages are available from the RidgeRun SDK in the configuration menu.
Working with the CAN bus requires enabling the 'ip' tools from iputils2 package (the 'ip' tool from busybox won't work). The socketcan package is optional and provide you with tools to debug your can bus.
 
These packages are available for selection from the RidgeRun SDK in the configuration menu.
 
== Enable the CAN controller kernel driver ==
 
=== AM35x kernel ===


== Enable the kernel driver ==
In the case of the [[:Category:AM35x]] platform the configuration is:
In the case of the [[:Category:AM35x]] platform the configuration is:
  Linux Kernel Configuration
  Linux Kernel Configuration
Line 15: Line 19:
                   CAN bit-timing calculation
                   CAN bit-timing calculation
                   TI High End CAN controller (HECC)
                   TI High End CAN controller (HECC)
=== OMAP3x kernel ===
In the case of the [[:Category:OMAP3x]] platform with a MCP2515 chip the configuration is:
Linux Kernel Configuration
      Networking support
        CAN bus subsystem support
            CAN device drivers
                Platform CAN drivers with Netlink support
                  CAN bit-timing calculation
                  Microchip MCP251x SPI CAN controller


== Setup the networking rules==
== Setup the networking rules==
Edit your /etc/networking/interfaces on the target filesystem and add the following rules (required to setup the bit-rate of the bus):
Edit your /etc/networking/interfaces on the target filesystem and add the following rules (required to setup the bit-rate of the bus):


Line 27: Line 43:


== References==
== References==
* http://processors.wiki.ti.com/index.php/Sitara_AM35x_CAN_(HECC)_Linux_Driver
* http://processors.wiki.ti.com/index.php/Sitara_AM35x_CAN_(HECC)_Linux_Driver


[[Category:AM35x]][[Category:Whitepaper]]
[[Category:AM35x]][[Category:Whitepaper]]

Revision as of 04:51, 20 December 2010

This article explains how to enable the CAN bus using as examples the AM35x EVM and [[:Category:OMAP35x OMAP35x], but can be applied to other platforms as well. In addition, steps to exchange data with a MCP2515 Bus Monitor board is also documented.

Build the SDK with socketcan and ip tools

Working with the CAN bus requires enabling the 'ip' tools from iputils2 package (the 'ip' tool from busybox won't work). The socketcan package is optional and provide you with tools to debug your can bus.

These packages are available for selection from the RidgeRun SDK in the configuration menu.

Enable the CAN controller kernel driver

AM35x kernel

In the case of the Category:AM35x platform the configuration is:

Linux Kernel Configuration
     Networking support
        CAN bus subsystem support
           CAN device drivers
               Platform CAN drivers with Netlink support
                 CAN bit-timing calculation
                 TI High End CAN controller (HECC)

OMAP3x kernel

In the case of the Category:OMAP3x platform with a MCP2515 chip the configuration is:

Linux Kernel Configuration
     Networking support
        CAN bus subsystem support
           CAN device drivers
               Platform CAN drivers with Netlink support
                 CAN bit-timing calculation
                 Microchip MCP251x SPI CAN controller

Setup the networking rules

Edit your /etc/networking/interfaces on the target filesystem and add the following rules (required to setup the bit-rate of the bus):

auto can0
iface can0 inet manual
	#pre-up ip link set $IFACE type can bitrate 125000 listen-only off
	pre-up /ip link set $IFACE type can bitrate 125000 triple-sampling on
	up /sbin/ifconfig $IFACE up
	down /sbin/ifconfig $IFACE down

References