yashsingh1/xdaforums huggingface dataset:
[Nexus 4 Original Android Development] ziddey:
2013.05.17 0107ET: ziddey-otg-05170107.zip Added check for other proprietary charger case. Update base to Franco's #137.

This release aims to detect the other "type" of proprietary charger.

Based on these conditions:

usb hub/drive/reader:
<7>[ 56.599334] *** chg_det = 0 ***
<7>[ 56.629272] *** portsc = 8c000804 ***
<7>[ 56.629272] *** line_state = 800 ***
<7>[ 56.629272] *** dm_vlgc = 0 ***
...
<7>[ 57.044311] portsc = 88001205

usb keyboard/mouse:
<7>[ 177.380889] *** chg_det = 1 ***
<7>[ 177.409271] *** vout ***
<7>[ 177.409301] *** portsc = 8c000404 ***
<7>[ 177.409332] *** line_state = 400 ***
<7>[ 177.409332] *** dm_vlgc = 400 ***
...
<7>[ 177.826416] portsc = 84001405

case1 proprietary:
<7>[ 405.897003] *** chg_det = 0 ***
<7>[ 405.927124] *** portsc = 8c000404 ***
<7>[ 405.927154] *** line_state = 400 ***
<7>[ 405.927185] *** dm_vlgc = 400 ***
...
<7>[ 406.344451] portsc = 84001405

I'm hoping that case1 won't catch any usb devices. I measured the data pins for a bunch of usb devices I had and found 5V on both D+ and D- for keyboards/mice, and 3.3V on D+ and little voltage on D-. Looks like the difference between keyboards/mice and case1 proprietary chargers is chg_det (vout). Case2 is the same as before -- it has to switch to host mode to be able to detect the portsc.

