Installation Guide – CANpro/104 Family Socket-CAN Driver for Linux Kernel 2.6+

Introduction

This Socket-CAN driver supports the following Connect Tech Inc. products:

  • CANpro/104 Opto
  • CANpro/104-Plus Opto

The Socket-CAN project is maintained at http://developer.berlios.de/projects/socketcan/. The driver packages distributed by Connect Tech Inc. are created from the Socket-CAN source control system and modified to include support for Connect Tech Inc. products. The source control system used by the Socket-CAN project is Subversion (SVN), where the repository root is svn://svn.berlios.de/socketcan. Connect Tech Inc. Socket-CAN packages are based on the specific revisions of the contents of svn://svn.berlios.de/socketcan/trunk.

See the README file in the Socket-CAN package for more information on Socket-CAN.

Installation

Hardware installation

Before you install the driver, please refer to hardware installation procedure in the User’s Manual for your Connect Tech Inc. product.
NOTE: Ensure that jumper to configure the board for BasicCAN addressing mode is NOT installed on the CANpro/104 Opto.

Driver files

The Socket-CAN driver package may be obtained from the CANpro/104 CD-ROM or from the Connect Tech Inc. website. The first step is to copy the driver package “YYYYMMDD_socketcan_bundle_rSSSS.tar.bz2” to your hard disk, then execute ‘tar -xjf YYYYMMDD_socketcan_bundle_rSSSS.tar.bz2’, where YYYYMMDD is the release date of the driver bundle package, and SSSS is the Subversion revision that the driver package is a snapshot of. After extraction is complete a new directory named “YYYYMMDD_cti_socketcan_bundle_rSSSS”, is created which contains a tar archive snapshot of the Subversion repository and a patch file “YYYYMMDD_cti_socketcan_bundle_rSSSS.patch”, with our modifications. You will need to extract this snapshot by executing ‘tar -xjf socketcan_trunk_rSSSS.tar.bz2’, which will produce a directory called “socketcan_trunk_rSSSS”,. We will refer to this directory  <sc_root> as as in the remainder of this document.

The contents of  <sc_root> are a specific revision of the Subversion repository and not modified by Connect Tech Inc. and is provided for your convenience in the event that for any reason you cannot perform the Subversion checkout At the time of this writing, the revision was 1190, and so the contents of is the result of the following.

svn checkout –revision 1190 svn://svn.berlios.de/socketcan/trunk

You may still wish to perform your own checkout of the repository, however should you chose to checkout HEAD instead of the specific version, provided and noted here you may have problems with the patch provided here.

To apply the patch with our modifications, change to the directory and execute ‘patch -p1 -i ../YYYYMMDD_cti_socketcan_rSSSS.patch’

Module driver configuration

The driver module requires a kernel build environment in order to compile. By default, the kernel build environment is looked for in /lib/modules//build. If you wish to compile the driver module for a kernel other than the one currently running, then specify the KERNELDIR variable on the make command line.

  1. Build and install
    1. Choose one of the following two methods.
      1. Built against the booted kernel
        # cd /kernel/2.6
        # make modules
        # make modules_install
        # depmod -a
      2. Built against specified kernel# make KERNELDIR=/path/to/kernel modules
        # make KERNELDIR=/path/to/kernel modules_install
        # depmod -a
    2. Build utility and test applications
      # cd /can-utils
      # make
      # cd /test
      # make
  2. Driver runtime configuration
    The directory ‘/etc’ contains the file ‘can.conf’. This file contains the aliases and module options needed for Socket-CAN to function. The contents of this file should be copied into your modutils configuration.
    For example:
    # cp /etc/can.conf /etc/modprobe.d/
    OR
    Copy the contents of can.conf into ‘/etc/modprobe.conf’. Locate the CANpro/104 section of modutils configuration and modify it to include the CANpro/104 Opto models of your choice.
    For example:

    ##> CTI CANpro/104
    ##> Uses the standard sja1000_isa
    ##> Options:
    ##> port - I/O port base addresses of each controller
    ##> (ensure J3.AddrMode is not populated)
    ##> mem - I/O memory base addresses of each controller
    ##> (ensure J3.AddrMode is not populated)
    ##> irq - IRQ number of each controller
    #alias can0 sja1000_isa
    #alias can1 sja1000_isa
    #options sja1000_isa base=0x200,0x280 irq=10,5
    
    ##> CTI CANpro/104-Plus
    ##> Uses a slightly tweaked standard plx_pci
    #alias can2 plx_pci
    #alias can3 plx_pci
  3. To manually load the Socket-CAN modules:# modprobe can-raw# modprobe sja1000_isa   (Only required for ISA based card)# modprobe plx_pciThis will load the basic modules needed to operate the CANpro/104 Opto and the CANpro/104-Plus Opto.
    1. Set bitratesBefore the CAN interfaces can be brought up, their bitrates need to be set.For kernel 2.6
      # echo 100000 >/sys/class/net/can0/can_bittiming/bitrate
      # echo 50000 >/sys/class/net/can1/can_bittiming/bitrate
      For kernal 3.0
      # ip link set can0 type can bitrate 1000000
      ip link set can1 type can bitrate 1000000
    2. Bring up CAN interfacesSimilar to other network devices, the CAN interfaces need to be brought up.# ifconfig can0 up# ifconfig can1 up
    3. Verify driver installationThe CAN utilities and test applications that were compiled previously can now be used to exercise your CANpro/104 board.For example:To display frames on the first CAN controller:# <sc_root>/can-utils/candump can0 -t z

      To send an 8 bytes frame with ID 123 on the second CAN controller:

      # <sc_root>/can-utils/cansend can1 123#1122334455667788

      To view CAN statistics:

      # cat /proc/net/can/stats

Version History

20081217 – Initial release.

Based on revision 879 of Socket-CAN.

20090922 – Support more models

Based on revision 1061 of Socket-CAN.

20100727 – Switch to plx_pci

Patch against revision 1190 of Socket-CAN

20121010 – Added support for kernel 3.0

Patch against revision 1190 of Socket-CAN

Go to Top