Android kernel modules build failed - android

i want to build pixel3 blueline android10 kernel module.
my example test.c:
#include"linux/module.h"
#include"linux/kernel.h"
int init_module(void)
{
printk(KERN_INFO "Hello android kernel...\n");
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye android kernel...\n");
}
my Makefile:
obj-m += test.o
all:
make -C /home/ijiami/newdisk/android10/aosp_kernel M=$(PWD) modules
i get android kernel branch android-msm-crosshatch-4.9-android10-qpr3:
ijiami#ijiami-All-Series:~/newdisk/android10/aosp_kernel$ ls
build build.config out prebuilts prebuilts-master private
the error:
ijiami#ijiami-All-Series:~/newdisk/android10/ko_test$ make
make -C /home/ijiami/newdisk/android10/aosp_kernel M=/home/ijiami/newdisk/android10/ko_test modules
make[1]: Entering directory '/home/ijiami/newdisk/android10/aosp_kernel'
make[1]: *** No rule to make target 'modules'. Stop.
make[1]: Leaving directory '/home/ijiami/newdisk/android10/aosp_kernel' Makefile:4: recipe for target 'all' failed
make: *** [all] Error 2

It appears that the makefile in the specified directory is not being found or is not being executed properly. Make sure that you are in the correct directory and that the makefile exists.
The error message also suggests that there is no rule for building target 'modules' in the makefile. Check the makefile in the specified directory and ensure that it has the correct target and dependencies for building the kernel modules.
Make sure that the kernel source has been successfully built and that the environment is set up correctly for building kernel modules. This typically involves setting the CROSS_COMPILE variable to point to the correct toolchain and ensuring that the correct headers are in place.
Also check if you have the necessary build dependencies installed.
It might be helpful to check the build documentation for the specific Android version and device that you are working with to ensure that you are following the correct steps for building kernel modules.

Related

Error cross-compiling openconnect-8.08 for android

