Testing can requires ip,can-utils and libsocketcan libraries.
Configure can, such as rate, enable and disable can, etc. with IP tools. The IP that cannot be compiled with BuildRoot needs to be recompiled.
1. Compile IP:
IP Source http://pkgs.fedoraproject.org/repo/pkgs/iproute/iproute2-2.6.39.tar.gz/8a3b6bc77c2ecf752284aa4a6fc630a6/ Iproute2-2.6.39.tar.gz
1>. Modify Makefile
destdir=/home/tom/myd-xc7z010/usr/Modifying the installation directory
#DBM_INCLUDE: =$ (rootdir)/usr/include screen this line
CC = ARM-XILINX-LINUX-GNUEABI-GCC compiled with cross compiler
2>. Run the build.sh compilation under the IP source directory, build.sh content:
#!/bin/sh
# Create by Myir Tom 2015-01-28
# put this file under the IP source root dir
CP Misc/makefile{,.orig}
Sed '/^targets/[email protected]@@g ' Misc/makefile.orig > Misc/makefile
Export Gnueabi=arm-xilinx-linux-gnueabi
Export cc= $GNUEABI-GCC
Export ld= $GNUEABI-ld
Export nm= $GNUEABI-nm
Export ar= $GNUEABI-ar
Export ranlib= $GNUEABI-ranlib
Export cxx= $GNUEABI-c++
Export prefix= $FILESYS _path/usr
Export cross_compile_prefix= $PREFIX
Export path= $TOOL _chain_path/bin: $PATH
Export Dbm_include=/usr/include
Export Includes=/usr/include
Export destdir= $PREFIX/
./configure--host=arm-xilinx-linux-gnueabi--prefix= $PREFIX--enable-debug
Make
sudo make install
3>. Copy the IP tool to the file system
/usr/sbin the/HOME/TOM/MYD-XC7Z010/USR/SBIN/IP copy to the embedded file system directory, you also need to rename the BuildRoot-brought IP (in the/sbin directory) to Ip_buildroot.
To view the IP version and usage:
$./ip-v
IP utility, iproute2-ss110629
$./IP Link Help
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 {dev DEVICE | group Devgroup} [{up |}]
[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]
[VF NUM [Mac Lladdr]
[VLAN Vlanid [QoS Vlan-qos]]
[Rate Txrate]]
[Master DEVICE]
[Nomaster]
IP link Show [DEVICE | Group Group]
TYPE: = {VLAN | veth | vcan | dummy | ifb | macvlan | can}
2. Can-utils and Libsocketcan can be compiled using BuildRoot
Target Packages > Libraries > Networking selected
[*] Libsocketcan
Target Packages > Networking applications pick up
[*] Can-utils
3. Testing
The can interface needs to be in the down state to set
1>. View can interface status
Down state
# IP link Set can0 down
# Ip-details Link Show Can0
2:can0: <NOARP,ECHO> MTU qdisc pfifo_fast State down Qlen 10
Link/can
Can state STOPPED (berr-counter TX 0 Rx 0) restart-ms 0
Bitrate 49999 sample-point 0.875
TQ 2500 prop-seg 3 PHASE-SEG1 3 PHASE-SEG2 1 SJW 1
XILINX_CAN:TSEG1 1..16 tseg2 1..8 sjw 1..4 BRP 1..256 brp-inc 1
Clock 99999999
Loopback status
# IP Link Set can0 type can bitrate 50000 loopback on
Xilinx_can E0008000.can can0:bitrate Error 0%
# Ip-details Link Show Can0
2:can0: <NOARP,ECHO> MTU qdisc pfifo_fast State down Qlen 10
Link/can
Can <LOOPBACK> state STOPPED (berr-counter TX 0 Rx 0) restart-ms 0
Bitrate 49999 sample-point 0.875
TQ 2500 prop-seg 3 PHASE-SEG1 3 PHASE-SEG2 1 SJW 1
XILINX_CAN:TSEG1 1..16 tseg2 1..8 sjw 1..4 BRP 1..256 brp-inc 1
Clock 99999999
Status under Up
# IP link Set can0 down
# IP Link Set can0 type can bitrate 50000 loopback off
Xilinx_can E0008000.can can0:bitrate Error 0%
# IP Link Set can0 up
# Ip-details Link Show Can0
2:can0: <NOARP,UP,LOWER_UP,ECHO> MTU qdisc pfifo_fast State UNKNOWN Qlen 10
Link/can
Can state error-active (berr-counter TX 0 Rx 0) restart-ms 0
Bitrate 49999 sample-point 0.875
TQ 2500 prop-seg 3 PHASE-SEG1 3 PHASE-SEG2 1 SJW 1
XILINX_CAN:TSEG1 1..16 tseg2 1..8 sjw 1..4 BRP 1..256 brp-inc 1
Clock 99999999
2>. Test using loopback mode:
Use the loopback mode to test whether the can driver of the machine is working properly.
# IP link Set can0 down
# IP Link Set can0 type can bitrate 50000 loopback on
Xilinx_can E0008000.can can0:bitrate Error 0%
# IP Link Set can0 up
# Candump Can0 &
# cansend Can0 123#11223344556677
# Can0 123 [7] 11 22 33 44 55 66 77
Can0 123 [7] 11 22 33 44 55 66 77
3>. The two-plate can interface, Canh to Canh, canl to Canl, one side of the transmission, the other side of the receiver, the test before the rate to be set, and can interface has been up.
#candump can0 Development Board 1 execute receive command
#cansend can0 123#11223344556677 Development Board 2 sending data
4> about the use of can tools (cansend, etc.), refer to the Lib.h file in the can source directory, the inside speaks very clearly
Can drive test under Linux