Unable to compile modules on Android kernel: MODPOST 0 modules - android

On a fresh Ubuntu installation, I have installed build-essential package, amongst other packages that I've then used to compile Nvidia driver for my PC. Meaning kernel and module compilation works on the PC.
Now on the same PC, I tried to Cross compile an Android linux kernel, using the Google NDK Toolchain based on gcc 4.4.3.
Compilation proceeds smoothly, however at the end, it gives the following output:
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
Building modules, stage 2.
MODPOST 0 modules
I have done 'make prepare' before invoking 'make menuconfig' and then doing a 'make'.
Note that the same toolchain, on a build server works with the same files cloned from a git repo. In short, same kernel source, same toolchain, builds modules on the server, doesnt build any modules on my PC.
.config has "Loadable modules support" enabled.
$cat modules.order
kernel/drivers/scsi/scsi_wait_scan.ko
kernel/drivers/net/wireless/bcmdhd/dhd.ko
kernel/drivers/net/wireless/btlock/btlock.ko
kernel/drivers/net/tun.ko
The Makefiles have correct obj-m and obj-$ setup, which is also obvious by the fact that it works on one PC.
I'll be glad to have some insight on why I cant get my PC to compile modules for my Android kernel.

After a lot of searching, I found the answer.
I'm sharing it here because it's almost inconceivable that anyone would think that this is the reason for this issue!
I have GREP_OPTIONS set for providing color automatically, and to number the results. It seems that a the script which builds modules depends on grep, and seems to get messed up.
unsetting the envt variable made it perform modpost successfully.
So the solution is to:
GREP_OPTIONS=
And remove the setting from the profile and .bashrc scripts.

Related

cross compile glibc for Android ARM - configure error

I am trying to cross-compile glibc (version 2.28) for ARM (because the libc.a distributed with Android NDK lacks the xdr_() routines I need) and I am hitting an issue in the configure.
This is my configure:
../glibc-2.28/configure --prefix=/home/me/TEST --host=arm-linux-androideabi --disable-multilib
The error output by configure is:
GNU libc requires kernel header files from Linux 3.2.0 or later to be
installed before configuring.
It is defaulting to kernel headers in /usr/include/linux. I know I can change where it looks for kernel header files with --with-headers, but don't know where to point this to? I tried apt-get upgrade (and update) but still get the same configure error.
Note 1:
I have already built my arm-linux-androideabi-() binaries successfully and have built other packages OK. I am running on a Linux debian 4.9.0-8-amd64 system.
Note 2:
I checked stackoverflow for similar questions and found one, very similar, but the suggestion was to replace --host with --target. However, the responder was mistaken in thinking that the --host argument defines the machine on which the code is being compiled.

How to build android AOSP to a specific target product

