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.

Android Froyo on AM3517 - How to enable and access CAN interface?

Other Parts Discussed in Thread: AM3517

Hello,

Hardware: AM3517

OS: Android Froyo development kit

Problem: How to bring up CAN interface can0, and access it from a java application?

 

I need to be able to access the CAN interface on my CPU, from an Android user-application.

The socketCAN project (berlios) introduces the CAN module as a socket interface and provides you with a utility to test the same.

This is now supported in the Linux kernel release, as from 2.6.32 as far as I understand.. and therefore in Android Froyo as well.

Using the linux development kit for the AM3517, this is working fine, as you cross-compile your utility and then you can run your test from terminal, or access it from your user application.

I need to do the same on Android.

It would be nice to be able to compile one of these utilities as a native application, and access it from a java application.

The problem is, Android-NDK is not supporting this... at the moment. The header files to be found in ...include/linux/can.h and ..include/linux/can/raw.h etc. are not there.

 

Another thing, how can I bring up the can0 interface, using netcfg, or more specific set the bit-timing.

# netcfg can0 up
ti_hecc ti_hecc.1: bit-timing not yet defined
ti_hecc ti_hecc.1: open_candev() failed -22
action 'up' failed (Invalid argument)

From standard linux, you have the ip tool, which is not available in Android.

Does all this mean a dead end for Android, apart from doing major rebuilds and re-configuration?

 

Regards

