TWR-MPC8309 TWR-INDCTRL - CAN User Manual Freescale Semiconductor Linux BSP

Description

The MPC8309 have four controller area network (FlexCAN) blocks. 
The TWR-MPC8309 + TWR-INDCTRL platform supports 4 CANs connected to the high speed CAN interfaces.

Modules Loading

The CAN controller is not enabled by default. There are two ways to enable the CAN function.

 
One way is to select the linux configuration file with CAN enabled as described in help/software/LTIB_BSP_TWR-MPC830x document.
Another way is to enable the CAN function manually in LTIB as documented in the next section.

 
In addition, it is also required to enable the CAN test package in order to run the test procedure.

 
 ./ltib -c

 
When the LTIB start, scroll down the Package selection and select Package list and enable “cantest” package.

 
 ---  Package selection
       Package list   --->
              ….
              [  ]  can4linux
              [*]  cantest
              [  ]  ccache

 

Kernel Configuration

In LTIB build, select “linux-2.6.33.7-mpc8309twr-INDCTRL-CAN.config” for the kernel configuration:

 
./ltib -c

 
When the window pops up, scroll down and select “Config file”.
Under Config file, select the configuration as shown:

 
  [  ] Produce cscope index
        Config file (Default configuration)  --->
                     (  )  Default configuration
                     (  )  Configuration with IEEE1588v2 support
                     (x)  Configuration with TWR-INDCTRL CANs support
                     (  )  custom

 
Exit and save.

 
OR
In LTIB, enable “Configure the kernel”.

 
When the Linux Kernel Configuration window pops up, scroll down to Networking support and enable the CAN as followed.

 
 [*] Networking support --->
       --- Networking support
                ……..
      <*>   CAN bus subsystem support --->
                ---  CAN bus subsystem support
                <*>     Raw CAN Protocol
                < >      Broadcast Manager CAN Protocol
                            CAN Device Drivers  --->
                            < >   Virtual Local CAN Interface
                            < >   Platform CAN drivers with Netlink support
                            <*>   Support for Freescale FLEX CAN
                            <*>      Freescale MPC830X onboard CAN controller
                            [*]            Freescale MPC830X I/O configuration for CAN1
                            [*]            Freescale MPC830X I/O configuration for CAN2
                            [*]            Freescale MPC830X I/O configuration for CAN3
                            [*]            Freescale MPC830X I/O configuration for CAN4
                            [  ]   CAN devices debugging messages

 
Exit, save and build.

 
Note:
It is required to use mpc8309twr-indctrl.dtb. 
Rename mpc8309twr-indctrl.dtb to mpc8309twr.dtb.
OR in u-boot, change the dtbname as followed:
=> echo $dtbname
mpc8309twr.dtb
=> set dtbname mpc8309twr-indctrl.dtb
=> run tftpramboot

 

Test Procedure

TWR-INDCTRL board has 4 CANs where CAN1 is connected to CAN2 and CAN3 to CAN4 for testing.
Connect pin 6 (CAN_H1) of J600 to pin 6 (CAN_H2) of J602 and pin 2 (CAN_L1) of J600 to pin 2 (CAN_L2) of J602.
Connect pin 6 (CAN_H3) of J603 to pin 6 (CAN_H4) of J604 and pin 2 (CAN_L3) of J603 to pin 2 (CAN_L4) of J604.
In J601, put jumpers between pin 1 to pin 2, pin 3 to pin 4, pin 5 to pin 6 and pin 7 to pin 8.

 
· Power up the platform.
· Use mpc8309twr-indctrl.dtb instead of mpc8309twr.dtb.
· After login in the kernel, bring up the CAN interfaces.
· Note that under linux, the CAN are referenced as can0, can1, can2 and can3 for CAN1, CAN2, CAN3 and CAN4 respectively.

 

 
[root@mpc8309twr root]# ifconfig can0 up
flexcan_open can0
[root@mpc8309twr root]# ifconfig can1 up
flexcan_open can1
[root@mpc8309twr root]# ifconfig can2 up
flexcan_open can2
[root@mpc8309twr root]# ifconfig can3 up
flexcan_open can3
[root@mpc8309twr root]#

 
[root@mpc8309twr root]# ifconfig
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING 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:64
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

 
can1      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING 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:64
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

 
can2      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING 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:64
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

 
can3      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING 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:64
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

 

 
· Script, “test_can_0_1.sh” is provided to use "cantest" to send 5 frames from can0 to can1 and then send 5 frames from can1 to can0.

 
[root@mpc8309twr root]# cd can
 [root@mpc8309twr can]# ./test_can_0_1.sh
