Archive for the ‘Android’ Category

Hello World Example of Double Ratchet Algorithm

November 8, 2017

The Double Ratchet is used in many applications to provide secure end-to-end encryption. There are also many documents that try to describe this concept, but in my experience, the more reading it, the more I get confused.

So, I decided to create an example, as a proof of concept about how it works. This example is using Signal’s Curve X25519 key agreement algorithm, and also its related class library for encryption and decryption process.

First, let’s define the test string to be encrypted and decrypted and also create a byte array container for generated key agreement secret for Bob and Alice. In this example, Bob is sending party that will send encrypted “Hello, World” string to Alice:

You can also see, that the sample text is converted to a byte array.

Then, let’s create a bunch of required Bob’s and Alice’s private and public key and other keys required to start up the decryption and encryption process:

Note the KeyPair suffix variable statement above, which means that the generated key will consists of Public Key and Private Key.

Then, compute a sophisticated secret using the above key pair information:

Now, the important step is to derive message key that will be use to encrypt the message:

The calculateDerivedKeys is using Signal’s KDF algorithm and it is from this step that I can create the message key that will be used to encrypt the message. Where transportDetails class is used to create proper padding for the text to be encrypted, depending on KDF version.

Here is the actual encryption process using derived message key:

The encrypted result is stored in ciphertextBody variable.

Now, let’s review the decryption process:

You can see that the recipient side (Alice) perform a similar steps using sending side (Bob) required public key to calculate the message key for decryption process.

The plaintext will contain decrypted text.

Now, what about subsequent sending and receiving ? Do each party have to repeat the above tedious process ? No.

The sending party (Bob) just calculate the next Message Key, encrypt it using this new message key, and the receiving party (Alice) does also the same step and decrypt it using newly created message key:

If I try to decrypt Bob’s second message using Alice’s previous message key, it will result in InvalidMessageException error. The above steps can be repeated as many times as required.

I think that’s the essence of end-to-end encryption because after the initial key exchange, neither party is transmitted risky data over the wire. Also it supports forward secrecy because each encryption and decryption requires unique message keys.

Advertisements

Experiences in Debugging Open Whisper System’s Signal Client APK

October 27, 2017

So, when I try to add a new test variable and perform debugging to the starting activity:

D:\Projects\AndroidProgram\Signal\Client2\src\org\thoughtcrime\securesms\ConversationListActivity.java

This is the compiled debug version of Open Whisper System’s Signal client APK.

Here is the result.

The anomaly is that even when I already step through the statement at line 74, the inspected variable still show:

“nTest” is not a known variable in the current context.

This is not just newly created variable that I’ve created, but also in all of local variable scope in all existing activities.

I just can only step through the application modules or functions, but can’t inspect its local variables. What kind of debugging activity is that ?

Searching through the internet reveals nothing to shed a light in this situation.

So, I try to perform some analysis by comparing the build.gradle file from the one of sample program that works to the build.gradle that failed.

The build.gradle that has the problem contains minifyEnabled true in the debug configuration. So, by setting it to false and perform recompilation, now I can view the local variable:

I just wondering, is it just accidently or purposely put by the developer of the application ?

Introducing GradleMover Utility

October 26, 2017

In the previous article about methods of compiling Android application using Gradle for offline mode, I’ve describe the manual method to download file and checks for required missing file.

The offline mode is certainly required for development environment behind proxy and certain website that is required dependencies for Gradle compilation is also blocked.

But this proves to be rather tedious and painstaking, because, Gradle only try to find to resolve missing files one at a time. Even using file checking monitor utility, it can be frustrating because Gradle only shows one missing file at a time.

Imagine if the application requires hundreds of file, it will take weeks just to resolve all required missing file.

So, another approach is using un-restricted internet environment for Gradle dependencies resolving process, and then copied all the dependencies already resolved by Gradle to Local Repository to development environment behind proxy.

The GradleMover is used to copy all resolved dependencies by gradle to a permanent local repository for doing offline compilation.

To use this utility, the first step is to copy all the resolved dependencies in gradle cache to a temporary folder, let’s call it D:\temp.

To locate the gradle caches that contains the resolved dependencies, look at the folder that contains files that contains *.pom, *.jar, etc for example in my machine it is located in:

C:\Documents and Settings\xxx\.gradle\caches\modules-2\files-2.1

So then copies all of the content inside this folder to a temporary (D:\temp), and perform command line as follows:

D:\Projects\GradleMover\bin\Debug>GradleMover d:\temp D:\Android\sdk\extras\m2re
pository

Where d:\temp is temporary of gradle caches that contains all resolved dependencies and D:\Android\sdk\extras\m2repository is the local repository

How to Compile Open Whisper Systems’ Signal Client APK

October 25, 2017

This article will explore whether it is possible to do compilation on offline mode using Gradle.

Perform gradle compiler environment check:

D:\Projects\AndroidProgram\Signal\Client>gradlew
Downloading https://services.gradle.org/distributions/gradle-3.3-all.zip

Exception in thread “main” java.net.ConnectException: Connection timed out: conn
ect

Replace the wrapper with gradle-4.0 (newer version).

But now I have:

D:\Projects\AndroidProgram\Signal\Client>gradlew
Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project ‘Client’.
> Could not resolve all files for configuration ‘:classpath’.
> Could not resolve com.android.tools.build:gradle:2.3.0.

Perform revision in D:\Projects\AndroidProgram\Signal\Client\build.gradle:

The above error is gone now, but I have:

Android\sdk\system-images\android-19\default\armeabi-v7a’)
IOException: https://dl.google.com/android/repository/addons_list-3.xml
java.net.ConnectException: Connection timed out: connect
IOException: https://dl.google.com/android/repository/addons_list-2.xml
java.net.ConnectException: Connection timed out: connect
IOException: https://dl.google.com/android/repository/addons_list-1.xml
java.net.ConnectException: Connection timed out: connect

This is because the proxy connection denies connection to the above website. So I have to find another method to make it work. More detailed examination of the above download attempt is because the gradle tries to find missing version of Android Build Tools. So perform revision again in build.gradle as follows:

But this time, the gradle taking too long to execute the compilation process.

Using this to see the internal works of gradle:

The reason it is taking very long time is that it is waiting for the refused connection caused by the proxy to:

09:14:56.641 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver] Loading https://dl.bintray.com/amulyakhare/maven/com/android/support/appcompat-v7/25.1.0/appcompat-v7-25.1.0.pom

Checking the log to set Maven local repositories:

15:51:55.538 [DEBUG] [org.gradle.api.internal.artifacts.mvnsettings.DefaultLocalMavenRepositoryLocator] No local repository in Settings file defined. Using default path: C:\Users\xxx\.m2\repository

This is because gradle tries to find settings.xml in:

Copy settings.xml from installed maven to this folder. But gradle still tries to find the appcompat-v7-25.1.0.pom using external repository.

Perform revision in D:\Projects\AndroidProgram\Signal\Client\build.gradle:

But, still gradle tries to find appcompat-v7-25.1.0.pom using external repository. So, remark this statement because it is blocked by the proxy:

Now gradle can perform its work without getting restricted. But several dependencies is indeed can not be found:

16:34:39.166 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] No meta-data file or artifact found for module ‘com.google.android.gms:play-services-gcm:9.6.1’ in repository ‘maven6’.

16:36:46.053 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] No meta-data file or artifact found for module ‘com.google.android.gms:play-services-maps:9.6.1’ in repository ‘maven6’.

The indicator of missing file can be in the form of hanged status as follows:

> Resolve dependencies :compile > play-services-places-9.6.1.pom

Before trying to resolve the above dependency errors, I notice that even with the above command line, gradle still try to print error output in the console. This will create confusion as to whether all the log is indeed written to log file.

So using this command line:

And compare it in the log file, and indeed some of the log file in the console is not get written to log file. Gradle team (if any) should fix it.

Searching through the log debug message also indicated failed git command to get the last timestamp:

13:52:09.475 [DEBUG] [org.gradle.process.internal.DefaultExecHandle] Process ‘command ‘git” finished with exit value -1 (state: FAILED)

Which from D:\Projects\AndroidProgram\Signal\Client\build.gradle using getLastCommitTimestamp as follows:

Since my machine do not have git program installed, I try to obtain it from https://github.com/git-for-windows/git/releases/download/v2.14.2.windows.3/Git-2.14.2.3-32-bit.exe.

Then test the command line to get the timestamp:

Try:

Then:

Disable this command for the time being and replace it with constant Unix TimeStamp.

Then gradle stops at:

Resolve dependencies :_playDebugApk

Using ProcMon to detect missing modules required by gradle:

Reveals that gradle first checks the repository in Android SDK folder, and tries to connect to the internet, which is not allowed using proxy, and it will then try to locate through maven local repository. The transition between first failed remote repository to the local maven repository is taking too long, because it tries to wait for the connection.

There might be some settings in gradle systems that fiddle with the waiting time. I will try to use other approach by moving all the local maven to Android SDK’s folder.

This should be done repeatedly for all stages of dependency resolving process.

This approach is very slow, but the result is a solid availability of local dependencies, so that the compilation still can be executed even when the required version is not available on remote location.

How to Compile Andromax C3Si (NC36B1G) Kernel

October 10, 2017

The purpose of this article is to explore whether it is possible to re-construct the kernel source to be compiled and be able to run in Andromax C3Si phone.

This part of article is to provide necessary steps to create successful compile from vanilla QualComm MSM8610 kernel. The next phase will be to deploy the resulting zImage to an existing boot image of Andromax C3Si (NC36B1G) to see how far the kernel can go.

The first step is to get the workable Stock ROM (or whatever ROMs that can be booted successfully). And at the time of writing this article, the ROM from:

http://blognyatresna.blogspot.co.id/2015/08/stockrom-andromax-c3si.html

Is already tested and proves to be bootable and work without error (bootloops, etc). Using Carliv Image Kitchen, the working boot.img is extracted and content of extracted files is examined and analyzed.

The boot.img-dt file is moved to D:\Projects\AndromaxC3si\Device to be converted back to *.dtc file to get some insights about the device tree used.

Now perform some series of data transformation as follows:

D:\Projects\AndromaxC3si\Device>split-appended-dtb boot.img-dt
Found 1 appended dtbs, please check the output.

Then:

D:\Projects\AndromaxC3si\Device>dtc -I dtb -O dts -o AndromaxC3si.dts dtbdump_1.
dtb
Warning (reg_format): “reg” property in /i2c@f9924000/nfc-nci@e has invalid leng
th (4 bytes) (#address-cells == 2, #size-cells == 1)
Warning (avoid_default_addr_size): Relying on default #address-cells value for /
i2c@f9924000/nfc-nci@e
Warning (avoid_default_addr_size): Relying on default #size-cells value for /i2c
@f9924000/nfc-nci@e

Ignore the warning for the time being. You can refer to my previous article about dtb transformation if you are curious about how to create those executable files.

There’s also the file called kernel. When I try to examine the format, it is also have QCDT signature in it. So let’s perform split again. But… I have:

D:\Projects\AndromaxC3si\Device>split-appended-dtb kernel
ERROR: Appended Device Tree Blob not found!

Leave it for a while.

Now perform symbols checking by importing symbols from working phone:

This will be handy as a reference to be compared to the compiled version of kernel, what kind of functions that is unique inside the working kernel.

Check whether compiled kernel support in-kernel configuration:

shell@HS8610QC:/ $ cat /proc/config.gz
/system/bin/sh: cat: /proc/config.gz: No such file or directory

Retrieve kernel to be compiled from:

https://github.com/CAF-MSM8610/kernel-msm

Retrieve toolchain from:

https://launchpad.net/gcc-arm-embedded/4.7/4.7-2013-q3-update

Then, perform configuration as follows:

D:\Projects\AndromaxC3si\Kernel>make msm8610_defconfig

But the windows crash miserably.

After close examination, the command line should be this one:

D:\Projects\AndromaxC3si\Kernel>make V=1 CROSS_COMPILE=C:/NDK/toolchains/arm-201
3q3/bin/arm-none-eabi- msm8610_defconfig

Because there’s no default settings in the makefile. But I have:


***
*** Can’t find default configuration “arch/x86/configs/msm8610_defconfig”!
***
make[1]: *** [msm8610_defconfig] Error 1
make: *** [msm8610_defconfig] Error 2

Try:

D:\Projects\AndromaxC3si\Kernel>make V=1 CROSS_COMPILE=C:/NDK/toolchains/arm-20
3q3/bin/arm-none-eabi- ARCH=arm msm8610_defconfig

I have:

scripts/kconfig/conf –defconfig=arch/arm/configs/msm8610_defconfig Kconfig
arch/arm/configs/msm8610_defconfig:235:warning: unexpected data
arch/arm/configs/msm8610_defconfig:253:warning: override: reassigning to symbol
INPUT_MOUSEDEV
#
# configuration written to .config
#

There’s some warning, but leave it for a while. Perform compile:

D:\Projects\AndromaxC3si\Kernel>make V=1 CROSS_COMPILE=C:/NDK/toolchains/arm-201
3q3/bin/arm-none-eabi- ARCH=arm

But again, windows crash miserably.

Perform revision in:

D:\Projects\AndromaxC3si\Kernel\scripts\checksyscalls.sh
D:\Projects\AndromaxC3si\Kernel\scripts\gcc-goto.sh
D:\Projects\AndromaxC3si\Kernel\scripts\gcc-version.sh
D:\Projects\AndromaxC3si\Kernel\scripts\gcc-x86_32-has-stack-protector.sh

You can see what kind of revision by reading about compiling Samsung GT-S5360 article in this blog.

Re-compile again, but I have:

/bin/sh scripts/checksyscalls.sh /d/Projects/AndromaxC3si/Kernel/scripts/gcc-w
rapper.py C:/NDK/toolchains/arm-2013q3/bin/arm-none-eabi-gcc -Wp,-MD,./.missing-
syscalls.d -nostdinc -isystem c:/ndk/toolchains/arm-2013q3/bin/../lib/gcc/arm-n
one-eabi/4.7.4/include -I/d/Projects/AndromaxC3si/Kernel/arch/arm/include -Iarch
/arm/include/generated -Iinclude -include /d/Projects/AndromaxC3si/Kernel/inclu
de/linux/kconfig.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-msm/include -Wal
l -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -W
error-implicit-function-declaration -Wno-format-security -fno-delete-null-pointe
r-checks -O2 -marm -fno-dwarf2-cfi-asm -fstack-protector -mabi=aapcs-linux -mno-
thumb-interwork -funwind-tables -D__LINUX_ARM_ARCH__=7 -march=armv7-a -msoft-flo
at -Uarm -Wframe-larger-than=1024 -fomit-frame-pointer -g -Wdeclaration-after-st
atement -fno-strict-overflow -fconserve-stack -D”KBUILD_STR(s)=#s” -D”KBUILD_
BASENAME=KBUILD_STR(missing_syscalls)” -D”KBUILD_MODNAME=KBUILD_STR(missing_sys
calls)”
make[1]: *** [missing-syscalls] Error 1
make: *** [prepare0] Error 2

Revert changes to (i.e. restore from original source):

D:\Projects\AndromaxC3si\Kernel\scripts\checksyscalls.sh

Re-compile and I get another windows crash.

Using this command line construct:

D:\Projects\AndromaxC3si\Kernel>make V=1 CROSS_COMPILE=C:/NDK/toolchains/arm-201
3q3/bin/arm-none-eabi- ARCH=arm > myTesting.txt

Will yield the error result without windows crashing:

close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr
make[1]: *** [init/main.o] Error 1
make: *** [init] Error 2

Removing reference to D:\Projects\AndromaxC3si\Kernel\scripts\gcc-wrapper.py in D:\Projects\AndromaxC3si\Kernel\Makefile:

Still cause windows to crash. But using re-direction construct get some different error:

init/main.c:76:0: fatal error: when writing output to : Invalid argument
compilation terminated.
make[1]: *** [init/main.o] Error 1
make: *** [init] Error 2

More detailed analysis reveals some issue in Windows OS in that it can not process pipe command inside make script such as this:

So the genksyms.exe do not get the required input and causes the compiler to crash.

Perform changes inside D:\Projects\AndromaxC3si\Kernel\scripts\Makefile.build as follows:

cmd_gensymtypes:

Then for cmd_modversions:

So, that it removes the temporary file (*.tmp) created from previous make command. After the above revision, the genksyms works correctly now, but I have:


arch/arm/mach-msm/smd_init_dt.c:24:25: fatal error: smd_private.h: No such file or directory
compilation terminated.
make[1]: *** [arch/arm/mach-msm/smd_init_dt.o] Error 1
make: *** [arch/arm/mach-msm] Error 2

This is because the compiler breaks at:

D:\Projects\AndromaxC3si\Kernel>C:\NDK\toolchains\arm-2013q3\bin\arm-none-eabi-g
cc -Wp,-MD,arch/arm/mach-msm/.smd_init_dt.o.d -nostdinc -isystem c:/ndk/toolcha
ins/arm-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/include -Id:/Projects/Andromax
C3si/Kernel/arch/arm/include -Iarch/arm/include/generated -Iinclude -include d:
/Projects/AndromaxC3si/Kernel/include/linux/kconfig.h -D__KERNEL__ -mlittle-endi
an -Iarch/arm/mach-msm/include -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs
-fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-form
at-security -fno-delete-null-pointer-checks -O2 -marm -fno-dwarf2-cfi-asm -fstac
k-protector -mabi=aapcs-linux -mno-thumb-interwork -funwind-tables -D__LINUX_ARM
_ARCH__=7 -march=armv7-a -msoft-float -Uarm -Wframe-larger-than=1024 -fomit-fram
e-pointer -g -Wdeclaration-after-statement -fno-strict-overflow -fconserve-stack
-D”KBUILD_STR(s)=#s” -D”KBUILD_BASENAME=KBUILD_STR(smd_init_dt)” -D”KBUILD_
MODNAME=KBUILD_STR(smd_init_dt)” -c -o arch/arm/mach-msm/.tmp_smd_init_dt.o arch
/arm/mach-msm/smd_init_dt.c
arch/arm/mach-msm/smd_init_dt.c:24:25: fatal error: smd_private.h: No such file
or directory
compilation terminated.

The required file does exist in D:\Projects\AndromaxC3si\Kernel\arch\arm\mach-msm. But why the compiler do not find it ?

Compared it with successful compile such as D:\Projects\AndromaxC3si\Kernel\arch\arm\mach-msm\smd_debug.c, It declares as:

Where as the failed one:

Let’s perform revise and re-compile. It is a success. Perform other changes regarding this issue in:

D:\Projects\AndromaxC3si\Kernel\arch\arm\mach-msm\smd_init_plat.c

Let’s perform long compile again:

D:\Projects\AndromaxC3si\Kernel>make V=1 CROSS_COMPILE=C:/NDK/toolchains/arm-201
3q3/bin/arm-none-eabi- ARCH=arm 2> myError.txt

After a some long compilation process, now I have:


ls: /drivers/gud/MobiCoreDriver/platforms: No such file or directory
In file included from drivers/gud/MobiCoreDriver/logging.c:21:0:
drivers/gud/MobiCoreDriver/main.h:24:22: fatal error: platform.h: No such file or directory
compilation terminated.
make[2]: *** [drivers/gud/MobiCoreDriver/logging.o] Error 1
make[1]: *** [drivers/gud] Error 2
make: *** [drivers] Error 2

Which is caused by compiler break at:

D:\Projects\AndromaxC3si\Kernel>C:\NDK\toolchains\arm-2013q3\bin\arm-none-eabi-g
cc -Wp,-MD,drivers/gud/MobiCoreDriver/.logging.o.d -nostdinc -isystem c:/ndk/to
olchains/arm-2013q3/bin/../lib/gcc/arm-none-eabi/4.7.4/include -Id:/Projects/And
romaxC3si/Kernel/arch/arm/include -Iarch/arm/include/generated -Iinclude -inclu
de d:/Projects/AndromaxC3si/Kernel/include/linux/kconfig.h -D__KERNEL__ -mlittle
-endian -Iarch/arm/mach-msm/include -Wall -Wundef -Wstrict-prototypes -Wno-trigr
aphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno
-format-security -fno-delete-null-pointer-checks -O2 -marm -fno-dwarf2-cfi-asm –
fstack-protector -mabi=aapcs-linux -mno-thumb-interwork -funwind-tables -D__LINU
X_ARM_ARCH__=7 -march=armv7-a -msoft-float -Uarm -Wframe-larger-than=1024 -fomit
-frame-pointer -g -Wdeclaration-after-statement -fno-strict-overflow -fconserve-
stack -DNDEBUG -Idrivers/gud -Wno-declaration-after-statement -Idrivers/gud/Mobi
CoreDriver/platforms/ -Idrivers/gud/MobiCoreDriver/public -Idrivers/gud/MobiCore
KernelApi/include -Idrivers/gud/MobiCoreKernelApi/public -DMODULE -D”KBUILD_ST
R(s)=#s” -D”KBUILD_BASENAME=KBUILD_STR(logging)” -D”KBUILD_MODNAME=KBUILD_STR(m
cDrvModule)” -c -o drivers/gud/MobiCoreDriver/.tmp_logging.o drivers/gud/MobiCor
eDriver/logging.c
In file included from drivers/gud/MobiCoreDriver/logging.c:21:0:
drivers/gud/MobiCoreDriver/main.h:24:22: fatal error: platform.h: No such file o
r directory
compilation terminated.

With error(s) as follows:

ls: /drivers/gud/MobiCoreDriver/platforms: No such file or directory
In file included from drivers/gud/MobiCoreDriver/logging.c:21:0:
drivers/gud/MobiCoreDriver/main.h:24:22: fatal error: platform.h: No such file or directory
compilation terminated.
make[2]: *** [drivers/gud/MobiCoreDriver/logging.o] Error 1
make[1]: *** [drivers/gud] Error 2
make: *** [drivers] Error 2

Which is caused by presence of backslash in the directory, confirmed by test command in bash shell as follows:

Revise the make file script in D:\Projects\AndromaxC3si\Kernel\drivers\gud\Makefile from:

Revise it to:

Re-compile again, and I have:


In file included from drivers/video/msm/mdss/mdss_mdp_trace.h:255:0,
from drivers/video/msm/mdss/mdss_mdp.c:60:
include/trace/define_trace.h:79:43: fatal error: ./mdss_mdp_trace.h: No such file or directory
compilation terminated.
make[4]: *** [drivers/video/msm/mdss/mdss_mdp.o] Error 1
make[3]: *** [drivers/video/msm/mdss] Error 2
make[2]: *** [drivers/video/msm] Error 2
make[1]: *** [drivers/video] Error 2
make: *** [drivers] Error 2

Copy required file mdss_mdp_trace.h and mdss_mdp.h to D:\Projects\AndromaxC3si\Kernel\include\trace.

Perform re-compile again, and I have:


sound/soc/codecs/msm8x10-wcd-tables.c:13:35: fatal error: msm8x10_wcd_registers.h: No such file or directory
compilation terminated.
make[3]: *** [sound/soc/codecs/msm8x10-wcd-tables.o] Error 1
make[2]: *** [sound/soc/codecs] Error 2
make[1]: *** [sound/soc] Error 2
make: *** [sound] Error 2

Same as the above case, perform revision on the source in D:\Projects\AndromaxC3si\Kernel\sound\soc\codecs\msm8x10-wcd-tables.c, by changing the include statement.

Re-compile again, now I have:


sound/soc/msm/msm8x10.c:29:40: fatal error: qdsp6v2/msm-pcm-routing-v2.h: No such file or directory
compilation terminated.
make[3]: *** [sound/soc/msm/msm8x10.o] Error 1
make[2]: *** [sound/soc/msm] Error 2
make[1]: *** [sound/soc] Error 2
make: *** [sound] Error 2

Perform revision in D:\Projects\AndromaxC3si\Kernel\sound\soc\msm\msm8x10.c, include statement revision.

Re-compile:


