How to use FlexCAN in Android OS

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use FlexCAN in Android OS

Jump to solution
12,049 Views
dureshasanka
Contributor II

Hi everyone,

I am new-bee to the ARM platform.

I am using Android 4.0 running in i.MX6Q for my project.

I want to use CAN to communicate with other devices (CAN-Microcontrollers). I have downloaded the linux drivers for I.MX6Q (i.MX 6 Series Software and Development Tool Resources Product Summary Page</title><meta nam...) with the Freescale technical support guidance.

In the FlexCAN driver section in the documentation section of "SABRE for Automotive Infotainment", the pdf "Linux_6DQ_RM_L3.0.35_1.1.0.pdf" has mentioned about "flexcan.c", which is I can not find.

But there is a folder called, "cantest-1.0" and inside there, there are can drivers (which is called SocketCAN).

Could anyone please tell me that, can I use these drivers?

I am using Eclips IDE to build my Android application. But I do not know how to use these drivers in my application.

Could anyone please guide me.

Labels (3)
1 Solution
1,723 Views
andreygelman
Contributor III

You must distinguish two things:

1. Linux kernel

2. User-space, which might be Linux (Ubuntu or Debian ...) or Android

1. To test that you have FlexCAN support in your kernel, type in the command line:

In Linux:    ifconfig -a

In Android:    busybox ifconfig -a

In the list of network devices look for 'can0'.

If it is not there ...

Follow this guide: All Boards FlexCAN, which is for Linux user-space, but the kernel part is just the same.

Note: regarding your post above, do the 'menuconfig' on your PC  -  google building Linux kernel.

Note 2: there are 'special kernel boot arguments' might be required to enable FlexCAN - flexcan.

2. Now the user-space utilities ...

Linux user-space: follow this guide: All Boards FlexCAN

Android user-space: there are two options:

1) build the Linux utilities for Android (i.e. compile statically) and call them from your Java code as you would invoke any system command (I think it will require root access)  -  for reference: java - How to run terminal command in Android application? - Stack Overflow

2) Follow this developer: zhangjie201412/Flexcan · GitHub

that teaches us how to bridge between Java and native library in regard of FlexCAN. When you can successfully execute 'cansend' using his project, you will be able to extend this work referring to the Linux utilities.

But you should really start with the 'ifconfig -a', otherwise it will all be for nothing ...

View solution in original post

13 Replies
1,723 Views
sachusanal
Contributor III

Hai Sir ,

as per your suggestion i can bring up CAN driver from the kernel space.

Could please help me to access from the user space part.

could you please suggest how can build the developer  Freescale flexcan module in Android

code. or how can build the linux utlites for android in linux .

please help me.

its an urgent issue?

0 Kudos
1,723 Views
bandelaprathyus
Contributor II

Hi,

      Could you please tell clearly how to use canbus on android system, like how to configure kernel etc.. I am using android kitkat ported on Sabre AI (i.mx6).

0 Kudos
1,723 Views
hpsolutions
Contributor I

As Alenjandro mentioned the link you sent contains a non-official Android porting of FlexCAN, using a somewhat old flexcan driver (please someone correct me if I am wrong). If you asked the same question 1-2 years back, the link you sent might contain the answer for you. There is no guarantee that this driver will be stable against fairly new hardware like i.MX 6 that you have. So use it at your own risk.

Freescale BSPs are now coming with FlexCAN driver which is included in the mainline Linux kernel (which is getting updated frequently). Using of this standard flexcan.c driver which comes with the BSP is recommended. How? just follow the steps mentioned here All Boards FlexCAN. There are Canutils and Libsocketcan packages also to test the functionality at user space.

Porting the FlexCAN interface to Android is a different story. You will need at least a lower level library, may be an Android Service and more depending on your requirements. I am not an expert in Android, but if I am correct ADT plugin for Eclipse does not contain standard APIs related to CAN whatsoever, simply because SDK does not have it. If you are planning to build your app using Eclipse with ADT, you will need a mechanism to add your custom API calls to your IDE as well. How? Sadly I don't know. Try Googling :smileygrin:.

1,723 Views
dureshasanka
Contributor II

Hi,

Thank you very much for the comprehensive reply.

As the  All Boards FlexCAN it is a very clear guidance to use FlexCAN. But because I am new to Linux & Android, I am confused how to add the Canutils & Libsocketcan in to Android BSP and also configure the 'menuconfig'.

