My adventures with Android (I)

The history:

Recently I bough a “Ainol tornados” for testing purposes, and that was the cheapest one (~60€ shipping included!)
When it arrives to me, I tried to install openvpn (is basic for my project) but nothing on the “tun.ko” repo works for me :-(, the “magic string” which makes match a module with the kernel does not match and I tried all the avalaible rom except 4.0.4.
The problem was the insmod itself, not the tun.ko installer.
So I decided to build my own version of the android :-)

Here begins the adventure itself…
I downloaded the source code directly from Ainol forums… That HUGE package contains EVERYTHING for building (android-sdk, android-ndk, crosscompilers in multiple versions, emulator files… ETC), so don’t care about that if you’ll donwnload it.
Starting from the AOSP project wiki, I set up the build environment with java6, make 3.81.
So:

. build/envsetup.sh
lunch full-eng
make -j2

Ressult:

============================================
PLATFORM_VERSION_CODENAME=IceCreamSandwich
PLATFORM_VERSION=4.0.3
TARGET_PRODUCT=full
TARGET_BUILD_VARIANT=eng
TARGET_BUILD_TYPE=release
TARGET_BUILD_APPS=
TARGET_ARCH=arm
TARGET_ARCH_VARIANT=armv7-a
HOST_ARCH=x86
HOST_OS=linux
HOST_BUILD_TYPE=release
BUILD_ID=GB.AMLOGIC.20121026
============================================
File "build/tools/findleaves.py", line 95
print r
^
SyntaxError: invalid syntax
File "build/tools/findleaves.py", line 95
print r
^
SyntaxError: invalid syntax
make: *** No rule to make target `out/target/common/obj/PACKAGING/public_api.txt', needed by `out/target/common/obj/PACKAGING/checkapi-last-timestamp'.  Stop.

FUUUUUUU
After some tries, I decided to go for the kernel as the complete build will be hard :-)

cd kernel
. env.sh
export codeOMPILER="${ARM_EABI_TOOLCHAIN}/arm-eabi-"

I copied the /proc/config.gz from the Tornados and run the build:

make ARCH=arm CROSS_COMPILE=$codeOMPILER -j2
...... compiling stuff .....
~/ics-amlogic-f08ref0511-20120608185359/kernel/scripts/gen_initramfs_list.sh: Cannot open '../out/target/product/f06ref848L/root/'
make[1]: *** [usr/initramfs_data.cpio] Error 1
make: *** [usr] Error 2
make: *** Waiting for unfinished jobs....

Cool! browse internet and found that the problem was the config parameter:
CONFIG_INITRAMFS_SOURCE="../out/target/product/f06ref848L/root/"
Remove it& building again (I don’t use parallelism to avoid possible problems):

make ARCH=arm CROSS_COMPILE=$codeOMPILER clean
rm -f include/generated/autoconf.h include/config/auto.conf
make ARCH=arm CROSS_COMPILE=$codeOMPILER

CPU wait cicles :-) and:

gcode: error: directory: No such file or directory
gcode: error: directory": No such file or directory
gcode: error: directory: No such file or directory
gcode: error: directory": No such file or directory
gcode: error: directory: No such file or directory
gcode: error: directory": No such file or directory
gcode: error: directory: No such file or directory
gcode: error: directory": No such file or directory
gcode: error: directory: No such file or directory
gcode: error: directory": No such file or directory
gcode: error: directory: No such file or directory
gcode: error: directory": No such file or directory
gcode: error: directory: No such file or directory
gcode: error: directory": No such file or directory
gcode: error: directory: No such file or directory
gcode: error: directory": No such file or directory
gcode: error: directory: No such file or directory
gcode: error: directory": No such file or directory
gcode: error: directory: No such file or directory
gcode: error: directory": No such file or directory
gcode: error: directory: No such file or directory
gcode: error: directory": No such file or directory
gcode: error: directory: No such file or directory
gcode: error: directory": No such file or directory
LD drivers/amlogic/mali/built-in.o
code [M] drivers/amlogic/mali/common/mali_kernel_core.o
arm-eabi-gcode: directory: No such file or directory
arm-eabi-gcode: directory": No such file or directory
: warning: missing terminating " character
In file included from drivers/amlogic/mali/common/mali_uk_types.h:24,
from drivers/amlogic/mali/common/mali_kernel_subsystem.h:19,
from drivers/amlogic/mali/common/mali_kernel_core.c:11:
/home/jholgado/Descargas/ainol_tornados/ics_tornados/ics-amlogic-f08ref0511-20120608185359/kernel/drivers/amlogic/mali/regs/mali_200_regs.h:102:2: error: #error "No supported mali core defined"
/home/jholgado/Descargas/ainol_tornados/ics_tornados/ics-amlogic-f08ref0511-20120608185359/kernel/drivers/amlogic/mali/regs/mali_200_regs.h:124:2: error: #error "No supported mali core defined"
/home/jholgado/Descargas/ainol_tornados/ics_tornados/ics-amlogic-f08ref0511-20120608185359/kernel/drivers/amlogic/mali/regs/mali_200_regs.h:144:2: error: #error "No supported mali core defined"
/home/jholgado/Descargas/ainol_tornados/ics_tornados/ics-amlogic-f08ref0511-20120608185359/kernel/drivers/amlogic/mali/regs/mali_200_regs.h:166:2: error: #error "No supported mali core defined"
In file included from drivers/amlogic/mali/common/mali_kernel_subsystem.h:19,
from drivers/amlogic/mali/common/mali_kernel_core.c:11:
drivers/amlogic/mali/common/mali_uk_types.h:576: error: 'MALI200_NUM_REGS_FRAME' undeclared here (not in a function)
drivers/amlogic/mali/common/mali_kernel_core.c: In function 'mali_kernel_constructor':
drivers/amlogic/mali/common/mali_kernel_core.c:167: error: missing terminating " character
drivers/amlogic/mali/common/mali_kernel_core.c:167: error: expected expression before ')' token
drivers/amlogic/mali/common/mali_kernel_core.c:172: error: missing terminating " character
drivers/amlogic/mali/common/mali_kernel_core.c:172: error: expected expression before ')' token
make[3]: *** [drivers/amlogic/mali/common/mali_kernel_core.o] Error 1
make[2]: *** [drivers/amlogic/mali] Error 2
make[1]: *** [drivers/amlogic] Error 2
make: *** [drivers] Error 2

DOH!
F*uc*ng AMLogic drivers!!!
I know the problem was a which was breaking the compilation but where?
So I just begin editing the mali source code…
I began looking all around searching for a broken pair of , I couldn’t find anything.
Then I found a pastebin with EXACTLY the same problem, and searching a bit more, I found a logged irc conversation talking about that pastebin. Decrypted the conversation, I manually applied the diff code that “steev” provided… Launch the compilation and… it works!!!
I’ve the kernel built:


[dodger@ciberterminal kernel]$ ll arch/arm/boot/
total 15468
drwxr-xr-x 2 dodger dodger    4096 jun  8 12:59 bootp
-rwxr-xr-x 1 dodger dodger 3757788 jun 20 13:27 codeImage.lzma
drwxr-xr-x 2 dodger dodger    4096 oct 25 18:27 compressed
-rwxr-xr-x 1 dodger dodger 8022496 oct 25 18:27 Image
-rw-r--r-- 1 dodger dodger    1274 jun  8 12:59 install.sh
-rw-r--r-- 1 dodger dodger    4586 jun  8 12:59 Makefile
-rwxr-xr-x 1 dodger dodger   56328 jun  8 12:59 mkimage
-rwxr-xr-x 1 dodger dodger 3973368 oct 25 18:27 zImage

FUCK YEAH!

Now it’s time to test it…
More is coming ;-D

14 thoughts on “My adventures with Android (I)

  1. I believe I found an error in your guide
    all the way at the top, the line that sais
    “lunch full-eng”
    I think thats to build the emulator rom
    “lunch” by itself spits out a menu — my guess the tornado is the last two entries, just a guess I don’t know — its currently compiling, its taking a long time, the fan in my laptop is going crazy but i think its working

  2. Hi all,
    Dude, you’re right, I’ve successfully compiled the whole rom by using the lunch option:
    “f06ref848L-eng”
    But I couldn’t boot it :-( I was writting the 2nd part with all that info.
    I decided to build it in one of “my” servers which was idle with a dual Xeon (16cores) and 128GB of ram…
    It took about 1hour to build, so building it in a desktop will be really hard.
    If you want, I cant provide the output “*img”‘s for testing, but as I said, I tried emulator and directly on the tornados and no of them boot :-(

  3. I am trying to complie the r06ref-user — I get errors — when I looked them up on google, they said its all fixed on the master copy and to do a repo sync, and so thats what I am doing, freaking thing also takes a long time also, syncing 5 million lines of code as claimed, its also eating diskspace like crazy, it already ate 4GB on top of the original 5GB — I am running out of diskspace actually…

  4. I’m not using the google sources, I’m using the Ainol one’s, the big package they provide in their forums, so I don’t sync anything, just patch their bugs.
    Which error do you get?

    You’ve the correct distro, as source.android.com says they use ubuntu 10.04 for building…
    The 1st you must look for is the python & make versions: you must have Python 2.6.x as the primary python version (any actual distro will have python 3.x) and make 3.81 (actually 3.82).

  5. Could you go into detail about what exactly you patched in mali_kernel_core.c? I’m having this exact same problem and could not figure out how the diff mentioned in the IRC conversation has any changes to any files that resolves this issue.

    http://pastebin.com/baNLHQJX

  6. Sure,
    The problem is that for any reason the Makefile script calls subversion expecting a supposed version of the mali code, that return an undeclared variable, that’s the reason of seeing that ‘directory “:’ or ‘directory :’ values that are empty.
    What I did was manually apply the patch of the irc people and it works.
    If you see, what they simply do is simply is modify the variable:
    DEFINES += -DSVN_REV=$(SVN_REV)
    And transform it into a constant:
    DEFINES += -DSVN_REV_STRING=0000
    that in every variable which make use of the command “$(SVN_REV)”.
    You have the files patches here:
    http://blog.ciberterminal.net/others/mali_patched.tar.bz2
    You only need to download and replace the original “kernel/drivers/amlogic/mali” folder with the one inside that tarball.

  7. I played with the sources a bitmore, tried to compile the kernel, to add to your guide I found out that when you type

    make help

    it lists out the available target configurations, so you don’t have to copy and apply config.gz, I believe “meson_reff08_defconfig” is the default config for the tornado, so if you type

    make meson_reff08_defconfig

    it applies the configuration. Anyways, I ran into a speed bump, I got a 2GB laptop with 2 cores. maybe its my limited hardware but maybe you can help. when I try to compile just the kernel I get:

    make: *** No rule to make target `include/config/kernel.release’, needed by `prepare3′. Stop.

    whatup with that?

  8. You must define the kernel “version” you’re building,
    Check if the file: include/config/kernel.release
    Exists, it shouldn’t exists, what I did was simply:

    echo "3.0.8-dudeofx" > include/config/kernel.release

    I append my own version (release) of the kernel instead of yours.
    I don’t know if later failures comes from that…

    Talking about the make version, don’t know… I just took the config from tornados and modify as my own needings… that SHOULD work but it doesn’t (my kernel does not boot either on emulator or tornados…)

  9. that helped but now it gives me the following error

    arch/arm/mach-meson3/board-m3-reff08.c:58:62: fatal error: ../../../drivers/amlogic/power/axp_power/axp-cfg.h: No such file or directory
    compilation terminated.
    make[1]: *** [arch/arm/mach-meson3/board-m3-reff08.o] Error 1
    make: *** [arch/arm/mach-meson3] Error 2

    — just to note I am currently trying to compile the whole ROM again, cause I managed to compile the Open WebOS for desktop using machine with only a single core with 1GB of RAM — It took it 5 long hours but it did it.

  10. I’m not sure you’re building the correct driver, reading a bit, axp seems to be the chipset of the fire/aurora which controls the “power” (i suppose the electrical power cause there are settings inside the headers talking about mW).
    btw, I see the rest of the kernel driver is there, on the ainol huge tar, so maybe you must create by your own the config for the driver, normally that is not a good idea xD but I can’t locate that file over internet… there’s a reference on a pastebin (again) talking about that file and a git, but anything else…
    did you sink the hole android opensource source??? (or CM9)

    If you have successfully built the rom, can you try to use it on the emulator?? Just to see if it works, cause I also want to modify some startup scripts but I couldn’t re-pack the ramdisk file so it works either on real hard & qemu…

  11. I successfully compiled kernel 3.10.33 and got the uImage.But when i try to make ota package in android 5.0 , i end up with below error.

    make: *** No rule to make target `out/target/product/f06ref848L/kernel’, needed by `out/target/product/f06ref848L/boot.img’. Stop.

    If i build normally , it is creating system.img .But not able to create otapackage. :(
    Any help will be really appreciated .

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.