Also updated the base to Franco's #137.
[Nexus 4 Original Android Development] sga999:
With that latest release, both of my power banks are now charging. Good work!
[Nexus 4 Original Android Development] sga999:
Deleted most of this post....I thought I was using a "bad" cable (didn't charge) and that it now somehow worked, but I was wrong and was using a "good" cable. Sorry ziddey and ritchea if you read this before I deleted those details just now.

I'm still trying to figure out what's going on with my micro sd card not working well (in 4 different readers and a couple of different cables). ziddey, I know you've already looked at those logs, and you think it's something about the connection not being good. Right now, I don't know what it is because I don't think all readers and all cables are "broken".
[Nexus 4 Original Android Development] tarroyo:
Does anyone have a picture of the wall outlet connected for the extra power thats needed? I don't have a battery pack at the moment.
[Nexus 4 Original Android Development] ziddey:
You mean the one that comes with the phone?
[Nexus 4 Original Android Development] tarroyo:
yes was reading over this guide, only has pics of the battery pack.
[Nexus 4 Original Android Development] ziddey:
Hmm, I'm confused what you're referring to. I never took any pictures of a battery pack. The Nexus 4 comes with a wall charger if that's what you mean. Hook that up to the OTG Y-cable?
[Nexus 4 Original Android Development] tarroyo:
I apologize, forgot to add the link to the guide I was reading.

http://www.androidcentral.com/android-advanced-usb-otg-nexus-4
[Nexus 4 Original Android Development] alguien24:
I've been out for a month, and I applied the 17 may patch and now the mod is enabled properly on 4.2.1 stock as I wanted. Thank you a lot ziddey!

Enviado desde mi Nexus 4 usando Tapatalk 2
[Nexus 4 Original Android Development] mc01319:
Is something wrong with the links?

I can't download the latest version.
[Nexus 4 Original Android Development] LordXeth:
Hi,

Franco.Kernel 138 is out
[Nexus 4 Original Android Development] thebrainkafka:
Anyone tested this for e.g. dslr controller app?

As the cam has its own power, do i still need a y cable?

Thx
[Nexus 4 Original Android Development] sga999:
RussianBear, I'm beginning to believe that all 4 of my usb card readers must be "flawed". I mean, they work fine when plugging directly into a PC. And with my Samsung Galaxy Tab 2 7.0 with its 30-pin type of OTG cable. And into my neighbor's Nexus 7 with an OTG cable. And even for me on my Nexus 4, but only some of the time. I wonder if it's something about not enough power, as this thread mentions. (This is not about our phone, but it mentions similar problems).

http://androidforums.com/samsung-ga...1-usb-otg-mounts-microsd-via-usb-adapter.html

You said you tried another reader, and it worked. Can you tell me the brand and model? Do you think there might be a brand that's better than others? Or just that I need to pay more? (I got all 4 of mine from eBay, each for $2 maybe).
[Nexus 4 Original Android Development] RussianBear:
It's an old Kingston (5 in one, I believe) reader. The cheap one of eBay was the giving me issues.
[Nexus 4 Original Android Development] sga999:
Thanks, RussianBear. I'll have to look for a better micro sd card reader. I don't know enough about getting power to these "bad" readers. But it seems so strange to me that once it works, it will continue to work "forever". For instance, I can plug the micro usb connector into the phone anywhere from 1 to 4 times, and the micro sd won't mount. But once it mounts, I can unplug/replug ad infinitum, and all is well. It also never loses power from that point on, i.e. if I just leave it connected for hours, all is well.

So ziddey (or anyone who understands the hardware side of this), does this make sense to you? If it's a bad connection, why wouldn't it ever fail on some subsequent attempts after it works? Luck? I doubt it. Of course, I can't say that I've tried it more than 15 times after it works, but that seems like enough. Maybe someone can give me a very brief explanation of what's going on here.

A flash drive never fails, just these 4 micro sd card readers. All 4 work on the 2nd to 5th plug-in and then continue to work until reboot.
[Nexus 4 Original Android Development] thebrainkafka:
Anyone?
[Nexus 4 Original Android Development] sga999:
Posts 215 and 217 on the page below (and prior posts in that thread) address this issue, but it doesn't sound like they got it working properly. I know nothing about this, but I just thought I'd show you some other discussion.

http://xdaforums.com/showthread.php?p=40580015
[Nexus 4 Original Android Development] thebrainkafka:
Sorry cant find these posts in mobile Version. May i ASK for a link. THX.

Edith. Got it. Thx

---------- Post added at 07:10 PM ---------- Previous post was at 06:44 PM ----------

Do i need an extern an power and y lead when i use a USB device which has inbuild power?
[Nexus 4 Original Android Development] ziddey:
It looks like the phone still needs to see 5v in order to detect the device. It may be possible to override this by overwriting the portsc register. I'll do some testing when I get the chance. I hacked together a cable that isolates the data and voltage pins to separate cables.

So manual mode still won't make a difference. The phone will be in host mode, but it can't detect any devices if power isn't detected. Y-cable + power is the only solution for now.
[Nexus 4 Original Android Development] thebrainkafka:
Highly appteciated!

Theresia must be a way to override this. Ill know youll manage it :thumbup:
[Nexus 4 Original Android Development] KarloHD:
Hello people. My logitech mouse is not detected. USB stick works without problems. Have also tried a different mouse, also does not work. CarbonRom have installed.

Vom Nexus 4 Gebeamt CarbonRom
[Nexus 4 Original Android Development] ziddey:
Please provide relevant dmesg (starts with PMIC: BSV set). I have a feeling the mouse is being caught by case1 proprietary charger. Both my logitech mice get detected okay though.

Does ziddey-otg-05091729.zip work?
[Nexus 4 Original Android Development] KarloHD:
This version yesterday I flashed ziddey-otg-05170107.zip

Edit :

05091729 works :thumbup:

Fix you do that in the current version?

Vom Nexus 4 Gebeamt CarbonRom

---------- Post added at 11:40 PM ---------- Previous post was at 11:07 PM ----------

Can I change or eiger make lighter the color of the mouse pointer? Can sometimes recognize the bad pointer.:o

Vom Nexus 4 Gebeamt CarbonRom
[Nexus 4 Original Android Development] RussianBear:
Anyone having issues connecting their phone as a mtp device? my pc can't install the mtp drivers and the phone itself is giving a "android.process.media has stopped" repeatedly. Tried franco's 139 and the same thing happened. Tried stock aokp kernel and everything works as it should.
[Nexus 4 Original Android Development] ritchea:
I have read that enabling fast charge can cause this, but it doesn't cause this for me. Since reverting to stock (aosp although I will assume "stock" is stock), try reflashing ziddey to see if it sorted itself out.
[Nexus 4 Original Android Development] RussianBear:
No far charge here. Tried reflashing many things to no avail. Seems kernel related, as that's the only thing changing. Not saying it's ziddey's fault, as 139 has this also.
[Nexus 4 Original Android Development] ritchea:
I'm running the May 15 version (franco 136). I don't know if this is the latest or not as ziddey was working so fast to help solve some usb controller issues (I didn't pay much attention as I didn't share that need) and cranking them out one after another.

I do know that when I get some of those process errors (not particularly the one you got), I would revert to stock kernel, reboot, then flash the ziddey/franco kernel. FWIW, I am running XenonHD version 8. I think I have been running that rom steadily from version 5 (except for a brief sojourn with ver 9 which didn't last as the OTG didn't work at all with it) since trying ziddey's kernels.
[Nexus 4 Original Android Development] RussianBear:
Here's the log with crash info, if anyone is curious.

http://db.tt/XyvL2R6b
[Nexus 4 Original Android Development] Megacamz:
Is there an Idiots guide to this yet?

I could spend 3 hours and work it out, but I am a family man and I have **** to do, If someone would want to even help me make an idiots guide? perhaps a youtube video at least, I don't mind spending time if it helps other people out too.

The problems I'm facing is I only want to patch my mobile to support OTG (I want to retain the stock 4.2.2) and I have an external batter source aswell.

The other thing I don't get it is the Y cables you've linked, they're not correct surely? you want a cable that goes Micro USB to Male USB/Female USB.

so one end goes into the phone (micro usb) then one end you connect to your external power source (male usb) then USB storage plugs into the female USB.

This whole page is over complicated.

You just need to say "Install this, like this, using this"

Then "take this cable, plug it into here, plug this into that and that into this"

then you're good to go, I'd be willing to clarify this and make it easy for people (people like me who want to store movies/music and games for emulators on external drives), I want to store GC games, PS2 games etc for my Gameklip for example.

I'd like to help develop an idiots guide, who can help explain the software side to me so I can create a how to video?
[Nexus 4 Original Android Development] RussianBear:
Guide:

1.buy an otg y cable (type this into eBay)

2. Flash the kernel in the op

3. Enjoy your family/movie time.

Easy enough?

P.s. it's male micro usb to female usb and female micro usb.
[Nexus 4 Original Android Development] ziddey:
Hmm, works fine for me (cm10.1). I compared Franco's ramdisk with stock and don't see any differences related to mtp. I looked at your logcat and am not sure why that's happening. The only thing I can think of would be the modification to framework-res.apk. Have you tried rolling that back to the original? A backup is made at /system/framework/framework-res.apk.1. Or reflash AOKP and then Franco's kernel.

Not sure what kind of "idiot" guide you're looking for. I'm not trying to insult anyone here.. It sounds like you're way overcomplicating things. I kept the hardware "requirements" simple because the idea is simple and I'm not trying to dictate what people use. The phone and device both need 5V. However you want to do that is up to you. I provided another example since not everyone can get the Y-cable where they live, it's often a lot more expensive than getting a traditional OTG cable, and a lot of users already have an OTG cable from an earlier device. With a traditional OTG cable, you'd then need to provide power to it somehow, obviously; that's where the USB Y-cable comes into play-- it leaves you with a male USB A to plug into your wall charger, battery pack, computer, or what-have-you. Again, at the end of the day, as long as you provide 5V/gnd to the phone and device, and the device and phone's data pins are connected, you're good to go.

Get the Y-cable and call it a day then. Simple.

As far as including a guide of how to flash, that's really required background knowledge for being in this subforum. Go to the general/Q&A subforums and read the stickies.

As far as updates go, I'm trying to decide what to do with regards to proprietary chargers. It seems that one "type" of such chargers is not differentiable from some keyboards/mice, and I'd rather break compatibility with these chargers/battery-packs.

I said earlier that I wasn't interested in keeping up with every Franco release. If I'm making my own updates to OTG, I'll release with whatever is current. Otherwise, I'll try to aim for updating when Franco releases a big update or every two weeks or so. Currently, it looks like Franco rewound his git to early May and recommitted everything since then, so I'll have to figure out how to do the same. ^%$&%*$^%$
[Nexus 4 Original Android Development] Megacamz:
I can flash the kernel with the toolkit and it only replaces the kernel, doesn't require me to backup my phone or anything?

I'll order the stuff and I'll make a youtube video for n00bs when I get it and post it here, sounds good?
[Nexus 4 Original Android Development] RussianBear:
Use cwm or twrp recovery to flash kernels on the go. I never backup between kernel flashes.
[Nexus 4 Original Android Development] Megacamz:
Both ebay and Amazon don't return the Y cable, they come up with a Micro to Female USB, no extra usb for a power source, so that means I have to do this....

Micro usb from the phone that has a femal USB port on the end of it, then into that I plug a usb extension cable which has input for extra USB drives, and into that I plug my USB pen and then I connect my battery pack from another usb cable? how many cables does this need? I cannot find the right one.

This is what I come up with... This http://www.ebay.co.uk/itm/BLACK-OTG..._MobilePhoneDataCables_JN&hash=item589f986ef8

Into this http://www.ebay.co.uk/itm/4-Port-Ex...t=UK_Computing_USB_Cables&hash=item51ad33758a

Then a USB pen into one of those, and an external power pack connected with this http://www.ebay.co.uk/itm/5m-USB-2-...t=UK_Computing_USB_Cables&hash=item3efedf2357

That can't be right, surely?
[Nexus 4 Original Android Development] RussianBear:
Look for "usb host otg cable" it is on eBay for a few bucks.

End time: Jun 13, 2013 9:37:09 PM

Item: Host OTG Micro USB Cable w/ Power 4 Samsung i9100 i9250 i9300 N7100 S3 A500 Tab

URL: http://pages.ebay.com/link/?nav=item.view&id=261215928986

Alt URL: http://www.ebay.com/itm/Host-OTG-Mi...0-i9250-i9300-N7100-S3-A500-Tab-/261215928986

(Sent from eBay Mobile for Android)
[Nexus 4 Original Android Development] Megacamz:
Thank you!, that's the mother****er I'm looking for, finally, this is what I mean, it's not very clear, I'll order this biach and get a video posted up for everybody to peruse and get their On The Go shiznit down.
[Nexus 4 Original Android Development] RussianBear:
There was one in the states for about ten bucks, that's where I got mine from. It was in Texas somewhere.
[Nexus 4 Original Android Development] sga999:
ziddey, I know I gave you some logs about that older power bank, but if you need some other kind of log, let me know. It sure seems like there would be some way to distinguish these devices. I'm surprised that the code is the same as for keyboards and mice. Anyway, I will understand if you have to remove the support for that charger in favor of "more likely" devices.

This is probably impossible, but I'll ask Let's say you change the code to support the keyboard/mice. Is there any way to have some kind of "parameter" (in some file) where I can tell you I want to use that power bank? If you read the file and see that parameter, you would allow my power bank. Or....is there any way for me to patch the code where you detect the proprietary charger so that it compares to one code instead of another?

I think your way of releasing every couple of weeks is just fine...I don't think it needs to be perfectly in synch with Franco. I know nothing about the "git"....but it sounds like Franco has done something that makes it more difficult for you to make your changes. That's unfortunate!
[Nexus 4 Original Android Development] RussianBear:
genius. swapped the apks and it works now. do you have any ideas why other people with franco and no mods to framework have no issues with this?

i've reflashed (dirty) the nightly and franco on top to no avail before. Thanks!
[Nexus 4 Original Android Development] ziddey:
Franco's kernel is just that (plus ramdisk). It's my otg patch that modifies framework-res.apk (specifically, storage_list.xml) and makes a backup as framework-res.apk.1. So assuming you didn't flash the otg patch again, you're probably missing the usb storage section in settings->storage.

The problem is that there's no good way to modify storage_list.xml within framework-res.apk on the fly (in recovery). My approach is to use a modified one for a specific CM10.1 framework-res.apk, and simply change the hex values associated with the strings for "Internal Storage" and "USB Storage". I'm not too familiar with the ins and outs of how it gets compiled, but based on the original xml, it doesn't look like anything else would be dependent on other components of the framework:

<?xml version="1.0" encoding="utf-8"?>
<StorageList
xmlns:android="http://schemas.android.com/apk/res/android">
<storage android:storageDescription="@string/storage_internal" android:emulated="true" android:mtpReserve="100" />
<storage android:mountPoint="/storage/usbdisk0" android:storageDescription="@string/storage_usb" android:primary="false" android:removable="true" />
</StorageList>

It's definitely possible that injecting a rogue file into a framework could cause issues; I'll look into AOKP's framework and see if I can find something.

The other assumption I'm making in my update script is that framework-res.apk.1 will always be the original apk. This assumes that dirty flashes of ROMs will wipe /system. I know CM does this (calling the GAPPS backup/restore script so it survives). If the update script for a ROM doesn't wipe /system, the .1 backup can go stale and cause issues. However, since restoring your .1 backup fixed it, it's not the case for you.
[Nexus 4 Original Android Development] ziddey:
Not sure what's unclear. I was figuring the links in the OP were out of date, but they all still work and are in stock...
[Nexus 4 Original Android Development] RussianBear:
cool. good to know. i've uploaded a ton of pics/vids to a copy account (get it while you can, btw - 15gigs free. let me know if you want an invite for additional 5 gigs for both of us lol) and now using the phone's memory as my dash cam. thanks once again, ziddey!
[Nexus 4 Original Android Development] ziddey:
As part of the "stock" debugging implementation, ACA can be manually toggled:

# echo enable (or disable) > /sys/kernel/debug/msm_otg/aca

I can definitely move the code to force host mode into the aca detect function. That way, if aca is manually disabled, it'd be able to just leave proprietary charger detection as is.

Been thinking about doing that for a while, but figured no one would be interested. That and I had hoped the two cases for proprietary charger detection wouldn't cause false positives and it wouldn't be necessary.

Will include in next release.

edit: I suppose I could just find where the usb host is issuing retries and set a limit. Then, it'd just give up on enumeration and proceed to enable charging. Not a pretty solution but it'd work.
[Nexus 4 Original Android Development] Megacamz:
The problem is you've over saturated the post with information, you need to streamline and summarise then put the really technical, nitty gritty stuff after the jump.

I'm no technophobe, I know my ****, I'm highly capable, but Jesus christ I'm sick of having to trawl through hundreds of words and research into every single aspect of something.

I like to live in the fast lane, and I'll be looking forward to donating to whomever developed this, but I'll make a youtube video for this post, so you can link it as a tutorial, as I'm sure there's a lot of 8GB owners out there with the same dilemma as I.

I want to clarify, this is not a go at you, I just want to help simplify things.
[Nexus 4 Original Android Development] benjdm:
I don't think so. You need a Y cable like the following, where one connection goes into the phone, one into the USB device you want to connect, and one to a 5V source:

http://www.amazon.com/Micro-Cable-Power-Samsung-AtomicMarket/dp/B009YPYORM

Then you just need a 5V power supply, whether it's a USB adapter or external battery.

(If I'm wrong, someone please correct me.)
[Nexus 4 Original Android Development] Megacamz:
I got it now dude thanks, I'm gonna make a tutorial video.
[Nexus 4 Original Android Development] sga999:
I'm not sure if anyone pointed to this other type of Y-cable yet, so I thought I'd mention it. Maybe you can mention that there are multiple types in your video. I like this type because it has USB male A for power, which can plug directly into a PC, wall charger, or power bank. The other Y-cable that has been mentioned has a female micro USB, which meant it required the charging/data cable to be plugged into it.

There are many of this type of Y-cable on eBay, and I'm not recommending a specific one...just giving this one as an example.

http://www.ebay.com/itm/Micro-USB-B..._USB_Cables_Hubs_Adapters&hash=item51ad40ace4

---------- Post added at 08:58 PM ---------- Previous post was at 08:53 PM ----------

So if you're going to do it the "aca way", will I need to disable it as you've shown in that echo command in order for that proprietary charger to work?

Or if you are deciding to do it the "retry way", I wouldn't have to do any echo command, right? Just let me know which way you decide to handle it. Thanks for finding a couple of ways to make this work!
[Nexus 4 Original Android Development] ziddey:
2013.05.22 2305ET: ziddey-otg-05222305.zip Update base to Franco's #140. Revert checks for actual proprietary chargers in favor of manually disabling automatic host mode (temporary). Issue "# echo disable > /sys/kernel/debug/msm_otg/aca" to disable automatic host mode (enable to re-enable).

One of the test cases for actual proprietary chargers was causing a "false positive" with some usb devices, so I've reverted the tests for now. Instead, I've made some changes so that automatic host mode can be disabled. This will be necessary in order to use proprietary chargers outside an "OTG" scenario (charger hooked up directly to phone).

This is an interim solution while I look into if it'd be possible to give up enumeration after X retries and start charging.
[Nexus 4 Original Android Development] sga999:
It seems like the disable is working fine for me with both proprietary chargers, i.e. they don't charge when I first boot, but after the disable, they do. However, if I re-enable, charging is still occurring. Not sure if that is what you intended.
[Nexus 4 Original Android Development] ritchea:
This sounds great if you have the time. Thanks.
[Nexus 4 Original Android Development] thebrainkafka:
Anyway to get USB host mode working in eg dslr cam without using 5v supply?

Thx
[Nexus 4 Original Android Development] Megacamz:
Apparently there was then google took it out, am I correct in thinking that? or it lacks the hardware capability to power an external source (correct?)

I'm waiting on hardware to arrive then I'm going to do a n00bs guide to getting this to work (youtube video).