sound/soc/msm/qdsp6v2/rtac.c:29:21: fatal error: q6voice.h: No such file or directory
compilation terminated.
make[4]: *** [sound/soc/msm/qdsp6v2/rtac.o] Error 1
make[3]: *** [sound/soc/msm/qdsp6v2] Error 2
make[2]: *** [sound/soc/msm] Error 2
make[1]: *** [sound/soc] Error 2
make: *** [sound] Error 2

Perform revision in D:\Projects\AndromaxC3si\Kernel\sound\soc\msm\qdsp6v2\rtac.c.

There are no more issues after that and the resulting zImage is located at D:\Projects\AndromaxC3si\Kernel\arch\arm\boot, ready for deployment.

This completes the first stage of Andromax C3Si (NC36B1G) kernel reconstruction activity. But I will stop for now 🙂

Experiences in Using Open Whisper Systems’ Signal (TextSecure) Server

October 3, 2017

Let’s perform some checks on available parameter for this server:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar
usage: java -jar TextSecureServer-1.65.jar
[-h] [-v]
{server,check,directory,vacuum,trim,stats,rmuser,accountdb,messagedb}

positional arguments:
{server,check,directory,vacuum,trim,stats,rmuser,accountdb,messagedb}
available commands

optional arguments:
-h, –help show this help message and exit
-v, –version show the application version and exit

Let’s see what kind of output we get when use the check parameter.

First, see the help info about check parameter:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar check -h config/textse
cure.yml
usage: java -jar TextSecureServer-1.65.jar
check [-h] [file]

Parses and validates the configuration file

positional arguments:
file application configuration file

optional arguments:
-h, –help show this help message and exit

Now runs it:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar check config/textsecur
e.yml
config/textsecure.yml has an error:
* Failed to parse configuration at: testDevices; Can not deserialize instance
of java.util.ArrayList out of START_OBJECT token
at [Source: N/A; line: -1, column: -1] (through reference chain: org.whispersys
tems.textsecuregcm.WhisperServerConfiguration[“testDevices”])

Let’s add test device (although the reason is not clear at this time) in D:\Projects\AndroidProgram\Signal\Server\config\TextSecure.yml as follows:

Re-run, but still has the same error. Change it again to:

This time, there are no error, but also no output. But, upon more close examination, the output is actually resides in the log file (D:\tmp\textsecureshserver.log) as follows:

INFO [2017-09-29 02:18:18,936] io.dropwizard.cli.CheckCommand: Configuration is OK

Hmm, nice.

Now for directory command:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar directory -h config/te
xtsecure.yml
usage: java -jar TextSecureServer-1.65.jar
directory [-h] [file]

Update directory from DB and peers.

positional arguments:
file application configuration file

optional arguments:
-h, –help show this help message and exit

Now, let’s run directory command:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar directory config/texts
ecure.yml
java.lang.NullPointerException

Log file info as follows:

WARN [2017-09-29 02:22:12,800] org.whispersystems.textsecuregcm.workers.DirectoryCommand: Directory Exception
! java.lang.NullPointerException: null
! at org.whispersystems.textsecuregcm.workers.DirectoryCommand.run(DirectoryCommand.java:67)
! at org.whispersystems.textsecuregcm.workers.DirectoryCommand.run(DirectoryCommand.java:43)

Peform debug as follows:

D:\Projects\AndroidProgram\Signal\Server>java -Xdebug -Xrunjdwp:transport=dt_soc
ket,server=y,address=8880,suspend=y -jar target\TextSecureServer-1.65.jar direc
tory config/textsecure.yml
Listening for transport dt_socket at address: 8880

After firing up NetBeans to connect to the program, the result as follows:

Checking the dbConfig variable, reveals it is a null, which means the getReadDataSourceFactory fails to get the required class instance. Checking to the source of this class, suggested that the application tries to read data from another data source and perform update to destination data.

So, I decided to leave it for a while.

Let’s examine accountdb parameter:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar accountdb
too few arguments
usage: java -jar TextSecureServer-1.65.jar
accountdb [-h] {migrate,status} …

Run database migrations tasks

positional arguments:
{migrate,status}

optional arguments:
-h, –help show this help message and exit

Let’s use status argument:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar accountdb status confi
g/textsecure.yml
Validation Error:
Validation Failed:
1 changes have validation failures
columnDataType is required for addNotNullConstraint on mssql, migratio
ns.xml::2::matt

Perform changes to D:\Projects\AndroidProgram\Signal\Server\src\main\resources\accountsdb.xml as follows:

Now, recompile and re-run. I have this time:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar accountdb status confi
g/textsecure.yml
5 change sets have not been applied to textsecure@jdbc:sqlserver://:
1433;jaasConfigurationName=SQLJDBCDriver;serverPreparedStatementDiscardThreshold
=10;enablePrepareOnFirstPreparedStatementCall=false;fips=false;socketTimeout=0;a
uthentication=NotSpecified;authenticationScheme=nativeAuthentication;xopenStates
=false;sendTimeAsDatetime=true;trustStoreType=JKS;trustServerCertificate=false;T
ransparentNetworkIPResolution=true;serverNameAsACE=false;sendStringParametersAsU
nicode=true;selectMethod=direct;responseBuffering=adaptive;queryTimeout=-1;packe
tSize=8000;multiSubnetFailover=false;loginTimeout=15;lockTimeout=-1;lastUpdateCo
unt=true;encrypt=false;disableStatementPooling=true;databaseName=accountsdb;colu
mnEncryptionSetting=Disabled;applicationName=Microsoft JDBC Driver for SQL Serve
r;applicationIntent=readwrite;

Let’s use:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar accountdb migrate conf
ig/textsecure.yml

But I have:

Migration failed for change set migrations.xml::2::matt:
Reason: liquibase.exception.DatabaseException: Column, parameter, or variab
le #9: Cannot find data type json. [Failed SQL: ALTER TABLE [dbo].[accounts] ADD
[data] [json]]

After perform some analysis, it is found that my current Microsoft SQL Server construct is not supporting json data type, and also each commands inside the accountsdb.xml script is heavily utilize the PostgreSQL Syntax and facillity.

So, I decided to install and use PostgreSQL instead. Good bye MS SQL Server.

Download from:

https://get.enterprisedb.com/postgresql/postgresql-9.6.5-1-windows-binaries.zip

Installation in C:\PostgreSQL

Database initialization:

C:\PostgreSQL\bin>initdb c:\postgresql\data

But I have:

Install Visual C++ Redistributable Packages for Visual Studio 2013 from:

https://www.microsoft.com/en-us/download/details.aspx?id=40784

Re-run the above command line program, now it is run successfully.

Activate the server, but now I have:

C:\PostgreSQL\bin>postgres -D c:\postgresql\data
Execution of PostgreSQL by a user with administrative permissions is not
permitted.
The server must be started under an unprivileged user ID to prevent
possible system security compromises. See the documentation for
more information on how to properly start the server.

So using:

Then:

Again, in postgres user windows, but I have:

C:\PostgreSQL\bin>postgres -D c:\postgresql\data
PANIC: could not open control file “global/pg_control”: Permission denied

Perform add permission with full control for C:\PostgreSQL to postgres user. Re-run the above command and I now have:

C:\PostgreSQL\bin>postgres -D c:\postgresql\data
LOG: database system was shut down at 2017-10-02 13:51:22 +07
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started

Now, for the client command to list databases:

C:\PostgreSQL\bin>psql -l
psql: FATAL: role “postgres” does not exist

Remove the data folder that was created previously and perform initdb under newly created postgres user. Now the command runs successfully:

C:\PostgreSQL\bin>psql -l
List of databases
Name | Owner | Encoding | Collate | Ctype
| Access privileges
———–+———-+———-+—————————-+—————–
———–+———————–
postgres | postgres | WIN1252 | English_United States.1252 | English_United S
tates.1252 |

Another command to display current user status and capabilities:

C:\PostgreSQL\bin>psql -c “\du”
List of roles
Role name | Attributes | Member
of
———–+————————————————————+——-
—-
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

Seems PostgresSQL is running fine now. Let’s creates the required databases for TextSecure Server:

C:\PostgreSQL\bin>createdb accountsdb

C:\PostgreSQL\bin>createdb messagedb

Let’s focus again to the TextSecure server itself.

Perform changes to D:\Projects\AndroidProgram\Signal\Server\config\TextSecure.yml:

Re-run this command:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar accountdb status confi
g/textsecure.yml

But again I have:

ERROR [2017-10-02 08:52:14,820] org.apache.tomcat.jdbc.pool.ConnectionPool: Unable to create initial connections of pool.
! java.lang.ClassNotFoundException: org.postgresql.Driver
! at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
! at java.lang.ClassLoader.loadClass(ClassLoader.java:424)

This is because the dependency is set to Microsoft SQL Server in the previous session in an attempt to use SQL Server as data source, which do not have features in PostgreSQL such as json, array data type, etc.

So revert back to using jdbc class for PostgreSQL in D:\Projects\AndroidProgram\Signal\Server\pom.xml:

Perform re-compile and re-run, I have:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar accountdb status confi
g/textsecure.yml
Connection to :5432 refused. Check that the hostname and port are co
rrect and that the postmaster is accepting TCP/IP connections.

Perform modification in C:\PostgreSQL\data\postgresql.conf:

Then in c:\PostgreSQL\data\pg_hba.conf:

But in the client now I have:

It says:

psql: FATAL: password authentication failed for user “postgres”

In the server log, I have as follows:

FATAL: password authentication failed for user
DETAIL: User has no password assigned.
Connection matched pg_hba.conf line 84: “host all all
0.0.0.0/0 md5”

Revert md5 back to trust in the above pg_hba.conf. Re-start the server and login into PostgreSQL and perform command as follows:

Change back trust back to md5 in the above pg_hba.conf, stop and re-start the server again. This time, the password scheme works correctly in psql:

Now let’s re-run the TextSecure server:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar accountdb status confi
g/textsecure.yml
5 change sets have not been applied to postgres@jdbc:postgresql://:5
432/accountsdb

Seems to be working now. Let’s do this one:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar accountdb migrate conf
ig/textsecure.yml

No error and by examining the log file, I have:


INFO [2017-10-03 08:11:48,091] liquibase: migrations.xml: migrations.xml::5::moxie: Columns timestamp(bigint) added to pending_devices
INFO [2017-10-03 08:11:48,101] liquibase: migrations.xml: migrations.xml::5::moxie: ChangeSet migrations.xml::5::moxie ran successfully in 83ms

Checking into the PostgreSQL server:

So far so good. Now this one:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar messagedb migrate conf
ig/textsecure.yml

Also no error:


INFO [2017-10-03 08:26:25,984] liquibase: messagedb.xml: messagedb.xml::4::moxie: Custom SQL executed
INFO [2017-10-03 08:26:25,986] liquibase: messagedb.xml: messagedb.xml::4::moxie: ChangeSet messagedb.xml::4::moxie ran successfully in 19ms
INFO [2017-10-03 08:26:25,995] liquibase: Successfully released change log lock

TextSecure server now has database and tables to be worked upon. The next phase would be to create the client to interact with this server.

How to Compile and Run Open Whisper Systems’ Signal Server (Part 3)

September 29, 2017

Last time when try to run the server, I got Multiple exceptions. From the log file it is found:

WARN [2017-09-28 02:02:11,451] org.whispersystems.textsecuregcm.metrics.NetworkSentGauge: NetworkSentGauge
! java.io.FileNotFoundException: \proc\net\dev (The system cannot find the path specified)
! at java.io.FileInputStream.open0(Native Method)
! at java.io.FileInputStream.open(FileInputStream.java:195)
! at java.io.FileInputStream.(FileInputStream.java:138)
! at java.io.FileReader.(FileReader.java:72)
! at org.whispersystems.textsecuregcm.metrics.NetworkGauge.getSentReceived(NetworkGauge.java:16)
! at org.whispersystems.textsecuregcm.metrics.NetworkSentGauge.(NetworkSentGauge.java:19)
! at org.whispersystems.textsecuregcm.WhisperServerService.run(WhisperServerService.java:270)
! at org.whispersystems.textsecuregcm.WhisperServerService.run(WhisperServerService.java:111)
! at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:43)
! at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:85)
! at io.dropwizard.cli.Cli.run(Cli.java:74)
! at io.dropwizard.Application.run(Application.java:89)
! at org.whispersystems.textsecuregcm.WhisperServerService.main(WhisperServerService.java:276)

This is the Linux style to get network statistics. So, for windows environment, the coding inside this class should be modified using equivalent netstat -e command to obtain the necessary data.

Let’s re-compile and run again. But again I get alpn error just as in previous article. Upon some checking, it is found that the alpn-boot-8.1.11.v20170118.jar is missing in target folder. Seems that maven deletes this file when compilation process finished.

So, I decided to move this class to alpn folder and perform running as follows:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar server config/textsecu
re.yml
Multiple exceptions

To my surprise, although I already modify the source, this error below persist:

WARN [2017-09-28 06:38:21,293] org.whispersystems.textsecuregcm.metrics.NetworkSentGauge: NetworkSentGauge
! java.io.FileNotFoundException: \proc\net\dev (The system cannot find the path specified)
! at java.io.FileInputStream.open0(Native Method)
! at java.io.FileInputStream.open(FileInputStream.java:195)
! at java.io.FileInputStream.(FileInputStream.java:138)
! at java.io.FileReader.(FileReader.java:72)
! at org.whispersystems.textsecuregcm.metrics.NetworkGauge.getSentReceived(NetworkGauge.java:16)

After some checking, it is realized the source is modified in duplicated NetBeans project for the purpose of debugging, where as the original folder is not get modified. For the moment, just copy the source content to the one in used.

Let’s now focus on Multiple exceptions exception error that is triggred from:

! at org.eclipse.jetty.server.Server.doStart(Server.java:419)
! … 7 common frames omitted
! Causing: org.eclipse.jetty.util.MultiException: Multiple exceptions

Which may caused by connection error to postgre:

! Causing: org.postgresql.util.PSQLException: Connection to localhost:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
! at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:239)

Since our infrastructrure already have MS SQL instead of PostgreSQL, I try to change the configuration in TextSecure.yml as follows:

And perform necessary user and database setup in MS SQL.

This time, the error is different:

ERROR [2017-09-28 07:02:56,113] org.apache.tomcat.jdbc.pool.ConnectionPool: Unable to create initial connections of pool.
! java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
! at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

Add dependency in D:\Projects\AndroidProgram\Signal\Server\pom.xml:

Re-compile but I still have:

ERROR [2017-09-28 07:34:50,826] org.apache.tomcat.jdbc.pool.ConnectionPool: Unable to create initial connections of pool.
! java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver
! at java.net.URLClassLoader.findClass(URLClassLoader.java:381)

Checking the class binary, and I realized that the class name should be: com.microsoft.sqlserver.jdbc.SQLServerDriver.

Ok, let’s try again:

D:\Projects\AndroidProgram\Signal\Server>java -Xbootclasspath/p:alpn\alpn-boot-8
.1.11.v20170118.jar -jar target\TextSecureServer-1.65.jar server config/textsecu
re.yml
Multiple exceptions

Still a same error here, but let’s examine the log file:

ERROR [2017-09-28 07:42:12,557] org.apache.tomcat.jdbc.pool.ConnectionPool: Unable to create initial connections of pool.
! java.sql.SQLException: Driver:SQLServerDriver:3 returned null for URL:jdbc:microsoft:sqlserver://xxx:1433;DatabaseName=accountsdb
! at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:329)
! at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:203)

Revise the URL prefix to:

jdbc:sqlserver

Now I have:

ERROR [2017-09-28 07:53:26,338] org.apache.tomcat.jdbc.pool.ConnectionPool: Unable to create initial connections of pool.
! com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user ‘textsecure’. Reason: The password of the account must be changed. ClientConnectionId:64be0383-755a-401a-a4f4-696e47d82c7f
! at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:258)
! at com.microsoft.sqlserver.jdbc.TDSTokenHandler.onEOF(tdsparser.java:256)

But when I try to un-check the password expiration policy, I have:

Well, I just perform manual password change on MS SQL Client console. There are no more exit of the loop, but there are many warning error such as these in the log file:

WARN [2017-09-28 08:07:13,082] org.whispersystems.textsecuregcm.providers.RedisClientFactory: Error connecting
! java.net.ConnectException: Connection refused: connect
! at java.net.DualStackPlainSocketImpl.connect0(Native Method)

Copy executable from Redis-x64-3.2.100.zip to D:\Projects\AndroidProgram\Signal\Server\redis

Then, on another command prompt box:

D:\Projects\AndroidProgram\Signal\Server\redis>redis-server
[364] 28 Sep 16:29:58.727 # Warning: no config file specified, using the default
config. In order to specify a config file use redis-server /path/to/redis.conf

There are no more redis connection error now in the log file. Server seems to be working now.

How to Print Image to LCD at Samsung GT-S5360 Kernel Start Up

September 28, 2017

This article explores the possibility to print out some information in the form of the images to the LCD for Samsung GT-S5360 at boot start up. This will be handy for debugging kernel problem at kernel boot start up. Different image set up can be shown at different stage of boot sequence so that certain problem can be isolated.

The only drawback is that, the boot sequence should be at least succeeded at the point of initializing the LCD driver. Any point before that should be done by other methods.

Found lcd_init log:

[ 0.640197] [lcd_init]: enter

In D:\Projects\AndroidKernel\Samsung\kernel4\common\drivers\video\broadcom\dss\bcm215xx\lcdc.c

But unable to find the possible call stack leading to this call. So, adding dump_stack() in this function to see what happens.

This device is using CONFIG_BCM_LCD_ILI9341_BOE_REV05 as apparent from bcm21553_totoro_defconfig

The result is:

[ 0.624755] [] (unwind_backtrace+0x0/0x164) from [] (dump_stack+0x18/0x1c)
[ 0.624847] [] (dump_stack+0x18/0x1c) from [] (lcd_init+0x24/0x98)
[ 0.624969] [] (lcd_init+0x24/0x98) from [] (do_one_initcall+0x64/0x1b4)
[ 0.625061] [] (do_one_initcall+0x64/0x1b4) from [] (kernel_init+0xd0/0x1b8)
[ 0.625152] [] (kernel_init+0xd0/0x1b8) from [] (kernel_thread_exit+0x0/0x8)

The reason of difficulty for finding this kind of call, is that the compiler defines it using macro:

#define INIT_CALLS \
VMLINUX_SYMBOL(__initcall_start) = .; \
INITCALLS \
VMLINUX_SYMBOL(__initcall_end) = .;

So, the kernel is just using the function pointer to the above structure.

The do_initcalls is inside function do_initcalls that iterates initcall structure and perform the call to the function.

This is proven by using application that can open vmlinux file such as IDA Dissasembler, the call to lcd_init as follows:

.init:C0032898 __initcall_lcd_init6 DCD lcd_init ; DATA XREF: .text:C04EA690o

Next, there’s interesting log called lcd_pwr_on_controll in the above source code, which appears once in the log. This function is called in lcd_probe:

[ 0.625671] lcdc: Broadcom LCD Controller Driver: 0.01 for S6D04H0X20 LCD

[ 0.632080] [lcd_pwr_on_controll]: enter

But it is difficult to determine which function that calls it, so again, placing dump_stack() in this function.

Result as follows:

[ 0.625305] [] (unwind_backtrace+0x0/0x164) from [] (dump_stack+0x18/0x1c)
[ 0.625427] [] (dump_stack+0x18/0x1c) from [] (lcdc_probe+0x38/0x4dc)
[ 0.625518] [] (lcdc_probe+0x38/0x4dc) from [] (platform_drv_probe+0x20/0x24)
[ 0.625640] [] (platform_drv_probe+0x20/0x24) from [] (driver_probe_device+0x188/0x318)
[ 0.625732] [] (driver_probe_device+0x188/0x318) from [] (__driver_attach+0x68/0x8c)
[ 0.625823] [] (__driver_attach+0x68/0x8c) from [] (bus_for_each_dev+0x50/0x84)
[ 0.625915] [] (bus_for_each_dev+0x50/0x84) from [] (driver_attach+0x20/0x28)
[ 0.626007] [] (driver_attach+0x20/0x28) from [] (bus_add_driver+0x194/0x344)
[ 0.626098] [] (bus_add_driver+0x194/0x344) from [] (driver_register+0xb0/0x140)
[ 0.626220] [] (driver_register+0xb0/0x140) from [] (platform_driver_register+0x4c/0x60)
[ 0.626312] [] (platform_driver_register+0x4c/0x60) from [] (lcd_init+0x70/0x94)
[ 0.626434] [] (lcd_init+0x70/0x94) from [] (do_one_initcall+0x64/0x1b4)
[ 0.626525] [] (do_one_initcall+0x64/0x1b4) from [] (kernel_init+0xd0/0x1b8)
[ 0.626617] [] (kernel_init+0xd0/0x1b8) from [] (kernel_thread_exit+0x0/0x8)

From the above stack, it is clear that power on of LCD is initialized inside lcd_init itself.

Let’s check whether this LCD driver is functional on the boot process by placing the call to:

lcdc_disp_img(IMG_INDEX_AP_DUMP);

in do_basic_setup after initcalls already finished.

But it is not shown when the kernel is compiled and applied to the phone.

Later on, I found there’s a lcd_display_test function inside this program, so I decided to put it into test. But it is also not shown. After some more checking, the reason it is not showing is that there’s a check of screen size against the dirty row data inside lcd_dev_dirty_rect function:

So, by fixing the dirtyRect structure data, the screen before the boot animation logo is now showing 2 pink triangle.

But the question remain, why the function lcdc_disp_img is not showing at all ? After some more detailed test and checking, it is obvious that lcdc_disp_img is using different method of writing to LCD which proved to be not working.

The lcd_display_test can be used as a prototype for a more creative function to display images to the LCD.

Apparently it is using 32 bit format in the form of AARRGGBB for each pixel. For example, this small function below will show blue rectangle the size of 50×50 pixels on top left corner at booting process.

For other more complex function, such as decoding text string to the image format, I will leave this task to the reader.

Experiences in Using Compiled Samsung GT-S5360’s Kernel

September 24, 2017

So, from the previous article, I already have a compiled kernel. And in no time, using Carliv Image Kitchen, I already have boot.img and flashed it into my Samsung GT-S5360.

But it stuck on the Samsung logo. Hoping to gain some more information, I try to recompile using tty0 as its kernel parameter, but with the same result.

Using ODIN I managed to revert back to functional stock ROM. Try to find methods to get the kernel message on booting process proves to be difficult. So I decided to try another kernel source as an alternative.

And searching for another alternative, I’ve found:

https://github.com/Maroc-OS/Merruk-Technology

Let’s give it a try:

D:\Projects\AndroidKernel\Samsung\kernel3\common>make V=1 ARCH=arm bcm21553_toto
ro_05_defconfig CROSS_COMPILE=C:\NDK\toolchains\arm-linux-androideabi-4.8\prebui
lt\windows\bin\arm-linux-androideabi-

After .config file is created, Then:

D:\Projects\AndroidKernel\Samsung\kernel3\common>make V=1 CONFIG_DEBUG_SECTION_M
ISMATCH=y EXTRA_AFLAGS=’-mfpu=neon -ftree-vectorize -mfloat-abi=softfp’ CROSS_CO
MPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux

Then near the end of compilation process I have:

C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-and
roideabi-gcc -Wp,-MD,arch/arm/boot/compressed/.head.o.d -nostdinc -isystem c:/n
dk/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/../lib/gcc/arm-linu
x-androideabi/4.8/include -I/d/Projects/AndroidKernel/Samsung/kernel3/common/arc
h/arm/include -Iinclude -I../modules/include -include include/generated/autocon
f.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-bcm215xx/include -Iarch/arm/pla
t-bcmap/include -D__ASSEMBLY__ -mabi=aapcs-linux -mno-thumb-interwork -funwind-t
ables -D__LINUX_ARM_ARCH__=6 -march=armv6k -mtune=arm1136j-s -include asm/unifi
ed.h -msoft-float -gdwarf-2 -mfpu=neon -ftree-vectorize -mfloat-abi=softfp
-c -o arch/arm/boot/compressed/head.o arch/arm/boot/compressed/head.S
(cat arch/arm/boot/compressed/../Image | lzma -9 && printf \\340\\134\\173\\00
0) > arch/arm/boot/compressed/piggy.lzma || (rm -f arch/arm/boot/compressed/pigg
y.lzma ; false)
C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-and
roideabi-gcc -Wp,-MD,arch/arm/boot/compressed/.piggy.lzma.o.d -nostdinc -isyste
m c:/ndk/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/../lib/gcc/ar
m-linux-androideabi/4.8/include -I/d/Projects/AndroidKernel/Samsung/kernel3/comm
on/arch/arm/include -Iinclude -I../modules/include -include include/generated/a
utoconf.h -D__KERNEL__ -mlittle-endian -Iarch/arm/mach-bcm215xx/include -Iarch/a
rm/plat-bcmap/include -D__ASSEMBLY__ -mabi=aapcs-linux -mno-thumb-interwork -fun
wind-tables -D__LINUX_ARM_ARCH__=6 -march=armv6k -mtune=arm1136j-s -include asm
/unified.h -msoft-float -gdwarf-2 -mfpu=neon -ftree-vectorize -mfloat-abi=so
ftfp -c -o arch/arm/boot/compressed/piggy.lzma.o arch/arm/boot/compressed/pigg
y.lzma.S
-androideabi- 2>myError.txt

With error sbb:

lzma: Cannot allocate memory
arch/arm/boot/compressed/piggy.lzma.S: Assembler messages:
arch/arm/boot/compressed/piggy.lzma.S:4: Error: file not found: arch/arm/boot/compressed/piggy.lzma
make[2]: *** [arch/arm/boot/compressed/piggy.lzma.o] Error 1
make[1]: *** [arch/arm/boot/compressed/vmlinux] Error 2
make: *** [zImage] Error 2

Source to the lzma command is located at D:\Projects\AndroidKernel\Samsung\kernel3\common\scripts\Makefile.lib as follows:

Testing the lzma command yield this result:

D:\Projects\AndroidKernel\Samsung\kernel3\common>lzma -9 arch/arm/boot/compresse
d/../Image > test.lzma
lzma: Cannot allocate memory

Try to change the option -9 to -8 seems to be succeeded, let’s apply to the makefile.lib, and re-compile again, arrgh.

But this time it is a breeze. The zImage is eventually located in D:\Projects\AndroidKernel\Samsung\kernel3\common\arch\arm\boot

There’s no necessary tweaking in the last steps of compiling process.

But after applying the repacking using carliv, I still can not make the working kernel. It is already properly compiled. And this is the third attempt in creating the kernel using various sources.

The first one I even do not managed to achieve a kernel image (percy’s github).

So I decided to back to step one and verify the correctness of the output. Let’s verify the carliv image kitchen first.

The working kernel zip file that is working is from kernel_CM7_v4.0_totoro.zip, which is already discussed in my previous post.

I unzip this file and take the boot.img file and placed it in carliv folder, then perform unpacking.

After that, I perform repacking of the unpacking of boot.img and I notice the output file is different.

The original one is:

Where the one from carliv:

Nevermind, so, let’s used it to flash the phone to see whether it is still working or not. Well, it still working, despite the size differences.

This makes me to re-think what is exactly the crucial steps that I’m missing. And searching from the forum, I’ve found some reference about the importance of ext4 file format for CM7 and its associated ROMs, thanks to bieltv3.

Here is the link:

https://forum.xda-developers.com/showthread.php?t=2673610

Try to find the matching configs that has this feature, I’ve found cyanogenmod_totoro_defconfig and decided to give it a try.

But this time, I revert back to kernel2 which is from CM

Now, perform config with:

D:\Projects\AndroidKernel\Samsung\kernel2>make V=1 ARCH=arm cyanogenmod_totoro_d
efconfig CROSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/wind
ows/bin/arm-linux-androideabi-

Compile again:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 CROSS_COMPILE=C:/NDK/to
olchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi- 2
>myError.txt

So again, I have:

lzma: Cannot allocate memory
arch/arm/boot/compressed/piggy.lzma.S: Assembler messages:
arch/arm/boot/compressed/piggy.lzma.S:4: Error: file not found: arch/arm/boot/compressed/piggy.lzma
make[2]: *** [arch/arm/boot/compressed/piggy.lzma.o] Error 1
make[1]: *** [arch/arm/boot/compressed/vmlinux] Error 2
make: *** [zImage] Error 2

Apply patch based on description above, and re-compile.

There again the piggy error, and should perform these last steps again:

D:\Projects\AndroidKernel\Samsung\kernel2>C:\NDK\toolchains\arm-linux-androideab
i-4.8\prebuilt\windows\bin\arm-linux-androideabi-gcc -Wp,-MD,arch\arm\boot\compr
essed\.lib1funcs.o.d -nostdinc -isystem c:\ndk\toolchains\arm-linux-androideabi
-4.8\prebuilt\windows\bin\..\lib\gcc\arm-linux-androideabi\4.8\include -Id:\Proj
ects\AndroidKernel\Samsung\kernel2\arch\arm\include -Iinclude -include include\
generated\autoconf.h -D__KERNEL__ -mlittle-endian -Iarch\arm\mach-bcm215xx\inclu
de -Iarch\arm\plat-bcmap\include -D__ASSEMBLY__ -mabi=aapcs-linux -mno-thumb-int
erwork -funwind-tables -D__LINUX_ARM_ARCH__=6 -march=armv6k -mtune=arm1136j-s –
include asm\unified.h -msoft-float -gdwarf-2 -Wa, -c -o arch\arm\boot\compre
ssed\lib1funcs.o arch\arm\boot\compressed\lib1funcs.S

D:\Projects\AndroidKernel\Samsung\kernel2>C:\NDK\toolchains\arm-linux-androideab
i-4.8\prebuilt\windows\bin\arm-linux-androideabi-gcc -Wp,-MD,arch\arm\boot\compr
essed\.head.o.d -nostdinc -isystem c:\ndk\toolchains\arm-linux-androideabi-4.8\
prebuilt\windows\bin\..\lib\gcc\arm-linux-androideabi\4.8\include -Id:\Projects\
AndroidKernel\Samsung\kernel2\arch\arm\include -Iinclude -include include\gener
ated\autoconf.h -D__KERNEL__ -mlittle-endian -Iarch\arm\mach-bcm215xx\include -I
arch\arm\plat-bcmap\include -D__ASSEMBLY__ -mabi=aapcs-linux -mno-thumb-interwor
k -funwind-tables -D__LINUX_ARM_ARCH__=6 -march=armv6k -mtune=arm1136j-s -inclu
de asm\unified.h -msoft-float -gdwarf-2 -Wa, -c -o arch\arm\boot\compressed\
head.o arch\arm\boot\compressed\head.S

D:\Projects\AndroidKernel\Samsung\kernel2>C:\NDK\toolchains\arm-linux-androideab
i-4.8\prebuilt\windows\bin\arm-linux-androideabi-gcc -Wp,-MD,arch\arm\boot\compr
essed\.piggy.lzma.o.d -nostdinc -isystem c:\ndk\toolchains\arm-linux-androideab
i-4.8\prebuilt\windows\bin\..\lib\gcc\arm-linux-androideabi\4.8\include -Id:\Pro
jects\AndroidKernel\Samsung\kernel2\arch\arm\include -Iinclude -include include
\generated\autoconf.h -D__KERNEL__ -mlittle-endian -Iarch\arm\mach-bcm215xx\incl
ude -Iarch\arm\plat-bcmap\include -D__ASSEMBLY__ -mabi=aapcs-linux -mno-thumb-in
terwork -funwind-tables -D__LINUX_ARM_ARCH__=6 -march=armv6k -mtune=arm1136j-s
-include asm\unified.h -msoft-float -gdwarf-2 -Wa, -c -o arch\arm\boot\comp
ressed\piggy.lzma.o arch\arm\boot\compressed\piggy.lzma.S

D:\Projects\AndroidKernel\Samsung\kernel2>C:\NDK\toolchains\arm-linux-androideab
i-4.8\prebuilt\windows\bin\arm-linux-androideabi-ld -EL –defsym zreladdr=0x8160
0000+0x8000 -p –no-undefined -X -T arch\arm\boot\compressed\vmlinux.lds arch\ar
m\boot\compressed\head.o arch\arm\boot\compressed\piggy.lzma.o arch\arm\boot\com
pressed\misc.o arch\arm\boot\compressed\decompress.o arch\arm\boot\compressed\li
b1funcs.o -o arch\arm\boot\compressed\vmlinux

D:\Projects\AndroidKernel\Samsung\kernel2>C:/NDK/toolchains/arm-linux-androideab
i-4.8/prebuilt/windows/bin/arm-linux-androideabi-objcopy -O binary -R .note -R .
note.gnu.build-id -R .comment -S arch/arm/boot/compressed/vmlinux arch/arm/boot/
zImage

Needless to say, this method is also not working.

Later on, after examining the github source, I’ve found the compilation is done using 4.4.3 toolchain:

D:\Projects\AndroidKernel\Samsung\kernel2>make V=1 CROSS_COMPILE=C:/NDK/toolchai
ns/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi- 2>myE
rror.txt

This time, the zImage is created right away without requiring some tweaking as done above.

But this is also not working. After flashing, the phone stuck on the GT-S5360 logo 🙂

After some consideration, I decided to retry the .config that I’ve found from Percy’s github. Rename it into percy_defconfig and placed it in D:\Projects\AndroidKernel\Samsung\kernel2\arch\arm\configs

But I have to manually resolve this error from my previous post:

drivers/built-in.o:silabs_f760_totoro.c:function silabs_ts_probe: error: undefin
ed reference to ‘Synaptics_Connected’
drivers/built-in.o:silabs_f760_totoro.c:function silabs_ts_init: error: undefine
d reference to ‘Synaptics_Connected’
make: *** [.tmp_vmlinux1] Error 1

In the previous post, I decided to use another configs that is compilable, but now I realize that the compiled kernel is not working also.

The missing variable is actually exported from synaptics_i2c_rmi_tma140_totoro.c. This variable is controlled by CONFIG_TOUCHSCREEN_TMA140. And it is nowhere to be found in Percy’s config. So, I decided to add it.

Perform re-configuration:

D:\Projects\AndroidKernel\Samsung\kernel2>make V=1 ARCH=arm percy_defconfig CROS
S_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm
-linux-androideabi-

Now re-compile:

D:\Projects\AndroidKernel\Samsung\kernel2>make V=1 CROSS_COMPILE=C:/NDK/toolchai
ns/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi- 2>myE
rror.txt

But again, the phone still can not boot to recovery, but there’s a slightly different state now. Instead of showing the Samsung logo forever, the logo now is gone. Seems it is trying to enter different state but get stuck again.

After some pondering of this matter, there comes the idea of obtaining yet another samsung kernel, this time, I will verify that it is indeed has Linux version 2.6.35.7, and not like Percy’s github, has complete drivers and other required file to be compilable.

Previous kernels that I have compiled and did not success until now has Linux version 2.6.35.14.

And I found it from some one called Dreamboxuser as follows:

https://github.com/Dreamboxuser/samsung-kernel-totoro

Download it, then copied bcm21553_totoro_defconfig that I will be used bcm21553_totoro_mod_defconfig and perform modifications to file systems format, to be same from Percy’s config.

Again, I have to perform some necessary modifications to the build system, as already explained from my previous post.

After that, here we go:

D:\Projects\AndroidKernel\Samsung\kernel4\common>make V=1 ARCH=arm bcm21553_toto
ro_mod_defconfig CROSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.4.3/pre
built/windows/bin/arm-linux-androideabi-

D:\Projects\AndroidKernel\Samsung\kernel4\common>make V=1 CROSS_COMPILE=C:/NDK/t
oolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi
– 2>myError.txt

But I have this error:

drivers/built-in.o: In function `con_set_default_unimap’:
D:\Projects\AndroidKernel\Samsung\kernel4\common/drivers/char/consolemap.c:619: undefined reference to `dfont_unitable’
D:\Projects\AndroidKernel\Samsung\kernel4\common/drivers/char/consolemap.c:619: undefined reference to `dfont_unicount’

This is caused by empty file of consolemap_deftbl.c which is generated by conmakehash.exe, which probabaly propagated from previous error. Let’s delete this file and also remove consolemap.o which is the source that causes the error.

Let’s re-compile and now the zImage is generated without any incidents. But it is still a failure.

This makes me wonder as to whether the board-totoro.c source actually can be used for my phone. To prove this, I create an unzipped file of the actual kernel that I know it works (kernel_CM7_v4.0_totoro.zip) and see whether code signature specific for board-totoro.c is actually inside this kernel image.

First, I also create the unzipped file of my kernel that doesn’t work that used is as confirmation.

After some detail examination, it is indeed that the kernel that works is indeed using board-totoro.c.

So, why is that my kernel still don’t work ?

After I has exhausted all of other options, I am starting to re-trace my steps in compiling process, and the only one I’ve never tried is, the entire compiler itself. At first, I try to change only the compiler version. Checking into Percy’s make file I’ve modified, I’ve found reference to arm-2009q3 compiler.

And also by searching through forum, finally I found this thread in xda:

http://forum.xda-developers.com/showpost.php?p=24747881&postcount=4

Someone called irfanbagus in that forum mention that:

“it’s not working. sgy stock kernel do not have /proc/config.gz and gcc version in arm-2011.03 not compatible with other precompiled module.”

I decided to give it a try, by downloading from:

http://docs.leaflabs.com/static.leaflabs.com/pub/codesourcery/arm-2009q3-68-arm-none-eabi-toolchain-win32.tar.gz

And perform compile with:

D:\Projects\AndroidKernel\Samsung\kernel4\common>make V=1 CROSS_COMPILE=C:/NDK/t
oolchains/arm-2009q3-68/bin/arm-none-eabi- 2>myError.txt

Suddenly it works at least it can go back to recovery mode instead of stuck of Samsung Logo. The next step will be trying to get compatible ROM for the compiled kernel. But that’s another issue.

How to Compile Samsung GT-S5360’s Kernel on Windows OS

September 4, 2017

The sources uses for this article is this one:

https://github.com/percy-g2/GNU-kernel

But later on, this proves to be useless, as you can see near the end of this article

This is downloaded and placed in D:\Projects\AndroidKernel\Samsung\kernel

Rooting the device using:

https://forum.xda-developers.com/showthread.php?t=2085390

Install required Samsung USB driver SAMSUNG_USB_Driver_for_Mobile_Phones.zip.

First perform some file study on the ramdisk structure of existing device by transferring files from device to PC:

C:\Android\sdk\platform-tools>adb pull init.rc d:\z
adb: error: failed to copy ‘init.rc’ to ‘d:\z\init.rc’: remote Permission denied

So, it is a remote Permission denied. Let’s leave it for a while.

Install CWM to the device:

C:\Android\sdk\platform-tools>adb push D:\Projects\AndroidKernel\Samsung\cwm.zip
/sdcard
D:\Projects\AndroidKernel\Samsung\cwm….ed. 4.8 MB/s (1418804 bytes in 0.281s)

Install CWM and perform back up.

Later on, when I restart the phone, I’ve found that ADB functionality is disabled, which means that when I plug the USB cable to my PC, the phone only reacted with charging only.

After performing the factory reset, the ADB functionality is come back as expected. So I decided to investigate further.

When I connect the phone using USB cable, the device is registered as BCM21553-Thunderbird.

A question to my mind: does the driver is coming from Samsung USB driver I installed earlier, or is it coming from the phone itself ?

I unplugged the phone, and perform uninstall of the USB driver. There’s no Samsung driver now, I plug the USB cable. It registered as BCM21553-Thunderbird, and ready to use but the ADB command can not detect the device.

So, unplug, and re-install the USB driver, and re-plug, and see what happens now.

It tries to install the driver, and when I skip the windows update, the installation process brings out status as follows:

So, the Samsung USB driver is indeed required for ADB functionality. Now, let’s try to disable USB debugging in the phone and see what happens.

It reverts to USB storage. When I enable USB debugging and USB storage through the phone menu, both the ADB and file system in my PC can detect the files. Hmm, great !

So, what causes the failure in the ADB functionality ? Is it because I install CWM.zip recovery image ?

Unplug and re-install CWM (ClockworkMod Recovery v5.0.2.6) recovery, then perform re-boot, and see what happens. The ADB still detect the device. Hmm, strange. Maybe there are extra steps that I’ve done in recovery program that causes this. But let’s leave this for the moment.

Let’s empty the SD card leaving only update.zip (for rooting) and CWM.zip for recovery.

Unplug, entering to recovery mode and install CWM again. This time, I try to perform backup and see what files that gets created. One of interesting file is boot.img. Let’s examine it.

The carliv image kitchen failed to recognize this file, turns out the boot.img contains nothing only a series of 0xFF from start to the end of file.

The boot.img is important because it will be used as base line for the compiled kernel source. So, I have some options as follows: try to examine the CWM recovery source file or try to get the stock rom.

I decided to use custom rom for GT-S5360 from this site:

http://www.droidthunder.com/update-samsung-galaxy-y-s5360-to-android-5-0-lollipop/

By following the exact step, I get the working Android Lollipop themed on my Samsung GT-S5360 phone, with also a working USB storage and debugging for ADB command purposes.

Next, I try to identify objects inside the custom kernel’s (kernel_CM7_v4.0_totoro.zip) boot.img to find out what will be the requirements to get a workable kernel image.

D:\Projects\AndroidKernel\Samsung\carliv>carliv

This time carliv image kitchen works, and examining the result, the boot.image consists of the kernel and ramdisk.

Checking the root structure of the system verifies that it is indeed from ramdisk:

C:\Android\sdk\platform-tools>adb she
$ su
# ls -a
efs
config
cache
sd-ext
sdcard
acct
mnt
vendor
d
etc
ueventd.rc
ueventd.goldfish.rc
tmp
system
sys
sbin
res
recovery.rc
proc
lib
init.rc
init.goldfish.rc
init.charge.rc
init.bcm21553.rc
init
fota.rc
default.prop
data
root
dev
#
# pwd
/
#

Let’s check the log files whether it is exist, this is done by perform all backup to the sdcard, copying content to the PC for ease of searching and investigating. Searching for *log* yield no result whatsoever.

Try to search using *.txt find some interesting file called SYSTEM_BOOT@1293963501309.txt with content as follows:

Build: samsung/GT-S5360/GT-S5360:2.3.6/GINGERBREAD/XWKTN:user/release-keys
Hardware: totoro
Bootloader: unknown
Radio: unknown
Kernel: Linux version 2.6.35.7 (bieltv3@bieltv3) (gcc version 4.4.3 (GCC) ) #32 PREEMPT Fri Feb 14 16:33:03 CET 2014

From recovery_kernel_log.txt on back up of original ROM I also get information about the machine:

[ 0.000000] Machine: BCM21553 ThunderbirdEDN31 platform

Try to get more information about the kernel based on the above string information proves to be very difficult and vague, but later on, I’ve found that dmesg is useful to get kernel messages for this ROM.

In the adb shell:

$ su
# dmesg > sdcard/mymsg.txt

Then:

C:\Android\sdk\platform-tools>adb pull /sdcard/mymsg.txt d:\z
/sdcard/mymsg.txt: 1 file pulled. 5.4 MB/s (89066 bytes in 0.016s)

Let’s perform some queries of this Samsung devices:

# ls -s /proc
total 0
0 rfs
0 LinuStoreIII

# cat /proc/cpuinfo
Processor : ARMv6-compatible processor rev 5 (v6l)
BogoMIPS : 832.90
Features : swp half thumb fastmult vfp edsp java
CPU implementer : 0x41
CPU architecture: 6TEJ
CPU variant : 0x1
CPU part : 0xb36
CPU revision : 5

Hardware : BCM21553 ThunderbirdEDN31 platform
Revision : 0000
Serial : 0000000000000000

# cat /proc/devices
Character devices:
1 mem
2 pty
3 ttyp
4 /dev/vc/0
4 tty
4 ttyS
5 /dev/tty
5 /dev/console
5 /dev/ptmx
7 vcs
10 misc
13 input
29 fb
89 i2c
90 mtd
108 ppp
116 alsa
128 ptm
136 pts
151 gememalloc
199 bcm_gps
200 bcm_cntin
201 bcm_kril
202 bcm_log
203 bcm_atc
204 bcm_fuse_ipc
205 bcm_rpc
206 bcm_alsa_pcg
207 bcm_audio_log
208 bcm_vsp
209 bcm_alsa_voip
210 hx170dec
211 h6270enc
212 bcm_kpdp
216 rfcomm
230 memalloc
243 lcd
246 camera
250 BrcmHeadset
251 v3d
252 ttyGS
253 cache-ops
254 rtc

Block devices:
1 ramdisk
259 blkext
7 loop
31 mtdblock
137 bml
138 stl
179 mmc
254 device-mapper
#

To verify the start up codes against the downloaded source, let’s extract the boot.img.

At the end of the boot process routines, I expected to find 0x1F and 0x8B for gzip signature, but I found none. It has 0x5D as the signature, and at the end of the kernel binary, there’s an interesting string: bad header. So, based on sources searching, it is found that this error message is uniquely found in D:\Projects\AndroidKernel\Samsung\kernel\common\lib\decompress_unlzma.c.

For a verification, I dissected the binary portion and placed it in test.lzma file using WinHex and try to decompress with 7-zip without any incidence.

Next, I try to load the extracted kernel into IDA Dissasembler to examine the routine and compared it with D:\Projects\AndroidKernel\Samsung\kernel\common\arch\arm\boot\compressed\head.S from downloaded kernel source.

The first statements until SVC 0x123456 is still consistent with the source code. But after instruction MSR CPSR_c, R2 there are two mysterious statement which consists of ANDEQ R0, R0, R0 twice, which is actually 0x00 bytes of 8 bytes size.

But later on, upon close examination, it is maybe inserted by the linker, as evidenced from comment of head.s source code: some architecture specific code can be inserted by the linker here, but it should preserve r7, r8, and r9 …

Statement after this is consistent. The downloaded source looks promising. So, let’s prepare for the compilation process.

Let’s test the basic logic of the make file:

D:\Projects\AndroidKernel\Samsung\kernel\common>make
make: /home/percy/sgy/arm-2009q3/bin/arm-none-eabi-gcc: Command not found
HOSTCC scripts/basic/fixdep
scripts/basic/fixdep.c:116:23: fatal error: arpa/inet.h: No such file or directo
ry
compilation terminated.
make[2]: *** [scripts/basic/fixdep] Error 1
make[1]: *** [scripts_basic] Error 2
make: *** No rule to make target `include/config/auto.conf’, needed by `include/
config/kernel.release’. Stop.

So, let’s try:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 ARCH=arm SUBARCH=arm CR
OSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm
-none-androideabi-
make: C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-none-
androideabi-gcc: Command not found
make -f /d/Projects/AndroidKernel/Samsung/kernel/common/Makefile silentoldconfig

make -f scripts/Makefile.build obj=scripts/basic
gcc -Wp,-MD,scripts/basic/.fixdep.d -Wall -Wmissing-prototypes -Wstrict-protot
ypes -O2 -fomit-frame-pointer -o scripts/basic/fixdep scripts/basic/fixdep.c

scripts/basic/fixdep.c:116:23: fatal error: arpa/inet.h: No such file or directo
ry
compilation terminated.

Perform changes in the make file:

HOSTCC:=i686-pc-cygwin-gcc-4

Now I have:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 ARCH=arm SUBARCH=arm CR
OSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm
-none-androideabi-
make: C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-none-
androideabi-gcc: Command not found
make -f /d/Projects/AndroidKernel/Samsung/kernel/common/Makefile silentoldconfig

make -f scripts/Makefile.build obj=scripts/basic
i686-pc-cygwin-gcc-4 -Wp,-MD,scripts/basic/.fixdep.d -Wall -Wmissing-prototype
s -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/basic/fixdep scrip
ts/basic/fixdep.c
scripts/basic/fixdep.c: In function `parse_config_file’:
scripts/basic/fixdep.c:242:4: warning: array subscript has type `char’
scripts/basic/fixdep.c: In function `parse_dep_file’:
scripts/basic/fixdep.c:323:4: warning: array subscript has type `char’
scripts/basic/fixdep: scripts/basic/fixdep: cannot execute binary file
make[2]: *** [scripts/basic/fixdep] Error 126
make[1]: *** [scripts_basic] Error 2
make: *** No rule to make target `include/config/auto.conf’, needed by `include/
config/kernel.release’. Stop.

Checking the files in location D:\Projects\AndroidKernel\Samsung\kernel\common\scripts\basic reveals there’s a fixdep file in ELF format. Remove it and the error is gone, but I have a crashed windows, hmm, interesting 🙂

But let’s focus to this error:

make: C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-none-
androideabi-gcc: Command not found

This is because the current NDK does not have arm-none-androideabi-gcc.exe binary. So, let’s change it to arm-linux-androideabi-gcc, which causes windows crashing as in previous incident:

To solve this problem, let’s use info command. Starting by:

$(info verbose is $(KBUILD_VERBOSE))

To check whether the script is already set to verbose mode, and the result is yes, it is already verbose. But still, there’s no verbose information leading to the clue to the cause of crashing.

After spending considerable time I’ve found the location of the cause of crashing is from D:\Projects\AndroidKernel\Samsung\kernel\common\scripts\Kbuild.include:

try-run = $(shell set -e; \
TMP=”$(TMPOUT).$$$$.tmp”; \
TMPO=”$(TMPOUT).$$$$.o”; \
if ($(1)) >/dev/null 2>&1; \
then echo “$(2)”; \
else echo “$(3)”; \
fi; \
rm -f “$$TMP” “$$TMPO”)

Revise the above script into:

MYTMP:=$$$$.tmp
MYTMPO:=$$$$.o
try-run = $(shell set -e; \
if ($(1)) >/dev/null 2>&1; \
then echo “$(2)”; \
else echo “$(3)”; \
fi; \
rm -f $(MYTMP) $(MYTMPO))

And change all the successive call to try-run using the above construct, for example:

cc-ldoption = $(call try-run,\
$(CC) $(1) -nostdlib -xc /dev/null -o “$$TMP”,$(1),$(2))

Become:

cc-ldoption = $(call try-run,\
$(CC) $(1) -nostdlib -xc /dev/null -o $(MYTMP),$(1),$(2))

Will solve the above initial crash problem.

Now I have not only crashing windows but also my command prompt gone by itself. Hmm, intriguing 🙂

After spending some time investigating this issue, the causes turns out to be trivial, i.e. there’s again some ELF file in the downloaded kernel that cause confusion in the OS.

Now I have:


scripts/kconfig/menu.c: In function `menu_add_prop’:
scripts/kconfig/menu.c:134:3: warning: array subscript has type `char’
scripts/kconfig/menu.c:136:4: warning: array subscript has type `char’
scripts/kconfig/conf: scripts/kconfig/conf: cannot execute binary file

