5,606,650 Members 36,893 Now Online
XDA Developers Android and Mobile Development Forum

[USB OTG] [11DEC13] [PATCH] Externally Powered USB OTG

Tip us?
 
ziddey
Old
(Last edited by ziddey; 12th March 2013 at 03:51 AM.)
#21  
Senior Member - OP
Thanks Meter 1439
Posts: 1,517
Join Date: Aug 2007

 
DONATE TO ME
Oh wow, I just noticed a nasty bug with the current hack. I didn't realize the case for a wall charger (USB_DCP_CHARGER) falls through to USB_PROPRIETARY_CHARGER, which is being used to trigger host mode. This causes the device to switch to host mode, drop back out, and then get in a suspended mode. This makes it look like the charger keeps cutting out in rapid succession, resulting in a failure to properly charge. I'm still working on some other problems, but here's an interim release to restore proper charging with a wall charger. Also addressed is the delay in disabling host mode, which is currently introducing/exaggerating some new issues. For the mean time, don't attach/detach devices while the otg cable is connected to the phone, and there shouldn't be a problem.

otg_boot_r3.img: http://d-h.st/vST
The Following 2 Users Say Thank You to ziddey For This Useful Post: [ Click to Expand ]
 
pcsjx
Old
#22  
Junior Member
Thanks Meter 0
Posts: 1
Join Date: Nov 2009
In fact the framework you modified can only work on CM 10.1 up to 0311 version. After the 0312 the file was updated. Using your file will lead to a lot of problems. And the kernel is based on Franco r80. It seems to be a little old.
 
sga999
Old
#23  
Senior Member
Thanks Meter 54
Posts: 434
Join Date: Mar 2012
Quote:
Originally Posted by pcsjx View Post
In fact the framework you modified can only work on CM 10.1 up to 0311 version. After the 0312 the file was updated. Using your file will lead to a lot of problems. And the kernel is based on Franco r80. It seems to be a little old.
The #80 is ziddey's own numbering system for his builds. I think he said it is currently based on Franco #93.
The Following User Says Thank You to sga999 For This Useful Post: [ Click to Expand ]
 
ziddey
Old
(Last edited by ziddey; 14th March 2013 at 10:39 PM.)
#24  
Senior Member - OP
Thanks Meter 1439
Posts: 1,517
Join Date: Aug 2007

 
DONATE TO ME
Update time. Took a more straightforward approach this time, and adjusted code to simulate what would happen if it "naturally" detected an ID_A condition (host mode with charging -- 36.5kohm between pin4/5). Consequently, this should have fixed all prior issues. Should be able to unplug/replug devices at will and maintain an unpopulated (empty) hub without charging issues or requiring a reboot to regain usb functionality.

I've left /sys/kernel/debug/msm_otg/mode in place, but would advise not manipulating it except for debugging purposes. The mechanism for activating host mode is unchanged, and you will likely run into issues.

Now based on Franco's git as of 3/1 (after r102).

Also changed usb mount point from /storage/usbdisk to /storage/usbdisk0. Update vold.fstab accordingly. This also breaks the posted framework-res.apk. I'm about to update to the current nightly, so I'll post a new file shortly.

diff msm_otg.c msm_otg.orig
Code:
694,695c694
< 	// simulating aca_enabled() since using ID_A for host mode -ziddey
< 	if (aca_enabled() || test_bit(ID_A, &motg->inputs))
---
> 	if (aca_enabled())
1102,1103c1101
< 	// force fast charging in host mode -ziddey
< 	/*if ((motg->chg_type == USB_ACA_DOCK_CHARGER ||
---
> 	if ((motg->chg_type == USB_ACA_DOCK_CHARGER ||
1108c1106
< 		mA = IDEV_ACA_CHG_LIMIT;*/
---
> 		mA = IDEV_ACA_CHG_LIMIT;
1215,1216c1213
< 		// simulating aca_enabled() since using ID_A for host mode -ziddey
< 		if (aca_enabled() || test_bit(ID_A, &motg->inputs))
---
> 		if (aca_enabled())
2115,2121c2112,2113
< 			if (line_state) /* DP > VLGC or/and DM > VLGC */ {
< 				// simulating ID_A to force usb host mode with charging -ziddey
< 				//motg->chg_type = USB_PROPRIETARY_CHARGER;
< 				pr_debug("***FORCING USB HOST MODE WITH CHARGING - SET ID_A***\n");
< 				set_bit(ID_A, &motg->inputs);
< 				motg->chg_type = USB_ACA_A_CHARGER;
< 			}
---
> 			if (line_state) /* DP > VLGC or/and DM > VLGC */
> 				motg->chg_type = USB_PROPRIETARY_CHARGER;
2975d2966
< 	// need BSV interrupt in A Host Mode to detect cable unplug -ziddey
2977,2978c2968,2969
< 	/*if (otg->phy->state >= OTG_STATE_A_IDLE);
< 		return;*/
---
> 	if (otg->phy->state >= OTG_STATE_A_IDLE)
> 		return;
2986,2992d2976
< 
< 		// hack to disable usb host mode (if enabled) -ziddey
< 		if (test_and_clear_bit(ID_A, &motg->inputs)) {
< 			pr_debug("***UNFORCING USB HOST MODE WITH CHARGING - CLEAR ID_A***\n");
< 			motg->chg_type = USB_INVALID_CHARGER;
< 			motg->chg_state = USB_CHG_STATE_UNDEFINED;
< 		}
3314,3316c3298,3299
< 	// enable /sys/kernel/debug/msm_otg/host (for debug purposes only. manipulation not recommended) -ziddey
< 	if (motg->pdata->mode == USB_OTG /*&&
< 		motg->pdata->otg_control == OTG_USER_CONTROL*/) {
---
> 	if (motg->pdata->mode == USB_OTG &&
> 		motg->pdata->otg_control == OTG_USER_CONTROL) {

2013.03.14 1648ET: otg-franco-boot-03141621.img should have fixed all issues involving unpopulated hubs, unplugged devices, host mode timeout, and charging. changed main mount point to /storage/usbdisk0 since that seems to be the new standard (update vold.fstab accordingly). based on Franco's git as of 3/12 (after r102)
The Following 3 Users Say Thank You to ziddey For This Useful Post: [ Click to Expand ]
 
sga999
Old
#25  
Senior Member
Thanks Meter 54
Posts: 434
Join Date: Mar 2012
Thanks, ziddey. I like it that this is based on Franco's r102. Your version now shows as #11. It was #80 before, so I want to make sure I'm getting the right version. Is this #11 the current one?

No one gave me a solution to my problem with trying your changes to framework-res.apk on the stock rom. I wonder if I'm unable to do this for a stock rom at all. I found this thread where someone wants to make "enhancements" to the stock rom on the Nexus 4.
http://forum.xda-developers.com/show....php?t=2066784

Post 3 says:
"Also you will most likely need a rom that's deodexed which the stock rom is not."

Could this explain why I'm not able to use a modified framework-res.apk on the stock rom (I get bootloop, even with the file you gave me)? I've done lots of googling, and I don't see others saying you can't change the framework-res.apk on stock, but I'm probably just missing something.
The Following User Says Thank You to sga999 For This Useful Post: [ Click to Expand ]
 
ziddey
Old
(Last edited by ziddey; 15th March 2013 at 12:50 AM.)
#26  
Senior Member - OP
Thanks Meter 1439
Posts: 1,517
Join Date: Aug 2007

 
DONATE TO ME
http://forum.xda-developers.com/show...6446&page=3#22
Try simply copying storage_list.xml from your new apk to the original.

http://forum.xda-developers.com/show...hp?t=1806602#5
Or you could try copying the meta-inf folder and androidmanifest.xml from the original apk if you want to work in the other direction.
The Following User Says Thank You to ziddey For This Useful Post: [ Click to Expand ]
 
sga999
Old
(Last edited by sga999; 16th March 2013 at 01:54 AM.)
#27  
Senior Member
Thanks Meter 54
Posts: 434
Join Date: Mar 2012
Quote:
Originally Posted by ziddey View Post
http://forum.xda-developers.com/show...6446&page=3#22
Try simply copying storage_list.xml from your new apk to the original.

http://forum.xda-developers.com/show...hp?t=1806602#5
Or you could try copying the meta-inf folder and androidmanifest.xml from the original apk if you want to work in the other direction.
Thanks for the suggestions! I've tried the first one, and it did work for me. (Your comment states exactly what I did, i.e. copy storage_list.xml from new to original, but the post you referred to was talking about the opposite direction). I haven't tried your second suggestion yet.

For "fun", I decided to install a deodexed version of 4.2.2 from here:
http://forum.xda-developers.com/show....php?t=2147281
[ROM][OTA][mako]Android 4.2.2 JDQ39: Rooted Busybox Deodexed/Odexed (2/13/13)

Also, I think I found a bug in Framework Flasher! See my post:
http://forum.xda-developers.com/show...52&page=11#110

I have made 3 different update.zip files for framework-res.apk. Let's call them:
a. update-odex (from your first suggestion)
b. update-nofix (made by Framework Flasher without my bug fix)
c. update-bugfix (made by Framework Flasher with my bug fix)

Here are results of several tests!
1. Stock odexed 4.2.2 will only work with your update-odex (a).
2. Stock deodexed 4.2.2 will work with ALL three update.zip versions (a, b, c)!

I had really hoped that update-bugfix would have worked on the odexed rom, but no such luck. (Your second suggestion about meta-inf and androidmanifest.xml may be necessary here).

So now I'm tempted to just stay on the deodexed rom, since it is more "lenient". I know there may be a slight performance hit in running the deodexed version (sorry, I don't know that much about this, but I read somewhere that separating out the .odex helped when loading an app). But is there any other reason I shouldn't stick with the deodexed rom?

P.S. Back to the real topic here!! Your current version is working well for me. Thanks very much.
 
sga999
Old
(Last edited by sga999; 17th March 2013 at 07:16 AM.)
#28  
Senior Member
Thanks Meter 54
Posts: 434
Join Date: Mar 2012
Okay, this is the last time I'll clutter up this thread with stuff about creating framework-res.apk properly.

I have made 2 changes to Framework Flasher. The first change was already mentioned in the prior post (it is about fixing the incorrect -o switch on the '7za x" command line...this makes temp-files get created properly). The second change is to the COPY line when preparing to create update.zip). I'm putting UN in front of signedframework-res.apk. This is the modified line.

COPY "%~dp0place-framework-res-here\UNsignedframework-res.apk" "%~dp0resources\struct\system\framework\framew ork-res.apk"

The only way this change works is that I'm NOT executing step 3 (signing) at all, I just do steps 1, 2, and 4. The resulting zip (or unsigned apk) works for both stock 4.2.2 odexed and deodexed roms. Please note that if you want to sign the apk (I haven't figured out why you should ever sign framework-res.apk), this change to the COPY line is not correct.

ziddey, I read lots of posts about copying the original AndroidManifest.xml, META-INF folder into the new apk (as you said in one suggestion). And lots about copying the new resources.arsc back into the original apk. I'm not sure....all I know is that these changes to Framework Flasher work well for me,

EDIT: Another bug fix for Framework Flasher. This line had forward slash before resources.arsc, but I've changed it to backslash. However, I'm not sure this line should even be in the runme.bat. It seems like it should be the user's responsibility to delete files from temp-files. But I'm not sure what the author's intent was.

DEL /Q %~dp0temp-files\resources.arsc
 
ziddey
Old
#29  
Senior Member - OP
Thanks Meter 1439
Posts: 1,517
Join Date: Aug 2007

 
DONATE TO ME
2013.03.17 1548ET: otg-aio-20130317.zip All-in-one flashable zip that includes modified kernel/ramdisk, vold.fstab, and precompiled storage_list.xml for framework-res.apk (thanks arpruss for precompiled zip-for-android). Kernel unchanged from last release (Franco r102 base), but removed unrelated line previously added to default.prop in ramdisk
The Following User Says Thank You to ziddey For This Useful Post: [ Click to Expand ]
 
baltac
Old
(Last edited by baltac; 18th March 2013 at 04:19 AM.)
#30  
Senior Member
Thanks Meter 82
Posts: 126
Join Date: Aug 2006
Location: Assisi
Quote:
Originally Posted by ziddey View Post
2013.03.17 1548ET: otg-aio-20130317.zip All-in-one flashable zip that includes modified kernel/ramdisk, vold.fstab, and precompiled storage_list.xml for framework-res.apk (thanks arpruss for precompiled zip-for-android). Kernel unchanged from last release (Franco r102 base), but removed unrelated line previously added to default.prop in ramdisk
Just tested the zip file and it's working (tested with a 4Gb usb stick, mouse and keyboard), but the "Mount/Unmount USB Storage" is not present in my settings page.

Just a little thing and after I'll not bother you anymore, with my noob questions: I'm not skilled with android programming, so I didn't understand almost anything of the contents of this thread, so I didn't understand if I need to revert the usb in a "standard" state after the OTG. Apparently all works normal without touch anything (connecting the phone to PC, it works as mtp device with adb support), but I remember that when I was on LG Optimus Dual, that in the first release of his ICS Rom hasn't the Mass Storage mode, I used to change the usb mount state (I was needed it when I'm on my Mac Book), with this adb strings:

Code:
#disconnect and reconnect after every command

#put the device to mass_storage mode, with adb support
adb shell "setprop persist.sys.usb.config mass_storage,adb"

#after mass_storage before disconnecting, change the usb mode to one of following states

#put the device in MTP mode, with adb support
adb shell "setprop persist.sys.usb.config mtp,adb"

#put the device in only charge mode with adb support
adb shell "setprop persist.sys.usb.config adb"
I've tried this in nexus (not the mass_storage, to avoid any possible data loss), and obviously they works. The question is: there is (if needed) an analog string to switch in OTG mode? I've tried with otg, host, usb_host, usb_otg... but nothing happens...
Hit the "THANKS" button if this post is useful.

My LG Nexus 4 Conf:
- [ROM] CyanogenMod 10.1
- [K3rN3l] Franko's Kernel modded for OTG by ziddey

Tags
usb otg host
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes