[RECOVERY/MOD] TWRP 2.6.3.0+ with externally-powered USB-OTG support [2013-10-05]

zman0900

Senior Member
Jan 20, 2010
277
230
0
Columbus, OH
I have built a flashable zip to replace the kernel in your recovery image with one that supports USB-OTG. I have repacked the TWRP 2.6.0.0 recovery image with a different kernel that enables the use of USB-OTG when booted to recovery. The kernel is taken from Ziddey's patch for externally powered usb-otg and is a modified version of Franko's kernel. See that thread for more info on the kernel. (Note that this won't change the kernel used in your rom, only within TWRP).

Currently, TWRP is the only recovery I know of that supports USB-OTG. So while you can probably run this without problems on other recoveries, it like won't do anything useful either.

I didn't actually develop anything here other than the script in the zip. I just used unpackbootimg to extract the kernel from ziddey's boot.img and extract the ramdisk from twrp's recovery.img the recovery installed on your phone, then build a new recovery image using those parts with mkbootimg.

This will not work with a standard, unpowered OTG cable!
Try this at your own risk. It works for me, but I am not responsible if anything goes wrong.



Requirements
  • An unlocked Nexus 4 (with TWRP installed)
  • A USB OTG Y-cable. It should have a female regular USB, and both female and male micro-USB.
  • Flash Drive (As of TWRP 2.6.3.0, FAT, exFat, and ext4 format worked, ntfs and f2fs didn't)
  • Micro-USB power source (charger, battery, tiny gasoline generator, solar panels, finely tuned potatoes, etc)

Changes
  • 2013-10-05
    • Complete rebuild to do the work of replacing the kernel on your phone so I don't have to update every time TWRP does.
    • Updated to Ziddey's kernel 2013.10.01 1954ET r188 for JSS/JLS
  • 2013-09-19
    • Original release

Installation (zip method)
  1. Download the zip file to your phone
  2. Boot into your phone's recovery (CWM / TWRP)
  3. Flash the zip
  4. Reboot to recovery
  5. Repeat these steps after upgrading your recovery image.

Use
  1. Boot into recovery
  2. Connect flash drive and charger to OTG Y-cable.
  3. Connect Y-cable to phone.
  4. You should now be about to mount USB-OTG, select it for backup/restore, browse it with file manager, etc

Downloads
usbotg-replace-recovery-kernel-20131005.zip - 5.71 MB

Old Downloads
openrecovery-twrp-2.6.0.0-mako-usbotg.img - 7.11 MB
openrecovery-twrp-2.6.0.0-mako-usbotg.zip - 7.24 MB

Thanks
Ziddey - For his modifications to the kernel that made this possible (see thread linked above)
TeamWin - For TWRP recovery
Franko - For his kernel
Fkrone - For his flashable zip for CWM Recovery that I based mine off of
Koush - For his AnyKernel updater. I used it as an example and for the binaries.


See Also
If you want to or are already using Ziddey's method to enable USB-OTG in your rom, he has made a flashable zip that will copy the kernel installed for your rom to your recovery. See Post #13 for more info and to download.
 
Last edited:

nikkpap

Senior Member
Jan 6, 2007
463
82
0
Thessaloniki
www.techmesh.co
I have repacked the TWRP 2.6.0.0 recovery image with a different kernel that enables the use of USB-OTG when booted to recovery. The kernel is taken from Ziddey's patch for externally powered usb-otg and is a modified version of Franko's kernel. See that thread for more info on the kernel. (Note that this won't change the kernel used in your rom, only within TWRP)

I didn't actually develop anything here. I just used unpackbootimg to extract the kernel from ziddey's boot.img and extract the ramdisk from twrp's recovery.img, then built a new recovery image using those parts with mkbootimg.

This will not work with a standard, unpowered OTG cable!
Try this at your own risk. It works for me, but I am not responsible if anything goes wrong.



Requirements
  • An unlocked Nexus 4
  • A USB OTG Y-cable. It should have a female regular USB, and both female and male micro-USB.
  • Flash Drive (FAT and ext4 format tested, others may work)
  • Micro-USB power source (charger, battery, tiny gasoline generator, solar panels, finely tuned potatoes, etc)

Installation (fastboot method)
  1. Boot into your phone's bootloader (fastboot mode)
  2. Connect to computer with regular USB cable
  3. Run
    Code:
    fastboot devices
    to verify device is connected.
  4. Run
    Code:
    fastboot flash recovery /path/to/openrecovery-twrp-2.6.0.0-mako-usbotg.img
  5. Reboot into recovery

Installation (zip method)
  1. Download the zip file to your phone
  2. Boot into your phone's recovery (CWM / TWRP)
  3. Flash the zip
  4. Reboot to recovery

Use
  1. Boot into recovery
  2. Connect flash drive and charger to OTG Y-cable.
  3. Connect Y-cable to phone.
  4. You should now be about to mount USB-OTG, select it for backup/restore, browse it with file manager, etc

Downloads
openrecovery-twrp-2.6.0.0-mako-usbotg.img - 7.11 MB
openrecovery-twrp-2.6.0.0-mako-usbotg.zip - 7.24 MB

Thanks
Ziddey - For his modifications to the kernel that made this possible (see thread linked above)
TeamWin - For TWRP recovery
Franko - For his kernel
Fkrone - For his flashable zip for CWM Recovery that I shamelessly stole
can you do this for the latest CWM by philz touch recovery... plz

http://d-h.st/users/philz_touch/?fld_id=16051#files
 

ritchea

Senior Member
Sep 6, 2011
830
172
43
okeechobee
I have repacked the TWRP 2.6.0.0 recovery image with a different kernel that enables the use of USB-OTG when booted to recovery. The kernel is taken from Ziddey's patch for externally powered usb-otg and is a modified version of Franko's kernel. See that thread for more info on the kernel. (Note that this won't change the kernel used in your rom, only within TWRP)
This is great! Thanks. :good:
 

ziddey

Senior Member
Aug 26, 2007
1,788
1,552
0
Hah, awesome thinking! I had foolishly assumed the recovery used a stripped down kernel.

I see you used the JSS kernel. Good to know it works with twrp 2.6.0.0. Have you considered a sort of "anyrecovery" implementation? So long as the recovery in question supports otg properly (can't remember if cwm even had the option), it should work. Worst case, the user will have to flash a known good recovery via fastboot or android (say goomanager).

Sorry you didn't even make it one post before some goon decided to quote the first post :p


Good thinking :good:
 

zman0900

Senior Member
Jan 20, 2010
277
230
0
Columbus, OH
can you do this for the latest CWM by philz touch recovery... plz

http://d-h.st/users/philz_touch/?fld_id=16051#files
I've never actually used CWM on this phone and haven't used it on any device for about a year, so I don't know if they even support OTG. If they do, I can add in the kernel and it should probably work.

Hah, awesome thinking! I had foolishly assumed the recovery used a stripped down kernel.

I see you used the JSS kernel. Good to know it works with twrp 2.6.0.0. Have you considered a sort of "anyrecovery" implementation? So long as the recovery in question supports otg properly (can't remember if cwm even had the option), it should work. Worst case, the user will have to flash a known good recovery via fastboot or android (say goomanager).

Sorry you didn't even make it one post before some goon decided to quote the first post :p


Good thinking :good:
I thought about the "AnyRecovery" idea. Its definitely possible since I actually did all the work on the phone over adb just because I didn't feel like finding the code for unpackbootimg and mkbootimg to compile for x86. If CWM supports OTG, I may do it, otherwise it will probably just cause confusion. Thanks for your work on the kernel by the way.


EDIT: As far as I can tell, CWM does not support OTG. Does anyone know of any other recovery that has support? I may make the AnyRecovery thing anyways just to support future version of TWRP, but I'll probably wait until the next version of TWRP or ziddey's kernel is ready.
 
Last edited:

Sillik

Senior Member
Dec 11, 2010
259
54
0
Well this is awesome! Thanks for the good job...

However, does this have the issue found on regular TWRP 2.6.0.0 where you can't move your backup afterwards?

Also, it is easy to test making a backup, but has someone tried restoring from a backup? I wouldn't want to notice it doesn't work when I really need it! :)
 

ziddey

Senior Member
Aug 26, 2007
1,788
1,552
0
EDIT: As far as I can tell, CWM does not support OTG. Does anyone know of any other recovery that has support? I may make the AnyRecovery thing anyways just to support future version of TWRP, but I'll probably wait until the next version of TWRP or ziddey's kernel is ready.
Could always do an "any-any" where it'd essentially be script only-- dump existing boot kernel and recovery ramdisk, make new image, and flash as recovery.


Sent from my phone. Please forgive typos and brevity.
 

xcooper

Member
Apr 7, 2008
17
1
0
it works for backup and restore. THANKS

Just flushed the ZIP image TWRP-OTG and tested backup and restoration. Also tested to flash new kernel through the external USB drive. Every thing works :good:. Thank you for sharing this mod recovery. Is there a plan to update the TWRP 2.6.1.0 ?
 

ritchea

Senior Member
Sep 6, 2011
830
172
43
okeechobee
Just flushed the ZIP image TWRP-OTG and tested backup and restoration. Also tested to flash new kernel through the external USB drive. Every thing works :good:. Thank you for sharing this mod recovery. Is there a plan to update the TWRP 2.6.1.0 ?
The mod seems to work on 2.6.1.0.
 

zman0900

Senior Member
Jan 20, 2010
277
230
0
Columbus, OH
Just flushed the ZIP image TWRP-OTG and tested backup and restoration. Also tested to flash new kernel through the external USB drive. Every thing works :good:. Thank you for sharing this mod recovery. Is there a plan to update the TWRP 2.6.1.0 ?
I'll put something together soon.




The mod seems to work on 2.6.1.0.
This completely overwrites the recovery partition, so flashing it will put you back at 2.6.0.0. I plan to make the next version only flash the kernel to whatever recovery you have installed.

Sent from my Nexus 4 using XDA Premium 4 mobile app
 

ritchea

Senior Member
Sep 6, 2011
830
172
43
okeechobee
I'll put something together soon.






This completely overwrites the recovery partition, so flashing it will put you back at 2.6.0.0. I plan to make the next version only flash the kernel to whatever recovery you have installed.

Sent from my Nexus 4 using XDA Premium 4 mobile app
Thanks for the info. No wonder it appears to work.:laugh:
 

ziddey

Senior Member
Aug 26, 2007
1,788
1,552
0
Crosspost:

I made a sort of "any-any" recovery mod: recoverymod.zip

It replaces the recovery's kernel with the boot kernel. Flashing this after the main OTG patch will therefore also apply the OTG-enabled kernel to the recovery. From there, it's up to the recovery to "natively" support usb devices. TWRP does. For any that don't, you'll have to manually mount partitions via adb.

Do understand what you're getting into-- if recovery for some reason fails to load, you'll have to be capable of reflashing it, be it via fastboot, goomanager, or however else.

I've tested this with TWRP 2.6.1.0.
 

xcooper

Member
Apr 7, 2008
17
1
0
Crosspost:

I made a sort of "any-any" recovery mod: recoverymod.zip

It replaces the recovery's kernel with the boot kernel. Flashing this after the main OTG patch will therefore also apply the OTG-enabled kernel to the recovery. From there, it's up to the recovery to "natively" support usb devices. TWRP does. For any that don't, you'll have to manually mount partitions via adb.

Do understand what you're getting into-- if recovery for some reason fails to load, you'll have to be capable of reflashing it, be it via fastboot, goomanager, or however else.

I've tested this with TWRP 2.6.1.0.
could you give more detail how to flash the recoverymod.zip ? I flashed the new TWRP image for mako v2.6.1.0 and v2.6.1.1. Boot into to recovery mode then flash the recoverymod.zip file. The OTG in TWRP did not work. Flashed back to zman0900's v2.6.0.0.

Thanks
 

ziddey

Senior Member
Aug 26, 2007
1,788
1,552
0
could you give more detail how to flash the recoverymod.zip ? I flashed the new TWRP image for mako v2.6.1.0 and v2.6.1.1. Boot into to recovery mode then flash the recoverymod.zip file. The OTG in TWRP did not work. Flashed back to zman0900's v2.6.0.0.

Thanks
Ah, it was a crosspost from my OTG thread. It depends on you having my otg patch installed since it merely copies the boot kernel to the recovery kernel.
 

xcooper

Member
Apr 7, 2008
17
1
0
Ah, it was a crosspost from my OTG thread. It depends on you having my otg patch installed since it merely copies the boot kernel to the recovery kernel.
Thanks. I see. it works now. I patch the OTG mod in kernel, then flash the recoverymod.zip to replace the kernel in TWRP. It works for TWRP 2.6.1.1 too.
 

punitthereddevil

Senior Member
Jun 26, 2012
675
112
0
Belgaum
Thanks. I see. it works now. I patch the OTG mod in kernel, then flash the recoverymod.zip to replace the kernel in TWRP. It works for TWRP 2.6.1.1 too.
Just clear this out for me...are these the right steps...?

Flash TWRP 2.6.1.1 > flash ziddeys r182 build > flash recoverymod.zip...

I tried this but the usb-otg option in "backup" is not "clickable"...and in terminal, I see "unable to mount usb-otg" everytime I tried clicking the option...

Am I missing something...?

Edit : it worked fine...it was a fault with the cable...thanks anyways...:)


***Hit the "Thanks" button and save yourself the effort of typing it***

NEXUS 4 | STOCK 4.3 JWR66Y | ZIDDEY'S OTG KERNEL | OTG ENABLED TWRP 2.6.0.0
 
Last edited:

punitthereddevil

Senior Member
Jun 26, 2012
675
112
0
Belgaum
Is anyone here using this recovery to flash latest PA...? I heard there are issues with flashing PA with TWRP...can anyone help me here...?

***Hit the "Thanks" button and save yourself the effort of typing it***

NEXUS 4 | STOCK 4.3 JWR66Y | ZIDDEY'S OTG KERNEL | OTG ENABLED TWRP 2.6.1.1
 

zman0900

Senior Member
Jan 20, 2010
277
230
0
Columbus, OH
Finally made that AnyRecovery thing

Good news everybody!

I finally had some time to update this. If you're already using Ziddey's stuff to enable USB-OTG in your rom, then his Any-Any method above will work just a well for you, but if your like me and only care about USB-OTG for backups in recovery, this is for you. See the OP for more info, but basically this will replace the kernel of whatever recovery you currently have installed with one the one that is included in the zip, which should enable OTG support in TWRP and probably do nothing (or maybe blow up) in other recoveries.

Sorry this took so long. I finally got a real, paid development job :victory: so I haven't had as much time for messing around with my phone.