Again I still have some windows crashes like the picture below:

But this time, after all of the issue of lingering ELF file already solved. And when I press the “Close the program”, my console window is gone also, and I have to start over and type the path to the kernel source location. This kind of error will cause a great sorrow and very discouraging.

I realized this is caused by the using of make command. So when I use this command line:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 ARCH=arm SUBARCH=arm CR
OSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm
-linux-androideabi-

The windows will crashes.

But using this one, by adding -p option for make debugging traces, there’s no crash:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 ARCH=arm SUBARCH=arm CR
OSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm
-linux-androideabi- -p > myTesting.txt

Maybe this is caused by the Cygwin compiler behaviour. And because the host command application already created, there’s no reason to keep creating it each time when doing the compilation process, so let’s remark this make script portion in D:\Projects\AndroidKernel\Samsung\kernel\common\Makefile:

#PHONY += scripts_basic
#scripts_basic:
# $(Q)$(MAKE) $(build)=scripts/basic
# $(Q)rm -f .tmp_quiet_recordmcount

The crash is gone, but now I have:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 ARCH=arm SUBARCH=arm CR
OSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm
-linux-androideabi-
build image is zImage
make -f /d/Projects/AndroidKernel/Samsung/kernel/common/Makefile silentoldconfig

make[1]: *** No rule to make target `silentoldconfig’. Stop.
make: *** No rule to make target `include/config/auto.conf’, needed by `include/
config/kernel.release’. Stop.

There are new target error here, so, let’s create a dummy target for script_basic:

PHONY += scripts_basic
scripts_basic:
@echo “Script Basic”

Now again I get crash, which is caused by another call to cygwin compiler. So, make combined with cygwin compiler will cause windows crash, but can be remedied by using -p options.

I decided to investigate it further, of why the exact nature of the crashing windows when it is using without -p options.

After spending some considerable time, I found the source of the problem, which is the present of extra hyphen or minus in one of the compiler checking script.

The script in question is located at D:\Projects\AndroidKernel\Samsung\kernel\common\scripts\kconfig\check.sh, which contains:

Please pay a close attention to the above script. I’ve marked the extra hyphen or minus sign in that script. And by removing that extra hyphen and try to call make again without -p option, the windows crashing is now gone, for a moment.

By perform global text searching, this kind of construct is also located in D:\Projects\AndroidKernel\Samsung\kernel\common\scripts\kconfig\lxdialog\check-lxdialog.sh. So, to prevent another frustration, it is also fixed.

This makes me wonder, why in Linux OS system do not crash, or is it some form of preventive measure from Linux community to thwart the Windows OS to get a successful compile ? Hmm, anyway it is an interesting phenomena.

Now I have:


arch/arm/Kconfig:1138: can’t open file “drivers/pci/Kconfig”
make[2]: *** [silentoldconfig] Error 1
make[1]: *** [silentoldconfig] Error 2
make: *** No rule to make target `include/config/auto.conf’, needed by `include/
config/kernel.release’. Stop.

First error:

arch/arm/Kconfig:1138: can’t open file “drivers/pci/Kconfig”

Can be resolved by create a blank Kconfig file in D:\Projects\AndroidKernel\Samsung\kernel\common\drivers\pci

Same for:

arch/arm/Kconfig:1140: can’t open file “drivers/pcmcia/Kconfig”
arch/arm/Kconfig:1632: can’t open file “drivers/cpuidle/Kconfig”
net/Kconfig:211: can’t open file “drivers/net/appletalk/Kconfig”

And after several hundreds of this kind of replacement, I came at:

make[1]: `include/generated/mach-types.h’ is up to date.
make -f scripts/Makefile.build obj=.
(cat /dev/null; ) > modules.order
./scripts/basic/hash: ./scripts/basic/hash: cannot execute binary file
./scripts/basic/hash: ./scripts/basic/hash: cannot execute binary file

fixdep:
: No such file or directory
make[1]: *** [kernel/bounds.s] Error 2
make: *** [prepare0] Error 2

Again the lingering ELF file for hash. Let’s try again after removing it.

The fixdep still has error. And based on my previous post about compiling goldfish kernel, there should be some small changes in the source file, so by copying it into this folder and re-compile fixdep, I have:

i686-pc-cygwin-gcc-4 -Wp,-MD,scripts/mod/.mk_elfconfig.d -Wall -Wmissing-proto
types -Wstrict-prototypes -O2 -fomit-frame-pointer -o scripts/mod/mk_elfconf
ig scripts/mod/mk_elfconfig.c
scripts/mod/mk_elfconfig scripts/mod/elfconfig.h
scripts/mod/mk_elfconfig: scripts/mod/mk_elfconfig: cannot execute binary file
make[2]: *** [scripts/mod/elfconfig.h] Error 126
make[1]: *** [scripts/mod] Error 2
make: *** [scripts] Error 2

Oh boy, another lingering ELF, I suppose. Remove, and this time, I have another windows crashing.

Again after spending some time checking for this issue, it is found that this construct in D:\Projects\AndroidKernel\Samsung\kernel\common\scripts\mod\Makefile:

The green one which the original one will cause windows to crash. Apparently, simultaneously redirecting input and output can’t be handled by windows at this time.

So I have to modify it without output redirection, but using routines inside D:\Projects\AndroidKernel\Samsung\kernel\common\scripts\mod\mk_elfconfig.c to create the required output file.

Now I have:


usr/gen_init_cpio: usr/gen_init_cpio: cannot execute binary file
make[1]: *** [usr/initramfs_data.cpio] Error 126
make: *** [usr] Error 2

Remove the offending ELF file, after some compilation time, I have:

Let’s try:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 ARCH=arm bcm21553_totor
o_02B0_defconfig CROSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebu
ilt/windows/bin/arm-linux-androideabi-

Then:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 CROSS_COMPILE=C:/NDK/to
olchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi- 2
>myError1.txt

Checking on the result file:

In file included from arch/arm/plat-bcmap/include/plat/gpio.h:22:0,
from arch/arm/mach-bcm215xx/include/mach/gpio.h:16,
from d:/Projects/AndroidKernel/Samsung/kernel/common/arch/arm/include/asm/gpio.h:5,
from include/linux/gpio.h:7,
from arch/arm/mach-bcm215xx/include/mach/setup.h:24,
from arch/arm/mach-bcm215xx/board-totoro.c:36:
include/asm-generic/gpio.h: In function ‘gpio_get_value_cansleep’:
include/asm-generic/gpio.h:206:2: error: implicit declaration of function ‘gpio_get_value’ [-Werror=implicit-function-declaration]
return gpio_get_value(gpio);

Let’s try again with:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 ARCH=arm bcm21553_totor
o_02B0_defconfig CROSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebu
ilt/windows/bin/arm-linux-androideabi-

Then:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 CROSS_COMPILE=C:/NDK/to
olchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi- 2
>myError2.txt

But I still have:


In file included from arch/arm/plat-bcmap/include/plat/gpio.h:22:0,
from arch/arm/mach-bcm215xx/include/mach/gpio.h:16,
from d:/Projects/AndroidKernel/Samsung/kernel/common/arch/arm/include/asm/gpio.h:5,
from include/linux/gpio.h:7,
from arch/arm/mach-bcm215xx/include/mach/setup.h:24,
from arch/arm/mach-bcm215xx/board-totoro.c:36:
include/asm-generic/gpio.h: In function ‘gpio_get_value_cansleep’:
include/asm-generic/gpio.h:206:2: error: implicit declaration of function ‘gpio_get_value’ [-Werror=implicit-function-declaration]
return gpio_get_value(gpio);

No matter what combination of possible configs that I throw to the compiler, the result is always the same.

So, I decided to use the default auto.conf from original Percy’s github and copied to D:\Projects\AndroidKernel\Samsung\kernel\common\include\config\auto.conf.

Then I have to disable the conf.exe by modifying the source in D:\Projects\AndroidKernel\Samsung\kernel\common\scripts\kconfig\conf.c from action by just returning to the caller, so that the auto.conf do not get modified:

But this time I have:


init/do_mounts_rd.c: At top level:
init/do_mounts_rd.c:158:12: error: redefinition of ‘rd_load_image’
int __init rd_load_image(char *from)

Upon close examination, the cause of the above error is undefined variable called CONFIG_BLK_DEV_RAM in D:\Projects\AndroidKernel\Samsung\kernel\common\init\do_mounts.h, which causes compilation process goes to the else block:

By checking the parameter passed to the compiler, it is realized that this variable depends on D:\Projects\AndroidKernel\Samsung\kernel\common\include\generated\autoconf.h for the above definition.

Let’s copy this file content from the original github location to this one, and the previous compiler error at board-totoro.c is now gone, and after a significant progress in compiling process that takes considerable time, I have:


make -f scripts/Makefile.build obj=drivers
make -f scripts/Makefile.build obj=drivers/auxdisplay
scripts/Makefile.build:44: /d/Projects/AndroidKernel/Samsung/kernel/common/drive
rs/auxdisplay/Makefile: No such file or directory
make[2]: *** No rule to make target `/d/Projects/AndroidKernel/Samsung/kernel/co
mmon/drivers/auxdisplay/Makefile’. Stop.
make[1]: *** [drivers/auxdisplay] Error 2

Let’s try to use drivers inside:

https://github.com/broadcomCM/android_kernel_samsung_bcm21553-common

And copy the content of drivers into D:\Projects\AndroidKernel\Samsung\kernel\common\drivers. Re-compile, and I have:


scripts/conmakehash: scripts/conmakehash: cannot execute binary file
make[2]: *** [drivers/char/consolemap_deftbl.c] Error 126
make[1]: *** [drivers/char] Error 2
make: *** [drivers] Error 2

Delete the offending ELF file and after compiling process of considerable time, there’s an error, but the my windows console do not keep the earliest error location. So I have to recompile using this option:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 CROSS_COMPILE=C:/NDK/to
olchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi- 2
>myError.txt

This wlll trap any error into the file for further analysis.

And here is the earliest compiler error message:


drivers/staging/android/lowmemorykiller.c: In function ‘lowmem_shrink’:
drivers/staging/android/lowmemorykiller.c:275:27: error: ‘TIF_MM_RELEASED’ undeclared (first use in this function)

Checking to the source makes me question the validity of the copied folder from broadcomCM’s github source. So, I try to retrieve lowmemorykiller.c from:

https://android.googlesource.com/kernel/samsung/+/android-samsung-2.6.35-gingerbread/drivers

And it compiles without any error.

This lead me to replace the entire drivers folder by this one, to see what happens:


drivers/mmc/card/block.c: In function ‘mmc_blk_issue_rq’:
drivers/mmc/card/block.c:387:6: error: implicit declaration of function ‘mmc_card_adjust_cfg’ [-Werror=implicit-function-declaration]
mmc_card_adjust_cfg(card->host, READ);

Let’s revert back the drivers from broadcomCM, but this time, replace lowmemorykiller.c from android-samsung-2.6.35-gingerbread.

Now I have:

In file included from drivers/staging/bcm21553/drivers/char/brcm/fuse_at/atc_kernel.c:58:0:
drivers/staging/bcm21553/drivers/char/brcm/fuse_rpc/rpc_CIB/public/rpc_ipc.h:138:22: error: ‘IPC_PROPERTY_START_AP’ undeclared here (not in a function)
RPC_PROP_START_AP = IPC_PROPERTY_START_AP, ///make V=1 CROSS_COMPILE=C:/NDK/to
olchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi- d
rivers/staging/bcm21553/drivers/char/brcm/fuse_at/atc_kernel.o

Copy IPCProperties.h from broadcomCM github source to D:\Projects\AndroidKernel\Samsung\kernel\common\include\linux\broadcom\IPCProperties.h.

Perform quick re-compiling by invoking the above message, and although there are many warnings, the compiler managed to create atc_kernel.o.

Now, let’s perform a long compile again:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 CROSS_COMPILE=C:/NDK/to
olchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi- 2
>myError.txt

And I have:


drivers/staging/bcm21553/drivers/video/bmem/bmem.c:165:5: error: unknown field ‘GetFreeMemorySize’ specified in initializer
.GetFreeMemorySize = bmem_GetFreeMemorySize,

Copy the file to D:\Projects\AndroidKernel\Samsung\kernel\common\include\linux\broadcom\bmem_wrapper.h. And verify again by quick compiling, it is a success again.

So, copy the entire folder from broadcomCM github to D:\Projects\AndroidKernel\Samsung\kernel\common\include\linux\broadcom folder.

Now I have:


drivers/video/fbmem.c: In function ‘fb_mmap’:
drivers/video/fbmem.c:1360:2: error: implicit declaration of function ‘vm_iomap_memory’ [-Werror=implicit-function-declaration]
return vm_iomap_memory(vma, start, len);

Copy this file from broadcomCM github to:

D:\Projects\AndroidKernel\Samsung\kernel\include\linux\mm.h
D:\Projects\AndroidKernel\Samsung\kernel\mm\memory.c

Quick compile is a success now, let’s do long compile again. And we have:


mm/memory.c: In function ‘unmap_mapping_range’:
mm/memory.c:2679:21: error: ‘struct address_space’ has no member named ‘unmap_mutex’
mutex_lock(&mapping->unmap_mutex);

Replace:

D:\Projects\AndroidKernel\Samsung\kernel\fs\inode.c
D:\Projects\AndroidKernel\Samsung\kernel\include\linux\fs.h

And I have:

mm/mlock.c: At top level:
mm/mlock.c:139:19: error: redefinition of ‘vma_stack_continue’
static inline int vma_stack_continue(struct vm_area_struct *vma, unsigned long addr)

At this point, I believe this kind of compiler error will not be resolved till the end of time 🙂

So, I decided to get a kernel source tree version check, and I’ve found:

The one I try to compiled that do not have complete drivers folder, which cause drivers/auxdisplay make error:

D:\Projects\AndroidKernel\Samsung\kernel\common>make V=1 CROSS_COMPILE=C:/NDK/to
olchains/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi- k
ernelversion
2.6.35.7

The one from broadcomCM github that has the complete driver folder:

D:\Projects\AndroidKernel\Samsung\kernel2>make V=1 CROSS_COMPILE=C:/NDK/toolchai
ns/arm-linux-androideabi-4.8/prebuilt/windows/bin/arm-linux-androideabi- kernelv
ersion
2.6.35.14

Let’s switch to the kernel from broadcomCM, and let’s see how far it can go with the compiling process. To do this, I’ve prepared the source base in:

D:\Projects\AndroidKernel\Samsung\kernel2

But copy the configuration info from the kernel I’ve try to compile and bypass the conf.exe checking, using tricks I’ve described above. This is necessary so that the auto.conf, .config and autoconf.h is intact without get modified by conf.exe. Also perform some necessary script revision and program patches as described above, then let’s compile:


drivers/built-in.o:silabs_f760_totoro.c:function silabs_ts_probe: error: undefin
ed reference to ‘Synaptics_Connected’
drivers/built-in.o:silabs_f760_totoro.c:function silabs_ts_init: error: undefine
d reference to ‘Synaptics_Connected’
make: *** [.tmp_vmlinux1] Error 1

This puts configuration data from percy-g2 into question. Let’s use another configuration by using this command. But first, I have to enable the conf.c to process the Kconfig to generate auto.conf instead of bypassing it.

Then use this configuration:

D:\Projects\AndroidKernel\Samsung\kernel2>make V=1 ARCH=arm bcm21553_totoro_05_d
efconfig CROSS_COMPILE=C:/NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/wind
ows/bin/arm-linux-androideabi-

After that, perform re-compiling, but I have:


c:\NDK\toolchains\arm-linux-androideabi-4.8\prebuilt\windows\bin\arm-linux-androideabi-ld.exe: error: arch/arm/boot/compressed/piggy.gzip.o: unknown CPU architecture
c:\NDK\toolchains\arm-linux-androideabi-4.8\prebuilt\windows\bin\arm-linux-androideabi-ld.exe: error: arch/arm/boot/compressed/lib1funcs.o: unknown CPU architecture
make[2]: *** [arch/arm/boot/compressed/vmlinux] Error 1

This is the classic error and already resolved in my previous article about how to compile goldfish kernel, i.e by manually compiling the offending lib1funcs.S by deleting the -march=all switch.

Now, to get the information of the last steps that should be manually taken for creating the boot kernel, I have to re-compile using -p switch again.

These three should be compiled manually without -march=all option (piggy.gzip.S, head.S and lib1funcs.S):

D:\Projects\AndroidKernel\Samsung\kernel2>C:\NDK\toolchains\arm-linux-androideab
i-4.8\prebuilt\windows\bin\arm-linux-androideabi-gcc -Wp,-MD,arch\arm\boot\compr
essed\.lib1funcs.o.d -nostdinc -isystem c:\ndk\toolchains\arm-linux-androideabi
-4.8\prebuilt\windows\bin\..\lib\gcc\arm-linux-androideabi\4.8\include -Id:\Proj
ects\AndroidKernel\Samsung\kernel2\arch\arm\include -Iinclude -include include\
generated\autoconf.h -D__KERNEL__ -mlittle-endian -Iarch\arm\mach-bcm215xx\inclu
de -Iarch\arm\plat-bcmap\include -D__ASSEMBLY__ -mabi=aapcs-linux -mno-thumb-int
erwork -funwind-tables -D__LINUX_ARM_ARCH__=6 -march=armv6k -mtune=arm1136j-s –
include asm\unified.h -msoft-float -gdwarf-2 -Wa, -c -o arch\arm\boot\compre
ssed\lib1funcs.o arch\arm\boot\compressed\lib1funcs.S

D:\Projects\AndroidKernel\Samsung\kernel2>C:\NDK\toolchains\arm-linux-androideab
i-4.8\prebuilt\windows\bin\arm-linux-androideabi-gcc -Wp,-MD,arch\arm\boot\compr
essed\.head.o.d -nostdinc -isystem c:\ndk\toolchains\arm-linux-androideabi-4.8\
prebuilt\windows\bin\..\lib\gcc\arm-linux-androideabi\4.8\include -Id:\Projects\
AndroidKernel\Samsung\kernel2\arch\arm\include -Iinclude -include include\gener
ated\autoconf.h -D__KERNEL__ -mlittle-endian -Iarch\arm\mach-bcm215xx\include -I
arch\arm\plat-bcmap\include -D__ASSEMBLY__ -mabi=aapcs-linux -mno-thumb-interwor
k -funwind-tables -D__LINUX_ARM_ARCH__=6 -march=armv6k -mtune=arm1136j-s -inclu
de asm\unified.h -msoft-float -gdwarf-2 -Wa, -c -o arch\arm\boot\compressed\
head.o arch\arm\boot\compressed\head.S

D:\Projects\AndroidKernel\Samsung\kernel2>C:\NDK\toolchains\arm-linux-androideab
i-4.8\prebuilt\windows\bin\arm-linux-androideabi-gcc -Wp,-MD,arch\arm\boot\compr
essed\.piggy.gzip.o.d -nostdinc -isystem c:\ndk\toolchains\arm-linux-androideab
i-4.8\prebuilt\windows\bin\..\lib\gcc\arm-linux-androideabi\4.8\include -Id:\Pro
jects\AndroidKernel\Samsung\kernel2\arch\arm\include -Iinclude -include include
\generated\autoconf.h -D__KERNEL__ -mlittle-endian -Iarch\arm\mach-bcm215xx\incl
ude -Iarch\arm\plat-bcmap\include -D__ASSEMBLY__ -mabi=aapcs-linux -mno-thumb-in
terwork -funwind-tables -D__LINUX_ARM_ARCH__=6 -march=armv6k -mtune=arm1136j-s
-include asm\unified.h -msoft-float -gdwarf-2 -Wa, -c -o arch\arm\boot\comp
ressed\piggy.gzip.o arch\arm\boot\compressed\piggy.gzip.S

Then for final steps:

D:\Projects\AndroidKernel\Samsung\kernel2>C:\NDK\toolchains\arm-linux-androideab
i-4.8\prebuilt\windows\bin\arm-linux-androideabi-ld -EL –defsym zreladdr=0x8160
0000+0x8000 -p –no-undefined -X -T arch\arm\boot\compressed\vmlinux.lds arch\ar
m\boot\compressed\head.o arch\arm\boot\compressed\piggy.gzip.o arch\arm\boot\com
pressed\misc.o arch\arm\boot\compressed\decompress.o arch\arm\boot\compressed\li
b1funcs.o -o arch\arm\boot\compressed\vmlinux

And:

D:\Projects\AndroidKernel\Samsung\kernel2>C:/NDK/toolchains/arm-linux-androideab
i-4.8/prebuilt/windows/bin/arm-linux-androideabi-objcopy -O binary -R .note -R .
note.gnu.build-id -R .comment -S arch/arm/boot/compressed/vmlinux arch/arm/boot/
zImage

This image is the kernel and can be used to create boot.img using carliv image kitchen.