Can bus migration and test summary under Linux

Source: Internet
Author: User

C An transplant and test summary

Adding Flexcan driver Support on Kernel

A. on kernel menuconfig, add the following items:

[*] Networking Support--->
<*> CAN Bus subsystem Support--->
<*> Raw CAN Protocol (raw access with Can-id filtering)

<*> broadcast Manager CAN Protocol (with content filtering)
CAN Device Driver--->
<*> Virtual Local CAN Interface (Vcan)
[*] CAN Devices Debugging messages
<*> support for Freescale FLEXCAN based chips

To modify the driver:

1.board-mx6q_sabresd.h

Add to

/*can2*/

Mx6q_pad_key_col4__can2_txcan,

Mx6q_pad_key_row4__can2_rxcan,

Mx6q_pad_gpio_1__gpio_1_1,/*can_stby Power -down switch, 0 wakeup, 1 sleep */

2.board-mx6q_sabresd.c

/*can1*/

Gpio_request (Sabresd_can1_stby, "Flexcan1_stby");

Gpio_direction_output (sabresd_can1_stby,1);

static void Mx6q_sabresd_flexcan0_switch (int enable)

{

if (enable) {

PRINTK ("\nflexcan0 up\n");

Gpio_set_value (Sabresd_can1_stby, 0);

} else {

PRINTK ("Flexcan0 down\n");

Gpio_set_value (Sabresd_can1_stby, 1);

}

}

static const struct FLEXCAN_PLATFORM_DATA

Mx6q_sabresd_flexcan0_pdata __initconst = {

. Transceiver_switch = mx6q_sabresd_flexcan0_switch,//Control The sleep wake-up of the can device power-saving switch

};

/*can1*/

Imx6q_add_flexcan0 (&mx6q_sabresd_flexcan0_pdata);

two. can test:

Pre-Knowledge :

--build= who compiles here? Where do you run your current compilation action? If you are compiling an arm toolchain, although the toolchain is for ARM, the tool chain is built on the host. So--build=i686-pc-linux-gnu

--host= where are the currently compiled programs running? So after the tool chain is ready, the compiler program for the target system is all set to the host arm.

--target= for who compiles the program, this in cross-compile time with host a meaning, is generally guess, and the Configure script will say is =--host.

In general, we compile complex cases of cross-compiling, it is said that there is a very complicated situation, three platforms:

Compare, I am now on the i686 machine, want to compile a cross tool chain running on PPC, then this cross tool chain is ARM production program, this is even more complicated.

This is supposed to be the BINUTILS,GCC,LIBC three--be careful about setting it up.

May be

· --build=i686-pc-linux-gnu

· --host=ppc-xxx

· --target=arm-xxx

No experiment, you can experiment next day, under the study.

Continued: Three platform cross-compilation experiment

Extract the Binutils source code, configured as follows:

.. /binutils-2.21.1/configure--build=i686-pc-linux-gnu--host=armv5l-jztech-linux-gnueabi--target=mips-linux-- Prefix=/home/dbh/workspace/linux-dev/nmru/prjhome/sources/bin-build/dest

then make, find the compile time most of the time called ARMV5L-XX-GCC, successfully completed,

Make install and install to dest below:

then ls dest

Bin Lib Mips-linux share

It seems that target is really MIPS, then file:

File Bin/mips-linux-as
Bin/mips-linux-as:elf 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), for Gnu/linux 2.6.16, not stripped

Mips-linux-as is a cross compiler oh, running on arm, but Target is MIPS, Haha, it seems a little feeling.

This can be understood, in fact, compile the compile system according to the appropriate host, build to invoke the appropriate GCC to do things, you can see, in three platforms, the--build platform is run compiled script or make, will call host compiler, It is also obvious that the host specified must be a cross compiler.

Start work :

sudo tar-xvf Xx.tar

to freecale LTIB environment:

./ltib-m Shell

Start work :

Download Canutils's latest source http://www.pengutronix.de/software/socket-can/download/canutils.

Download Libsocketcan. http://www.pengutronix.de/software/libsocketcan/download/download is Libsocketcan 0.0.9.

Unzip two packs

sudo bzip2-d xx.tar.bz2 from the case of the cross tool chain, you can summarize the following

1. since canutils-4.0.6 needs Libsocketcan 0.0.9 its library support, compile Libsocketcan 0.0.9 first

(1) Export your path to the build tool chain:

Export path= $PATH:/disk2/extand1/yg_work/test/arm-2011.03/bin/

(2) Configuring the compilation tool chain and installation directory

./configure--prefix=/disk2/extand1/yg_work/test/can/libsocketcan_out/--host= Arm-none-linux-gnueabi

(3) Compile and install

Make

Make install

2. Compiling canutils-4.0.6

(1) Configure the compilation tool chain, installation directory and link library, etc.

CD canutils-4.0.6/

Export path= $PATH:/disk2/extand1/yg_work/test/arm-2011.03/bin/

./configure--host=arm-none-linux-gnueabi

--prefix=/disk2/extand1/yg_work/test/can/canutils-4.0.6_out/libsocketcan_libs=-lsocketcan LDFLAGS= "-L/disk2/ extand1/yg_work/test/can/libsocketcan_out/lib/"libsocketcan_cflags="-i/disk2/extand1/yg_work/test/can/ Libsocketcan_out/include "

(2) statically compiled canutils-4.0.6 to src directory

CD src

Cp.. /.. /libsocketcan_out/include/libsocketcan.h. /.. /libsocketcan_out/include/can_netlink.h./

Arm-none-linux-gnueabi-gcc-dhave_config_h-i.-I.. /include-i. /include-i. /include-o Candump candump.c–static

Arm-none-linux-gnueabi-gcc-dhave_config_h-i.-I.. /include-i. /include-i. /include-o Cansend cansend.c–static

The rest of the same way is compiled into static , because simple make discovery compiled into a dynamic always run on the arm board said no such file.

Error :

Canconfig.c:34:26:fatal error:libsocketcan.h:no such file or directory

workaround : copy the previously compiled

(3) Copy the compiled cansend to the bin directory of the corresponding Development Board

DMESG | grep can

IP link Set can0 up type can bitrate 500000

Ifconfig can0 up

Cansend can0-i0xb00 0x31 0x32 0x33 0x41 0x42 0x43

Note : If such information is found in the test

Cansend can0-i0xb00 0x31 0x32 0x33 0x41 0x42 0x43

interface = can0, family =, Tyflexcan imx6q-flexcan.0:error Warning IRQ

the description :

your kernel configuration is OK, but you and your other board communication problem (maybe the hardware is not connected or you simply did not connect the board)

PE = 3, proto = 1

Another board can be accepted.

Send Board :

[Email protected]:/# cansend can0-i0xb00 0x31 0x32 0x33 0x41 0x42 0x43

interface = can0, family =, type = 3, proto = 1

Receiver Board :

CAN receive = 00000031 00000032 00000033 00000041 00000042 00000043

2, can bus test FAIL j2,e7,e8,c33,c11,r15,r20,r154,r153,u2,c62,r23,r83

CAN receive = 00000031 00000032 00000033 00000041 00000042 00000043

Proven success

Can bus migration and test summary under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.