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
-#define CONFIG_FSL_ENV_IN_MMC
+#define CONFIG_FSL_ENV_IN_SATA 

+#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
CONFIG_ATA=y
CONFIG_ATA_VERBOSE_ERROR=y
CONFIG_SATA_AHCI_PLATFORM=y
CONFIG_ATA_SFF=y

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 mksdcard-android.sh /dev/mmcblk0"> Partitioning...
+"push" body="$ sh mksdcard-android.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.

存理克欲(六)

孟子曰:“雞鳴而起,孳孳(zi资)為善者,舜之徒也。雞鳴而起,孳孳為利者,蹠之徒也。欲知舜與蹠之分,無他,利與善之閒也。” 

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/com.android.providers.settings/databases/settings.db
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/PowerManagerService.java”, 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)
{
    case SCREEN_BRIGHT:
        when = now + mKeylightDelay;
        break;
    case SCREEN_DIM:
        if (mDimDelay >= 0) {
            when = now + mDimDelay;
            break;
        } else {
            Slog.w(TAG, "mDimDelay=" + mDimDelay + " while trying to dim");
        }
    case SCREEN_OFF:
        synchronized (mLocks) {
            when = now + mScreenOffDelay;
        }
        break;
    default:
        when = now;
        break;
    }
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
robust
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.
da9052_tsi_window_filter()
{
     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
da9052_tsi_process_reg_data()
{
…
# if (ENABLE_WINDOW_FILTER)
    ret = da9052_tsi_window_filter(priv, &tmp_raw_data);
    if (ret != SUCCESS)
        continue;
#endif
    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");
        up(&priv->tsi_reg_fifo.lock);
        return;
    }
    priv->tsi_raw_fifo.data[priv->tsi_raw_fifo.tail] = tmp_raw_data;
    incr_with_wrap_raw_fifo(priv->tsi_raw_fifo.tail);
    up(&priv->tsi_raw_fifo.lock);
…
}
From above code, we can see when da9052_tsi_window_filter() return failure, the priv->tsi_raw_fifo.data[priv->tsi_raw_fifo.tail] will not get value. So we can see the touch panel suck.

Solution

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"
da9052_tsi_window_filter()
{
     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

存理克欲(五)

宋牼(keng)将之楚,孟子过于石丘,曰:“先生将何之?”曰:“吾闻秦、楚构兵,我将见楚王,说而罢之;楚王不悦,我将见秦王,说而罢之。二王我将有所遇焉。”
曰:“轲也请无问其详,愿闻其指。说之将何如?”曰:“我将言其不利也。”
曰:“先生之志则大矣,先生之号则不可。先生以利说秦、楚之王,秦、楚之王悦于利,以罢三军之师,是三军之士乐罢而悦于利也。为人臣者,怀利以事其君;为人子者,怀利以事其父;为人弟者,怀利以事其兄;是君臣、父子、兄弟终去仁义,怀利以相接;然而不亡者,未之有也。
先生以仁义说秦、楚之王,秦、楚之王悦于仁义,而罢三军之师;是三军之士乐罢而悦于仁义也。为人臣者,怀仁义以事其君;为人子者,怀仁义以事其父;为人弟者,怀仁义以事其兄;是君臣、父子、兄弟去利,怀仁义以相接也;然而不王者,未之有也。何必曰利?”(《告子》下·四)

语译:
宋牼将要到楚国去,孟子在石丘遇到他,问说:先生要去哪儿?宋牼说:我听说秦国和楚国要打仗,我将见楚王游说他,希望他能停止战争;如果楚王不喜欢听,那么我就会见秦王,游说他,希望他能停止战争。在两个国君之中,总有一个和我意见相合的。
  孟子说:我不想知道详细的情况,只想知道您的大意。您打算怎么去说服他们?宋牼说:我告诉他们,打仗是不利的。
  孟子说:先生的志向很伟大,但是先生的号召却是行不通的。先生以利来说服秦,楚之王,秦,楚之王为了贪利而不出动军队,这就使三军官士都乐于罢兵,因此喜爱图利。做臣子的,怀抱着图利心去服事君主;做儿子的,怀抱着图利心去服事父亲;做弟弟的,怀抱着图利心去服事哥哥;那么君臣,父子,兄弟之间就会抛弃仁义,存着图利的念头来互相交往,这样而能不灭亡,那是不可能的事。
  先生如果能以仁义去说服秦,楚之王,秦楚之王为了仁义而不出动军队,这就使三军官士都乐于罢兵,因此喜爱仁义。做臣子的,怀抱着仁义去服事君主;做儿子的,怀抱着仁义服事父亲;做弟弟的,怀抱着仁义去服事哥哥;那么君臣,父子,兄弟之间就会抛弃图利心,存着仁义的念头来互相交往;这样却还不能完成王业,那也是不可能的事。先生为什么一定要说利呢?
析论:
  何必曰利?不以私利为利,而以仁义为利,是合于孟子的仁义思想的阐发。

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.
traceback:
main::host_checks:1397
main:542
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/Ltibutils.pm, found zlib point to libz.so.
    zlib  => sub { my @f = (glob('/usr/lib/libz.so*'),
                            glob('/lib/libz.so*'),
                            glob('/lib64/libz.so*')  ); @f > 1 ? 1 : 0 },
Locate where libz.so in my Ubuntu 11.04
$ locate libz.so
/lib/x86_64-linux-gnu/libz.so.1
/lib/x86_64-linux-gnu/libz.so.1.2.3.4
/usr/lib/vmware-tools/lib32/libz.so.1
/usr/lib/vmware-tools/lib32/libz.so.1/libz.so.1
/usr/lib/vmware-tools/lib64/libz.so.1
/usr/lib/vmware-tools/lib64/libz.so.1/libz.so.1
/usr/lib/x86_64-linux-gnu/libz.so
/usr/lib32/libz.so
/usr/lib32/libz.so.1
/usr/lib32/libz.so.1.2.3.4
So we got that libz.so locate at "/lib/x86_64-linux-gnu/libz.so.1", so change the code as below:
-      glob('/lib64/libz.so*')  ); @f > 1 ? 1 : 0 },
+      glob('/lib/x86_64-linux-gnu/libz.so*')  ); @f > 1 ? 1 : 0 },
Which same way, we found glibc-devel point to "libm.so". and libm.so locate at '/usr/lib/x86_64-linux-gnu/libm.so'
-'glibc-devel'    => sub { -f '/usr/lib/libm.so' || -f '/usr/lib64/libz.so'},
+'glibc-devel'    => sub { -f '/usr/lib/x86_64-linux-gnu/libm.so' || -f '/usr/lib6/x86_64-linux-gnu/libz.so'},

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 http://www.ubuntu.com/download/ubuntu/download
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/envsetup.sh
$ 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.