When i follow instructions here, i get this error when running latest instruction that is "make":
make[1]: Entering directory '/home/fasegiar/Downloads/openconnect-8.08'
CC libopenconnect_la-ssl.lo
In file included from ssl.c:41:
In file included from ./openconnect-internal.h:102:
In file included from /usr/include/libxml2/libxml/tree.h:1307:
In file included from /usr/include/libxml2/libxml/xmlmemory.h:218:
In file included from /usr/include/libxml2/libxml/threads.h:35:
In file included from /usr/include/libxml2/libxml/globals.h:18:
In file included from /usr/include/libxml2/libxml/parser.h:810:
/usr/include/libxml2/libxml/encoding.h:31:10: fatal error: 'unicode/ucnv.h' file not found
#include <unicode/ucnv.h>
^~~~~~~~~~~~~~~~
1 error generated.
Makefile:1037: recipe for target 'libopenconnect_la-ssl.lo' failed
make[1]: *** [libopenconnect_la-ssl.lo] Error 1
make[1]: Leaving directory '/home/fasegiar/Downloads/openconnect-8.08'
Makefile:749: recipe for target 'all' failed
make: *** [all] Error 2
The TARGET that i use is: armv7a-linux-androideabi
My TOOLCHAIN is: /home/fasegiar/Documents/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64
Here is the output of the config.log after ./configure call
From the snippet you posted I can already tell you this is not going to work.
When cross-compiling you need to cross-compile all dependencies first for your target platform (ie Android) and then tell the configure script where to find the installed dependencies. For openconnect the dependencies are:
Required:
libxml2 (this in turn requires libicu, as your error points out)
zlib (this is bundled)
Either OpenSSL or GnuTLS (v3.2.10+) (see NDKPorts)
Optional:
p11-kit (for PKCS#11 support)
libp11 (also needed for PKCS#11 support if using OpenSSL)
libproxy
trousers (for TPMv1 support if using GnuTLS)
libtasn1 and either tss2-esys or IBM's TPM 2.0 TSS. (for TPMv2 support if using GnuTLS)
libstoken (for SecurID software token support)
libpskc (for RFC6030 PSKC file storage of HOTP/TOTP keys)
libpcsclite (for Yubikey hardware HOTP/HOTP support)

Building dictool_aosp.jar from source

I couldn't be able to build dictool_aosp.jar. I downloaded the aosp source from the repository then run the following commands:
source build/envsetup.sh
lunch aosp_flo-userdebug
make -j3
make dictool_aosp
But, I got the following error:
including ./system/vold/Android.mk ...
including ./tools/external/fat32lib/Android.mk ...
make: *** No rule to make target `dictool_aosp'. Stop.
#### make failed to build some targets (01:02 (mm:ss)) ####
Can you please guide me on how to build the jar file?
I have also tried to build from the directory using mm and mma and got the following result:
$ cd packages/inputmethods/LatinIME/tools/dicttool/
$ mma
...
including ./tools/external/fat32lib/Android.mk ...
No private recovery resources for TARGET_DEVICE flo
make: Entering directory `/android-repo'
make: Nothing to be done for `all_modules'.
make: Leaving directory `/android-repo'
#### make completed successfully (24 seconds) ####
$ mm
...
No private recovery resources for TARGET_DEVICE flo
make: Entering directory `/android-repo'
make: *** No rule to make target `/temp/out/dist/android-repo/host/linux-x86/framework/junit.jar', needed by `/temp/out/dist/android-repo/host/common/obj/JAVA_LIBRARIES/dicttool_aosp_intermediates/javalib.jar'. Stop.
make: Leaving directory `/android-repo'
Although mma succeeded there is no jar file in the output directory.
I assume you receive this error when you run make dictool_aosp:
make: *** No rule to make target `dictool_aosp'. Stop.
Means there is no make target named dictool_aosp.
You could try to build dictool_aosp by checking the Android.mk of that package. Look if there is a LOCAL_MODULE definition. If there is one you can use this one for your make call. If not you can add that or simply run mm on top of your project directory you want to build.
Some useful hints:
You can see all make targets with: make modules
You can build a subproject with mm (builds all of the modules in the current directory) or use mma (builds all of the modules in the current directory with dependencies)

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 kernel source code compilation error

I need to customize the kernel of android to run on my Nexus S.
So I download the kernel with branch name "remotes/origin/android-samsung-2.6.35-gingerbread"
I tried to follow the instruction here http://source.android.com/source/building-kernels.html to build the kernel. To do this, I need the cross compile tool.In my target android source code version android-2.3.5_r1, there is no such tool(no prebuilts/ folder). So I downloaded the version 4.1.2 and set up the tool as path prebuilts/gcc/linux-x86/arm/arm-eabi-4.6/bin .
Then I tried to build my kernel, but I got the following error:
[root#localhost samsung]# make
scripts/kconfig/conf -s arch/arm/Kconfig
CHK include/linux/version.h
CHK include/generated/utsrelease.h
make[1]: `include/generated/mach-types.h' is up to date.
CALL scripts/checksyscalls.sh
CHK include/generated/compile.h
CC drivers/gpu/pvr/osfunc.o
In file included from drivers/gpu/pvr/osfunc.c:39:0:
include/linux/pagemap.h: In function 'fault_in_pages_readable':
include/linux/pagemap.h:415:16: error: variable 'c' set but not used [-Werror=unused-but-set-variable]
drivers/gpu/pvr/osfunc.c: In function 'OSAccessOK':
drivers/gpu/pvr/osfunc.c:2144:13: error: variable 'linuxType' set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
make[3]: *** [drivers/gpu/pvr/osfunc.o] Error 1
make[2]: *** [drivers/gpu/pvr] Error 2
make[1]: *** [drivers/gpu] Error 2
make: *** [drivers] Error 2
Should I just disable the "all warnings being treated as errors" to solve it? Or maybe I need a better toolchain?
PS: The tool chain of the master branch and branch 4.2 can not be used by me. Because it looks like they are made for a 64-bit OS while my linux is 32-bit
Do you have the path of ARCH=ARM and TOOLCHAIN pointing to the toolchain in \prebuilts folder?
make ARCH=ARM TOOLCHAIN=\<homeofAOSP>\prebuilt\.. herring_defconfig
make clean before you do the make

Can't build hello world kernel module on Android JellyBean

I'm trying to build a simple kernel module on Android JellyBean.
Code:
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_ALERT */
MODULE_LICENSE("GPL");
MODULE_AUTHOR("test");
MODULE_DESCRIPTION("Android ko test");
int init_module(void)
{
printk(KERN_ALERT, "Hello world\n");
// A non 0 return means init_module failed; module can't be loaded.
return 0;
}
void cleanup_module(void)
{
printk(KERN_ALERT "Goodbye world 1.\n");
}
Makefile:
obj-m +=hello.o
KERNELDIR ?= ~/android/kernel
PWD := $(shell pwd)
CROSS_COMPILE=~/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
ARCH=arm
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) ARCH=arm CROSS_COMPILE=$(CROSS_COMPILE) modules
clean:
$(MAKE) -C $(KERNELDIR) M=$(PWD) clean
Output:
make -C ~/android/kernel M=/home/test/testmod ARCH=arm CROSS_COMPILE=~/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi- modules
make[1]: Entering directory `/home/test/android/kernel'
ERROR: Kernel configuration is invalid.
include/generated/autoconf.h or include/config/auto.conf are missing.
Run 'make oldconfig && make prepare' on kernel src to fix it.
WARNING: Symbol version dump /home/test/android/kernel/Module.symvers
is missing; modules will have no dependencies and modversions.
CC [M] /home/test/testmod/hello.o
In file included from <command-line>:0:
/home/test/android/kernel/include/linux/kconfig.h:4:32: error: generated/autoconf.h: No such file or directory
In file included from /home/test/android/kernel/arch/arm/include/asm/types.h:4,
from include/linux/types.h:4,
from include/linux/list.h:4,
from include/linux/module.h:9,
from /home/test/testmod/hello.c:1:
include/asm-generic/int-ll64.h:11:29: error: asm/bitsperlong.h: No such file or directory
In file included from /home/test/android/kernel/arch/arm/include/asm/posix_types.h:38,
from include/linux/posix_types.h:47,
from include/linux/types.h:17,
from include/linux/list.h:4,
from include/linux/module.h:9,
from /home/test/testmod/hello.c:1:
include/asm-generic/posix_types.h:70:5: warning: "__BITS_PER_LONG" is not defined
error, forbidden warning: posix_types.h:70
make[2]: *** [/home/test/testmod/hello.o] Error 1
make[1]: *** [_module_/home/test/testmod] Error 2
make[1]: Leaving directory `/home/test/android/kernel'
make: *** [default] Error 2
If I follow the suggestion in the output, and run 'make oldconfig && make prepare' on the kernel, it leads me through dozens of kernel config yes / no questions. After that, the compile still fails on the next error, which is about bitsperlong.h.
Android puts output binaries under out directory. So for example one can have out/target/product/<target name>/obj/KERNEL_OBJ/ or $ANDROID_PRODUCT_OUT/obj/KERNEL_OBJ/ if $ANDROID_PRODUCT_OUT is defined. This directory may have a different name from different vendors but simply that's the directory containing vmlinux.
So when you compile a kernel module under Android repo, you should submit make command like below inside your module's directory.
make -C $ANDROID_PRODUCT_OUT/obj/KERNEL_OBJ/ M=`pwd` ARCH=arm CROSS_COMPILE=arm-eabi- modules
Make modules should be done after compiling the kernel at least once. You have not compiled the kernel, that's why Module.symvers is missing. During compilation certain header files like asm/bitsperlong.h are created.
Firstly make sure that you have compiled kernel in the specified path.
that is
" /home/test/android/kernel" but you are using
" /home/android/kernel " during compilation of module
KERNELDIR ?= ~/android/kernel has to be KERNELDIR ?= ~/test/android/kernel
If not then in the ~/android/kernel directory run the below command to compile the kernel.
make ARCH=arm CROSS_COMPILE=~/test/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi
After your kernel is compiled you will get this "__BITS_PER_LONG" variable defined in System.map file of kernel i,e
~/test/android/kernel/System.map
After this you will be able to compile your module without any hurdle

Categories

Resources