Search This Blog

Jun 29, 2011

Android r10.2 support SATA boot up on i.MX53 SMD rev B board

1. u-boot

In include/configs/mx53_smd_android.h

+#elif defined(CONFIG_FSL_ENV_IN_SATA)
+ #define CONFIG_ENV_IS_IN_SATA   1
+ #define CONFIG_SATA_ENV_DEV     0
+ #define CONFIG_ENV_OFFSET       (768 * 1024)

2. Kernel

In kernel-imx/arch/arm/configs/imx5_android_defconfig

Make sure # CONFIG_SATA_PMP is not set in .config (It’s important.)

3. Android

In device/fsl/imx53_smd/init.rc
-    mount ext4 /dev/block/mmcblk0p2 /system
-    mount ext4 /dev/block/mmcblk0p2 /system ro remount
-    mount ext4 /dev/block/mmcblk0p5 /data nosuid nodev
-    mount ext4 /dev/block/mmcblk0p6 /cache nosuid nodev
+    mount ext4 /dev/block/sda2 /system
+    mount ext4 /dev/block/sda2 /system ro remount
+    mount ext4 /dev/block/sda5 /data nosuid nodev
+    mount ext4 /dev/block/sda6 /cache nosuid nodev

4. MFG tool

Copy all android relate image files to "files/android"
Modify ucl.xml
change mmcblk to sda in "MX53SMD-Android-SATA"
-"push" body="$ sh /dev/mmcblk0"> Partitioning...
+"push" body="$ sh /dev/sda"> Partitioning...

5. Blown SATA internal boot fuse

To boot from SATA with internal clock, ensure the fuse “SATA_ALT_CLK_REF” is blown.
The following U-Boot command can blown SATA internal boot fuse:
$ iim blow 4 3 4

6. u-boot parameter

$ setenv ethaddr 00:04:9f:00:ea:d3
$ setenv fec_addr 00:04:9f:00:ea:d3
$ setenv loadaddr 0x70800000
$ setenv rd_loadaddr 0x70D00000
$ setenv bootcmd 'run bootcmd_sata; bootm ${loadaddr} ${rd_loadaddr}'
$ setenv bootcmd_sata 'sata read ${loadaddr} 0x800 0x2000; sata read ${rd_loadaddr} 0x3000 0x300;'
$ setenv bootargs console=ttymxc0 init=/init androidboot.console=ttymxc0 video=mxcdi1fb:RGB666,XGA ldb=di1 di1_primary ip=dhcp gpu_nommu, gpu_memory=64M
$ saveenv

7. Bootup Android

We can see Android bootup and done.



Mencius said, 'He who rises at cock-crowing and addresses himself earnestly to the practice of virtue, is a disciple of Shun. He who rises at cock-crowing, and addresses himself earnestly to the pursuit of gain, is a disciple of Zhi. If you want to know what separates Shun from Zhi, it is simply this: the interval between the thought of gain and the thought of virtue.'



Android screen-off timer set as 2 seconds

Customer reported that they set screen off timer as 2 seconds, however, the result is 6 seconds enter into suspend mode.

1. I tried to reproduce this issue by blow actions:

a. Power up Android, input Screen-off timer to 2 seconds in console.
$ sqlite3 /data/data/
sqlite> update system set value="2000" where name="screen_off_timeout";
sqlite> .quit
b. Unlock the screen and wait for suspend message, about 6 seconds, I can see suspend message output from console. It shows what I see is exactly same as customer’s.

2. Locate the reason.

