Enabling Loadable Modules Android - android

I'm trying to compile a kernel (Goldfish) to later insert some modules. I know that I need to enable module support, module loading, and unloading. I'm using OSX Mavericks.
So far I have checked out goldfish from git, and have done the following:
make ARCH=arm goldfish_armv7_defconfig
No problems there. Now when I do:
make ARCH=arm CROSS_COMPILE=/Volumes/untitled/WORKING_DIRECTORY/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6/bin/arm-eabi- menuconfig
I get the following:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: * [scripts/kconfig/mconf] Error 1
make: * [menuconfig] Error 2
Is there a way that I can enable modules another way? Maybe go into a file and do it manually?
If I just run (which I'm supposed to run after to get a zImage):
make ARCH=arm SUBARCH=arm CROSS_COMPILE=/Volumes/untitled/WORKING_DIRECTORY/prebuilts/gcc/darwin-x86/arm/arm-eabi-4.6/bin/arm-eabi -j16
The kernel compiles and I can run it via an emulator, but obviously I can't upload kernel modules.

module loading is disabled by default in android kernel.
Enable it using CONFIG_MODULES=y in your config file.

Open scripts/kconfig/lxdialog/check-lxdialog.sh
Replace ldflags() with this
ldflags()
{
for ext in so a dylib ; do
for lib in ncursesw ncurses curses ; do
#$cc -print-file-name=lib${lib}.${ext} | grep -q /
#if [ $? -eq 0 ]; then
if [ -f /usr/lib/lib${lib}.${ext} ]; then
echo "-l${lib}"
exit
fi
done
done
exit 1
}
Now make menuconfig should work. The problem seems to be the result of a bug with clang on OS X. The -print-file-name option doesn't work correctly.
Alternatively, you could open .config file in a text editor and set
CONFIG_MODULES=y

Related

Cross Compile the Kernel

I am trying to achieve something similar to this
https://github.com/volatilityfoundation/volatility/wiki/Android#initialize-the-android-build-environment.
Below is the environment I am using:
Ubuntu 14.04, Android Studio 2.3, Android NDK r14, emulator -api22.
I am facing difficulties at step Cross Compile the Kernel.
I am targeting the goldfish kernel 3.10
following are the step I followed. Any help would be really appreciated.
method 1:
export ARCH=arm
export SUBARCH=arm
export CROSS_COMPILE=~/android-ndk/android-ndk-r14/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
The tutorial suggesting that we have to run the next command as
make goldfish_armv7_defconfig
but when I checked the directory "android-source/arch/arm/configs/" there is no such config file there. Some tutorials suggesting that we can just copy and paste the file from kernel 2.6, so I did the same thing, and after that add
CONFIG_MODULES=y
CONFIG_MODULES_UNLOAD=y
CONFIG_MODULES_FORCE_UNLOAD=y
But futher
$ make
results in error:
arch/arm/mm/mmu.c: In function 'build_mem_type_table':
arch/arm/mm/mmu.c:470:18: error: 'L_PTE_MT_VECTORS' undeclared (first use in this function)
vecs_pgprot |= L_PTE_MT_VECTORS;
^
arch/arm/mm/mmu.c:470:18: note: each undeclared identifier is reported only once for each function it appears in
arch/arm/mm/mmu.c: At top level:
arch/arm/mm/mmu.c:637:23: warning: 'early_pte_alloc_and_install' defined but not used [-Wunused-function]
static pte_t * __init early_pte_alloc_and_install(pmd_t *pmd,
^
make[1]: *** [arch/arm/mm/mmu.o] Error 1
make: *** [arch/arm/mm] Error
methos 2:
Everything is same as in method 1, I just changed single variable
export ARCH=arm64
And run
make ranchu_deconfig
But I got the same error.
method 3:
$ export ARCH=arm
$ export SUBARCH=arm
$ export CROSS_COMPILE=~/android-ndk/android-ndk-r14/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
$ make ranchu_defconfig
$ vim .config # added this to .config file
CONFIG_MODULES=y
CONFIG_MODULES_UNLOAD=y
CONFIG_MODULES_FORCE_UNLOAD=y
$ make
This command run successfully: zImage found.
But when I run the emulator using the below command
root#ubuntu:~/Android/Sdk/tools# ./emulator -avd Nexus5x22 -kernel ~/android-source2/android-source/arch/arm/boot/zImage -show-kernel –verbose
I am getting the error of "Linux kernel too old to run ram disk":
ram disk error
Google's Android Kernel is messed up. They forgot to define L_PTE_MT_VECTORS when they back ported this patch.
The solution is to just add it here.

Building PJSIP: "Make dep" command giving error on Windows7

I have followed all the steps written in the pjsip-startup guide.
But the last step (make dep && make clean && make) is giving me the following errors. I am on Windows 7.
$ make dep && make clean && make
for dir in pjlib/build pjlib-util/build pjnath/build third_party/build pjmedia/b uild pjsip/build pjsip-apps/build ; do \
if make -C $dir dep; then \
true; \
else \
exit 1; \
fi; \
done
make[1]: Entering directory '/cygdrive/d/android/pjproject-2.2.1/pjlib/build'
make -f /cygdrive/d/android/pjproject-2.2.1/build/rules.mak APP=PJLIB app=pjlib depend
make[2]: Entering directory '/cygdrive/d/android/pjproject-2.2.1/pjlib/build'
.pjlib-arm-unknown-linux-androideabi.depend:1: *** multiple target patterns. St op.
make[2]: Leaving directory '/cygdrive/d/android/pjproject-2.2.1/pjlib/build'
Makefile:88: recipe for target 'depend' failed
make[1]: *** [depend] Error 2
make[1]: Leaving directory '/cygdrive/d/android/pjproject-2.2.1/pjlib/build'
Makefile:14: recipe for target 'dep' failed
make: *** [dep] Error 1
Can someone help me to resolve these errors? Thanks!
After some research I come to know that don't use WINDOWS for building the PJSIP v2.x version. Now I am going to install Ubuntu on my system.
The build system is known to work on the following hosts:
Linux, many types of distributions.
MacOS X 10.2 mingw (Win2K, XP)
FreeBSD (must use gmake instead of make)
Building Win32 applications with Cygwin is currently not supported by the autoconf script (there are some conflicts with Windows headers), but one can still use the old configure script by calling ./configure-legacy. More over, cross-compilations might also work with Cygwin using this build system.
See the link for details.

Android build Error on OSX 10.8.5: cp: the -R and -r options may not be specified together

I'm trying to compile Android FS, on OSX 10.8.5, and I'm getting an error that seems related to the fact that the build is being done on OSX.
I did all the brew installations and the compilation is being done on a case-sensitive FS,
yet I'm getting the following:
target arm C++: libwebrtc_apm <= out/target/product/generic/obj/STATIC_LIBRARIES/libwebrtc_apm_intermediates/proto/external/webrtc/src/modules/audio_processing/test/unittest.pb.cc
Symlink: out/target/product/generic/system/vendor/lib/libbltsville_cpu.so -> ./libbltsville_ticpu.so
Symlink: out/target/product/generic/system/vendor/lib/libbltsville_ticpu.so -> ./libbltsville_ticpu.2.1.0.0.so
Install: out/host/darwin-x86/bin/minigzip
cp: the -R and -r options may not be specified together.
make: * [out/target/product/generic/system/vendor/lib/libbltsville_ticpu.so] Error 1
make: * Deleting file `out/target/product/generic/system/vendor/lib/libbltsville_ticpu.so'
make: * Waiting for unfinished jobs....
Any ideas?
I know that -R can solve this issue, but the build is being done by scripts and it'll be very hard to change all the spots where -avr will be -avR!!
I'm looking for a way to replace the cp command to a more linux like command....
So I got an answer for this conundrum:
The Makefile & main.mk located in build/core
Are the rogue files that made the trouble, hope this'll help someone.

compilation of VLC for Android fail

I'm trying to compile vlc using the following instructions http://wiki.videolan.org/AndroidCompile.
i get the vlc source using git but when i'm doing the next command:
cd extras/contrib
./bootstrap -t arm-eabi -d android
i'm getting this error:
[contrib] No install dir specified, using '/android-sdk-mac_x86/vlc-android/extras/contrib/hosts/arm-eabi'
[contrib] *****************************************************************
[contrib] * If you need contribs with all debug information, run this *
[contrib] * line and compile the libraries on your own. *
[contrib] * CONTRIBS_RELEASE=no ./bootstrap *
[contrib] *****************************************************************
[contrib] Using 1 processor(s)
when i make the next step that is 'make' i got the following failure;
make -C build-src tools
make[1]: Nothing to be done for `tools'.
make -C build-src
(cd zlib; CC="arm-linux-androideabi-gcc --sysroot=/android-ndk-r5b//platforms/android-9/arch-arm" CXX="arm-linux-androideabi-g++ --sysroot=/android-ndk-r5b//platforms/android-9/arch-arm" LD="arm-linux-androideabi-ld" RANLIB="arm-linux-androideabi-ranlib" AR="arm-linux-androideabi-ar" STRIP="arm-linux-androideabi-strip" ./configure --prefix=/android-sdk-mac_x86/vlc-android/extras/contrib/hosts/arm-eabi --static && make install)
Building static library libz.a version 1.2.5 with arm-linux-androideabi-gcc --sysroot=/android-ndk-r5b//platforms/android-9/arch-arm.
Checking for off64_t... No.
Checking for fseeko... No.
Checking for unistd.h... No.
Checking whether to use vs[n]printf() or s[n]printf()... using s[n]printf().
Checking for snprintf() in stdio.h... No.
WARNING: snprintf() not found, falling back to sprintf(). zlib
can build but will be open to possible buffer-overflow security
vulnerabilities.
Checking for return value of sprintf()... No.
WARNING: apparently sprintf() does not return a value. zlib
can build but will be open to possible string-format security
vulnerabilities.
arm-linux-androideabi-gcc --sysroot=/android-ndk-r5b//platforms/android-9/arch-arm -I/android-sdk-mac_x86/vlc-android/extras/contrib/hosts/arm-eabi/include -DNDEBUG -D__STDC_VERSION__=199901L -I/android-ndk-r5b//sources/cxx-stl/gnu-libstdc++/include -I/android-ndk-r5b//sources/cxx-stl/gnu-libstdc++/libs/armeabi/include -isystem /android-sdk-mac_x86/vlc-android/extras/contrib/hosts/arm-eabi/include -I/android-ndk-r5b//platforms/android-9/arch-arm/usr/include -DNO_FSEEKO -DNO_snprintf -DHAS_sprintf_void -I/android-sdk-mac_x86/vlc-android/extras/contrib/hosts/arm-eabi/include -DNDEBUG -D__STDC_VERSION__=199901L -I/android-ndk-r5b//sources/cxx-stl/gnu-libstdc++/include -I/android-ndk-r5b//sources/cxx-stl/gnu-libstdc++/libs/armeabi/include -isystem /android-sdk-mac_x86/vlc-android/extras/contrib/hosts/arm-eabi/include -I/android-ndk-r5b//platforms/android-9/arch-arm/usr/include -c -o adler32.o adler32.c
make[2]: arm-linux-androideabi-gcc: No such file or directory
make[2]: *** [adler32.o] Error 1
make[1]: *** [.zlib] Error 2
make: *** [using-src] Error 2
anyone can help? i'm using mac OS X 10.6.6
tnx
Given prior Linux CLI experience, the best I can tell you is that it doesn't look like your tool-chain is fully initialized and needs some setup. Below is a link that documents initialization for a MAC build environment:
http://source.android.com/source/initializing.html
You probably should have set your NDK installation properly.
Download the latest Android NDK.
Unzip and move the extracted “android-ndk-r6″ directory to “/Applications”, so you end up with “/Applications/android-ndk-r6″.
Edit “~/.profile” to add the following:
export ANDROID_NDK=/Applications/android-ndk-r5b
export PATH=$PATH:$ANDROID_NDK:$ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/darwin-x86/bin
The PATH was the key to solve this kind of problem to me. Because it makes possible to find and use "arm-linux-androideabi-gcc".
Refer to this web site.
http://www.doitscared.com/632/eclipse-indigo-for-android-development-on-mac-os-x-snow-leopard/

How do you create a loadable kernel module for Android?

I know there a number of walkthroughs and tutorials floating around out there which describe this activity, but after having read many of them I still can't get this working. If anyone has the patience to wade through the steps I've taken (posted below) and suggest where I may have gone off track I'd be very appreciative. I've spent about a day and a half staring at make files and reading walkthroughs so literally any suggestions would be helpful.
Environment:
I'm using an Ubuntu 10.04 32 bit vm.
I'm hosting from a 64 bit windows 7
My Core 2 Duo does not have the hardware support for 64 bit VMs so i'm trying to compile against Android 2.1 kernel
I have installed Java 1.5 from the Dapper repo and removed my 1.6 installation
The rest of the tooling has been acquired according the Android dev documentation...
As per Initializing a Build Environment:
Java:
$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper main multiverse"
$ sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu dapper-updates main multiverse"
$ sudo apt-get update
$ sudo apt-get install sun-java5-jdk
Other required:
$ sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev libncurses5-dev x11proto-core-dev libx11-dev libreadline5-dev libz-dev libgl1-mesa-dev
$ sudo apt-get install gcc-multilib g++-multilib libc6-i386 libc6-dev-i386
Then from Downloading the Source Tree:
Repo:
$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ mkdir WORKING_DIRECTORY
$ cd WORKING_DIRECTORY
$ repo init -u https://android.googlesource.com/platform/manifest -b eclair
$ repo sync
$ gpg --import (imported the huge key)
And from Building the System:
Initialize:
$ source build/envsetup.sh
Choose a Target:
$ lunch generic-user
Build the Code:
$ make -j4
Added!
Output of make -j4:
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.1-update1
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ECLAIR
============================================
build/core/copy_headers.mk:15: warning: overriding commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h'
build/core/copy_headers.mk:15: warning: ignoring old commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h'
/bin/bash: line 0: cd: sdk/layoutopt/app/src/resources: No such file or directory
Install: out/host/linux-x86/bin/acp
target Generated: libclearsilver-jni <= out/host/common/obj/JAVA_LIBRARIES/clearsilver_intermediates/javalib.jar
target Generated: libclearsilver-jni <= out/host/common/obj/JAVA_LIBRARIES/clearsilver_intermediates/javalib.jar
host SharedLib: libneo_cs (out/host/linux-x86/obj/lib/libneo_cs.so)
host C++: aapt <= frameworks/base/tools/aapt/AaptAssets.cpp
host C++: aapt <= frameworks/base/tools/aapt/Command.cpp
error: error reading out/host/common/obj/JAVA_LIBRARIES/clearsilver_intermediates/javalib.jar; error in opening zip file
error: error reading out/host/common/obj/JAVA_LIBRARIES/clearsilver_intermediates/javalib.jar; error in opening zip file
error: error reading out/host/common/obj/JAVA_LIBRARIES/clearsilver_intermediates/javalib.jar; cannot read zip file
error: cannot access org.clearsilver.HDF
class file for org.clearsilver.HDF not found
javadoc: error - Class org.clearsilver.HDF not found.
Error: No classes were specified on the command line. Try -help.
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libclearsilver-jni_intermediates/org_clearsilver_HDF.h] Error 15
make: *** Waiting for unfinished jobs....
error: error reading out/host/common/obj/JAVA_LIBRARIES/clearsilver_intermediates/javalib.jar; cannot read zip file
error: cannot access org.clearsilver.CS
class file for org.clearsilver.CS not found
In file included from frameworks/base/tools/aapt/AaptAssets.h:18,
from frameworks/base/tools/aapt/AaptAssets.cpp:5:
frameworks/base/tools/aapt/ZipFile.h:65: warning: ‘typedef’ was ignored in this declaration
javadoc: error - Class org.clearsilver.CS not found.
Error: No classes were specified on the command line. Try -help.
In file included from frameworks/base/tools/aapt/AaptAssets.h:18,
from frameworks/base/tools/aapt/Main.h:14,
from frameworks/base/tools/aapt/Command.cpp:6:
frameworks/base/tools/aapt/ZipFile.h:65: warning: ‘typedef’ was ignored in this declaration
make: *** [out/host/linux-x86/obj/SHARED_LIBRARIES/libclearsilver-jni_intermediates/org_clearsilver_CS.h] Error 15
Added!
So it turns out i've got some problems here. I assume that once i've overcome these issues, i'll have an environment capable of compiling kernel modules. Please do correct me if I'm wrong.
Next I head into my directory containing my module.c file and it's makefile. Contents of makefile below:
obj-m += mymodule.o
CROSS_COMPILE=~/WORKING_DIRECTORY/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-
KERNEL_DIR ?= /home/<myuser>/WORKING_DIRECTORY
VERSION = v1.1
all:
make -C $(KERNEL_DIR) M=$(PWD) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) modules
rm -rf *.c~
rm -rf *.mod*
rm -rf *.o
clean:
make -C $(KERNEL_DIR) M=$(PWD) clean
I have very little experience with make and makefiles, but this looked reasonable to me. My main concern with this file is the KERNEL-DIR variable. I tried a few different values for that variable, but got all sorts of errors where I do not with it's current value. Of course, it could still be wrong, so any comments here are welcome.
So, as far as I know, I should be able to execute make with no args or anything and will figure out what it needs to do. I have tried make, make -f both with and without sudo. All four permutations yield the same results:
make -C /home/<myuser>/WORKING_DIRECTORY M=/home/<myuser>/Desktop/<MyModuleDir> ARCH=arm CROSS_COMPILE=~/WORKING_DIRECTORY/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi- modules
============================================
PLATFORM_VERSION_CODENAME=REL
PLATFORM_VERSION=2.1-update1
TARGET_PRODUCT=generic
TARGET_BUILD_VARIANT=eng
TARGET_SIMULATOR=
TARGET_BUILD_TYPE=release
TARGET_ARCH=arm
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=ECLAIR
============================================
make[1]: Entering directory `/home/<myuser>/WORKING_DIRECTORY'
build/core/copy_headers.mk:15: warning: overriding commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h'
build/core/copy_headers.mk:15: warning: ignoring old commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h'
/bin/bash: line 0: cd: sdk/layoutopt/app/src/resources: No such file or directory
Available sub-modules:
01-test dumpsys libminui LotsOfApps
20-dns.conf dvz libminzip lowstoragetest
95-configured dx libmp4recognizer_utility lsd
aapt dx-tests libmtdutils LunarLander
acc edify libnativehelper LunarLanderTests
AccountAndSyncSettings Email libneo_cgi MagicSmokeWallpapers
accRuntimeTest EmailTests libneo_cs make_cfst
acp emma libneo_util makedict
adb emmalib libnetutils make_g2g
adbd emulator libocr makekeycodes
add-property-tag emulator-arm libomx_aac_component_lib make_ve_grammar
afar emulator-hw libomx_aacdec_sharedlibrary mediaframeworktest
aidl emulator-tcg libomx_amr_component_lib MediaProvider
AlarmClock EnabledTestApp libomx_amrdec_sharedlibrary mediaserver
AliasActivity etc1tool libomx_amrenc_component_lib memtest
am eventanalyzer libomx_amrenc_sharedlibrary minigzip
android event-log-tags libomx_avc_component_lib mkbootfs
android.core.tests.annotation exc_dump libomx_avcdec_sharedlibrary mkbootimg
android.core.tests.archive ext libomx_baseclass_lib mksdcard
android.core.tests.concurrent Fallback libomx_common_lib mkstubs
android.core.tests.crypto fastboot libomx_m4v_component_lib mkyaffs2image
android.core.tests.dom FixedGridLayout libomx_m4vdec_sharedlibrary Mms
android.core.tests.logging flash_image libomx_mastercore_lib MmsTests
android.core.tests.luni.io FontLab libomx_mp3_component_lib monkey
android.core.tests.luni.lang framework libomx_mp3dec_sharedlibrary monkeyrunner
android.core.tests.luni.net FrameworkPermissionTests libomx_queue_lib mtpd
android.core.tests.luni.util framework-res libomx_sharedlibrary MultiResolution
android.core.tests.math FrameworkTest libop Music
android.core.tests.nio framework-tests libopencore_author MusicTests
android.core.tests.nio_char FrameworkTestTests libopencore_common nc
android.core.tests.prefs fsck_msdos libopencore_download netcfg
android.core.tests.regex fs_config libopencore_downloadreg netperf
android.core.tests.runner fs_get_stats libopencore_mp4local netserver
android.core.tests.security Gallery libopencore_mp4localreg ninepatch
android.core.tests.sql Gallery3D libopencore_net_support NinePatchLab
android.core.tests.text GalleryTests libopencore_player NoShareUidApp
android.core.tests.xml gdbserver libopencore_rtsp NotePad
android.core.tests.xnet genext2fs libopencore_rtspreg NotePadTests
android.cts.dpi GestureBuilder libosclbase opcontrol
android.cts.refapp GL2JNI libosclerror openssl
android.policy GLJNI libosclio OpenWnn
android.policy_mid GlobalSearch liboscllib oprofiled
android.policy_phone GlobalSearchBenchmarks libosclmemory org.eclipse.core.commands_3.4.0.I20080509-2000
androidprefs GlobalSearchPermissionTests libosclproc org.eclipse.equinox.common_3.4.0.v20080421-2006
android.test.runner GlobalSearchTests libosclregcli org.eclipse.jface_3.4.2.M20090107-0800
AndroidTests GlobalTime libosclregserv org-netbeans-api-visual
angeles GoogleContactsProvider libosclutil org-openide-util
ant GoogleContactsProviderTests libpagemap osgi
antlr-2.7.7 google-framework libpassthru_oma1 PackageInstaller
anttasks googlelogin-client libpcap parseStringTest
apicheck GoogleSearch libpixelflinger perm_checker
ApiDemos gpustate libpixelflinger_armv6 perm_checker.conf
ApiDemosReferenceTest gralloc.default libpixelflinger_static Phone
ApiDemosTests groovy-all-1.6.5 libplatform_library_jni PicoTts
apkbuilder grxmlcompile libpng ping
ApplicationsProvider gtest-filepath_test libpopt PinyinIME
applypatch gtest-linked_ptr_test libprotocolenginenode_base PlatformLibraryClient
applypatch_static gtest-message_test libprotocolenginenode_common platform.xml
app_process gtest-options_test libprotocolenginenode_download_common pm
AppWidgetHostTest gtest-port_test libprotocolenginenode_pdl post_trace
AppWidgetProvider gtest_pred_impl_unittest libprotocolenginenode_ps pppd
apriori gtest_prod_test libpv_aac_dec preload
archquery gtest-test-part_test libpvaacffparsernode ProcessTests
asm-3.1 gtest-typed-test2_test libpvaacffrecognizer procmem
atree gtest-typed-test_test libpvaacparser procrank
AudioHardwareRecord gtest_unittest libpvamrffparsernode profile_pid
AudioHardwareRecordLoop gzip libpvamrffrecognizer profile_trace
AudioInRecord HelloActivity libpv_amr_nb_common_lib Provision
backup_helper_test HelloActivityTests libpvamrwbdecoder pvplayer
BackupTest hierarchyviewer libpvauthorengine q2dm
BatteryWaster hist_trace libpv_avc_common_lib q2g
bb2sym Home libpvavcdecoder qemud
bb_dump hosttestlib libpvavifileparser qemu-props
bbprof hprof-conv libpv_config_parser qwerty2.kcm
bison HTMLViewer libpvdecoder_gsmamr qwerty.kcm
Bluetooth icache libpvdownloadinterface racoon
BluetoothChat icudata libpvdownloadmanagernode radiooptions
BluetoothDebug idegen libpvdownloadreginterface read_addr
bmgr ime libpvencoder_gsmamr read_method
bookmarks.xml ImfTest libpvfileoutputnode read_pid
bootanimation ImfTestTests libpvfileparserutils read_trace
Browser imgdiff libpvframemetadatautility recovery
BrowserPowerTests init libpvgendatastruct required_hardware.xml
BrowserTestPlugin input libpvgsmamrparser rgb2565
BrowserTests installd libpv_http_parcom rild
bsdiff invoke_mock_media_player libpvid3parcom rsg-generator
bspatch iptables libpvjitterbuffer RSSReader
btool ip-up-vpn libpvjitterbuffernode run-core-tests
bugreport iself libpvjitterbufferrtp run-core-tests-on-ri
BusinessCard isprelinked libpvlatmpayloadparser safe_iop_test
Calculator jarjar libpvmediadatastruct SampleBrowserPlugin
CalculatorTests jarutils libpvmediainputnode schedtest
Calendar jasmin libpvmedialayernode scp
CalendarProvider jasmin.jar libpvmediaoutputnode screenshot2
CalendarProviderTests javax.obex libpvmf sdklib
CalendarTests jcommon-1.0.12 libpvmfrecognizer sdkmanager
Camera jdiff libpvmimeutils SdkSetup
CameraTests jdwpspy libpvmioaviwavfileinput sdkstats
CertInstaller JETBoy libpvmiofileinput sdkuilib
cfassembler jfreechart-1.0.9 libpvmiofileoutput sdutil
check-lost+found jfreechart-1.0.9-swt libpvmp3 SearchableDictionary
check_prereq junit libpvmp3ff sensors.goldfish
check_stack jython libpvmp3ffparsernode service
check_trace kcm libpvmp3ffrecognizer servicemanager
clearsilver keystore libpvmp4decoder services
cmu2nuance keystore_cli libpvmp4ff Settings
com.android.inputmethod.pinyin.lib KeyStoreTests libpvmp4ffcomposer SettingsProvider
com.example.android.platform_library kxml2-2.3.0 libpvmp4ffcomposernode SettingsTests
commons-compress-1.0 latencytop libpvmp4ffparsernode sh
Compass LatinIME libpvmp4ffrecognizer ShareUidApp
ContactManager Launcher libpvmp4interface showlease
Contacts Launcher2 libpvmp4reginterface showmap
ContactsProvider launchperf libpvomxaudiodecnode showslab
ContactsProviderTests layoutlib libpvomxbasedecnode sig
ContactsTests layoutlib_api libpvomxencnode sig-check
core layoutlib_create libpv_omx_interface sig-create
core-tests layoutlib_utils libpvomx_proxy_lib signapk
CoreTests layoutopt libpvomxvideodecnode SignatureTest
coverage libabi libpvplayer_engine SignatureTestTests
cpueater libacc libpvpvxparser signature-tools
cpufeatures libaes libpvrtsp_cli_eng_node SimpleJNI
crasher libandroidpv libpvrtspinterface SkeletonApp
create_test_dmtrace libandroidpvauthor libpv_rtsp_parcom SkeletonAppTests
cts libandroid_runtime libpvrtspreginterface skia_bench
CtsAccessibilityServiceTestCases libandroid_servers libpvsdpparser skia_gm
CtsAccountManagerTestCases libapplypatch libpvsocketnode SlowSuggestions
CtsAppAccessData libarity libpvstreamingmanagernode SmokeTest
CtsAppSecurityTests libastl libpvthreadmessaging SmokeTestApp
CtsAppTestCases libaudioflinger libpvwav Snake
CtsAppWithData libaudiointerface libpvwavffparsernode SnakeTests
CtsBluetoothTestCases libaudiopolicygeneric libpvwavffrecognizer SoftKeyboard
CtsContentTestCases libbinder librank soslim
cts-dalvik-buildutil libbz libreference-cdma-sms sound
CtsDatabaseTestCases libc libreference-ril SoundRecorder
CtsDelegatingAccessibilityService libcameraservice libril SpammySuggestions
CtsDpiTestCases libcamerastub libRS SpareParts
CtsDpiTestCases2 libc_common librs_jni spec-progress
CtsExampleTestCases libc_debug librtppayloadparser sqlite3
CtsGestureTestCases libclearsilver-jni librtprtcp SRecTest
CtsGraphicsTestCases libc_nomalloc libsafe_iop SRecTestAudio
CtsHardwareTestCases libcolorconvert libsampleplugin ssh
CtsInstrumentationAppDiffCert libcpm libSDL SslLoad
CtsJniTestCases libcrypto libSDLmain stack_dump
CtsLocationTestCases libctest libsimplejni StatusBarTest
CtsMediaTestCases libcts_jni libskia Stk
CtsNetTestCases libctspermission_jni libskiagl strace
CtsOsTestCases libcutils libsonivox stringtemplate
CtsPerformance2TestCases libdb libsoundpool su
CtsPerformance3TestCases libdbus libspeex surfaceflinger
CtsPerformance4TestCases libdbus-tools-common libsqlite svc
CtsPerformance5TestCases libdex libsqlite3_android swing-worker-1.1
CtsPerformanceTestCases libdl libsqlite3_phone_number_utils_test swt
CtsPermission2TestCases libdrm1 libsqlite3_phonetic_string_utils_test system_server
CtsPermissionDeclareApp libdrm1_jni libSR_AcousticModels tcpdump
CtsPermissionTestCases libdrm2 libSR_AcousticState TelephonyProvider
CtsProviderTestCases libdvm libSR_AudioIn telephonytest
CtsSharedUidInstall libebl libSR_Core temp_layoutlib
CtsSharedUidInstallDiffCert libebl_arm libsrec_jni Term
CtsSimpleAppInstall libedify libSR_EventLog test_defs.xml
CtsSimpleAppInstallDiffCert libEGL libSR_G2P TestDeviceSetup
CtsSpeechTestCases libelf libSR_Grammar test-fb-refresh
CtsTargetInstrumentationApp libelfcopy libSR_Nametag test-fb-simple
CtsTelephonyTestCases libembunit libSR_Recognizer test_g2g
CtsTestStubs libemoji libSR_Semproc test-mdp
CtsTextTestCases libESR_Portable libSR_Session test-opengl-codegen
CtsUsePermissionDiffCert libESR_Shared libSR_Vocabulary test-opengl-fillrate
CtsUtilTestCases libETC1 libssl test-opengl-filter
CtsViewTestCases libexif libstagefright test-opengl-finish
CtsWebkitTestCases libexpat libstagefright_omx test-opengl-gl2_basic
CtsWidgetTestCases libext libstdc++ test-opengl-gl_basic
CubeLiveWallpapers libfdlibm libsurfaceflinger test-opengl-gralloc
CustomLocale libFFTEm libsvoxpico test-opengl-linetex
daemonize libfst libsystem_server test-opengl-swapinterval
dalvikvm libft2 libsysutils test-opengl-textures
dasm libgetactualaacconfig libterm test-opengl-tritex
dbus-daemon libgif libtestplugin test-progress
dbus-monitor libgl2jni libthread_db test-progress-new
dbus-send libGLES_android libthreadsafe_callback_ao test_swiarb
ddmlib libGLESv1_CM libtinyxml test_zipfile
ddms libGLESv2 libtomcrypt timeinfo
ddmuilib libgljni libtommath timetest
debuggerd libgoogleclient libttspico toolbox
DensityTest libgtest libttssynthproxy traceview
descGen libgtest_main libui TransformTest
DeskClock libhardware libunz TtsService
Development libhardware_legacy libutil tuttle2.kcm
dexdeps libhost libutils uix
dexdump libicudata-default libvorbisidec updater
dexlist libicudata-eu libwbxml UpgradeExample
dexopt libicudata-jp libwbxml_jni usbtest
dexopt-wrapper libicudata-large libwebcore UserDictionaryProvider
dexpreopt libicudata-us libwnndict VisualizationWallpapers
dex-tools libicui18n libWnnEngDic vm-tests
dhcpcd libicuuc libWnnJpnDic VoiceDialer
dhcpcd-run-hooks libiptc libwpa_client Voiper
dictTest libjavacore libxml2 vold
DisabledTestApp libjni_latinime libxml2wbxml VpnServices
dmtracedump libjni_pinyinime libz wbxmltest
DownloadProvider libjnitest libzipfile wdsclient
draw9patch libjpeg LightingTest webkitmerge
DrmProvider liblog line_endings Wiktionary
droiddoc libm linker WiktionarySimple
dumpeventlog libm4v_config LiveWallpapers xmlwriter
dumpkey libmedia LiveWallpapersPicker yuv420sp2rgb
dump_regions libmedia_jni localize zipalign
DumpRenderTree libmediaplayerservice logcat
dumpstate libmincrypt logwrapper
make[1]: Leaving directory `/home/<myuser>/WORKING_DIRECTORY'
rm -rf *.c~
rm -rf *.mod*
rm -rf *.o
You'll notice a few screwy warnings, but as best as I can tell, they are not real problems. If anyone feels differently about these, please say so.
make[1]: Entering directory `/home/<myuser>/WORKING_DIRECTORY'
build/core/copy_headers.mk:15: warning: overriding commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h'
build/core/copy_headers.mk:15: warning: ignoring old commands for target `out/target/product/generic/obj/include/libpv/getactualaacconfig.h'
/bin/bash: line 0: cd: sdk/layoutopt/app/src/resources: No such file or directory
I guess that last line sounds pretty suspicious but I have no idea what to do about it. Apart from the few strange things i've mentioned, it would appear that this all went smoothly. However, after the whole thing completes, I can't find the *.ko file anywere. I did a ls -alRg | grep *.ko on my home directory and it turns up nothing. I'm stumped. If I can provide any more information or run any tests or try anything differently i'll be checking in frequently.
Sorry for being late, but hope it helps:
http://tthtlc.wordpress.com/2011/12/29/how-to-write-a-kernel-module-on-android-sony-ericsson-xperia-arc-s/
I wrote and tested the code on my Sony Ericsson Xperia Arc S and it works (in general in should work for any Android phone).
Connecting via adb and USB, and “su” to root, the “lsmod” listed all the kernel module (in general, the article at
http://web.archive.org/web/20121106004141/http://developer.sonymobile.com/2011/05/06/how-to-build-a-linux-kernel gave a very good coverage of what to do in Linux kernel compilation for SonyEricsson phone):
lsmod
android_module 654 0 - Live 0x7f007000 (P)
sdio 16532 0 - Live 0x7f000000
“android_module” was the one I had inserted via insmod android_module.ko.
Here’s how to do it:
First the original program was copied from:
http://rechtzeit.wordpress.com/2011/03/21/77/
Or reproduced as follows:
android_module.c:
#include"linux/module.h"
#include"linux/kernel.h"
//replace the "" with angular brackets
int init_module(void)
{
printk(KERN_INFO "Hello android kernel...\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye android kernel...\n");
}
Makefile:
obj-m += android_module.o
all:
make -C /home/tteikhua/android/sony_ericsson_src/58/kernel/ M=$(PWD) modules
clean:
make -C /home/tteikhua/android/sony_ericsson_src/58/kernel/ M=$(PWD) clean
The directory where the kernel is located (“-C” above) is where kernel is located.
And the following command will use the Makefile from above:
ARCH=arm CROSS_COMPILE=/opt/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi- make
As shown above, the cross compiler I had used is from CodeSourcery.
And after insmod android_module.ko you can see the debugging message in dmesg output:
<6>[11184.063507] Hello android kernel...
<7>[11619.209655] msmrtc_timeremote_set_time: 11/29/2011 10:09:36 (04)
<6>[11619.210418] RPC CALL -- TOD TIME UPDATE: ttick = 404244221
<6>[11619.210418] stamp=52910543933046785, freq = 0
<7>[11619.211578] msmrtc_tod_proc_result: 12/29/2011 10:09:36 (03)
<6>[11619.211578] rs30000048 rs30000048.262144: setting system clock to 2011-12-29 10:09:36 UTC (1325153376)
<6>[11662.112365] device rmnet0 left promiscuous mode
<6>[11662.112579] device rmnet0 entered promiscuous mode
<6>[11669.958221] device rmnet0 left promiscuous mode
<6>[11669.958435] device rmnet0 entered promiscuous mode
<7>[11698.181060] msmrtc_timeremote_set_time: 11/29/2011 10:10:55 (04)
<6>[11698.187622] RPC CALL -- TOD TIME UPDATE: ttick = 406832008
<6>[11698.187652] stamp=52910548228014081, freq = 0
<7>[11698.193939] msmrtc_tod_proc_result: 12/29/2011 10:10:55 (03)
<6>[11698.194030] rs30000048 rs30000048.262144: setting system clock to 2011-12-29 10:10:55 UTC (1325153455)
<6>[11814.442901] bq27520 0-0055: bq27520_handle_soc_worker() capacity=97 (100) flags=0x229 ctrl_status=0x28b soh_state=0x3, valid=1
<6>[11984.057373] Goodbye android kernel...
And the “Goodbye” is when rmmod android_module is executed. In between are debugging message from other components in the kernel.
Final words:
The above are written in 2011, for more modern resources, please refe to the following to get started:
https://source.android.com/docs/core/architecture/kernel/modular-kernels
https://source.android.com/docs/core/architecture/kernel
https://source.android.com/docs/setup/build/building-kernels
https://source.android.com/docs/core/architecture/kernel/loadable-kernel-modules
I think I've red that emulator kernel does not support module, so you must compile also the kernel with modules support.
I hope that this link will help you
There are two things you'll need to do. Firstly, create an emulator kernel that supports loadable kernel modules.
There's a comprehensive post here covering the process of setting up the emulator kernel.
There are 2 parts of the instructions to alter:
I find it easiest to keep the kernel within the repo area (in this case, ~/WORKING_DIRECTORY), like so:
cd ~/WORKING_DIRECTORY
mkdir kernel
cd kernel
git clone git://android.git.kernel.org/kernel/common.git
The branch information is no longer correct, however, so where it says:
git checkout -t origin/android-goldfish-2.6.29 -b goldfish
use this instead:
git checkout -t archive/android-gldfish-2.6.29 -b goldfish
As you've found out, the kernel by default is not configured with loadable module support. Enable before compiling. After, this step:
make ARCH=arm goldfish_defconfig
do this:
make ARCH=arm menuconfig
A text-based menu will show up. Use the Up/Down arrow keys to navigate, Space to select an option, Enter to expand a menu (menus have --->) at the end of the line, and Esc-Esc to go back a menu.
Select "Enable loadable module support" by scrolling down and hitting Space
Hit Esc-Esc to exit, and hit Enter to save the new configuration
Now build. Using your setup, it would be:
make ARCH=arm CROSS_COMPILE=/home/<myuser>/WORKING_DIRECTORY/prebuilt/linux-x86/toolchain/arm-eabi-4.2.1/bin/arm-eabi-
Now that that's done you can do the second part, which is making a loadable kernel module. You were almost there, but because you didn't have the kernel source for the emulator, it didn't work. Just take the makefile you have and change KERNEL_DIR to:
KERNEL_DIR ?= /home/<myuser>/WORKING_DIRECTORY/kernel/common

Categories

Resources