• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Root [HOWTO] / [GUIDE] Compile Loki_patch and execute credits to C13v3r0n3

JJ_Azevedo

Android Enthusiast
Apr 3, 2012
270
42
28
California
Okay first off this is not my guide i take no credit i just found this guide to help more devs make kernels and roms.


Credits to C13v3r0n3 for this awesome guide and djrbliss for the amazing loki patch


Heres the guide


Things you will need:
Cygwin- http://www.cygwin.com/setup.exe
ADB- Android SDK | Android Developers
Loki Patch source- https://github.com/djrbliss/loki

These are the steps i took to compile and use loki_patch.

I will assume you have the android sdk setup and ready, I will assume your SDK is under c:/AndroidSDK(this is how mine is setup)

Pulling aboot.img using adb:

You can copy cmd.exe into the folder where adb is located and run it from there so you do not have to navigate to the folder manually, or just run cmd.exe and navigate to the adb folder, for me it is c:\AndroidSDK\sdk\platform-tools.
Once you are in your adb file path and your phone is connected and in debug mode follow these instructions to pull aboot.img from your phone.
Original instructions from djrbliss here https://github.com/djrbliss/loki

dan@pc:~$ adb shell
shell@android:/ $ su
shell@android:/ # dd if=/dev/block/platform/msm_sdcc.1/by-name/aboot of=/data/local/tmp/aboot.img
shell@android:/ # chmod 644 /data/local/tmp/aboot.img
shell@android:/ # exit
shell@android:/ $ exit
dan@pc:~$ adb pull /data/local/tmp/aboot.img
3293 KB/s (2097152 bytes in 0.621s)

Now you should have the file aboot.img in the platform-tools folder(where the adb.exe file is located)
Copy this file to your desktop so you know where it is.

Installing gcc with Cygwin:

Original Instructions came from here http://www.eecg.utoronto.ca/~aamodt/ece242/cygwin.html

Step 0: Download and run the cygwin installer.
Step 1: Select “Install from Internet”
Step 2: Install to default location
Step 3: Use default local package directory (click next)
Step 4: Use whatever internet connection settings (click next)
Step 5: Select a mirror (use the one already selected, click next)
Step 6 (a): In the “Select Packages” expand “Devel”:
Step 6 (b): Select gcc, gdb, and make
Step 7: click next and follow the rest of the installation instructions.

Ok, now that gcc is installed we can compile the loki_patch source to make the executable.

Go here https://github.com/djrbliss/loki

You should see a file called loki_patch.c, click this link and it will open and you can see all the code.

Select the code from top to bottom and right click, copy.

Now right click on your desktop and select new> text file.

Open this text file and paste the code into it, go to file and save as loki_patch.c (make sure you have your file extensions turned on so you can save this as a c source and not a txt file).

We should now have a file called loki_patch.c on the desktop, keep it there for now.

Open up windows explorer and navigate to the following:

c:\cygwin\home\<username>\

(You will see a few files and a kitchen folder)

Create a new folder in here called compile.

Now, let's go back to the desktop and copy loki_patch.c and aboot.img and paste those into the compile folder you just created.

Go ahead and run cygwin.

Now we need to change directories, so let's type the following:

cd compile

We should now be in the compile folder.

Lets compile this code so we can use it, type the following command:

gcc loki_patch.c -o loki_patch

We should now have a file in the compile folder called loki_patch.exe( windows added this .exe, the file extension can be left alone or deleted)

Now you need a boot.img file to patch, grab one from a rom or kernal and copy this into the compile folder.

Once all the files are in the compile folder run the following command to patch the boot.img file:

./loki_patch boot aboot.img boot.img boot.lok

We should now have a boot.lok file in the compile folder, hope this helps and i hope i didnt leave anything out, i will try and update this with screen shots later.
 
I get how to use the loki patcher, and ive made a few boot.lok's, but can we use this and try to dirty port recoveries without destroying a phone?

Im so tired of the 2ndinit, can we make a permanent solution like actual unlocked phones have?

I thought i remembered seeing some made a loki recovery, it just wiped everything every time someone booted?
 
Upvote 0
wtf, i tried this anyway. Made a recovery.lok image from the cwm 6.x.x for the optimus l9, and flashed as per the readme, but absolutely nothing happened... booo, not even a brick!:D It said passed validation and flashing complete, but absolutely nothing changed.

correction: i think i might be missing the factory reset operation during boot. the key sequence doesnt trigger it, but that may be due to the loki kerel.
 
Upvote 0
Anyone? I think it would really help us to have a proper recovery.







wtf, i tried this anyway. Made a recovery.lok image from the cwm 6.x.x for the optimus l9, and flashed as per the readme, but absolutely nothing happened... booo, not even a brick!:D It said passed validation and flashing complete, but absolutely nothing changed.

correction: i think i might be missing the factory reset operation during boot. the key sequence doesnt trigger it, but that may be due to the loki kerel.

Missing the factory reset is bcus of that..maybe...here try this.
Turn on your phone and hold the power button and volume down at the same time. It takes a while so just keep holding it
Factory reset should come up. Just keep clicking yes(with power button) and it should take you to the CWM screen.

Remember make a backup of everything first!
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones