[HTC ChaCha] spoutnik000:
[Q] custom mtd on chacha [please a dev (firerat) look at this]

Hi,

So I built a ChaCha specific 'recovery-v1.5.8-Beta-CustomMTD_S.chacha.zip' package and now I'll run it for real.

As I said, what I'll do is:

- reboot in recovery mode and install the 'recovery-v1.5.8-Beta-CustomMTD_S.chacha.zip' package

--> this will fail in the end, but it will extract all the necessary files to do things by hand

- reboot in fastboot mode and do operations by hand

*** [recovery mode] Installing the 'recovery-v1.5.8-Beta-CustomMTD_S.chacha.zip' package ***

The recovery I use is CWM v4.0.1.0 (original PH06img.zip thread).

install zip from sdcard > 'recovery-v1.5.8-Beta-CustomMTD_S.chacha.zip'

I get errors, as expected.

Then I reboot to fastboot mode.

*** [fastboot mode] Manual installation of 'recovery-v1.5.8-Beta-CustomMTD_S.chacha.zip' package ***

First, here is the content of the '/tmp/recovery.log' file that shows the expected errors (the same than in my first post):

~ # cd /tmp
cd /tmp
/tmp # ls
ls
recovery.log
/tmp # cat recovery.log
cat recovery.log
Starting recovery on Tue Jul 3 12:02:44 2012
can't open /dev/tty0: No such file or directory
framebuffer: fd 3 (480 x 320)
ClockworkMod Recovery v4.0.1.0
recovery filesystem table
=========================
0 /tmp ramdisk (null) (null)
1 /boot mtd boot (null)
2 /cache yaffs2 cache (null)
3 /data yaffs2 userdata (null)
4 /misc mtd misc (null)
5 /recovery mtd recovery (null)
6 /sdcard vfat /dev/block/mmcblk0p1 /dev/block/mmcblk0
7 /system yaffs2 system (null)
8 /sd-ext ext4 /dev/block/mmcblk0p2 (null)

I:Completed outputting fstab.
I:Processing arguments.
Fixing execute permissions for /cache
mtd: successfully wrote block at c3a6c00000000
I:Set boot command "boot-recovery"
I:Checking arguments.
I:device_recovery_start()
Command: "/sbin/recovery"

ro.secure=0
ro.allow.mock.location=1
ro.debuggable=1
persist.service.adb.enable=1
ro.build.id=GINGERBREAD
ro.build.display.id=full_chacha-eng 2.3.4 GINGERBREAD eng.mike.20110714.204851 test-keys
ro.build.version.incremental=eng.mike.20110714.204851
ro.build.version.sdk=10
ro.build.version.codename=REL
ro.build.version.release=2.3.4
ro.build.date=Thu Jul 14 20:49:56 CEST 2011
ro.build.date.utc=0
ro.build.type=eng
ro.build.user=mike
ro.build.host=AndroidCompiler
ro.build.tags=test-keys
ro.product.model=Full Android on Emulator
ro.product.brand=Android
ro.product.name=full_chacha
ro.product.device=chacha
ro.product.board=chacha
ro.product.cpu.abi=armeabi
ro.product.manufacturer=unknown
ro.product.locale.language=en
ro.product.locale.region=US
ro.wifi.channels=
ro.board.platform=unknown
ro.build.product=chacha
ro.build.description=full_chacha-eng 2.3.4 GINGERBREAD eng.mike.20110714.204851 test-keys
ro.build.fingerprint=Android/full_chacha/chacha:2.3.4/GINGERBREAD/eng.mike.20110714.204851:eng/test-
keys
keyguard.no_require_sim=true
ro.ril.hsxpa=1
ro.ril.gprsclass=10
ro.config.notification_sound=OnTheHunt.ogg
ro.config.alarm_alert=Alarm_Classic.ogg
ro.kernel.android.checkjni=1
ro.setupwizard.mode=OPTIONAL
net.bt.name=Android
net.change=net.bt.name
dalvik.vm.stack-trace-file=/data/anr/traces.txt
ro.factorytest=0
ro.serialno=HT15XV403307
ro.bootmode=recovery
ro.baseband=7.51.35.19
ro.carrier=HTC-FRA
ro.bootloader=1.10.0000
ro.hardware=chacha
ro.revision=128
init.svc.recovery=running
init.svc.adbd=running

I:Checking for extendedcommand...
I:Skipping execution of extendedcommand, file not found...
mtd: successfully wrote block at c3a6c00000000
I:Set boot command ""
mtd: successfully wrote block at c3a6c00000000
I:Set boot command ""

-- Installing: /sdcard/recovery-v1.5.8-Beta-CustomMTD_S.chacha.zip
mtd: successfully wrote block at c3a6c00000000
I:Set boot command "boot-recovery"
Finding update package...
I:Update location: /sdcard/recovery-v1.5.8-Beta-CustomMTD_S.chacha.zip
Opening update package...
Installing update...
CustomMTD Patcher v1.5.8-Betaabout to run program [/tmp/patchbootimg.sh] with 2 args

2344
16
Recovery Mode
Extracting Patch Tools...
BOARD_KERNEL_CMDLINE no_console_suspend=1 console=null
BOARD_KERNEL_BASE 12c00000
mtd: erase failure at 0x00000000
mtd: erase failure at 0x00040000
mtd: erase failure at 0x00080000
mtd: erase failure at 0x000c0000
mtd: erase failure at 0x00100000
mtd: erase failure at 0x00140000
mtd: erase failure at 0x00180000
mtd: erase failure at 0x001c0000
mtd: erase failure at 0x00200000
mtd: erase failure at 0x00240000
mtd: erase failure at 0x00280000
mtd: erase failure at 0x002c0000
mtd: erase failure at 0x00300000
mtd: erase failure at 0x00340000
mtd: erase failure at 0x00380000
mtd: erase failure at 0x003c0000
mtd: erase failure at 0x00400000
mtd: erase failure at 0x00440000
mtd: erase failure at 0x00480000
mtd: erase failure at 0x004c0000
mtd: erase failure at 0x00000000 (I/O error)
mtd: erase failure at 0x00000000 (I/O error)
mtd: skipping write block at 0x00000000
mtd: erase failure at 0x00040000 (I/O error)
mtd: erase failure at 0x00040000 (I/O error)
mtd: skipping write block at 0x00040000
mtd: erase failure at 0x00080000 (I/O error)
mtd: erase failure at 0x00080000 (I/O error)
mtd: skipping write block at 0x00080000
mtd: erase failure at 0x000c0000 (I/O error)
mtd: erase failure at 0x000c0000 (I/O error)
mtd: skipping write block at 0x000c0000
mtd: erase failure at 0x00100000 (I/O error)
mtd: erase failure at 0x00100000 (I/O error)
mtd: skipping write block at 0x00100000
mtd: erase failure at 0x00140000 (I/O error)
mtd: erase failure at 0x00140000 (I/O error)
mtd: skipping write block at 0x00140000
mtd: erase failure at 0x00180000 (I/O error)
mtd: erase failure at 0x00180000 (I/O error)
mtd: skipping write block at 0x00180000
mtd: erase failure at 0x001c0000 (I/O error)
mtd: erase failure at 0x001c0000 (I/O error)
mtd: skipping write block at 0x001c0000
mtd: erase failure at 0x00200000 (I/O error)
mtd: erase failure at 0x00200000 (I/O error)
mtd: skipping write block at 0x00200000
mtd: erase failure at 0x00240000 (I/O error)
mtd: erase failure at 0x00240000 (I/O error)
mtd: skipping write block at 0x00240000
mtd: erase failure at 0x00280000 (I/O error)
mtd: erase failure at 0x00280000 (I/O error)
mtd: skipping write block at 0x00280000
mtd: erase failure at 0x002c0000 (I/O error)
mtd: erase failure at 0x002c0000 (I/O error)
mtd: skipping write block at 0x002c0000
mtd: erase failure at 0x00300000 (I/O error)
mtd: erase failure at 0x00300000 (I/O error)
mtd: skipping write block at 0x00300000
mtd: erase failure at 0x00340000 (I/O error)
mtd: erase failure at 0x00340000 (I/O error)
mtd: skipping write block at 0x00340000
mtd: erase failure at 0x00380000 (I/O error)
mtd: erase failure at 0x00380000 (I/O error)
mtd: skipping write block at 0x00380000
mtd: erase failure at 0x003c0000 (I/O error)
mtd: erase failure at 0x003c0000 (I/O error)
mtd: skipping write block at 0x003c0000
mtd: erase failure at 0x00400000 (I/O error)
mtd: erase failure at 0x00400000 (I/O error)
mtd: skipping write block at 0x00400000
mtd: erase failure at 0x00440000 (I/O error)
mtd: erase failure at 0x00440000 (I/O error)
mtd: skipping write block at 0x00440000
mtd: erase failure at 0x00480000 (I/O error)
mtd: erase failure at 0x00480000 (I/O error)
mtd: skipping write block at 0x00480000
mtd: erase failure at 0x004c0000 (I/O error)
mtd: erase failure at 0x004c0000 (I/O error)
mtd: skipping write block at 0x004c0000
failed with error: -1
flashing recovery from /tmp/recovery.img
error writing recoveryrun_program: child exited with status 255
script result was [to take effect]
minzip: Extracted file "/tmp/mkbootimg"
minzip: Extracted file "/tmp/patchbootimg.sh"
minzip: Extracted file "/tmp/unpackbootimg"
Custom MTD written
Please wipe system,cache & data
& reboot to recovery for changes
to take effect

Install from sdcard complete.

And now, here are the manual steps to install by hand the 'recovery-v1.5.8-Beta-CustomMTD_S.chacha.zip' package:

Here is the content of the '/tmp' folder:

/tmp # ls
ls
mkbootimg recovery.img-cmdline unpackbootimg
patchbootimg.sh recovery.img-ramdisk.gz update_binary
recovery.img recovery.img-zImage
recovery.img-base recovery.log

Let's clean-up the formerly generated 'recovery.img' file:

/tmp # rm recovery.img
rm recovery.img

Now let's dump the recovery again and name it 'recovery_original.img' (and backup it to sdcard):

/tmp # dump_image recovery /tmp/recovery.img
dump_image recovery /tmp/recovery.img
/tmp # cp recovery.img recovery_original.img
cp recovery.img recovery_original.img
/tmp # cp recovery_original.img /sdcard/recovery_original.img
cp recovery_original.img /sdcard/recovery_original.img
/tmp # rm recovery.img
rm recovery.img

Now let's unpack the 'recovery_original.img' in order to repack it with modified command line afterwards:

/tmp # /tmp/unpackbootimg /tmp/recovery_original.img /tmp/
/tmp/unpackbootimg /tmp/recovery_original.img /tmp/
BOARD_KERNEL_CMDLINE no_console_suspend=1 console=null
BOARD_KERNEL_BASE 12c00000

Now is the IMPORTANT part, which is repacking with the correct kernel command line.

In our case, the kernel command line we want (as explained in my previous post) is the same as the original one + the new 'mtdparts' addition:

msm_nand:102
4K@0x00001FF00000(misc),5120K@0x000002FC0000(recovery),3328K@0x0000034C0000(boot),153600K@0x00001690
0000(userdata),10240K@0x000015F00000(devlog),300032K@0x0x000003800000(system),2048K@0x000015D00000(c
ache)

Here is the command:

/tmp # /tmp/mkbootimg --kernel /tmp/recovery_original.img-zImage --ramdisk /tmp/recovery_original.im
g-ramdisk.gz -o /tmp/recovery.img --cmdline "no_console_suspend=1 console=null mtdparts=msm_nand:102
4K@0x00001FF00000(misc),5120K@0x000002FC0000(recovery),3328K@0x0000034C0000(boot),153600K@0x00001690
0000(userdata),10240K@0x000015F00000(devlog),300032K@0x0x000003800000(system),2048K@0x000015D00000(c
ache)" --base 12c00000
/tmp/mkbootimg --kernel /tmp/recovery_original.img-zImage --ramdisk /tmp/
recovery_original.img-ramdisk.gz -o /tmp/recovery.img --cmdline "no_console_susp
end=1 console=null mtdparts=msm_nand:1024K@0x00001FF00000(misc),5120K@0x000002FC
0000(recovery),3328K@0x0000034C0000(boot),153600K@0x000016900000(userdata),10240
K@0x000015F00000(devlog),300032K@0x0x000003800000(system),2048K@0x000015D00000(c
ache)" --base 12c00000

This has repacked a 'recovery.img' file.

Let's name it 'recovery_modified.img' and copy it as well to sdcard:

/tmp # cp recovery.img recovery_modified.img
cp recovery.img recovery_modified.img
/tmp # cp recovery_modified.img /sdcard/recovery_modified.img
cp recovery_modified.img /sdcard/recovery_modified.img

Now let's unpack the 'recovery_modified.img' in order to check the BOARD_KERNEL_CMDLINE part:

/tmp/unpackbootimg /tmp/recovery_modified.img /tmp/
BOARD_KERNEL_CMDLINE no_console_suspend=1 console=null mtdparts=msm_nand:1024K@0x00001FF00000(misc),
5120K@0x000002FC0000(recovery),3328K@0x0000034C0000(boot),153600K@0x000016900000(userdata),10240K@0x
000015F00000(devlog),300032K@0x0x000003800000(system),2048K@0x000015D00000(cache)
BOARD_KERNEL_BASE 12c00000

This looks coherent with what I want to do.

Now I mount USB to copy the 'recovery_modified.img' in my android sdk tools folder ('D:\android-sdk-windows\tools\recovery_cMTD.img').

Then I'll flash this modified recovery with a "fastboot flash" command.

D:\android-sdk-windows\tools>adb reboot bootloader

D:\android-sdk-windows\tools>fastboot flash recovery recovery_cMTD.img
sending 'recovery' (3664 KB)...
OKAY [ 2.797s]
writing 'recovery'...
OKAY [ 3.266s]
finished. total time: 6.063s

The flashing process was a success, which is good.

Then I'll boot to recovery to see if this works.

In bootloader mode, I choose RECOVERY

--> THE RECOVERY DOES NOT BOOT !!!!! (stays frozen on green HTC banner...)

Argh........ the recovery does not boot...

And fortunately, when I reflash the original (CWM) recovery, I can boot to recovery.

So my question now is:

Why does the modified recovery does not boot??????

I compared (hexadecimal compare) the 'recovery_original.img' and the 'recovery_modified.img' files, and really the only difference in it is the command line part.

The file are exactly the same byte size.

And they are identical, except at offset 0x61 where:

the 'recovery_modified.img' file contains the following bytes:

[hexa]

206D746470617274733D6D736D5F6E616E643A313032344B403078303030303146463030303030286D697363292C353132304B403078303030303032464330303030287265636F76657279292C333332384B40307830303030303334433030303028626F6F74292C31303234304B403078303030303135463030303030286465766C6F67292C3239363936306B4030783030303030333830303030302873797374656D292C353132306B4030783135413030303030286361636865292C3136333834306B403078313546303030303028757365726461746129

[ascii]

mtdparts=msm_nand:1024K@0x00001FF00000(misc),5120K@0x000002FC0000(recovery),3328K@0x0000034C0000(boot),10240K@0x000015F00000(devlog),296960k@0x000003800000(system),5120k@0x15A00000(cache),163840k@0x15F00000(userdata)

whereas the the 'recovery_original.img' file contains 0x00 bytes (same number)...

So my question really is:

Why does the modified recovery does not boot??????

spoutnik