dimanche 4 novembre 2012

Creating a dd-able image (Mele_4.0_V1.3BETA_revised_en_us_4.img.bz2)


I saw the lundman method (see conversation: http://ibot.rikers.org/%23arm-netbook/20120702.html.gz, 03:01.59):
- dd if=/dev/zero of=/dev/sdx bs=4096 count=128000 #an image does not exceed 512MB, and I take 4096 as blocksize for read/write flash speedup.
- flash the firmware on the sdcard using PhoenixCard,
- using fdisk -l /dev/sdx you know the FAT partition begin, and as as consequence, the hidden partition end.
- hexdump the /dev/sdx -s <at supposed end of last partition>, see when it gets some zero, you have the real end of the flash image.
Example, on Mele_4.0_V1.3BETA_revised_en_us_4.img
Result: Mele_4.0_V1.3BETA_revised_en_us_4.ddimg.bz2
I flashed my firmware on my sdcard, that is shown as /dev/sdb.

fdisk -l /dev/sdb shows (I have a 2GB  SDCard):

Disk /dev/sdb: 1967 MB, 1967128576 bytes
1 heads, 62 sectors/track, 61968 cylinders, total 3842048 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *      695166     3839998     1572416+   b  W95 FAT32

Start of the visible partition is at 695166 sector # (means at 695166*512=355924992 bytes):

xxd -a -skip 355924992 /dev/sdb
1536fc00:eb3c 904d 5344 4f53 352e 3000 0208 2000  .<.MSDOS5.0... .
1536fc10:0200 0000 00f0 0000 0000 0000 0000 0000  ................
1536fc20:81fc 2f00 fd0b 0000 0000 0000 0200 0000  ../.............
1536fc30:0100 0600 0000 0000 0000 0000 0000 0000  ................
1536fc40:8000 296f 0000 0020 2020 2020 2020 2020  ..)o...         
1536fc50:2020 4641 5433 3220 2020 0000 0000 0000    FAT32   ......
1536fc60:0000 0000 0000 0000 0000 0000 0000 0000  ................
*
1536fdf0:0000 0000 0000 0000 0000 0000 0000 55aa  ..............U.
1536fe00:0000 0000 0000 0000 0000 0000 0000 0000  ................
*
15373c00:f8ff ffff ffff ffff ffff ff0f 0000 0000  ................
15373c10:0000 0000 0000 0000 0000 0000 0000 0000  ................
*
154f3600:f8ff ffff ffff ffff 0000 0000 0000 0000  ................
154f3610:0000 0000 0000 0000 0000 0000 0000 0000  ................
*
15673000:2020 2020 2020 2020 2020 2008 d0da e18c             .....
15673010:6441 6441 0000 e18c 6441 0000 0000 0000  dAdA....dA......
15673020:0000 0000 0000 0000 0000 0000 0000 0000  ................
*
1576fc00:f8ff ffff ffff ff0f ffff ff0f 0000 0000  ................
1576fc10:0000 0000 0000 0000 0000 0000 0000 0000  ................
*
15943600:f8ff ffff ffff ff0f ffff ff0f 0000 0000  ................
15943610:0000 0000 0000 0000 0000 0000 0000 0000  ................
*
15b17000:2020 2020 2020 2020 2020 2008 0000 0000             .....
15b17010:0000 0000 0000 0000 0000 0000 0000 0000  ................
... and nothing more until a little time.

Remember: I zeroed 4096*128000 bytes, I must find out the end, where there are many zeroes until this limit (4096*128000=0x1f400000).
In this case: 0x15b17010 seems to be the end of my FAT32 partition.

So you can suppose that the end of image (including the fat32 partitions) is at 0x15b17010.
0x15b17010 makes in decimal: 88856 blocks of 4096 bytes (rounded up).

dd if=/dev/sdb bs=4096 count=88856 |bzip2 -9 > Mele_4.0_V1.3BETA_revised_en_us_4.ddimg.bz2
The resulting file is a compressed dd-able image.

To write this dd-able image, you can perform:
bzip2 -cd Mele_4.0_V1.3BETA_revised_en_us_4.ddimg.bz2|dd of=/dev/sdx bs=4096


Mele_HTPC_0929_BETA_V1.3 Revised version: en_US v4

Another release that fixes the "reboot never ends" bug after having launched Google Play:
Mele_4.0_V1.3BETA_revised_en_us_4.img

On 4shared:
Mele_4.0_V1.3BETA_revised_en_us_4.img(4shared)
Mele_4.0_V1.3BETA_revised_en_us_4.ddimg.bz2(4shared)


Edit: md5sum=70aee0c6ae9c375e72d3f87bed594ef0  Mele_4.0_V1.3BETA_revised_en_us_4.img 
        dd-able image: Mele_4.0_V1.3BETA_revised_en_us_4.ddimg.bz2
        md5sum=ea14dab60e131feac04f20a7947291e9  Mele_4.0_V1.3BETA_revised_en_us_4.ddimg.bz2

Precision: this release disables the Google Play updates automatically (via a /etc/init.d/ script), that makes the bug occur. You don't need to perform the steps mentioned hereafter if you take it.

I hope this will be the last under Android 4.0 (next will be 4.1 JellyBean when Mele decides to release it).
After many tries (copy Vending.apk from old firmware, revert all /system/app and /system/framework, ...), nothing solved the "reboot never ends" issue.

Then I had the idea to revert the Market update (go to Paremeters->Applications->All->"Google Play"->"Uninstall updates".
And yes, it works. The Market update is what makes the system fail.

So the solution is to disable the Market update definitely. I don't know the consequences on a long term period, but for this release, no more "reboot never ends" issue.
In order to disable the Market update, see this thread: (How-to) prevent Android Market app from updating itself, that says:

Do "uninstall updates" on the market app (in "manage applications").
Open the terminal app.
Run "su" to become root.
Run: touch /data/app/com.android.vending-1.apk
Run: chattr +i /data/app/com.android.vending-1.apk

You can perform only "uninstall updates" step, but you will have to do that at each reboot.

In the above image, there is a init.d script that performs the required touch+chattr operations automatically.
I also removed the last Chinese application (sorry for them).

Note for Chinese people: this fix should apply on the Chinese firmware, but you have to add these lines in the init.rc script (on post-fs-data) since there is no init.d system in the original firmware.

dimanche 28 octobre 2012

Mele_HTPC_0929_BETA_V1.3 Revised version: en_US v3

Here is a new firmware version:
Mele_4.0_V1.3BETA_revised_en_us_3.img
What is fixed:
- fixed the reboot bug. Many thanks to tuscanman from the Russian forum 4pda.ru that gave the solution. Google Market did not get the right permissions, fix inside android.policy.jar: http://4pda.ru/forum/index.php?showtopic=342683&st=1420
- added the xpad.ko kernel module (/system/vendor/modules/xpad.ko, http://melea1000.blogspot.co.uk/2012/08/xbox-360-controller-errors.html )
- added the /etc/init.d/ facility. At boot, all scripts inside this directory will be called. This allows the user to run custom commands at boot (look at the script 99test that writes a test file at boot). You can add commands in this script or clone it to add some other commands (like insmod /system/vendor/modules/xpad.ko)
- called mksh where busybox sh is not really necessary in startup scripts. Abuse of busybox eats memory, well this gives minor effect.

Edit: the reboot bug stilll persist, I still get a system hang at reboot... sadly.
Edit(2): I just saw that on the serial console you have a login. Here is the logcat output, need to analyse it now...: logcat_reboot_fail.log

lundi 22 octobre 2012

Mele_HTPC_0929_BETA_V1.3 Revised version: en_US [again]

To be short, don't use the firmware in my previous post, generated a firmware from the update.zip provided on this site: http://bbs.mele.cn/showtopic-1102.aspx
Use this one:
Mele_4.0_V1.3BETA_revised_en_us_2.img
The reboot bug is still present (reboot never ends). Here is a typical console log: minicom_fail.cap

For the long story:
The previous firmware was buggy:
Mele_HTPC_0929_BETA_V1.3 Revised version: en_US is easy
Bugs:
1/ Going back from sleep mode, with F10 remote plugged-in, CPU consumption gets to 100% due to system_server.
The root cause is an additional library (that was not present in firmware 1.1), that adds some event capabilities to the F10 remote. But adds so many spurious events that it makes the system behave slowly.
The events can be seen doing "adb logcat".
Example:

D/Sensors ( 155): Sensor data: t x,y,z: 0.000000 0.000000, 0.000000, 0.000000
D/Sensors ( 155): Sensor data: t x,y,z: 3387016.000001 0.000000, 0.000000, 0.000000
...
I/EventHub( 155): Removing device '/dev/input/js0' due to inotify event
I/EventHub( 155): Removing device '/dev/input/event4' due to inotify event

The additional library is: /system/lib/hw/sensors.exDroid.so

2/ Some users burned this firmware, but it does not go further than the boot animation step.
I experienced this issue, but not at first boot (after several installs).
On the serial console you can see the consequence of this bug (I did not record the logs but should look like this):
init: waitpid returned pid 139, status = 00000009
init: process 'netd', pid 139 exited
init: process 'media', pid 140 exited
... in a loop.
It comes most probably from memory shortage at start. When memory is needed, Android kills background processes. But if background processes are essential to the system start... it fails.

As a consequence, in this _2 firmware image:
1/ renamed /system/lib/hw/sensors.exDroid.so into /system/lib/hw/sensors.exDroid.so_deactivated so that the system does not load it
2/ busybox is relatively huge:

size system/bin/busybox
   text   data    bss    dec    hex filename
1457781   2496  18304 1478581 168fb5 system/bin/busybox

compared to toolbox:

size system/bin/toolbox
   text    data     bss     dec     hex filename
  90234    7552   21348  119134   1d15e system/bin/toolbox
and mksh:

size system/bin/mksh
   text   data    bss    dec    hex filename
 143144   3184  19572 165900  2880c system/bin/mksh



So I re-applied the "toolbox" symlinks to minimize the busybox impacts,and replaced
/system/bin/sh -> busybox
by
/system/bin/sh -> mksh
Also, I replaced in /system/bin/preinstall.sh the shell:
#!/system/bin/busybox sh
by
#!/system/bin/sh
so that it loads mksh instead of busybox (for just a if [ ] then elif, should be sufficient).

Hope it works...

lundi 15 octobre 2012

Mele_HTPC_0929_BETA_V1.3 Revised version: en_US is easy

The 1.3 beta revised version (http://tmerle.blogspot.fr/2012/10/melehtpc0929betav13-revised-version.html) comes as an update.
It contains the original launcher as expected (at start, you have the choice in the launcher), with Google Play, and busybox commands are symlinked.

Edit: here is the equivalent PhoenixCard image, customized in en_US:
Mele_4.0_V1.3BETA_revised_en_us.img
Edit(2): Look at my updated firmware, fixing the CPU hog bug: http://tmerle.blogspot.fr/2012/10/melehtpc0929betav13-revised-version_22.html

Since this is an update.zip, no more PhoenixCard flashing process is needed, just a vfat formatted sdcard as a base media is sufficient.

From the archive, put on your sdcard:
- MeleTool.apk
- recovery.img (this is a CWM recovery image with Mele F10 recognition)
- bootloader.img (choose your flavor depending on the desired output VGA, HDMI,...)
- update.zip
You can edit system/build.prop in update.zip at your convenience. For example, you can setup the updated system in en_US directly.
So my customization is only a modified build.prop that you can put into update.zip (be careful to put it in system/)

Insert the SDCard in the device, install MeleTool.apk
Then launch the MeleTool.
Choose the option #4 talking about "Recovery" (wait a little so that the recovery img is written in nandg flash)
Choose the option #5 talking about "bootloader", the device will reboot after having written down in flash the nanda bootloader.
At this stage the device is stuck since it tries to boot on SD, remove SD, remove power, put power.
You should enter into CWM recovery. Insert again the SD.
Choose "apply sdcard:update.zip" (wipe data/cache before if needed)
After that, reboot and you are done.

dimanche 14 octobre 2012

Mele_HTPC_0929_BETA_V1.3 Revised version

Another version of the V1.3 Beta release:
http://bbs.mele.cn/showtopic-1102.aspx
Direct link to firmware: Mele_HTPC_0929_BETA_V1.3 Revised version
With a new package: Mele tools: http://bbs.mele.cn/attachment.aspx?attachmentid=1525
This application enables in order:
- shutdown,
- reboot in normal mode,
- reboot in recovery mode,
- write recovery img from SDCard
- write bootloader.img from SDCard
- go on the weibo site (don't know what for)

I found here: http://www.hdpfans.com/thread-156730-1-1.html some explanations about this newest firmware modifications, seems to be rebased on the V1.1 version instead of the V1.2 version, and based on the v1.1 launcher.

I experienced system latencies with the previous v1.3 beta and now it refuses to boot.
Downloading to see if it works better...

jeudi 11 octobre 2012

Mele Android 4.0.4 ICS firmware v1.3 en_US customized

New Mele firmware: http://www.slatedroid.com/topic/36614-mele-a1000a2000-install-cwm-cm9aokp-all-mods/page__view__findpost__p__437531
Its name is Mele_HTPC_0929_BETA_V1.3.rar
but the changelog does not show many improvements...

Nevertheless I customized this one here: Mele_4.0_V1.3BETA_custom_en_us_apex.img

I made the same customizations:
- replacing the stock /system/app/Launcher2.apk by ApexLauncher
- removing /system/app/Mele_Launcher.apk
- adding /system/app/Vending.apk (Google Play)
- removing preinstalled applications (7StationGame_v1.1.15_DXsigned.apk 360buy_TV_v1.0.1_meleTV.apk Googlepinyin.apk MELE4.0_wasu_1.0.0.6_0906.apk QQ_1.9.1.apk VoolePlayV1.0SP4_mailea10_20251.apk AdobeFlashPlayer11.1.112.60.apk)
- adding service.adb.tcp.port=5555 in build.prop
- adding Andrew patch 1.0.apk 

This time I managed to preinstall these things automatically at first start. A script named /system/bin/preinstall.sh is here to perform that, I just patched it in order to load packages from /system/preinstall/ instead of /sdcard/preinstall.