[HD2 Android NAND Development] wwchang:
Dexo Odex Script

For those who would like to try ODEXing on tytung's new JellyBean rom's, I have completed and tested this odexing script, self-contained tool based on 'Dexo - the Universal Odex Tool', running in a convenient Aroma installer.:cowboy:

Exclusively, I am running NativeSD installs so I have mostly tested it on NexusHD2-JellyBean-CM10 V1.0 NativeSD install only (tytung's latest V1.1 rom should work the same).:victory:

Actually, this 'Dexo ODEX Script 1.0' was purposely made self-contained and somewhat general purpose, that you may even be able to odex GingerBread rom as well as JellyBean roms, with just a few edits to the scripts.

I've included a readme.txt in the installer .zip that will generally guide you to customize for a specific rom to odex.

As it is, this stand-alone odexing tool should be able to odex any JellyBean rom, and esp. if it is in NAND-only without any NativeSD scripts to edit for the rom's NativeSD unique directory name.

**The only issue to watch out for is, that you have enough space on the NAND /system to contain the final odex state, esp. as tytung's roms tend larger.:good:

Surprisingly in actual testing on tytung's JB CM10 V1.0 rom, I got that only ~33mb total additional space was needed on /system in the final odexed state over the original deodexed - total difference.

The rom did run a bit faster, as some applications seemed to open more snappily:good: - but it is not like a 200% improvement in rom performance, maybe a few several percent better to be noticeable.

I definitely think it worthwhile but not a necessity.

The tool was made by me partly as just as a small project exercise, but it also resulted as a pretty useful tool too. Some of you who might have seen some recent previous postings on this with Xylograph may think this is his script, but actually it is not exactly.

Very assuredly, I got a 'proof of concept' of odexing from Xylograph's many 'latest-feature roms' but actually I needed a tool that could odex maybe a single file easily after having an already fully-odexed rom - eg. if I had a full-odexed rom and then wanted to change a modified SystemUI.apk and then wanted that new SystemUI.apk odexed too.

I didn't know how to do that I so I investigated Xylograph's odexing executables in his roms, and then found that they source from 'Dexo' which is like the only script-like-based odex tool out there. And when I found Dexo I just started to work from it's explanations since Xylograph implementation wasn't commented or stand-alone, and besides I already had found the sources with full explanations and examples.

Anyway, I proceeded to build the odexing tool using the Dexo original scripts from the Dexo webpage and tool .zip and customized it in an Aroma installer so options could easily be extracted for NAND install, SD-EXT install, or whatever, whatever.

For tytung's roms, some of you are using a hybrid kind of 'DataOnEXE' option I also included in the odexing tool Aroma selection, but I have not tested this option to completion.:confused:

Like I said, I am only running NativeSD nowadays, as I get very good speeds on full SD-EXT better than NAND, and have practically no /system or /data out-of-space issues any longer, or must-repartition issues, or issues with /data-to-sd scripts, etc. so I'm sticking to NativeSD. tytung's jb rom ran really responsively and well for me on NativeSD - on my ole' SanDisk 16g class 4 performs much better than even a Samsung 32g class 10 which I tried, for all the reasons in the threads, etc..

But in my odex script, I know the /directory mountings work as expected for NAND and NAND~SD-EXT hybrid / DataOnEXE even though I haven't tested these to completion, as I have for NativeSD - it's basically all the same and from testing I know these works as expected.

But from a glance at the thread, I see that many issues arising for DataOnEXE so if you are running this type of install and try this odexing tool, please don't blame me or the tool if something unexpected happens.:eek:

I have tested it quite thoroughly for NativeSD and the attached logs show good results.

__________________________

For those of you who just tried to use Xylograph's '00odex' from CMTight V1.0 startup scripts, it will not work in general for a technical reason which I later realized. I practically all worked with the original Dexo scripts as they had some explanatons, and only tried 00odex as a last try - all the scripts had problems giving a complete result.

This is a bit technical so, ...well it's just a bit technical, so skip all this if you wish.:eek:

In my first attempts with the original Dexo script, I was having difficulty getting odexing beyond just the '$BOOTCLASSPATH' main system files in /system/framework which was very frustrating, like /system/framework/framework.jar, /system/framework/framework2.jar, /system/framework/services.jar, etc. would odex, but everything else failed.

Why?!!:confused:

Finally I just read the source code for 'dexopt-wrapper', the main executable that actually effects the odexing in the Dexo tool.

The main problem is that in dexopt-wrapper.cpp, a child process is forked to actually effect the main odexing function

runDexopt( , , ), and this function needs the $BOOTCLASSPATH value which now after fork is only in the original parent process space, so you always get a 'child exited in error' in the logout, as the child is missing the $BOOTCLASSPATH value. See attached logs of http://xdaforums.com/showpost.php?p=32726713&postcount=320

The reason comes from this::cyclops:

dexopt-wrapper.cpp:

# /*

# * Fork a child process.

# */

# pid_t pid = fork(); <- dexopt-wrapper forks, and the child doesn't necessarily have the $BOOTCLASSPATH now

# if (pid == 0) {

# /* child -- drop privs */

# if (privFunc() != 0)

# exit(66);

.

# runDexopt(zipFd, odexFd, zipName); <- this executes in the child, w/o a defined $BOOTCLASSPATH

# exit(67); /* usually */

# } else {

# /* parent -- wait for child to finish */

# printf("waiting for verify+opt, pid=%d\n", (int) pid);

Anyway, if you work with shell, you're always doing 'export' on some variable to make it global, so that's what I finally did, and then the whole script worked! lol!

For Xylograph's 'odex on next boot' script 00odex, it doesn't explicitly define $BOOTCLASSPATH in the first place, but instead just explicitly lists the BOOTCLASSPATH files out, ...and nor does 00dex script 'export $BOOTCLASSPATH' anywhere as it hasn't defined it previously, so if you just try to copy it to tytung's /etc/init.d/ and push all the Dexo driver executables, and run the Dexo script that way, the overall result still won't work.

Basically you must define

'$BOOTCLASSPATH' and then export it to make it global

, and then seen by the runDexopt( , , ) in it's child process. This is the whole issue to make Dexo odex work in general.:good:

Argh!!!:mad:

So for Xylograph's CMTight 1.0 rom I think he somewhere defined and exported $BOOTCLASSPATH but it's not obviously where it was done in his rom - but in any case his 00odex works right off with the Dexo executables, giving a global $BOOTCLASSPATH to 'dexopt-wrapper.cpp' somehow, and resulting in a fully odexed rom.

So you cannot just copy over his 00odex script and expect it to work in tytung's rom for instance - you need to modify the script first, ...but even then you will only odex in a one-shot fashion if it works at all.

__________________________

Anyway, my Dexo ODEX Script 1.0 fully tested for tytung's JB V1. NativeSD is attached, as are log outputs showing the full odex rom results for a NativeSD install.:)

The Aroma installer is easy to use - just flash from recovery and follow the prompts.

A readme.txt inside the Aroma installer .zip contains further descriptions and explanations.

Suggestions:

If you are running full NAND, make sure you have enough space in /system before you attempt, and perhaps make a backup just to be safe. I tested that full odex will require ~+33mb or so for tytung's JB V1.0 and I hope this is what you will result too.:fingers-crossed:

If you are running DataOnEXE, then try on your own risk, owing that this type of install is already having some issues maybe.:confused:

If you are running full NativeSD, I have tested this enough and it seems to work well - see the attached logs.:victory:

I made this script as an exercise and benefit for myself originally, but I am freely sharing it with you - and esp. because I think tytung overwhelmingly and almost selflessly contributes to this forum, and hope to benefit him.:)

But finally too, if you find this script useful or interesting, please give me thanks, lol:);)

__________________________________________________________

EDIT (10/19): Actual installation and bootup testing for DataOnEXT:

- Partitioned NAND /system to 380mb

- Cleanly installed NexusHD2-JellyBean-CM10_V1.1.zip

- I wiped /data but it's not necessary if you want to preserve your setup.

- Did a single reboot, directly back in recovery (necessary for /system to umount completely)

..

tMous all-NAND installers will need to do this also.

- Applied attached Dexo Odex 1.0 tool from recovery.

- Rebooted Android as usual.

Results and Summary:

- The system booted and functioned as usual.

- Actual total /system size requirement, happened to be ~352 mb - originally partitioned to 380mb.

- I have 4 bad blocks on my EU hd2's NAND, but

luckily

was not affected by this

..

If you have issues with boot up bootloops after odexing, I suspect this is because of bad blocks on your NAND /system.

..perhaps try full NativeSD install in this case.

Attached: output of actual installation log for DataOnEXT case.

Dexo.Odex.1.0_output_for_DataOnEXT_tytung.JB.CM10.V1.1.txt

EDIT (10/20): For CM9 users: A specific version of the Odex Tool 1.0 has been configured and tested for CM9 rom builds,

[NIGHTLY] CyanogenMod 9 [tytung HWA R3.5] [SD/NativeSD] by c1cI0n

The tool was configured and tested successfully by gasanpride, with his usage description and d/l links:

Thanks again for gasanpride's enthusiasm and support in helping to make odex easily available to everyone.

For tytung's popular CM9 rom:

gasanpride's CM9 modification of Odex Tool 1.0 should also be directly applicable to:

NexusHD2-ICS-4.0.4-CM9-HWA V2.7 [NativeSD][tytung_HWA_r3.4]

EDIT (10/22): [NIGHTLY] CyanogenMod 9 [tytung HWA R3.5] [SD/NativeSD] by c1cI0n

c1cI0n has directly incorporated the Odex Tool 1.0 scripts in his CM9 rom's latest update.

EDIT (10/23): For CM7 users: gasanpride's has modified and tested Odex Tool 1.0 for most if not all CM7 rom:

Thanks again for gasanpride's enthusiasm and interest.

EDIT (11/07): For ParanoidAndroid enthusiasts: the PA-HD2 v2.52 - 1.x ROM by kovjanos includes an aroma installer option for applying the Dexo Odex 1.0 scripts to his new PA 2.52 rom install.

Thanks so much to kovjanos for continuing Xylograph's original unparalleled efforts for bringing the ParanoidAndroid experience to our hd2s - thanks again.

Power button / softkeys available too.

EDIT (11/19): For ParanoidAndroid enthusiasts: the PA-HD2 v2.54 - 2.x ROM by kovjanos includes an aroma installer option for applying the Dexo Odex scripts, and also to a port of the P.A.C. rom by szl.kiev.

.

.

.