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.

How to create *.so for android



Hi

       I'm working in AM335x with Android ICS . I have to connect my  cp210x USB to serial converter. Hence i have enabled USB serial converter driver for cp210x in menuconfig and its working fine.

I want to create the cp210x.c as *.SO (Shared Object) file for work with other android tablet.

Can anyone help me how to create *.so file from  kernel tree. and also i want to know if i placed the cp210x.so in system/lib and if i connect the USB converter it will recognize the .so and it will work fine.?

Thanks in advance

Sangilikumar

  • I think you mean to create *.ko (kernel module). You should be able to make that by configuring the respective driver as module (CONFIG_* = m) instead of builf-in (CONFIG_* = y) and then compiling the modules.

    But I'm not sure how you will be able to get the *.ko driver loaded on your device.

  • Hi Mr.Vishveshwar Bhat

                    I've compiled the image with ( CONFIG_* = y ) so my device can recognize the cp210x connector and its working fine. If i create *.ko ( loadable module ) and when i tried to load the module its showing error. So i decide it not possible for ever android tablet becuse kernel verison of every tablet is not same.

                    Hence we decide create *.so instead of .ko for work with every adroid device. Any possible to create cp210x.c which is in kernel/drivers/USB/serial/ cp210x.c to .so.

    If i create .so and placed system/lib it will work fine.?, if it will work fine kindly share the procedure for create *.so from kernel source tree.

    Thanks in advance

    M.Sangilikumar

  • Suggestion,

    You can try adding a library from NDK or for example a Platform Library that has the Add-on and the permission file to read the library and propagate the permissions from Apk-Java-Cpp-ko files.

    ./mydroid/device/sample/frameworks/PlatformLibrary/README.txt

    I know you are working in other processor than OMAP4, but this part is for Android that must be common.

    some of the information about Android permission and security are in this post from OMAP4 forum

    http://e2e.ti.com/support/omap/f/849/p/178679/648158.aspx#648158

    It could be needed to add some permission to use the HW from APK, like integrating the driver from the kernel then creating a .so library to access it, and then a platformlibrary and then the APK, I am not sure if you need to add some permission, but adding a server to access it from a Client code in the apk should be needed.

    Because of the security paths and Android it is not easy to access something from the kernel. At least is the information I have.

  • Hi Manuel Contreras

                  Thanks for your reply its really helpful for my future works.

    But in my current task i'm struggling lot, i have mentioned the problem below.

                  My source file directory is /kernel/drivers/usb/serial/cp210x.c ( linux kernel source tree) 

                  This *.c file have some header files these are < linux/kernel.h>, <linux/errno.h>,<linuxtty.h>,<linux/usb.h> etc..

    Inside the <linux/kernel.h>  some header files are included these are <stdarg.h>, <linux/stddef.h> etc... likewise every header files have some header files, so i struggling lot to assemble this files.

                  Can you help me to write make file for this and help me to get cp210x.so file.

                  Do you have any other idea to implement this ?

    Thanks in advance

    Sangilikumar M 



  • Brief explaining from my point of view,

    The kernel is made to handle the access to the HW or other devices, the way to interact with it is via modules that are loaded internally or able to be loading using insmod or related functions from OS. A third way is using /sys interface to read or modify some value but this code is inside the kernel module, a fourth way is using /proc directory to read actual system values. At least these the most common, there is enabling the debug info from Kernel config file.

    One of the reasons for the kernel is to separate the system processes from the user processes, like the part of booting that has Administrative access to HW and when it is complete sets the normal mode, this to avoid the access to processor's core or some important HW feature, for saying in some way.

    By searching a possible way by referencing your last post, I am trying to find a way to use a .so using some write input port function definitions to write to some register or something similar like it is done in other OSes but those interfaces are not available in Linux, instead of those it is the /sys directory the one used to interact with the kernel.

    That is the function to protect the registers or some external access by using system/user permission and other important stuffs.

    Apart, Android has the Sandbox explained in next 2 links,

    http://developer.android.com/guide/topics/security/permissions.html

    http://developer.android.com/training/articles/security-tips.html

    One last thing I am thinking about this is that Android offers a USB Host/Accessory code that could contain the interface you are looking for or could be implemented using this basements.

    http://developer.android.com/guide/topics/connectivity/usb/index.html

    The most of Android's USB code is not in the kernel it is part of Android OS. Android's USB accessory was available from GB 3.4, to use it before that it was released a package to be used.