In “frameworks/base/services/java/com/android/server/”, function private void setTimeoutLocked(long now, final long originalTimeoutOverride, int nextState), we can see below code. For nextState = SCREEN_BRIGHT, it will wait for mKeylightDelay and then enter next state.
switch (nextState)
        when = now + mKeylightDelay;
    case SCREEN_DIM:
        if (mDimDelay >= 0) {
            when = now + mDimDelay;
        } else {
            Slog.w(TAG, "mDimDelay=" + mDimDelay + " while trying to dim");
    case SCREEN_OFF:
        synchronized (mLocks) {
            when = now + mScreenOffDelay;
        when = now;
I checked code, mKeylightDelay get its value “LONG_KEYLIGHT_DELAY” in function private void setScreenOffTimeoutsLocked(). And we can see macro definition in this file.
//                       time since last state:               time since last event:
    // The short keylight delay comes from secure settings; this is the default.
    private static final int SHORT_KEYLIGHT_DELAY_DEFAULT = 6000; // t+6 sec
    private static final int MEDIUM_KEYLIGHT_DELAY = 15000;       // t+15 sec
    private static final int LONG_KEYLIGHT_DELAY = 6000;        // t+6 sec
    private static final int LONG_DIM_TIME = 7000;              // t+N-5 sec
From above definition, we can see that is Android default design method, and we know why we will wait 6 seconds to enter suspend mode even we set screen-off timer as 2 seconds.

3. Solution.

a. We should keep minimum screen-off timer as 6 seconds, just following Android default design method.
b. I tried to modify the macro definition like below, and have a test, it can enter into suspend mode within 2 seconds. However, user experience is not good. Because 2 seconds is too short, e-reader panel response is slow, it is very easy to enter suspend mode, we have to wakeup it frequency.
//                       time since last state:               time since last event:
    // The short keylight delay comes from secure settings; this is the default.
    private static final int SHORT_KEYLIGHT_DELAY_DEFAULT = 1000; // t+6 sec
    private static final int MEDIUM_KEYLIGHT_DELAY = 9000;       // t+15 sec
    private static final int LONG_KEYLIGHT_DELAY = 1000;        // t+6 sec
    private static final int LONG_DIM_TIME = 2000;              // t+N-5 sec
Please tradeoff it.

Jun 25, 2011

kermit setting with USB2UART cable under VMware

1. Starting VMware, login Ubuntu 1104.
2. In VMware toolbar, in "Virtual Machine->Removeable Devices", we will see our USB2UART device "future devices ft232r usb uart", set it as connect.  We will see windows popup message that device can be safely removed. We can find the device in VMware Ubuntu "/dev/ttyUSB0"
3. Install kermit with apt-get install ckermit
4. Setup kermit parameters
$ gedit ~/.kermrc
add below words in it.

set line /dev/ttyUSB0
set speed 115200
set carrier-watch off
set handshake none
set flow-control none
set file type bin
set file name lit
set rec  pack 1000
set send pack 1000
set window 5
save and exit
5. Run kermit
$ kermit -c
Now we can see UART message from kermit console.
6. Exit kermit
Press "Ctrl+\" and type "c", it will show below messages:

C-Kermit 8.0.211, 10 Apr 2004, for Linux
 Copyright (C) 1985, 2004,
  Trustees of Columbia University in the City of New York.
Type ? or HELP for help.
(/root/) C-Kermit>
Type "exit", it will exit kermit and back to console.

Jun 22, 2011

Seiko touch panel works abnormal with DA9052 TSI driver

Customer's Android touch screen sometimes no response if draw stylus quickly

Customer use Seiko touch panel and i.MX53 quick start board.

Reproduce the issue with same environment

Got reworked i.MX53 QS board and Seiko WVGA resistance touch panel. Build LTIB 1105 for testing, select "evtest" package. Bootup board and login as root. Run "$evtest /dev/input/event1", we can see coordinate messages output when touching the panel.However, if draw stylus quickly, we will see coordinate messages stops even we move the stylus everywhere on panel. Until we pickup stylus from panel and draw again, we can see coordinate messages output again.

Root cause

After investigating, we found the problem comes from DA9052 TSI driver, one window filter function da9052_tsi_window_filter(), there is code which compare current (x,y) with previous (x,y) coordinate, if coordinate difference large than 50 pixels, diff_within_window() will return fail, and pre_raw_data will not update.
     static struct da9052_tsi_data prev_raw_data;
       ret = diff_within_window(&prev_raw_data, raw_data);
       if (!ret){
                prev_raw_data = (*raw_data);
For example If we draw stylus quickly from coordinate (100,100) to (600,100), the current (x,y) value now is(600,100), and previous (x,y) is (100,100). the ‘X’ coordinate diff will be (600-100=500), it will cause prev_raw_data not update, as static variable prev_raw_data->x is still 100. Even we keep pressing stylus in (600,100), in function
    ret = da9052_tsi_window_filter(priv, &tmp_raw_data);
    if (ret != SUCCESS)
    priv->early_data_flag = FALSE;

    if (down_interruptible(&priv->tsi_raw_fifo.lock)) {
        DA9052_DEBUG("%s: Failed to ", __FUNCTION__);
        DA9052_DEBUG("acquire RAW FIFO Lock!\n");
    priv->[priv->tsi_raw_fifo.tail] = tmp_raw_data;
From above code, we can see when da9052_tsi_window_filter() return failure, the priv->[priv->tsi_raw_fifo.tail] will not get value. So we can see the touch panel suck.


Two ways to solve the issue.
1. in “include/linux/mfd/da9052/tsi_cfg.h, the code changed like below.
-define ENABLE_WINDOW_FILTER                      1
   +define ENABLE_WINDOW_FILTER                      0
2. In "drivers/input/touchscreen/da9052_tsi_filter.c"
     static struct da9052_tsi_data prev_raw_data;
       ret = diff_within_window(&prev_raw_data, raw_data);
-       if (!ret){
                prev_raw_data = (*raw_data);

Jun 21, 2011




Jun 19, 2011

LTIB 1105 miss zlib and glibc-devel under Ubuntu 1104

We built the LTIB 1105 under Ubuntu 1104, but it reported missing zlib and glibc-devel packages.

Package Minimum ver Installed info
------- ----------- ---------------
glibc-devel 0 not installed
zlib 0 not installed
Died at ./ltib line 1397.
Started: Wed Oct 19 18:02:59 2011
Ended: Wed Oct 19 18:03:05 2011
Elapsed: 6 seconds
Build Failed

The reason is zlib path changed in Ubuntu 1104.

Open ./bin/, found zlib point to
    zlib  => sub { my @f = (glob('/usr/lib/*'),
                            glob('/lib64/*')  ); @f > 1 ? 1 : 0 },
Locate where in my Ubuntu 11.04
$ locate
So we got that locate at "/lib/x86_64-linux-gnu/", so change the code as below:
-      glob('/lib64/*')  ); @f > 1 ? 1 : 0 },
+      glob('/lib/x86_64-linux-gnu/*')  ); @f > 1 ? 1 : 0 },
Which same way, we found glibc-devel point to "". and locate at '/usr/lib/x86_64-linux-gnu/'
-'glibc-devel'    => sub { -f '/usr/lib/' || -f '/usr/lib64/'},
+'glibc-devel'    => sub { -f '/usr/lib/x86_64-linux-gnu/' || -f '/usr/lib6/x86_64-linux-gnu/'},

Jun 2, 2011

Create VMware image contains Ubuntu 11.04 64bit and Androidr10.2

Android R10.2 need 64 bit environment, we choose latest Ubuntu 11.04 64 bit.

Create 64bit VMware image

Use VMware to create to 64 bit image, it will promote that need to enable VP in PC BIOS setting. We enable VP and poweroff/poweron again, and then we get VMware 64 bit image.

Download Ubuntu 11.04 64bit version and Android r10.2

Get Ubuntu 11.04 from
Get Android r10.2 from freescale extranet.

Be a root user

$ sudo passwd
enter root user password, reboot, select "other" and then login as root.

Setup proxy

Click System->Preference->Network proxy
setup your proxy setting and apply
Click System->Administration->Synaptic Package Manager
setup proxy and apply

Install all required package

$ apt-get install rpm m4 patch bison libncurses5-dev g++ zlib1g-dev nfs-common nfs-kernel-server xinetd tftp tftpd gkermit git-core flex gperf libsdl1.2-dev libwxgtk2.6-dev build-essential curl valgrind libreadline5-dev ccache telnetd ssh samba gettext libgtk2.0-dev libdbus-glib-1-dev liborbit2-dev intltool libtool uuid-dev liblzo2-dev gparted git-doc git-email git-gui meld openbsd-inetd sun-java6-jdk pidgin-sipe pidgin g++-multilib lib32ncurses5-dev ia32-libs lib32readline5-dev lib32z-dev

Build Uboot Images

$ cd ~/myandroid/bootable/bootloader/uboot-imx
$ export ARCH=arm
$ export CROSS_COMPILE=~/myandroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-
Command to build for i.MX53 TABLET board is:
$ make distclean
$ make mx53_smd_android_config
$ make

Build Kernel Image

Assume you had already built uboot. mkimage was generated under myandroid/bootable/bootloader/uboot-imx/tools/ and it's in your PATH
$ export PATH=~/myandroid/bootable/bootloader/uboot-imx/tools:$PATH
$ cd ~/myandroid/kernel_imx
$ export ARCH=arm
$ export CROSS_COMPILE=~/myandroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
$ make imx5_android_defconfig
Generate ".config" according to default config file under arch/cd ~/arm/configs.
$ make uImage

Build Android Image

$ cd ~/myandroid
$ export ARCH=arm
$ export CROSS_COMPILE=~/myandroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
Command to build for i.MX53 TABLET board is:
$ source build/
$ lunch imx53_smd-user
$ make
"imx53_smd" is the product names (see ~/myandroid/device/fsl/product)
After build, check build_*_android.log to make sure no build error.