I tried those commands in the Linux console coming out from the board. But those commands are not working.

I am sorry If I am asking some stupid question.

I am newbie to these things.

Could you please help me on this.

Thanks in advance.

0 Kudos
1,724 Views
andreygelman
Contributor III

You must distinguish two things:

1. Linux kernel

2. User-space, which might be Linux (Ubuntu or Debian ...) or Android

1. To test that you have FlexCAN support in your kernel, type in the command line:

In Linux:    ifconfig -a

In Android:    busybox ifconfig -a

In the list of network devices look for 'can0'.

If it is not there ...

Follow this guide: All Boards FlexCAN, which is for Linux user-space, but the kernel part is just the same.

Note: regarding your post above, do the 'menuconfig' on your PC  -  google building Linux kernel.

Note 2: there are 'special kernel boot arguments' might be required to enable FlexCAN - flexcan.

2. Now the user-space utilities ...

Linux user-space: follow this guide: All Boards FlexCAN

Android user-space: there are two options:

1) build the Linux utilities for Android (i.e. compile statically) and call them from your Java code as you would invoke any system command (I think it will require root access)  -  for reference: java - How to run terminal command in Android application? - Stack Overflow

2) Follow this developer: zhangjie201412/Flexcan · GitHub

that teaches us how to bridge between Java and native library in regard of FlexCAN. When you can successfully execute 'cansend' using his project, you will be able to extend this work referring to the Linux utilities.

But you should really start with the 'ifconfig -a', otherwise it will all be for nothing ...

View solution in original post

1,723 Views
sachusanal
Contributor III

Hi ,

I followed your document . I download android lolipop package from the freescale  and referring android user guide for the  android build.

Could you please help me to add flexcan module on  kernel and user space. after downloading the android source code  which command is used to configure the kernel.?

what is the use of this step

modify the file arch/arm/mach-mx5/mx53_loco.c

add the flexcan option.and register can driver. ?

how can we register the flexcan option on that file.

In conloe i can't neter any command. how can enter bysybox ifconfig -a  command

0 Kudos
1,723 Views
姜伟琼
Contributor I

how to use canbus on android system :

the way of freescale imx53 or imx6 flexcan debug on android system:

1)configure kernel

[*] Networking support  --->

    <*>  CAN bus subsystem support  --->

        <*>  Raw CAN Protocol (raw access with CAN-ID filtering)

        <*>  Broadcast Manager CAN Protocol (with content filtering)

    CAN Device Drivers  --->

        <*> Virtual Local CAN Interface (vcan)

        [*] CAN devices debugging messages

        <*> Freescale FlexCAN


2)modify the file arch/arm/mach-mx5/mx53_loco.c

add the flexcan option.and register can driver.

3)if you register can driver right,you will see can0 and can1,and it will have /sys/devices/platform/flexcan.0/

#busybox ifconfig -a

then you can use cansend and canecho to test it.

0 Kudos
1,723 Views
bandelaprathyus
Contributor II

Hi,

      Could you please tell clearly how to use canbus on android system, like how to configure kernel etc.. I am using android kitkat ported on Sabre AI (i.mx6).

0 Kudos
1,723 Views
AlejandroSierra
NXP Employee
NXP Employee

This is not official release from Freescale. Officially we don't support FlexCAN for Android.

Looking into the link you sent, it seems you need to copy this files into the proper Android enviroment and rebuild.

1,723 Views
dureshasanka
Contributor II

Thank you very much for you reply.

Could you please guide me, should I port the drivers in the directory "kernel/drivers/net/can/flexcan/" and can I use .java files in my project.


Thanks in advance

0 Kudos
1,723 Views
dureshasanka
Contributor II

Hi every one,

finally I got to know from freescale technical support, that FlexCAN has no support in Android. :smileysad:

Now I am stuck in the middle of my project.

But they said that, I should be able to port the Linux FlexCAN driver. But I do not know nothing about porting at all.

Could anyone please tell me how to do it.

Thanks in advance

0 Kudos
1,723 Views
YixingKong
Senior Contributor IV

Duresh, if your question has been answered, please click Correct Answer/Helpful Answer.

Thanks,

Yixing

0 Kudos
1,723 Views
dureshasanka
Contributor II

Hi,

Finally I found a open source source files used, FlexCAN in android.

Here is the link,

https://github.com/zhangjie201412/Flexcan

But I can not understand how to use them, because there is no any documents.

Could some one help me on this.

Thanks in advance.

0 Kudos