Sitara AM35x CAN (HECC) Linux Driver

From Texas Instruments Embedded Processors Wiki

Jump to: navigation, search
Translate this page to   

Contents

Overview

This wiki page provides information on using TI's CAN (HECC) Linux driver module on Sitara AM3517 EVM. The ti_hecc driver is already part of linux since 2.6.32. This document concerns the updated support targeting the linux-2.6.37 tree.

Linux Driver Information

How CAN driver fits into Linux architecture

  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)

Detailed Kernel Configuration

To enable/disable CAN driver support, start the Linux Kernel Configuration tool:

$ make menuconfig ARCH=arm


Select Networking support from the main menu.

    ...
    ...
    Power management options --->
    [*] Networking support --->
    Device Drivers --->
    File systems --->
    Kernel hacking --->
    ...
    ...


Select CAN bus subsystem support as shown here:

    ...
    ...
    Networking options  --->
[ ] Amateur Radio support  --->
<*> CAN bus subsystem support  --->
    IrDA (infrared) subsystem support  --->
    ...


Select Raw CAN Protocol & Broadcast Manager CAN Protocol as shown here:

    ...
    --- CAN bus subsystem support
<*> Raw CAN Protocol (raw access with CAN-ID filtering)
<*> Broadcast Manager CAN Protocol (with content filtering)
    CAN Device Drivers  --->


Select CAN Device Drivers in the above menu and then select the following options:

<*> Virtual Local CAN Interface (vcan)
<*> Platform CAN drivers with Netlink support
[*]   CAN bit-timing calculation
<*>   TI High End CAN Controller 
< >   Microchip MCP251x SPI CAN controllers 
          ...


Note: -> "CAN bit-timing calculation" needs to be enabled to use "ip" utility to set CAN bitrate


To enable PHY control, go back to the main-menu and select Device Drivers  :

    ...
    ...
    Power management options --->
    [*] Networking support --->
    Device Drivers --->
    File systems --->
    Kernel hacking --->
    ...
    ...


Select GPIO Support as shown below:

    ...
     ...
-*-  I2C support  --->
     PPS support  --->
[*]  SPI support  --->
-*-  GPIO Support  --->
< >  Dallas's 1-wire support  --->


Select PCA953x, PCA955x, TCA64xx, and MAX7310 I/O ports as shown below:

    ...
     ...
*** I2C GPIO expanders: ***
< > Maxim MAX7300 GPIO expander
< > MAX7319, MAX7320-7327 I2C Port Expanders
<*> PCA953x, PCA955x, TCA64xx, and MAX7310 I/O ports
[ ]     Interrupt controller support for PCA953x 
     ...

CAN Utilities

Note that if the kernel configuration for "CAN bit-timing calculation" is not enabled then each of the parameters: tq, PROP_SEG etc need to be set individually. When bit-timing calculation is enabled int he kernel then only setting the bitrate is sufficient as it calculates other parameters

ip (route2)

Usage: ip link set DEVICE type can
       [ bitrate BITRATE [ sample-point SAMPLE-POINT] ] |
       [ tq TQ prop-seg PROP_SEG phase-seg1 PHASE-SEG1
         phase-seg2 PHASE-SEG2 [ sjw SJW ] ]
       [ loopback { on | off } ]
       [ listen-only { on | off } ]
       [ triple-sampling { on | off } ]
       [ restart-ms TIME-MS ]
       [ restart ]
       Where: BITRATE       := { 1..1000000 }
              SAMPLE-POINT  := { 0.000..0.999 }
              TQ            := { NUMBER }
              PROP-SEG      := { 1..8 }
              PHASE-SEG1    := { 1..8 }
              PHASE-SEG2    := { 1..8 }
              SJW           := { 1..4 }
              RESTART-MS    := { 0 | NUMBER }
Usage: ip link add link DEV [ name ] NAME
                   [ txqueuelen PACKETS ]
                   [ address LLADDR ]
                   [ broadcast LLADDR ]
                   [ mtu MTU ]
                   type TYPE [ ARGS ]
       ip link delete DEV type TYPE [ ARGS ]
 
       ip link set DEVICE [ { up | down } ]
                          [ arp { on | off } ]
                          [ dynamic { on | off } ]
                          [ multicast { on | off } ]
                          [ allmulticast { on | off } ]
                          [ promisc { on | off } ]
                          [ trailers { on | off } ]
                          [ txqueuelen PACKETS ]
                          [ name NEWNAME ]
                          [ address LLADDR ]
                          [ broadcast LLADDR ]
                          [ mtu MTU ]
                          [ netns PID ]
                          [ alias NAME ]
       ip link show [ DEVICE ]


  TYPE := { vlan | veth | vcan | dummy | ifb | macvlan | can }