I am trying to generate a rom to install in my phone which is a Motorola 1Gen Codename Falcon. I have followed both instructions from the official tutorial on source.android.com and also this tutorial.
Summing up what I did:
set up the build environment
Get the AOSP source:
repo init -u https://android.googlesource.com/platform/manifest
repo sync
Get the device tree and kernel for Falcon:
git clone github.com/CyanogenMod/android_device_motorola_falcon -b cm-14.1 device/motorola/falcon
git clone github.com/CyanogenMod/android_kernel_motorola_msm8226 -b cm-14.1 kernel/motorola/msm8226
(I removed the https:// because my account can only post two links)
Defined the target architecture:
. build/envsetup.sh
lunch aosp_arm-eng
and finally build it:
make -j8
Accordin to this tutorial from xda-developers I posted, after the successful build, it was going to create a .zip file to be flashed at out/target/product/*CODENAME*. But it created only a out/target/product/generic with a system.img file and not a out/target/product/falcon as I expected (was my expectation right?).
So anyway, did I miss something important in the process of making it? How to correctly make for my target? Thanks in advance.
Cyanogenmod is no longer actively developed or supported. It has become LineageOS, so your best bet is to look there. Building Cyanogenmod (or LineageOS) is slightly different than what is described on AOSP. Look here for specific instructions for the Moto G: https://wiki.lineageos.org/devices/falcon/build
You're intentionally building for generic, though you're not aware of. lunch aosp_arm-eng sets the target. aosp_arm-eng is not the falcon you want to build for, it's the very generic.
To build for falcon, pick the correct item from lunch menu.
If the Target Platform suffix is what you are looking for, then there are two solutions:
Using a separate output directory:
$> export OUT_DIR=out_armv7
This will override the default out/ directory for your target binary.
Searching in the out/snoog/ directory (Android > 7.0) and find Target Platform specific .mk file, e.g. Android-asop_arm.mk

Installing Perl Modules on Android OS

Are there an options to install Perl modules like LWP on Android (on SL4A environment ). Also, are there prepackaged Perl modules that can be installed on Android, and is there an option to see which modules are installed using the Android Debug Bridge.
No. No. Perl can surely be asked to provide this, but you can start by looking under
$ ls /data/data/com.googlecode.perlforandroid/files/perl/5.10.0/
SL4A's perl actually comes with CPAN.pm - but not all of its dependencies, as you'll see with the errors you get with
$ perl -MCPAN -eshell
I used CPAN.pm on a Sharp Zaurus, running OpenBSD, and I used a CPAN.pm-less hack to install modules off of CPAN so that the process would be easier on my 64MB of RAM. My Galaxy Tab has slightly better hardware. But at present, nobody's done the work to make (unrooted) Android a comfortable home for Perl -- and as Perl is poorly-suited to Android app development, that may remain the case for a while.
EDIT: Well, try these:
App::FatPacker
App::cpanminus
Only "Pure Perl" modules that aren't coded in C (aka., "XS" modules) can be added to SL4A's version of Perl. You can view what modules are included in that simply by downloading the Perl zip installed by SL4A.
In SL4A's current version (Perl 5.10), modules are fairly limited due to the incomplete compile process used. A new version of the Perl for Android Interpreter should be available here soon, which will have more of the standard Perl Core modules, along with a description of how to compile more from CPAN.

Can the android NDK compile kernel module source?

I want make a dynamic loaded kernel module for android.
I don't want to install a linux, I just have cygwin and android NDK.
Yes, it is possible to build kernel modules with the NDK. Note, this works best with a Linux system (I'm told Linux x86_64 is the supported environment) because it's harder to cross-compile kernel code on case sensitive filesystems (such as those that come by default on Windows and Mac systems), and because building kernel modules requires building ELF-manipulation binaries (modpost) which require ELF headers typically only present on Linux.
That said...
First you need to get the source code to the same exact kernel on your device, and make sure that the configuration is the same as your device. (otherwise there's a chance you will confuse the build system)
Second, you need to determine where in your Android NDK the cross-compiler toolchain is. Here's how I found mine:
$ cd $NDK_HOME
$ find . | grep '\-gcc$'
./toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi-gcc
./toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc
(note, $NDK_HOME is where I installed the Android NDK)
Third, you need to add the $NDK_HOME/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin directory (or wherever it is on your system) to your PATH environment variable.
Then you need to export two environment variables:
export ARCH=arm
export CROSS_COMPILE=arm-eabi-
(note, the arm-eabi- prefix is the same as what we saw in the find command. When the kernel is built, commands such as gcc and ld will be prefixed with this. Note, if you were building for an x86 platform I expect you would have to adjust these. I have only built modules for ARM.)
Next, you should compile the kernel. (to do this, I pulled down /proc/config.gz from my Android device, ran zcat config.gz > .config within the kernel source directory, then ran make menuconfig && make.) Kernel build gurus may know some shortcuts here, but I wasn't able to set up the kernel source directory correctly for building a module without doing an actual build. (If the kernel in your build tree matches your device, you don't have to actually update the kernel, you can just insert the modules.)
Last, I used the normal process to build the kernel modules from source. Typically kernel modules will have a parameterized build which will read in the kernel source tree directory somehow, then invoke the build. At that point, as long as the kernel source tree is set up correctly and ARCH and CROSS_COMPILE are set up, your module should build!
Good luck with this. I'm sure there is some per-device variance.
Just now I found this URL where the user has attempted loading LKM and was successful, though on Android (Kernel core: 2.6.29) and I think it was on Linux and not on Cygwin. Hope you get it too!
There is one more resource here and here too!.
All the best!
Follow this URL, Android developer suggests to go for virtual Ubuntu image for this than cygwin.

Project from https://android.googlesource.com

If I download a project from https://android.googlesource.com to what Android API version will it be compatable ?
I have cloned a project.
Then created a project in Eclipse in that name with its res, src and manifest.xml, but still its shows error with some variables declaration missing , some functions arguments changed/not correct etc.
Any idea?
I'm using sdk_r08, and android 2.3 project working well.
Does the project from https://android.googlesource.com need any dependent files? If so what do I need to get those files?
Is there any extra arguments that I can set in git clone to get the project in a specific version?
You need to use the repo tool , then you can use the -b parameter to checkout a specific branch, see repo documentation for examples.
Actually you cannot load only a single project into eclipse since the whole OS tree is mutually dependent,
you have to checkout the whole source code, make a compile and then copy the .classpath in the root folder of the build and create a java project using this classpath. and ONLY then will you be able to load a project.
however note that the AOSP compiles only on 64bit Ubuntu 10.04 (version and distro is mostly because of library versions and dependencies, I've seen people do it on fedora and suse)
the compile is horrific however you ARE compiling an OS from scratch so ...
it takes about 5 hours on a dualcore pentium u 3gigs of ram..
and about 20 mins on i7 with running
make -j16
after importing everything in eclipse you can work with individual applications like, Launcher, Contacts, Calendar, Phone.. etc..
however to actually install anything on a real device (without flashing the whole rom) you have to refactor/rename the project package declaration since most of them are com.android.* which means the device will not override the default app installed
in short, after setting up the workstation:
(don use -b gingerbread since it is the bleeding edge branch, numbered versions are production branches so bugs are minimal)
repo init -u https://android.googlesource.com/platform/manifest -b android-2.3.4_r1
repo sync
. build/envsetup.sh
lunch 1
make -j8
most of the flags I am using are explained in the tutors below...
More info on the subject:
Workstation setup : http://source.android.com/source/initializing.html
Downloading source ; http://source.android.com/source/downloading.html
Building : http://source.android.com/source/building.html
and most important.. howtos...
http://www.youtube.com/watch?v=1_H4AlQaNa0
http://www.youtube.com/watch?v=rFqELLB1Kk8

Categories

Resources