This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Enabling CAN interface

Other Parts Discussed in Thread: AM3517

Hello to everyone,

I'm struggling with making CAN interface work in am3517 evm Linux kernel (version 2.6.32-rc5). I've installed successfully drivers for Peak PCAN PCI-E card on a host side (Ubuntu 10.10) and made a connection with a proper cable to the target side (CAN headers, J15). But I'm not managing to make that communication work. Here are some more details hoping someone could help me.

Currently I'm using the given (default) and already loaded configurations for Linux kernel and the U-Boot software. And also CodeSourcery tools for cross-compilation.

To test if communication works I've written a simple test application which sends some data (from target to host) using the SocketCAN. But as you've already guessed it doesn't work. It just fails to send the data and gives me the message Network is down. That seems perfectly valid as there's no CAN interface in the list after executing the command ifconfig. Similarly as I have been enabling the CAN interface on the host side, I tried pretty much the same on the target side just by typing ifconfig can0 up which generated the following errors:

ti_hecc ti_hecc.1: bit-timing not yet defined                                   
ti_hecc ti_hecc.1: open_candev() failed -22                                     
ifconfig: SIOCSIFFLAGS: Invalid argument

As that didn't work I referred to your CAN HECC Linux Manual (http://processors.wiki.ti.com/index.php/Sitara_AM35x_CAN_%28HECC%29_Linux_Driver) which gave me some answers but still didn't solve the problem. I can see that you recommend the ip(route2) utility for bringing up the CAN interface. That means that I need the cross-compiled version which I'm not able to find anywhere and to make one by myself I find it not very trivial. Is there any cross-compiled versions around? And more important, is this is a right way to solve my problem? Or perhaps is there any other way to make these things work?

Also is there any way to check the current target kernel configuration to see what modules are enabled/disabled because /usr/src/ folder is empty? I believe that CAN module should be enabled by default but that's just one of the things that crossed my mind.

Thank you very much for your time and help,

Adi

P.S. there's boot log attached just in case for more details needed.

7142.arago_output.txt

  • You may want to start off with a low level test that is provided by Logic PD in their BSL test code (which can be obtained off the support tab from logicpd.com).  This has a low level CAN test which will at least verify comminucations will work with your setup.  

    You can check the linux config with menuconfig.  I checked it and it looks like CAN is enabled by default. 

    Regards,

    James 

  • Hi James,

    thank you for your respond but I don't understand how am I supposed to run those BSL low level tests as they directly address processor registers in its code. And as much as I know this isn't possible while having an OS because of the memory address translation processes? Please correct me if I'm wrong. I'm still pretty much new to these kind of stuff.

    Is it possible that there's no cross-compiled iproute2 utility if it is of so much importance?

    Thanks,

    Adi

  • Adi, I didn't mean for the BSL to run with Linux.  It would be run separately just to test your CAN setup.  There is a separate CAN test you can run.  I'm not sure about the iproute2 utility.  I will have to defer to someone else to answer this.

    Regards,

    James

  • Ok. I finally found a solution. I managed to bring the CAN interface up by cross-compiling iproute2 source.

    At first I didn't want to go with this kind of a solution as I expected many problems and I'm also pretty much new to all these stuff.

    I didn't manage to compile the whole source successfully but it is enough to make CAN device work :)

    So I grabbed the iproute2 source from http://devresources.linuxfoundation.org/dev/iproute2/download/ and made following modifications to make things work:

    • /Makefile

    - deleted/commented DBM_INCLUDE:=$(ROOTDIR)/usr/include

    - set the right path to cross-compiler libraries (i.e. /home/<user_name>/Software/CodeSourcery/Sourcery_G++/arm-none-linux-gnueabi/libc/)

    LIBDIR=path/to/cross-compiler/libraries

    - set the cross-compiler (i.e. arm-none-linux-gnueabi-gcc)

    CC=cross-compiler

    - set the HOSTCC equally as CC

    - removed netem from SUBDIRS

    • /lib/Makefile (nothing)
    • /ip/Makefile (nothing)
    • /tc/Makefile (nothing)
    • /misc/Makefile

    - removed arpd from TARGETS

    - and thus removed arpd : arpd.c ... lines also

    - explanation:

    - it solved the compilation error: arpd.c: db_185.h no such file or directory

    - which is ok as this part is responsible only for ARP daemon which I don't need

    - that's why DBM_INCLUDE line is deleted/commented in the main Makefile (/ directory)

    • /netem/Makefile (nothing)

    - no need to modify anything as this component is completely removed from the main Makefile (/ directory)

    - reason is that I was getting the strange error which I wasn't able to solve: /bin/sh:./normal: cannot execute binary file

    • /genl/Makefile (nothing)

    So this should be everything I've done to make this source successfully cross-compile. I believe that you could compile the whole source with a little bit more effort but I've got what I needed. I think the only mandatory Makefiles for bringing the CAN interface up are in directories /lib and /ip. Others are additional utilities.

    Now for bringing and loading the CAN interface one could type:

    ./ip link set can0 type can bitrate 125000 triple-sampling on

    ifconfig can0 up

    James, thanks again for your support and I hope this will help people in solving their CAN errors :)

    Regards,

    Adi