<prompt> ./ip -V
ip utility, iproute2-ss090324
<prompt> ip link set can0 type can bitrate 125000 triple-sampling on
<prompt> ip link set can0 up

cansend

./cansend can0 111#1122334455667788 

candump

Options: -t <type>   (timestamp: (a)bsolute/(d)elta/(z)ero/(A)bsolute w date)
        -c          (increment color mode level)
        -i          (binary output - may exceed 80 chars/line)
        -a          (enable additional ASCII output)
        -S          (swap byte order in printed CAN data[] - marked with '`' )
        -s <level>  (silent mode - 0: off (default) 1: animation 2: silent)
        -b <can>    (bridge mode - send received frames to <can>)
        -B <can>    (bridge mode - like '-b' with disabled loopback)
        -l          (log CAN-frames into file. Sets '-s 2' by default)
        -L          (use log file format on stdout)
        -n <count>  (terminate after receiption of <count> CAN frames)
        -r <size>   (set socket receive buffer to <size>)
Up to 16 CAN interfaces with optional filter sets can be specified
on the commandline in the form: <ifname>[,filter]*
Comma separated filters can be specified for each given CAN interface:
 <can_id>:<can_mask> (matches when <received_can_id> & mask == can_id & mask)
 <can_id>~<can_mask> (matches when <received_can_id> & mask != can_id & mask)
 #<error_mask>       (set error frame filter, see include/linux/can/error.h)
CAN IDs, masks and data content are given and expected in hexadecimal values.
When can_id and can_mask are both 8 digits, they are assumed to be 29 bit EFF.
Without any given filter all data frames are received ('0:0' default filter).
Use interface name 'any' to receive from all CAN interfaces.
candump -c -c -ta can0,123:7FF,400:700,#000000FF can2,400~7F0 can3 can8
candump -l any,0~0,#FFFFFFFF    (log only error frames but no(!) data frames)
candump -l any,0:0,#FFFFFFFF    (log error frames and also all data frames)
candump vcan2,92345678:DFFFFFFF (match only for extended CAN ID 12345678)
candump vcan2,123:7FF (matches CAN ID 123 - including EFF and RTR frames)
candump vcan2,123:C00007FF (matches CAN ID 123 - only SFF and non-RTR frames)

EVM Information

Pin 1 - CAN-H
Pin 2 - CAN-L
Pin 3 - Bus termination (do not connect a wire to this externally)
Pin 4 - Ground 
Short pins 2 & 3 on J15 on each board
Board A J36 pins 1,2,4 connected to pins 1,2,4 of J36 on Board B respectively
No connection on pin 3 of J36 on any board
Board A J15 pins 2 & 3 shorted to terminate bus
Board A J36 pins 1,2,4 connect to Board B J36 pins 1,2,4 respectively
Board B J15 pins 1,2,4 connect to Board C J36 pins 1,2,4 respectively
Board C J15 pins 2 & 3 connected to terminate bus 
E2e.jpg For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article Sitara AM35x CAN (HECC) Linux Driver here.
Hyperlink blue.png Links
ARM Microcontroller MCU ARM Processor Digital Media Processor Digital Signal Processing Microcontroller MCU Multi Core Processor
Ultra Low Power DSP 8 bit Microcontroller MCU 16 bit Microcontroller MCU 32 bit Microcontroller MCU

Leave a Comment

Comments

Comments on Sitara AM35x CAN (HECC) Linux Driver


Tfischer said ...

Can you recommend a low-cost reference design / chip evaluation module / simple PCB that contains a CAN device (light, motor, sensor). Something simple that can be used to show the AM35x controlling a standard CAN device using the CAN bus protocol?

--tfischer 16:07, 1 April 2010 (CDT)

Personal tools
Namespaces
Variants
Actions
Navigation
Print/export
Toolbox