How to Install NopCommerce 3.90

November 15, 2017

Since the downloaded 3.90 source from:

https://github.com/nopSolutions/nopCommerce/releases/

Can be compiled using Visual Studio 2013 without any issues, this article will focused on deployment and installation of nopCommerce.

The target server machine is using Windows Server 2012 R2 64 bit and IIS 8.0.

First, create the virtual directory called NoC:

And assigned the proper Application Pool to it:

Then copy the entire compiled version of nopCommerce in D:\Projects\Mvc\NoC\3.90\src\Presentation\Nop.Web to the destination server folder.

Then fire up the browser using this link:

That’s all folks 🙂

Advertisements

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.

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.