Send 5 CAN frames from can0 and receive in can1:

 
read 16 bytes
5A1  [8] 11 22 33 44 55 66 77 88

 
read 16 bytes
5A1  [8] 11 22 33 44 55 66 77 88

 
read 16 bytes
5A1  [8] 11 22 33 44 55 66 77 88

 
read 16 bytes
5A1  [8] 11 22 33 44 55 66 77 88

 
read 16 bytes
5A1  [8] 11 22 33 44 55 66 77 88
Send 5 CAN frames from can1 and receive in can0:

 
read 16 bytes
5A0  [8] 99 11 22 33 44 55 66 77

 
read 16 bytes
5A0  [8] 99 11 22 33 44 55 66 77

 
read 16 bytes
5A0  [8] 99 11 22 33 44 55 66 77

 
read 16 bytes
5A0  [8] 99 11 22 33 44 55 66 77

 
read 16 bytes
5A0  [8] 99 11 22 33 44 55 66 77
end
[root@mpc8309twr can]#

 
· Script, “test_can_2_3.sh” is provided to use "cantest" to send 5 frames from can2 to can3 and then send 5 frames from can3 to can2.

 
[root@mpc8309twr can]# ./test_can_2_3.sh
Send 5 CAN frames from can2 and receive in can3:

 
read 16 bytes
5A4  [8] 44 55 66 77 88 99 11 22

 
read 16 bytes
5A4  [8] 44 55 66 77 88 99 11 22

 
read 16 bytes
5A4  [8] 44 55 66 77 88 99 11 22

 
read 16 bytes
5A4  [8] 44 55 66 77 88 99 11 22

 
read 16 bytes
5A4  [8] 44 55 66 77 88 99 11 22
Send 5 CAN frames from can3 and receive in can2:

 
read 16 bytes
5A3  [8] 33 44 55 66 77 88 99 11

 
read 16 bytes
5A3  [8] 33 44 55 66 77 88 99 11

 
read 16 bytes
5A3  [8] 33 44 55 66 77 88 99 11

 
read 16 bytes
5A3  [8] 33 44 55 66 77 88 99 11

 
read 16 bytes
5A3  [8] 33 44 55 66 77 88 99 11
end
[root@mpc8309twr can]#

 

 

 
To send and receive 20 frames,

 
· Run the script with a parameter of 20.

 
[root@mpc8309twr can]# ./test_can_0_1.sh 20
Send 20 CAN frames from can0 and receive in can1:

 
read 16 bytes
5A1  [8] 11 22 33 44 55 66 77 88

 
read 16 bytes
5A1  [8] 11 22 33 44 55 66 77 88
. . .
Send 20 CAN frames from can1 and receive in can0:

 
read 16 bytes
5A0  [8] 99 11 22 33 44 55 66 77

 
read 16 bytes
5A0  [8] 99 11 22 33 44 55 66 77
. . .
read 16 bytes
5A0  [8] 99 11 22 33 44 55 66 77
end
[root@mpc8309twr can]#

 
· To display the statistics,

 
[root@mpc8309twr can]# ifconfig
can0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:25 errors:0 dropped:0 overruns:0 frame:0
          TX packets:25 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:64
          RX bytes:200 (200.0 b)  TX bytes:200 (200.0 b)

 
can1      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:25 errors:0 dropped:0 overruns:0 frame:0
          TX packets:25 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:64
          RX bytes:200 (200.0 b)  TX bytes:200 (200.0 b)

 
can2      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:5 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:64
          RX bytes:40 (40.0 b)  TX bytes:40 (40.0 b)

 
can3      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP RUNNING NOARP  MTU:16  Metric:1
          RX packets:5 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:64
          RX bytes:40 (40.0 b)  TX bytes:40 (40.0 b)

 

 

Known Bugs, Limitations, or Technical Issues

· For TWR-MPC8309 Rev B board, the MPC_CAN3 (can2) signals are not connected to the Primary elevator by default. Therefore hardware modification will be required.

Supporting Documentation

· N/A
阅读更多

没有更多推荐了,返回首页