I would like to build AOSP code while integrating the kernel as well. I followed these instructions: http://jhshi.me/2014/06/30/build-kernel-in-tree-with-aosp-for-nexus-5-hammerhead/
but they seem to be specific to hammerhead. How would I do a full AOSP build with my custom msm kernel source directory (using flo)?
Thanks
I think you can follow the official guide source.android.com/source/building-kernels
to build your custom kernel, then move the binary file(zImage) into device/lge/mako-kernel/(this path is for Nexus 4) in android source code. This will replace the default kernel file.
Of course you need to change the path which is depends on your device.
Finally, build AOSP as usual.
Related
I followed the instructions in the cyanogenmod wiki page to build a custom ROM for grouper (Nexus 7 wifi only model). However, the CM-DATE-UNOFFICIAL.zip file is not created. I get this error message --
No private recovery resources for TARGET_DEVICE grouper.
I followed the answer in this link to add below line
TARGET_KERNEL_CONFIG := cyanogenmod_grouper_defconfig
to ~/android/system/device/asus/grouper/BoardConfig.mk and did "make modules" and "make grouper_defconfig", "make grouper" to no avail.
From further research, I found that I might be missing the kernel. I followed the android documentation on building the kernel. However, this also did not solve the issue (I might have not placed the kernel at the right location). Can someone tell me what I am missing?
I was able to generate the zip file. The main issue was that Ubuntu by default uses OpenJDK while Cyanogenmod needs Oracle JDK. Downloading and using Oracle JDK and following rest of the steps mention in this xda-developers forum thread generated the zip file. Also make sure that you have plenty of swap space (atleast as much as your ram or twice of that if possible)
Another thing that is not mentioned in the wiki for building Cyanogenmod is that the kernel has to be built first. I followed this link to build the Android kernel.
I have downloaded the android source code. And i want to make some modifications to the source code to embed some functionality which currently does not exist. But the problem here is that i am not able to understand how the source code is organised, what kind of files could be find where. So if someone could help me understand that it would be really helpful.
Here is short version of what you will find when you download the Android source. I will leave out some minor directories and dig deeper into a couple of the important ones. Basically what you will get (based on the current Ice Cream Sandwich release), in alphabetical order:
Bionic - the C-runtime for Android. Note that Android is not using glibc like most Linux distributions. Instead the c-library is called bionic and is based mostly on BSD-derived sources. In this folder you will find the source for the c-library, math and other core runtime libraries.
Bootable - boot and startup related code. Some of it is legacy, the fastboot protocol info could be interesting since it is implemented by boot loaders in a number of devices such as the Nexus ones.
Build - the build system implementation including all the core make file templates. An important file here is the envsetup.sh script that will help you a lot when working with the platform source. Running this script in a shell will enable commands to setup environment variables, build specific modules and grep in source code files.
Cts - the compatability tests. The test suite to ensure that a build complies with the Android specification.
Dalvik - the source code for the implementation of the Dalvik Virtual Machine
Development - projects related to development such as the source code for the sdk and ndk tools. Normally not a folder you touch when working with the platform for a target.
Device - product specific code for different devices. This is the place to find hardware modules for the different Nexus devices, build configurations and more.
External - contains source code for all external open source projects such as SQLite, Freetype and webkit.
Frameworks - this folder is essential to Android since it contains the sources for the framework. Here you will find the implementation of key services such as the System Server with the Package- and Activity managers. A lot of the mapping between the java application APIs and the native libraries is also done here.
Hardware - hardware related source code such as the Android hardware abstraction layer specification and implementation. This folder also contains the reference radio interface layer (to communicate with the modem side) implementation.
libcore - Apache Harmony.
libnativehelper - Helper functions for use with JNI.
(Kernel) - not part of the default source download but you can get access to this code either by downloading it manually or by adding the repository to the repo tool. Contains the sources for the Android version of the Linux kernel.
Out - the build output will be placed here after you run make. The folder structure is out/target/product/. In the default build for the emulator the output will be placed in out/target/product/generic. This is where you will find the images used by the emulator to start (or to be downloaded and flashed to a device if you are building for a hardware target).
Packages - contains the source code for the default applications such as contacts, calendar, browser.
Prebuilt - contains files that are distributed in binary form for convenience. Examples include the cross compilations toolchains for different development machines.
System - source code files for the core Android system. That is the minimal Linux system that is started before the Dalvik VM and any java based services are enabled. This includes the source code for the init process and the default init.rc script that provide the dynamic configuration of the platform
tools - Various IDE tools.
Beyond the above you also have the hidden .repo directory that contains the source for the repo utility. It also holds the manifest specifying what git repositories you want to track for this Android source project. If you have your own additions you could automatically track them by adding a local manifest here.
For modifications of the platform framework there are some instructions available in the device/sample folder of the source code tree. That will show you how to add APIs to Android without having to modify the core framework.
I have successfully built and run a version of the goldfish kernel in the emulator. What I want to do now is include this in the platform source I have. So that I can build and run the platform from scratch with my custom kernel.
I have looked everywhere for help in replacing the kernel that is already there. I believe I need to change the 'TARGET_PREBUILT_KERNEL=' line in a build file somewhere but I can't find the right place.
Any help would be much appreciated.
You don't need to change the configuration files. You can override them at the command line. If you export TARGET_PREBUILT_KERNEL="Path to my zImage" and then build the platform. When you build the platform, it will use your zImage as part of mkbootimg instead of the default.
However, if you did want to change this its under $(ANDROID_ROOT)/device/<my device>/device.mk.
So if you were building for the Galaxy Nexus, you would modify the file device/samsung/tuna/device.mk.
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.
Where do I find the version information in source files on Android platform?
I tried to find out some information listed in setting >> about phone. Some of the displayed information is, firmware version, module number, baseband version, kernel version, ...
You can give it check in platform\build\core\version_defaults.mk
For cyanogen, the source for this file is https://github.com/CyanogenMod/android_packages_apps_Settings/blob/cm-10.2/src/com/android/settings/DeviceInfoSettings.java , it looks like https://android.googlesource.com/platform/packages/apps/Settings/+/master/src/com/android/settings/DeviceInfoSettings.java is the equivalent in AOSP.
From those files, it looks like most of those values are constants or in the preferences, while the kernel is read from /proc/version.
First, the android kernel source code is divided from the main android source code.
The Android version is the build version. It is found in build/make/core/build_id.mk in the aosp android source (https://source.android.com/setup/build/downloading).
The Kernel version is in the top level Makefile of the android kernel source code (https://source.android.com/setup/build/building-kernels-deprecated)