i require to convert a linux driver to android.
can anyone help me with the kernel twiking ?
is there a change to the driver makefile ?
where to get the source files of the kernel ?
can i use insmod/mknod in adb shell to load the driver dynamically ?
any hint will be welcomed...
noam
Lots of questions...
Yes, you need to change the makefiles in the kernel. For example, if your driver source is in drivers/net, you'll need to change the Makefile there so that it builds your sources.
You will also need to add a new configuration option in the Kconfig file so that the build process knows if it needs to build your sources, if it needs to be built as a module, etc. You'll need to run 'make oldconfig' or similar to include your new option in the kernel .config.
Kernel sources are available in the same way as the Android sources (see http://source.android.com); you have to add a .repo/local_manifest.xml file such as:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project path="kernel" name="kernel/omap"
revision="refs/heads/android-omap-2.6.29"/>
</manifest>
And yes, if you build your driver as a module then you can use insmod/rmmod to insert/remove it from a running kernel.
HTH!
Related
I'm going through the u-boot source code and it has many arch and vendor's code.
Also it has the source code with pre-processor directive as "#ifdef" etc.
I want to filter/extract the code based on my u-boot configuration.
There should be some way to tell the compiler so it can copy only the source code (to a new folder) which will be the part of my executable.
If it's possible then it will be easy to go through the source code and understand the code flow.
Is there any tool or compiler option available for this?
Thanks,
Hardik
I just looked into the Yocto WORKDIR so it's having only required files
in this directory so now it would be easy to go through the code.
These are object files but based on file names I can refer the c files.
I am planning to add support for menuconfig in my project. The project is not associated with Linux kernel so, I have to write everything from scratch in menuconfig and Makefile.
How do I add support for menuconfig and create Kconfig and make the makefile read the defines in .config?
Any good tutorial to begin with?
If you are interested on using KBuild/KConfig for your custom applications, you may try the following Github projects. They aim to provide an initial template for projects using KBuild/KConfig and, therefore, supporting menuconfig.
Kbuild skeleton: https://github.com/masahir0y/kbuild_skeleton
Kbuild template: https://github.com/embedded-it/kbuild-template
First you need to copy the folders and files below from linux folder 'scripts' into your own project
basic
kconfig
Kbuild.include
Makefile.build
Makefile.host
Makefile.lib
Sources in folders basic and kconfig need to be built for your processor architecture. How to do it is written in the linux Makefile. You can change some names using next variables
KCONFIG_CONFIG = .config
KCONFIG_AUTOHEADER = application/autoconf.h
KCONFIG_AUTOCONFIG = build/include/config/auto.conf
KCONFIG_TRISTATE = build/include/config/tristate.conf
The following project initially created for ARM MCUs can help you to understand kconfig
https://github.com/mcu/kconfig
I'll assume you are making a driver that is outside of the kernel directory. Information for that can be found here: https://www.kernel.org/doc/Documentation/kbuild/modules.txt.
Outside of that, if you want a userspace file to see the .config variables, you can have it depend on the kernel build, and then include autoconf.h, which is in the include/generated folder for recent versions of the kernel. Userspace does not use kbuild directly.
I've written a Tcl script that uses the TclMagick extension together with GraphicsMagick.
For GraphicsMagick, I've both the Windows DLLs and the Linux SO files. I want to be able to make two Starkit/Starpack applications bundled with those libraries: one for Windows (with the DLLs) and one for Linux (with the SO files).
Is this reasonable? Can it be done?
EDIT
I cannot seem to use DLLs with dependencies under Windows. In my case, I want to use the TclMagick extension, but it needs the GraphicsMagick's DLLs and the starkit cannot find those. What should I do in this situation?
Yes. In the lib/tclmagick subdirectory of $starkit::topdir, you'll place the dynamic library and an appropriate pkgIndex.tcl file that loads the library. Use a Makefile or some other build script to use the correct dynamic library file, and generate the pkgIndex, depending the target platform.
The directory hierarchy:
appname.vfs/
main.tcl
lib/
app-appname/
appname.tcl
pkgIndex.tcl
tclmagick/
pkgIndex.tcl
tclMagick.so
package require tclmagick will work as you expect, for some capitalization of "tclmagick"
You can do it, but you might need some extra windows trickery to get things to work properly.
Windows has quite a few options to load dependent libraries, this page explains the basics:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms682586%28v=vs.85%29.aspx
There are is one part that can help you:
If a DLL with the same module name is already loaded in memory, the system checks only for redirection and a manifest before resolving to the loaded DLL, no matter which directory it is in. The system does not search for the DLL.
So, to get the dependencies right, you could get the dependent libraries loaded into memory first (sadly you cannot use load for this, but could use something from twapi, e.g. twapi::load_libary (see http://wiki.tcl.tk/9886) to get the library loaded from some temporary location).
Sadly most OS's do not provide an easy or portable way to load a dynamic library directly from memory, so you need to copy the dependent libs to a temporary location first (you can do it with appropriate hacks or by using something like an installable filesystem on windows/FUSE on Linux).
In most cases the easiest route is to just link all dependencies statically into the extension instead.
I'm compiling dalvik on Android 4.1 with both host and target set to x86. The make command is:
make dalvikvm core ext framework android.policy services
However, there are multiple compiled binaries:
out/host/linux-x86/bin/dalvikvm
out/host/linux-x86/bin/dalvik
out/target/product/generic_x86/system/bin/dalvikvm
out/target/product/generic_x86/symbols/system/bin/dalvikvm
But the target versions don't work. When run, they show:
bash: ./dalvikvm: No such file or directory
This error is so strange that, I mean, the file is just there.
Could anyone please tell me which one is the compiled result? I mean, if I make some modification to dalvik source, which one will contain the modified result? Thank you.
This is almost certainly a linkage issue. The host version is linked against the normal host libc, but the target versions are linked against the android libc that lives in /system/lib on the device, which your host ld knows nothing about.
You might try something like:
LD_LIBRARY_PATH=<android_root>/out/target/product/generic_x86/system/lib out/target/product/generic_x86/symbols/system/bin/dalvikvm
Although I'm not entirely sure if that would work
I have written a Linux kernel module, which I included in a kernel downloaded from kernel.org. I modified the Kconfig file of the directory where my module will be to include it in the configuration menu.
But when I run make menuconfig, I can only select it as built-in, I can't make it run as a module. What determines if a program is intended to be only built-in or only module or both?
I already figured out how to do it.
For a kernel program to be compiled "module only" it must be depending on "m". By example:
config FOO
depends on m
This will limit FOO to be module (=m) or disabled (=n).
For more information:
http://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt