yashsingh1/xdaforums huggingface dataset:
[Nexus 4 Original Android Development] ziddey:
I'm imagining that your powered hub is only supplying power to the devices, and not back upstream to the phone (probably a good quality hub..). The current trigger for host mode is essentially detection of power and data ("proprietary charger") since ID pin detection isn't working. So since there's no power, the phone doesn't know to switch to host mode. The same applies for your powered WD drive.

I'll try to do some testing later, but I'd imagine that forcing host mode via "echo host > /sys/kernel/debug/msm_otg/mode" should work. However, again, I haven't done any modifications for that method beyond enabling it, and last I remember, it is possible to end up stuck in a suspended/idle state, and require a reboot to be able to reuse the usb port.

If this method ends up working for you, I'll try to go through the code and catch any conditions where it'd get stuck. Of course, since there is no power supplied to the phone, it won't charge. I'm curious to know how bad the battery drain would be.

Otherwise, your best bet may be to mod a usb cable so you can supply your own 5v. Or buy a Y-cable or usb cable with an additional plug for power (like that come with some 2.5" external hard drives).

Someone did post asking if these would work with the N4 a few months ago: http://dx.com/s/cager+battery+sd

I'd be afraid the sd adapter is only connected to the microusb port, and that the two usb ports are just charge ports. Should be fairly easy to modify though, but then that kind of defeats the purpose of buying a premade unit.
[Nexus 4 Original Android Development] sga999:
ziddey probably gave you the answers you need, but I'll give you a little info about what does and doesn't work for me.

The original kernel from the "Manual OTG working" thread by CaptainMuon did work for me, similar to your setup, with an OTG cable and a powered hub (with flash drive connected to one of the ports). I used the echo command as ziddey showed you. (I don't know if a space is required, but I had one both before and after the >). However, this ziddey kernel does not work with that same setup.

What I'm using instead is a "special" Y-cable that connects to your phone, your power source, and your device. Unfortunately, I just looked on ebay, and it says "0 available". So maybe it sold out with so many people reading these threads. You may be able to find something like it elsewhere. This allows charging at the same time the device is connected. If I use an OTG cable with a " standard" Y-cable, this kernel works for me, but it does not charge at the same time.

This power bank works for me, and it's cheap. But you may want to go with the one you mentioned...I just wanted to see one of these work since I've never bought one before.

http://www.ebay.com/itm/5000mah-2-U...ablet_eReader_Accessories&hash=item35c17a088f

ziddey, I'm not able to do the original "echo" way now. I mean, I can issue the echo command, the device is mounted, I see files on the flash drive through the "old" /sdcard/usbSorage way of viewing the connected device. But I cannot play a song or a movie from the flash drive. Your "new way" of /storage/usbdisk0 works very well, so I don't really care about the old way, but I thought I'd mention it to you. Maybe I'm not understanding this, and both ways are not supposed to work at the same time.

EDIT: There are several posts from me up to post #87 about my Y-cable not working, while another cable did. Then I got another Y-cable, and it DOES work. See post #87 for details.
[Nexus 4 Original Android Development] ziddey:
The code for "manual otg" does exactly the same thing as CaptainMuon's so I don't understand why it doesn't work for you. It's completely independent from the main changes.

You mean something like this? As far as the device is concerned, that's no different than an "otg y-cable." Otherwise, it would not have been able to detect the charger type to switch to host mode in the first place.

The fact that the device is able to be recognized and mounted means the "original way" works just fine. How the drive is actually handled is on you. It sounds like you have Stickmount installed and it's automatically mounting the drive at /sdcard/usbStorage. I've never used Stickmount before so I can't comment about how it works or doesn't work. What do you mean you "cannot play a song or a movie?" /storage/usbdisk0 is via native Android. It's how it would have been had LG/GOOG enabled OTG to begin with.
[Nexus 4 Original Android Development] sszz:
Fast USB Charge broken

Just to report: fast USB charge seem to be broken, while it works ok in original Franco's Milestone1. Could you please look into this?

(I tried with franco's updater app and even the option is missing - flashing original kernel, it comes back.)

Thank you!
[Nexus 4 Original Android Development] ziddey:
That's bizarre. I compile using /proc/config.gz from the M1 build. I just checked and the force fast charge flag is indeed enabled. Here is the pertinent code:

if (motg->cur_power == mA)
return;
#ifdef CONFIG_FORCE_FAST_CHARGE
if (force_fast_charge == 1) {
mA = USB_FASTCHG_LOAD;
pr_info("USB fast charging is ON - 1000mA.\n");
} else {
pr_info("USB fast charging is OFF.\n");
}
#endif
dev_info(motg->phy.dev, "Avail curr from USB = %u\n", mA);

pm8921_charger_vbus_draw(mA);
msm_otg_notify_power_supply(motg, mA);

motg->cur_power = mA;

Maybe motg->cur_power == mA, and it returns before ever forcing fast charge? But again, the code is unchanged, so that would be happening with Franco's build too. Further, you're saying that the fast charge option has disappeared in Franco's app??

Can you check your dmesg (or cat /proc/kmsg to watch it live) when you're expecting to see fast charging? You should see "USB fast charging is ON - 1000mA." or "USB fast charging is OFF."

edit: Oh weird. I just checked on my end and can confirm that I'm seeing "USB fast charging is OFF." I'll look into it but I'm baffled why it's not working since nothing was changed, and the flag is set.. Come to think of it, I did run across this a week ago and thought it was strange.
[Nexus 4 Original Android Development] sszz:
Well, the problem is that I'm sitting on a train right now, so could you tell me how to check dmesg?

Sure, it is strange that the option is missing, but since it is not there any more, what should I check exactly?

Thanks again!
[Nexus 4 Original Android Development] ziddey:
I already confirmed the issue exists on my end. Trying to figure out why now since I didn't do anything that would have broken it.
[Nexus 4 Original Android Development] sszz:
Thanks in advance & good luck!
[Nexus 4 Original Android Development] sga999:
ziddey, I'll try some of these things again, but I've done these tests many times, so I think I'm being accurate in telling you what works and what doesn't.

I can use the Franco app to change kernels easily. So I am able to switch between yours and CaptainMuon's easily. Until I try it again, I'll say that the powered hub did work with Captain's kernel, but not with yours (not that I care to use the hub for this project...I had only tried that hub until I got other cables).

Now I'm going on to talking about testing without that hub, so that I could more closely match what CaptainMuon's setup was like. Your picture does not look like what I'm calling a "standard" Y-cable. Mine has 2 male USB A, like what you showed, but then it has a female USB A (while yours has a male micro USB). Sorry to be dense, but I don't see how the cable you showed works...one male USB A goes to the power, male micro goes to the phone, so how does the other USB male A connect to the flash drive?

Here's my Y-cable, which I connected to my existing OTG cable. I ordered this because I already had an OTG cable, and CaptainMuon's original post used an OTG cable with this Y-cable.

http://www.ebay.com/itm/USB-2-0-A-F...091?pt=LH_DefaultDomain_0&hash=item3cc23945d3

When I use this Y-cable with an OTG cable, no charging occurs. With the "special" Y-cable that is no longer available on ebay, charging occurs. That special Y-cable has a female micro to connect to the original charging cable for power, a male micro to connect to the phone, and a female USB A to connect to the flash drive.

Finally, for your last paragraph. For the "original" CaptainMuon way with the echo command, I've tried it with your kernel both with stickmount and without. The results are the same. What I mean by a song or movie won't play is that I can view those files under /sdcard/usbStorage, but when clicking on either of them , they will not play (some error like "Sorry, cannot play..."). But when I view those same files under /storage/usbdisk0, I can click on them and they play without any problem. Again, this is fine with me, but as you said, since it should work the CaptainMuon way, I'm letting you know what I've seen.

I hope I'm being clear enough for you. I'll try again, just to be sure one more time.
[Nexus 4 Original Android Development] Roastmeat:
Can you measure the current coming out of the regulator?

Also, did you try with something requiring less power, like a USB stick or mouse?
[Nexus 4 Original Android Development] defroster:
Yes I was going to try that today. Just wanted to check I wasn't missing something obvious.

E: tested with USB stick. No go.
[Nexus 4 Original Android Development] jcagara08:
-Yes finally my cable came in today!

-Flashed this kernel - http://xdaforums.com/showthread.php?t=2181820&highlight=nexus+4

(ziddey-otg-r156-06230339.zip)

-Already had USB audio recorder trial.

-started UsbAudioTesterROOT app, chose USB device 2:2 (it will be showing as Fiio E17 DAC)

-Apply all settings, start USB audio recorder pro and...

-Bam I confirm that NEXUS 4 4.2.2 (rooted with PA HALO ROM+and said kernel flashed) is compatible with Fiio E17's DAC function

Nexus 4 = Fiio E17 DAC

Can't believe google missed and skipped out this feature compared to major manufacturers, it should ideally be an out of the box feature as it is a Nexus device.

Will post audio setup soon...

Thank you so much OP ziddey!!

Will donate to you soon!
[Nexus 4 Original Android Development] tigeryee:
So can you show me a screenshot of what your flash drive in the file manager please? I tried the CM file manager and Es file explorer and don't see it. It could be my OTG does not have enough power to power a USB stick IDK ⚠ ⚠ ⚠
[Nexus 4 Original Android Development] jcagara08:
Yes

Sure!

here but just make sure this is the appropriate cable that you have to get and the USB flash drives should be in FAT32 mode, otherwise it will prompt a never ending notification that the USB is broken and reformat option notification is of no use in the Nexus 4.

BTW I use astro file manager since my galaxy s1 days..

Screenies show that yes it does mount, I even installed chainfire's stickmount free version just to make sure usb flash drives are to be forced-mounted to the Nexus 4.

enjoy and goodluck!
[Nexus 4 Original Android Development] ferreinf:
also bought one just like this, still waiting for it to arrive, but pretty excited, thanks :)
[Nexus 4 Original Android Development] Sillik:
Hello,

For those who are looking for the cable, I found one on this site that delivers even here in Europe for a very reasonable price:

http://dx.com/p/cy-u2-166-usb-femal...icro-usb-male-adapter-cable-black-15cm-205901

It works awesomely...

Thanks Ziddey!
[Nexus 4 Original Android Development] 4L3xN3t:
hi everyone!

I've got a nexus4, rooted but perfectly stock.

Yesterday I received the Y usb otg cable and would like to try flashing the modified kernel.

I've some questions about, not all referred specifically to the USB-otg problem, but are its consequences.

1) the modified kernel is franco-based, right? so it will have all the franco functionality + the usb otg ability?

2) I would like to not change my rom with custom ones, I really like a lot stock android, but it's ok to me changing just the kernel. I'll have problems when I'll update to android 4.3 with non-stock kernel?

3) does the slimport cable works properly with this kernel?

4) any known issue?

thank you guys!

bye
[Nexus 4 Original Android Development] jcagara08:
1. First I have noticed like my Wifi function had been disabled, flashed it like twice times and it fixed the wifi error. Franco functionality I am not so familiar with, maybe the battery life I guess is good.

2. When an android update is up, it is always mandatory to go back to stock ROM and flash the new update.

3. Theoretically yes since this cable needs another power source via micro usb right? (Not sure if Nexus 4 has HDMI out of the box feature)

4. Known issue non so far -

I am looking to try this cable as my USB DAC Fiio E17 has its own power, theoretically it might work -

Good luck!

---------- Post added at 05:39 PM ---------- Previous post was at 05:33 PM ----------

Here is one problem I can cite to you -

http://forums.androidcentral.com/nexus-4-accessories/281977-nexus-4-slimport-hdmi-no-audio-tv.html

maybe USB audio out is really crippled which can only be done via this kernel's feature and an app called USB audio recorder Pro .
[Nexus 4 Original Android Development] 4L3xN3t:
thx for replying,

about the point 2 I meant if there will be problem with non-stock kernel, cause my rom is still stock...in the statement "it is always mandatory to go back to stock ROM" is included the kernel?:silly:

about the slimport I've no problem with my cable, hdmi works perfectly audio & video, I read that usb otg conflicts with slimport and cannot be used concurrently, but want to know if a kernel with otg support have such "broken" slim port funcionality.

PS:about your cable I read in the first page that even powered devices will not work via otg cause they don't send power to the phone to make it understand there's something connected to...you'll probably verify this is true or not ;)

byeeee
[Nexus 4 Original Android Development] Sillik:
Well there is a requirement that you use a deodexed rom. It is not in the OP so I'm not completely sure about it but I read about it somewhere in the thread. So a real stock will not work I think...

Can someone confirm?

If that is indeed the case, you need to first flash a deodexed stock rom if you wish to keep your rom as close to stock as possible.

You can find one here:

http://xdaforums.com/showthread.php?t=2147281
[Nexus 4 Original Android Development] 4L3xN3t:
Understood...waiting for a confirmation

THX!

From my Nexus4 with love
[Nexus 4 Original Android Development] EDV11:
I have the kernel with stock rom

Enviado desde mi Nexus 4
[Nexus 4 Original Android Development] jcagara08:
√ what he said.
[Nexus 4 Original Android Development] 4L3xN3t:
stock not deodexed?
[Nexus 4 Original Android Development] EDV11:
Yes. Stock rom, not deodexed

Enviado desde mi Nexus 4
[Nexus 4 Original Android Development] 4L3xN3t:
ok, good news...

PS: if I would like to restore the stock kernel is there another way different from reflash the rom?
[Nexus 4 Original Android Development] Sillik:
If you have a nandroid backup, it should be possible to restore only boot.img, which is the kernel.

It will cause issues though as this mod modifies more than the kernel in the system.

I suggest restoring the entire system + boot in CWM.
[Nexus 4 Original Android Development] 4L3xN3t:
Ok...so I think si better waiting this mod will be based over franco kernel M3...so I could avoid flashing tons of ROM/kernel...I hate doing backup/restore continously

:thumbup:

From my Nexus4 with love
[Nexus 4 Original Android Development] ziddey:
Ah ha. I made a script to automate the build process (in terms of keeping up with Franco's releases). Somewhere along the way, Franco removed NTFS support from the kernel. This was only good for read access, but it's safe and supported by Android. I modified the script to reinclude kernel ntfs support.

I did some research on ntfs-3g, and have come to the conclusion that it's simply unsafe to be automatically mounting ntfs partitions read/writable, especially in the Android world where people may be inclined to unplug without first unmounting (not to mention accidental unplugs). FUSE is included and ntfs-3g does work without a hitch (ntfs-3g /dev/block/sda1 /storage/usbdisk0). The automatic read-only mount may need to be unmounted first. Or you could use Stickmount or similar to automate it.

2013.06.27 0427ET: ziddey-otg-r156-06270427.zip Re-enable read-only NTFS support in kernel.
[Nexus 4 Original Android Development] eran1243:
Chances are that this won't work with a regular cable even tough your device has its own power,for the same reason OTG didn't work with DSLR Controller and a self powered DSLR camera (and yes,I did use the manual host mode)

Lets hope ziddey manages to fix this.
[Nexus 4 Original Android Development] 4L3xN3t:
a question for [MENTION=584916]ziddey[/MENTION]: it would be so complicate to produce a zip to restore the system modified files?
[Nexus 4 Original Android Development] Sillik:
Yes it is complicated because it depends on the rom you are using.

So you have two options:

- restore from CWM backup (only system and boot are needed in "advanced restore")

- re-flash your rom on top

Both option allow you to keep all your data.
[Nexus 4 Original Android Development] 4L3xN3t:
understood...

but I always knew that by reflashing the ROM I lose all data...are you talking about installed apps and preferences?:confused:
[Nexus 4 Original Android Development] Sillik:
You only loose data if you do a full wipe (fatcory reset) in recovery.

Otherwise, all apps and their data + your internal memory content + your accounts, contacts, call log, messages... are all kept when you simply flash a new rom without wiping.

If you wipe data, your apps will be re-installed from the play store when you login with your Google account, but without data. You will loose your Angry birds progress for example...

Your contacts should be safe though as they are also synchronised with Google.
[Nexus 4 Original Android Development] 4L3xN3t:
ok, probably I was considering such as a must to wipe when flashing new roms...so when android 4.3 would come I could flash stock 4.3 and then reflash modified kernel over it.

now the "game" it's more clear!:laugh:

thank youuuuuuuuuu!
[Nexus 4 Original Android Development] Sillik:
You're correct.

And you're welcome! :good:
[Nexus 4 Original Android Development] ziddey:
2013.06.28 1551ET: ziddey-otg-M3-06281551.zip Maintenance build-- rebase to Franco M3.
[Nexus 4 Original Android Development] 4L3xN3t:
:D

From my Nexus4 with love
[Nexus 4 Original Android Development] SetiroN:
Hi [MENTION=584916]ziddey[/MENTION]

while trying to build an OTG-enabled kernel I've encountered an issue that you seemed to have back then when you were first trying to do so yourself:

drivers/usb/core/driver.c:1313:2: error: implicit declaration of function 'do_unbind_rebind' [-Werror=implicit-function-declaration]
do_unbind_rebind(udev, DO_UNBIND);
^
drivers/usb/core/driver.c:1313:25: error: 'DO_UNBIND' undeclared (first use in this function)
do_unbind_rebind(udev, DO_UNBIND);

how did you manage to solve it?

I'm guessing it's a config issue, but I didn't find either DO_UNBIND nor do_unbind_rebind in any file other than usb/core/driver.c

Thanks in advance!

p.s. I thought enabling CONFIG_VT_HW_CONSOLE_BINDING would do the trick, but it didn't...

EDIT: nevermind, I fixed it myself. :)
[Nexus 4 Original Android Development] ziddey:
That's from the second post. It is a bit of a lie (since certain features behave differently / are disabled when "OTG support" is not enabled) but in terms of what we're trying to do, it's best to keep it off (to prevent stuck states, timers, etc). Our code seems to have unbind and rebind in separate functions-- refer to a similar kernel (e.g. optimus g, htc droid dna).

Also, your patch is for a different commit:
[Nexus 4 Original Android Development] SetiroN:
Oh okay that's great, thanks!

(I extracted the wrong commit before, sorry, I've now uploaded the correct one just for the sake of it)
[Nexus 4 Original Android Development] MrPhilo:
Any chance these otg will work with the Nexus 4 using this kernel? (I doubt)

http://dx.com/p/c310-otg-tf-card-re...er-for-samsung-i9100-i9300-i9220-n7100-174106
[Nexus 4 Original Android Development] codf4ther:
not unless you put some kind of a powered pass-through adapter between that and the phone. The Nexus 4 is incapable of powering any OTG accessory, so you need to bring in power somehow.
[Nexus 4 Original Android Development] meranto:
Received a OTG-y-cable today after having received an external battery earlier. Flashed the Ziddey-otg-m3 kernel and I could instantly use the DSLR-controller app with all cables connected to my Canon EOS 700d. Works with the wall charger as power source as well off course. Fantastic work, thanks very much ziddey!
[Nexus 4 Original Android Development] MrPhilo:
I get it now, you need a standard usb female as it has external power to power it self?

For example this?

http://www.amazon.co.uk/gp/product/B005FUNQXS/ref=oh_details_o00_s00_i00?ie=UTF8&psc=1
[Nexus 4 Original Android Development] thebrainkafka:
Isnt that much cable stuff bothering ?
[Nexus 4 Original Android Development] meranto:
I need the y-cable, the Canon USB cable and the external battery, which is just a small thing, to me it's not much of an issue. I'll see if I can shoot a pic tomorrow of the setup to show its not bad considering the lack of USB host support to begin with :)
[Nexus 4 Original Android Development] tarroyo:
LOVE this patch! Has made transfering files so much easier.
[Nexus 4 Original Android Development] meranto:
As you can see, all it adds to how it should have been is the portable mobile charger and the little piece of cable of the OTG-y-cable.

Off course, jcagara08's cable looks much better, but this works for now so that is the most important thing. But if ziddey or someone else gets it to work with self-powered devices without external power, I would definitely go for the 1-cable solution.

BTW, I bought these:

Cable - http://www.ebay.com.hk/itm/ws/eBayISAPI.dll?ViewItem&item=140993909947 (4 dollars, free shipping, took 14 days)

Charger - http://www.ebay.co.uk/itm/1900mAh-M...rger-Mobile-Phone-Power-Station-/200914417868 (9.95 GB-pounds, took 5 days)
[Nexus 4 Original Android Development] ferreinf:
Finnaly it arrived working fine, thanks :)
[Nexus 4 Original Android Development] defroster:
When using these y cables, doesn't it drain the battery by charging the phone?
[Nexus 4 Original Android Development] codf4ther:
No that won't work. You need a "Y" style OTG like this one so the accessory can pull in power from your computer or a charger:

http://dx.com/p/micro-usb-male-to-usb-female-w-usb-male-otg-cable-black-170927
[Nexus 4 Original Android Development] eran1243:
Glad to hear this works,but it really kills your mobility and comfort to go around with all these cables...

When I bought the nexus 4 I also bought a clamp to put it on the top of the camera,because I tought all I'll need is an OTG cable from the phone to the camera :(
[Nexus 4 Original Android Development] meranto:
Just checked it, and yes it does drain the external battery by charging the phone.
[Nexus 4 Original Android Development] eris23:
ziddey-otg-M3-06281551.zip is incompatible with CyanogenaMod builds after 20130703. The problem seems to start with http://review.cyanogenmod.org/#/c/43194 which was fixed in the standard CyanogenMod build by http://review.cyanogenmod.org/#/c/45107/. Ziddey seems to need to fix the way the storage.list is now treated.
[Nexus 4 Original Android Development] sga999:
Can you post the framework-res.apk from that CM build? ziddey and I have usually been able to debug the script when a problem occurs for a new release.
[Nexus 4 Original Android Development] parkedraccoon:
I got a y-cable.

Is it possible to slow charging on the phone so my battery can still supply power to an external HDD? Currently the phone takes all the power leaving the hard drive without enough to successfully run.
[Nexus 4 Original Android Development] ziddey:
Thanks for the report. Chaos until Monday. Will look into it then.