Friday, August 10, 2012

Nexus 7 (Refunded)

I just got my Nexus 7 last week. It is one great looking device, plus it is much lighter compare to 10" tablets. Android Jellybean offers big improvement over Honeycomb. I owned 10" Galaxy Tab, I almost never used it for anything, since it is really bad. The browser is bad, and the tablet can become very slow over time.

Nexus 7 comes to the rescue. However, I got some issue with the LCD. It seems that ASUS has pretty bad QA. The LCD is not properly attached to the body. It is lifted by tiny bit, and I can feel it by gently touching the glass. I have contacted Google. They have confirmed that these issues are common. It just convinced me even more that ASUS has really bad QA. I will try to avoid their products in the future. I have had one bad experience with their laptop about 10 years ago. I thought they have changed.

The replacement tablet is on its way, and I hope it doesn't posses similar problem to my current one.

UPDATED: The replacement Nexus 7 still had the screen separation issue, it's even worse than my original. I decided to refund the item, because the screen separation issue was such a deal breaker for me.

Nexus 7

Tuesday, June 12, 2012

Cross Compile PHP for Arm

I just want to share some techniques to cross compile PHP for Arm using CodeSourcery Toolchain. Most of the resources I found out there do not show me how to include mysql client library as well as SimpleXML parser. These two libraries are needed for my case. Following are the how to Download PHP Source Code

I am using PHP 5.4.2. You can download it from php site.

Download libxml

I am using libxml2-2.8. TOOLCHAIN_DIR is the directory pointing to your toolchain library, in my case, it's /opt/toolchain/arm-2009q3/arm-none-linux-gnueabi/libc.

./configure --host=arm-linux-gnu --target=arm-linux CC=arm-none-linux-gnueabi-gcc
AR=arm-none-linux-gnueabi-ar LD=arm-none-linux-gnueabi-ld RANLIB=arm-none-linux-gnueabi-ranlib --prefix=[TOOLCHAIN_DIR]

Then issue

make install

Configure mysql config file

When compiling with MySQL support, I kept encountered following error:

mysqlnd/mysqlnd_portability.h:40:36: error: ./php_mysqlnd_config.h: No such file or directory

I got help from this site. Following is what you need to do to fix the missing file problem:
  1. Goto your php source folder, and navigate to ext/mysqlnd
  2. Then issue 
mv config9.m4 config.m4
sed -ie "s{ext/mysqlnd/php_mysqlnd_config.h{config.h{" mysqlnd_portability.h
phpize

Build PHP

Please note that I need to specify explicit location to libxml directory in order to compile successfully, please change the path to the location of your libxml library.

export CC=arm-none-linux-gnueabi-gcc
./configure --host=arm-linux --without-pear  --enable-libxml --with-libxml-dir=/opt/toolchain/arm-2009q3/arm-none-linux-gnueabi/libc --enable-simplexml --enable-mbregex --enable-sockets  --enable-soap --enable-pdo --with-pdo-sqlite --with-sqlite3 --with-openssl --enable-calendar --enable-mysqlnd --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --disable-all
make -j 12

Afterward, you can find the binary, php-cgi, inside sapi/cgi folder. Hope this tip could be useful.

Wednesday, May 23, 2012

GSOAP Unicode


It has been a while since my last post. I have been busy doing low level C stuff related to Bluetooth and WiFi in the last two years. There are couple of findings that I want to share during these years. I hope they could be useful to others as well.

Let's get down to the topic. We have been using GSOAP C++ to handle our web service call. We could tweak GSOAP to support unicode on Windows by modifying the typemap.dat file:

xsd__string   = | wchar_t* | wchar_t*

(note: some might wonder why we don't use std:string or std:wstring, one of the requirement given to us was to use primitive data type, so we don't really have choices here)

In Windows. char is 8 bits only and wchar_t is 16 bits. Things are good, we used wchar_t* to store all our strings. Then, we migrated to Linux. In Linux, we are using char, because it is already capable of supporting UTF-8 unicode (i.e. datatype char in Linux is 16 bits).

Under Linux, GSOAP doesn't support unicode if char is used. We found it too troublesome to change all our string datatype to to wchar_t*. 

I finally come up with the idea to hack header file generated by GSOAP wsdl2h. I modified certain strings that needs to be in unicode to wchar_t*. So, only certain string variables are in wchar_t*, not all.

Next, I encounter problem trying to convert wchar_t* to char*. Using wcstombs doesn't help. I have UTF-32 stored in wchar_t* from GSOAP, and I am trying to convert it to UTF-8 stored in char*.

I finally find handy help from code project. It pointed me to unicode.org library file; however, it's a broken link. I manage to find it hosted somewhere in Googlecode site. The code project help and unicode.org library help me to convert wchar_t* to char* (UTF-32 to UTF-8) successfully. It's a big relief.

That's it for now.