Palsson

  • Hi,

    As you noticed, TI Android DevKit currently does not support CAN.

    You are encouraged to ask around the various forums for more help on supporting CAN from the Android framework.

     

    -Vishveshwar

     

  • Hello Gestur,

    I am also working on developing a CAN interface for Android running on the OMAP platform.  I would be interested in any developments you have made in this area.  I would also be willing to share my progress.

    I am also considering using the TI Stellaris processor to work as a CAN co-processor along side the OMAP processor running Android. I have a simple prototype working now using USB to communicate to the Stellaris, which takes care of the CAN network.  Eventually I need a higher level protocol stack above the physical CAN layer.  Offloading this to another processor may make more sense for my application.

     

  • Hello Geoffrey,

     

    Well, I'm kinda stuck with the Android part, not supporting CAN at the moment.

    I need the CAN interface on my AM3517, when running Android, as a system bus.. and it would be preferable to not introduce a co-processor for the task. 

    I mentioned that I couldn't find some CAN header files in the NDK part of the Android build sources, but those you can just locate in your Android kernel sources and copy to your NDK directories. Then you are able to make some NDK builds with CAN dependencies. I still need to enable the ip tool from the iproute2 utility suite, and that is to bring up the CAN interface, set bitrate, etc. But this is not supported by Android... hopefully it will.

    You can locate the ip tool in your externals/.., but the Android.mk file is missing :-)

    I'm also trying out with different Android groups, but it seems like this issue is not on the top of the list..

     

    Regards
    Gestur 

  • Hi Geoffrey,

    No I'm not using Craneboard, I'm using TI's EVM and LogicPD AM3517 module on top.

    Is the IP tool included in mistrals image?

     

  • Gestur,

    I am not familiar with the IP tool.  I have not gotten into doing CAN on the OMAP platform yet.  I have only been working with CAN on the Stalleris platform.  I am working on bringing up Android on my OMAP platform now, then I will move to bringing up CAN.

    The Crane board seems much more focused on CAN type applications, rather than mobile phone and multimedia.  So, this goup may provide better support for this kind of thing.  Also, this board is very cheap compared to EVM, so you might think about purchasing one yourself.  The Crane board also has the same processor you are using on the EVM.

    Geoff

  • Hi Geoffrey,

    Just to mention it, I like the Stellaris devices.
    I'm using it in another forum.. great platform and development tools.

    Well I'm not an expert, but I was mentioning the ip tool as it comes with the TI-Linux distribution I have for the kit (and probably default for Linux). The CAN implementation in Linux, is supporting socketcan, and therefore you can use the ip tool to bring up the interface, set the bitrate, etc. Similar as netcfg, where you just can't set the bitrate. And when you have socketcan, you are accessing the CAN-interface as a socket in your application, which is nice. And talking about sockets and network interfaces, along with Android, I'm thinking, well sure. 

    The Craneboard is interesting, and as you say are focusing on CAN. The Android support is coming soon :-) but you have the Mistral image. It would be interesting to hear and know, how and if they support CAN. 

    Regards
    Gestur 

  • Hi Gestur,

    Thanks for the tip on SocketCAN.  I have not heard of that before.  I did a little research into this online.  I am in industrial automation doing motion control, so timing is very critical.  Do you think SocketCAN is up to the task of real time deterministic control?  We have been working with CANopen as protocol stack, which works on top of the physical CAN layer.  I just read online of a company using CANopen as a layer on top of the SocketCAN driver.

    Geoff

  • Hi Geoff,

    I can't say about the real time capabilities.
    It is the million dollar question when it comes to Linux :-)

    But, if socketcan is up to the task of real time deterministic control?
    Its an open question really. What is real time enough for you.

    Honestly, I can't answer it, as I haven't tried and tested the interface like that.
    But, if you are using Linux you can't rely on the deterministic part, can you?
    SocketCAN is being implemented as a network interface, and I would say that you can get similar real time capabilities as for the ethernet layer.. mabye.

    Have you managed so far, with your timing critical requirements, using Linux and "not-socketcan" CAN access?

    Regards
    Gestur 

  • Hi Gestur,

    what's your status? Have you tried these instructions? http://processors.wiki.ti.com/index.php/Sitara_DCAN_Driver_Guide#CAN_Utilities

    I'm also working on am3517 based board and got Android 2.3 running. I haven't tried to cross-compile the stuff yet, but it looks promising.

    Yegor

  • Hi Yegor,

    My status is that I left both Linux and Android.. unfortunately!

    I decided to implement with wince compact 7.

     

    I started playing with the Android image, on the board, but I never got the CAN up and running.

    That was a show-stopper! It was not supported at the time, don't know the current status.

     

    CAN worked very well on the 'standard' Linux.. (socketCAN) which is actually what is explained on the wiki.

    I think its a recent updated wiki.. as far as I rembember I had to look for this info googling around :-)

     

    Anyway, sorry can't help you regarding Android and CAN.. but would be interested to know if you get it fixed...

     

    /Gestur

  • Hi Gestur,

    it's sad that you had to leave Android, but what was wrong with normal Linux? Why did you move to WinCE? I'm using Qt via Qt's internal X-server, so I have my GUI and SocketCAN() in one package. I'm using Buildroot to create rootfs and it is working quite good.

    I'll try to cross-compile the stuff and let you know if it works.


    Yegor

  • Hi Yegor,

    Yes its sad :-)

    Moving to WinCE was also a matter of politics within my company. Not all my decision.

    I had my Linux with Qt running as well, pretty handy and working. Furthermore I was planning on trying with Java embedded, don't know if you have...

     

    But if you get to it.. cross-compiling Android and fixing the CAN.. it would be great to know.

    Then I might give it a try again, behind the scenes :-)

    Thanks.

     

    /Gestur

  • Hi Yegor

    I need android source code for craneboard, can you help me.

    Siddaram

  • HI Siddaram,

    what Android version are you using?

    I haven't made much with Android and CAN lately. If you have Android 4.x and you have the patched version of iproute2, then you can try to use this Java/CAN wrapper: https://github.com/entropia/libsocket-can-java

    It will be compiling so far (you need to create Android.mk infrastructure), but you'll have to fix Java code, as it still has Java 1.7 dependency.

    That's all so far. I don't have a working code at hand, so can't help you further.

    Yegor