# Can you charge & USB Host mode simultaneously?



## mvmacd

I wanna get a Nexus tablet, but I'm afraid that I won't be able to access my USB hdd and charge the device at the same time. Can someone confirm if it's possible? I asked over at xda forums, but I didn't get a solution.

could I perhaps use a USB OTG cable and a Y-cable with a USB charger? or even if I had to get a usb hub, I would, I just need to get some clarity. 
Thanks!


----------



## sfreemanoh

I doubt it. However, the battery life on this thing is really pretty good. From Tuesday around 5PM until mid Thursday, I used it for maybe 3 hours of screen-on time and had it unplugged the entire time. I watched some Youtube, flashed some a couple ROM's, blah blah blah, and the battery was around 65%.


----------



## mvmacd

Hmm.. Well, if it's impossible, is it hardware or software limitation?

Picture this, i plug in a powered USB hub, into the otg cable, except I cut out the 5v wires before it reaches the hub, then apply my own 5v from a separate charger. Would it charge upon receiving the voltage? Or would it ignore it cuz its in host mode?

Pardon the grammar I'm on my phone
Thx


----------



## mvmacd

bump.


----------



## mvmacd

another bump


----------



## AlexanderT

I don't think it would ignore the charge if it has enough power getting to it.


----------



## packruler

FYI http://www.ti.com/lit/ds/slusao5/slusao5.pdf


----------



## dansan

packruler said:


> FYI http://www.ti.com/li...ao5/slusao5.pdf


----------



## spbogie

Assuming that is the charge controller used in the n7...

Short Answer: No

Long Answer: When the device detects that it has entered USB Host Mode (OTG) the charge controller switches from charge mode to boost mode. In effect it reverses the charge circuitry (not exactly, but close enough for this explanation) so that instead of charging the battery it draws power from the battery to power whatever device is connected. When in Boost mode, the controller will not charge the battery from the V[sub]BUS[/sub] (USB) input. In theory, there are 2 ways in which host mode + charging could be accomplished. Method 1 (Hardware): The charge controller has an additional V[sub]IN[/sub] connection intended for use with an AC adapter which should be able to continue charging the battery even when V[sub]BUS[/sub] is in Boost mode. However, given the WCSP package (Surface mount connections under the chip itself, no exposed pins) this chip uses, connecting to this pin would be virtually impossible if it is not broken out somewhere on the circuit board. Method 2 (Software): The controller has an I[sup]2[/sup]C interface used to control its operation. This interface should be connected and being controlled by a kernel driver. If this driver is accessible, it should be possible to tell the charge controller not to enter Boost mode, and thus allow charging to continue while the USB interface is in host mode. This would allow charging, but also require an external source to power any attached usb devices. Note, this is all heavily dependent on the assumptions of the charge controller being used, and configuration it is in. In other words, Maybe...


----------



## dcplaya

spbogie said:


> Assuming that is the charge controller used in the n7...
> 
> Short Answer: No
> 
> Long Answer: When the device detects that it has entered USB Host Mode (OTG) the charge controller switches from charge mode to boost mode. In effect it reverses the charge circuitry (not exactly, but close enough for this explanation) so that instead of charging the battery it draws power from the battery to power whatever device is connected. When in Boost mode, the controller will not charge the battery from the V[sub]BUS[/sub] (USB) input. In theory, there are 2 ways in which host mode + charging could be accomplished. Method 1 (Hardware): The charge controller has an additional V[sub]IN[/sub] connection intended for use with an AC adapter which should be able to continue charging the battery even when V[sub]BUS[/sub] is in Boost mode. However, given the WCSP package (Surface mount connections under the chip itself, no exposed pins) this chip uses, connecting to this pin would be virtually impossible if it is not broken out somewhere on the circuit board. Method 2 (Software): The controller has an I[sup]2[/sup]C interface used to control its operation. This interface should be connected and being controlled by a kernel driver. If this driver is accessible, it should be possible to tell the charge controller not to enter Boost mode, and thus allow charging to continue while the USB interface is in host mode. This would allow charging, but also require an external source to power any attached usb devices. Note, this is all heavily dependent on the assumptions of the charge controller being used, and configuration it is in. In other words, Maybe...


I havent looked at that spec sheet but I just went over the USB OTG spec and the spec has details on how to get it to work. Charging the A-Device while connecting to the B-device is possible with a resistance between the ID pin and ground as well as power. Both devices get power from the charger. There is just no SRP support but also isnt needed since "VBUS is already asserted at both the OTG Port and Accessory Port."


----------



## spbogie

dcplaya,

Thanks for pointing that out. After some further looking I did find the Battery Charging Spec which describes an Accessory Charging Adapter specifically for this purpose. I cannot seem to find any real world implementations of it however, so it would be interesting to see if the n7 actually supports it. I may have to do some experimenting this weekend


----------



## Folsom

I'm pretty sure the ACA won't work. A friend of mine is on the USB standards committee, and he says only Nokia fully supported USB OTG. There is a lot of signalling needed to get ACA to work, so the Nexus 7 and Galaxy Nexus only support USB host.

His company makes power management ICs for camera, phones, etc., and he says the PMIC in the N7 will increase charging current until it sees a drop in voltage, so if you try to AC charge with a charger that can't supply the current, there is no danger in harming the charger.


----------



## Timur

Folsom said:


> I'm pretty sure the ACA won't work. A friend of mine is on the USB standards committee, and he says only Nokia fully supported USB OTG. There is a lot of signalling needed to get ACA to work, so the Nexus 7 and Galaxy Nexus only support USB host.
> 
> His company makes power management ICs for camera, phones, etc., and he says the PMIC in the N7 will increase charging current until it sees a drop in voltage, so if you try to AC charge with a charger that can't supply the current, there is no danger in harming the charger.


The Galaxy Nexus OTG kernel code does not evaluate a single resistor. So no [background=rgb(245, 245, 245)]Battery Charging Spec implemented here.[/background]
However, I was able to modify this kernel to make it accept a charge while in OTG host mode. A Y-cable is connecting my phone to a powered USB hub. The hub has a USB-to-Ethernet dongle, connected to a router. The hub is also powering the Gnex via the other end of the Y-cable. The phone can now, say, act as a WiFi access point (wired + 3G!) and it's battery level will never drop below 100% or 99%. One disadvantage: in a real on-the-go situation, this kernel will not anymore power slave devices. One could fix this by allowing the user to switch between OTG host mode charge-out (default) vs. OTG host mode charge-in. Should be possible with the N7 as well.


----------



## spbogie

Timur, could you possibly post the changes you made for the Galaxy Nexus. I was looking at a similar solution for the N7, but fear I'm a little lost.


----------



## Timur

On the Galaxy Nexus, removing the complete body of method tuna_set_vbus_drive() in arch/arm/mach-omap2/board-tuna-connector.c will disable charging of OTG slave devices and will allow the OTG host itself to be charged. The battery icon will not be updated by this modification alone.


----------



## mvmacd

Timur said:


> The Galaxy Nexus OTG kernel code does not evaluate a single resistor. So no [background=rgb(245, 245, 245)]Battery Charging Spec implemented here.[/background]
> However, I was able to modify this kernel to make it accept a charge while in OTG host mode. A Y-cable is connecting my phone to a powered USB hub. The hub has a USB-to-Ethernet dongle, connected to a router. The hub is also powering the Gnex via the other end of the Y-cable. The phone can now, say, act as a WiFi access point (wired + 3G!) and it's battery level will never drop below 100% or 99%. One disadvantage: in a real on-the-go situation, this kernel will not anymore power slave devices. One could fix this by allowing the user to switch between OTG host mode charge-out (default) vs. OTG host mode charge-in. Should be possible with the N7 as well.


This is good news, hopefully someone here or on xda can figure out how to make it work for Nexus 7.

So I had a question, you simply mean the tablet was not giving any power out to devices? What if you plugged the cable into a powered hub? Then plug one end of the Y into the USB OTG cable, and the other Y into the USB 5V 2A charger?

At least, that's what I am imagining in my head for a setup I would like for my Nexus 7. It hasn't actually arrived yet, it's gonna be delivered tomorrow!


----------



## Timur

mvmacd said:


> So I had a question, you simply mean the tablet was not giving any power out to devices? What if you plugged the cable into a powered hub? Then plug one end of the Y into the USB OTG cable, and the other Y into the USB 5V 2A charger?
> 
> At least, that's what I am imagining in my head for a setup I would like for my Nexus 7. It hasn't actually arrived yet, it's gonna be delivered tomorrow!


I'm not sure I understand your question. The Galaxy Nexus, when put in OTG host mode, does normally give 500mA out to connected slave devices. But it is unable to detect power in then. To allow power in, I switched off the host mode power out logic.

I want to add one thing: I am not using a straight Y-cable. I'm using one, where one of the two ends (the one for power in) has only the red + black wired through. Just like this person explains: 



. (Interestingly, the HP TouchPad does not seam to require any modification, in order to allow charging while in host mode.)

Ah and if you have any success with the N7 doing this, please share the info.


----------



## mvmacd

Timur said:


> I'm not sure I understand your question. The Galaxy Nexus, when put in OTG host mode, does normally give 500mA out to connected slave devices. But it is unable to detect power in then. To allow power in, I switched off the host mode power out logic.
> 
> I want to add one thing: I am not using a straight Y-cable. I'm using one, where one of the two ends (the one for power in) has only the red + black wired through. Just like this person explains:
> 
> 
> 
> (Interestingly, the HP TouchPad does not seam to require any modification, in order to allow charging while in host mode.)
> 
> Ah and if you have any success with the N7 doing this, please share the info.


tried to watch but my connection is too slow right now.. so anyway I was just trying to figure out what you meant by "[background=rgb(245, 245, 245)]One disadvantage: in a real on-the-go situation, this kernel will not anymore power slave devices." [/background] but I think I know now. And ok, so is it basically a Y cable [2 male USB 2.0, to 1 female 2.0] like [URL='http://ecx.images-amazon.com/images/I/31FobhCXlxL._SL500_AA300_.jpg]this[/URL]? but one part [say the grey plug in the picture] has the data pins severed? 
And just has the ground and +5 V? 
Then you plug that [grey plug] into the N7 charger? the other male 2.0 you plug into the OTG cable, and you plug in a HDD or flash drive into the female 2.0?

That is how I am picturing it in my mind anyway. And if someone could write an app to accept charging power instead of giving it, that would be perfect.
And another thing, if your usb used too much power, you could get a powered usb 2.0 hub, and plug it into that, right?


----------



## knyghtryda

Someone needs to dig into the USB otg code on the galaxy s3. It is supposed to support otg + mhl simultaneously with its special mhl adapter ( this is the reason all the old mhl adapters wouldn't work on it). This means it can also charge and do otg at the same time.


----------



## spbogie

The Galaxy S3 uses a special connector with extra pins to support USB + HML


----------



## Folsom

Timur said:


> The Galaxy Nexus OTG kernel code does not evaluate a single resistor. So no [background=rgb(245, 245, 245)]Battery Charging Spec implemented here.[/background]
> However, I was able to modify this kernel to make it accept a charge while in OTG host mode. A Y-cable is connecting my phone to a powered USB hub. The hub has a USB-to-Ethernet dongle, connected to a router. The hub is also powering the Gnex via the other end of the Y-cable. The phone can now, say, act as a WiFi access point (wired + 3G!) and it's battery level will never drop below 100% or 99%. One disadvantage: in a real on-the-go situation, this kernel will not anymore power slave devices. One could fix this by allowing the user to switch between OTG host mode charge-out (default) vs. OTG host mode charge-in. Should be possible with the N7 as well.


That is good news. I was incorrect where I thought the nexus would not work with the ACA cable.


----------



## Timur

Folsom said:


> That is good news. I was incorrect where I thought the nexus would not work with the ACA cable.


Here, the needed OTG charging Y-cables are coming from the factory now: http://www.ebay.com/itm/Micro-USB-Host-OTG-Cable-W-Micro-USB-power-for-Samsung-i9100-i9300-i9220-9250-/110931117836?pt=PDA_Accessories&hash=item19d402870c

Note how it says "can charge the extral USB device". The kernel mod is still required to also keep the host device charged, of course. 
In other words, without the kernel mod, this is only as good as using a powered USB hub.

Did anybody get the kernel mod for host mode charging working on the N7?
Or do I have to do this also? When we ever get to buy the N7 here in (old) Europe.


----------



## papatel

Just ordered one of those y-cables, cheap enough that I won't cry if it doesn't work 

Thanks for your expertise Timur. Maybe you can build us a kernel if you're all setup for it? I'd be happy to test


----------



## mvmacd

A member on xda said he got otg and charging simultaneously, and that it should work for any otg device.
Here is his instructions.
https://sites.google.com/site/sonicboomworld/my-projects/otg-and-charging

Anyone know if it would work for nexus 7?
If so I'd better order a hub.


----------



## romandesign

I'm considering upgrading to Galaxy S3 and need to use USB DAC and charge it at the same time (car usage with good audio). This topic is the only one that gave a clear explanation that it's not working, why, and how to make it work (in principal). The guy in XDA mentiones at his website that Galaxy S did NOT work with his dock.

Any news on how to do it? Is it possible via app? I wonder how easy it is to modify kernel (I've flashed ROMs before and I'm a web designer and developer but I don't know how to modify android kernels). I'd be OK with it not powering other devices, Y cable with power adapter would do that in the car. Please post any news here and any progress or instructions if there is a workaround...


----------



## Timur

A USB DAC in the car, driven by a phone. What a nice use case. Very geeky and totally reasonable. I want this, too, now.



romandesign said:


> Is it possible via app?


No. Here the four levels of host mode support:

1) No host mode support. I'm not 100% sure, but I think the Nexus S falls into this category.

2) Some devices do support host mode and because they have a separate power plug, charging is not an issue. My old LG tab, running CM10, falls into this category.

3) Some devices do support host mode, but have no separate power plug and do also not support the full battery charging spec. These devices are able to detect a short on the ID pin (-> OTG host mode), but are not able to detect resistors on the ID pin (for signaling: host mode + power incoming). The Galaxy Nexus falls into this category. And I assume the Nexus 7 does as well. What a kernel patch can do, is to pretend a resistor IS being detected. So in host mode, the modified kernel will not provide 500mA to the slave device (DAC, Ethernet, ...), but will instead accept external power to operate the host device.

4) Some devices seem to support host mode + battery charging spec. If the correct resistor is being detected, they automatically switch to be operated on an external power source. Sounds like the XPERIA S falls into this category. Kudos to Sony, if true.

USB host mode, being required to power itself + a slave device, all from battery, is near useless. Makes you think why "category 3" devices exist at all.


----------



## romandesign

Timur said:


> 3) Some devices do support host mode, but have no separate power plug and do also not support the full battery charging spec. These devices are able to detect a short on the ID pin (-> OTG host mode), but are not able to detect resistors on the ID pin (for signaling: host mode + power incoming). The Galaxy Nexus falls into this category. And I assume the Nexus 7 does as well. What a kernel patch can do, is to pretend a resistor IS being detected. So in host mode, the modified kernel will not provide 500mA to the slave device (DAC, Ethernet, ...), but will instead accept external power to operate the host device.
> USB host mode, being required to power itself + a slave device, all from battery, is near useless. Makes you think why "category 3" devices exist at all.


That's a major "facepalm moment" for Samsung, I guess. I don't have any idea about how to modify or compile kernel, especially in a good custom ROM like Cyanogetmod nightly build. Those kernels are probably unique for every model, so aking yout o modify it is pointless unless you too have similar Galaxy S3. Maybe a tutorial would be great, but it might be to complicated to explain to someone who has no experience with *nix and kernels...


----------



## WayneM

Timur said:


> On the Galaxy Nexus, removing the complete body of method tuna_set_vbus_drive() in arch/arm/mach-omap2/board-tuna-connector.c will disable charging of OTG slave devices and will allow the OTG host itself to be charged. The battery icon will not be updated by this modification alone.


Can you tell me where to find that body (more or less)?

Thanks.


----------



## Timur

WayneM said:


> Can you tell me where to find that body (more or less)?


Here: https://github.com/mehrvarz/android_kernel_samsung_tuna/blob/jb/arch/arm/mach-omap2/board-tuna-connector.c
Method tuna_set_vbus_drive() starts in line 261 and you can see how I out-remarked the body of this method.

If you happen to use CM10 on your Galaxy Nexus, you can flash this image containing the modified kernel:
https://github.com/mehrvarz/files/raw/master/boot-cm10-maguro-otg-power.img
This image contains the latest CM10 boot.img for GNex (GSM), but with the above patch.
To flash: fastboot flash boot boot-cm10-maguro-otg-power.img

With this image installed, your GNex will not power external devices when put in OTG host mode.
But it will accept external power (Y-cable!) to operate itself, so that it's battery will not loose charge.

To go back, here the current default CM10 boot image: https://github.com/mehrvarz/files/raw/master/boot-cm10-maguro.img

To flash: fastboot flash boot boot-cm10-maguro.img
You can, of course, also revert using CWM. Let me know if it works for you.


----------



## Sengir

i would love to try this patch in my nexus 7 but cannot modify kernel myself, do you plan to release it anytime timur?


----------



## Timur

Sengir said:


> i would love to try this patch in my nexus 7 but cannot modify kernel myself, do you plan to release it anytime timur?


Take a look here: http://mehrvarz.gith...wer-nexus7.html

I think this does what you want. But it's still very new. I got my N7 only end of last week 

As with the Galaxy Nexus: without external power, this kernel will NOT drive your USB slave devices.
But it will accept external power to operate both devices - and it will also (slowly) charge it's own battery while in host mode.


----------



## Sengir

Timur said:


> Take a look here: http://mehrvarz.gith...wer-nexus7.html
> 
> I think this does what you want. But it's still very new. I got my N7 only end of last week
> 
> As with the Galaxy Nexus: without external power, this kernel will NOT drive your USB slave devices.
> But it will accept external power to operate both devices - and it will also (slowly) charge it's own battery while in host mode.


Thank you so much,i'll try as soon my y camble arrives


----------



## Snazzy

Timur said:


> Take a look here: http://mehrvarz.gith...wer-nexus7.html
> 
> I think this does what you want. But it's still very new. I got my N7 only end of last week
> 
> As with the Galaxy Nexus: without external power, this kernel will NOT drive your USB slave devices.
> But it will accept external power to operate both devices - and it will also (slowly) charge it's own battery while in host mode.


Awesome, thanks Timur! Ordering the Y cable now. This will be perfect for an external HD. I was thinking about tearing down a keyboard to wire volume controls, back, and search to my steering wheel, but turns out when a keyboard is plugged in, you can no longer use the on-screen keyboard which will probably be necessary since I can't dictate everything I'll need (ex. foreign names).


----------



## markj_2222

Timur said:


> Here: https://github.com/m...una-connector.c
> Method tuna_set_vbus_drive() starts in line 261 and you can see how I out-remarked the body of this method.
> 
> If you happen to use CM10 on your Galaxy Nexus, you can flash this image containing the modified kernel:
> https://github.com/m...o-otg-power.img
> This image contains the latest CM10 boot.img for GNex (GSM), but with the above patch.
> To flash: fastboot flash boot boot-cm10-maguro-otg-power.img
> 
> With this image installed, your GNex will not power external devices when put in OTG host mode.
> But it will accept external power (Y-cable!) to operate itself, so that it's battery will not loose charge.
> 
> To go back, here the current default CM10 boot image: https://github.com/m...cm10-maguro.img
> 
> To flash: fastboot flash boot boot-cm10-maguro.img
> You can, of course, also revert using CWM. Let me know if it works for you.


Im quite new to android and im still early on the development curve and this is currently out of my skill level.

How would you allow it to charge at the same time as otg? If i can charge my phone while plugged into my external drive i can use my nexus instead of lugging around a laptop.


----------



## slugworth

My Y-cable is here, although I ordered this one instead (http://ebayitem.com/190710044655) as the description was more convincing that it would work for simultaneous charging and USB-OTG.

It is indeed working on my Galaxy S2! This is huge. External Keyboard/mouse + simultaneous charging = I can work all day from just about anywhere now.


----------



## PaulF

Did anyone ever succeed at this via the resistor method? If yes, what value of resistor did you use?


----------



## slugworth

Someone sent me a PM asking if I was using a custom ROM or kernel mod on my Galaxy S2. No, I'm just using stock ICS 4.0.4 rooted, and it just works.

To add to my earlier post, the reason I didn't get the one with the female microUSB port is because the listings I had found said that the charging would be for the external USB device. With the cable I purchased previously (http://ebayitem.com/190710044655) you'll need a standard USB extension plus a universal USB charging adapter since the female port is full sized USB.

Since my last post I decided to also try this cable (http://ebayitem.com/120980364117) with the female microUSB port. Hopefully it will work, too. I would prefer it since I could just use my regular microUSB chargers with it. I'll report back after it arrives.


----------



## romandesign

I ordered your original cable, will see if it works with north-american Galaxy S3. Just to be clear: USB power should go to male full-size USB on this cable, right? So if I have a car adapter that has a female USB port, I need "usb exnetsion" cable (F to M), correct? External device (USB DAC in my case) would be plugged into the female USB of Y cable, and microUSB to the phone. Correct?


----------



## slugworth

That's right, Roman.

I just got my 2nd cable with the female microUSB for charging (http://ebayitem.com/120980364117), and it also works for simultaneous USB-OTG and charging my phone, with the added benefit of being able to use any microUSB charger.


----------



## journeyman

Timur said:


> Here: https://github.com/m...una-connector.c
> Method tuna_set_vbus_drive() starts in line 261 and you can see how I out-remarked the body of this method.


I've built a kernel from AOSP source for the Galaxy Nexus using your code and it's working great. Thanks so much for this!

I've been participating in a thread at XDA Developers where I've posted the boot images for both yakju and takju. It's at http://forum.xda-dev...0&postcount=70.

One thing of note is that my phone and external USB device (flash drive) are both definitely being powered by the USB charger now. But it doesn't look like the phone battery is actually being charged--the charge level never goes up. It could be that there just isn't enough power to charge the battery while also powering the external device, but that doesn't seem all that likely.

Would there be some way in the kernel to actually turn on charging as well? It would be neat to have the phone battery topped off while using it in USB OTG mode.


----------



## Snow02

journeyman said:


> I've built a kernel from AOSP source for the Galaxy Nexus using your code and it's working great. Thanks so much for this!
> 
> I've been participating in a thread at XDA Developers where I've posted the boot images for both yakju and takju. It's at http://forum.xda-dev...0&postcount=70.
> 
> One thing of note is that my phone and external USB device (flash drive) are both definitely being powered by the USB charger now. But it doesn't look like the phone battery is actually being charged--the charge level never goes up. It could be that there just isn't enough power to charge the battery while also powering the external device, but that doesn't seem all that likely.
> 
> Would there be some way in the kernel to actually turn on charging as well? It would be neat to have the phone battery topped off while using it in USB OTG mode.


Is it charging in USB or AC mode? If usb, then it definitely makes sense that the battery level isn't going up.


----------



## journeyman

Snow02 said:


> Is it charging in USB or AC mode? If usb, then it definitely makes sense that the battery level isn't going up.


I've used both a dedicated wall charger and a USB cable connected to a computer, and neither seem to charge the battery. I thought about adding the patch to the kernel code that forces fast charging, but I'm guessing it wouldn't help if the phone isn't in a mode to know that it should be charging the battery.


----------



## Snow02

journeyman said:


> I've used both a dedicated wall charger and a USB cable connected to a computer, and neither seem to charge the battery. I thought about adding the patch to the kernel code that forces fast charging, but I'm guessing it wouldn't help if the phone isn't in a mode to know that it should be charging the battery.


Even if using a wall charger it can still be charging in usb mode. Open the battery stats while charging and it will tell you in which mode it's charging.


----------



## Timur

journeyman said:


> One thing of note is that my phone and external USB device (flash drive) are both definitely being powered by the USB charger now. But it doesn't look like the phone battery is actually being charged--the charge level never goes up.


Yes, the battery charge level on the Galaxy Nexus does not grow. But the device itself is fully operated on external power. The charge level also never shrinks. It just stays at the same level for days if not weeks. It is as if the battery in the Galaxy Nexus is completely disconnect, when in externally powered host mode. A more powerful power supply will not change anything.

Let me point out that my (more or less identical) patch for externally powered host mode on the Nexus 7 *does* also charge the battery.


----------



## journeyman

Thanks Snow02 for the information on determining the type of charging going on. I wasn't aware of this. And thanks Timur for the explanation of how your patch works on the GN in regard to powering but not charging the phone. And, indeed, the battery stats screen does show "Not charging" when operating on external power and in host mode, as expected.


----------



## romandesign

slugworth said:


> That's right, Roman.
> 
> I just got my 2nd cable with the female microUSB for charging (http://ebayitem.com/120980364117), and it also works for simultaneous USB-OTG and charging my phone, with the added benefit of being able to use any microUSB charger.


SUCCESS!!! I can confirm that this USB OTG cable (http://ebayitem.com/190710044655) DOES CHARGE MY GALAXY S3! I wanted to doplicate your experience so I got the exact same cable. I plugged in USB cardreader with SD card into the phone through this cable (it lit up and card is fully readable), then plugged USB cable end into PC and phone showed a charging icon! Moreover, after waiting for 5 min. with screen off (cardreader still glowing blue and working) battery has gone up from %72 to %75 (and while I was writing this, to 78%), so it is indeed charging! Yay! It probably won't get up in the car, where just phone alone is "not discharging" at best from the car adapter, but at least it should allow me to listen to music with quality DAC and use navigation without (or with minimal) discharging.

I have not tested it with USB DAC that I intend to use for my car (Behringer UCA222), because I have to go out and buy it. Hopefully it works. Anyway, this cable definitely works with simultaneously charging my north-american Samsung Galaxy S3 (from Bell Canada) while powering USB cardreader!


----------



## dmexs

Timur said:


> Yes, the battery charge level on the Galaxy Nexus does not grow. But the device itself is fully operated on external power. The charge level also never shrinks. It just stays at the same level for days if not weeks. It is as if the battery in the Galaxy Nexus is completely disconnect, when in externally powered host mode. A more powerful power supply will not change anything.
> 
> Let me point out that my (more or less identical) patch for externally powered host mode on the Nexus 7 *does* also charge the battery.


Two questions, if you don't mind:

1) Does the Nexus 7 display/acknowledge the fact that it is charging? Or does it say "Not Charging" on the battery panel?
2) Do you have a schematic of the cable you are using? I've seen a lot of mockups and am a little confused.


----------



## Timur

dmexs said:


> 2) Do you have a schematic of the cable you are using? I've seen a lot of mockups and am a little confused.


One arm of the Y-cable, the one going to the slave device(s), needs to have all four wires connected. And the other arm needs to have just two wires connected, those for 5V external power. And, of course, sense pin needs to be short against mass, to put the device into host mode. I guess all advertised Y-cables will just work. Of course, nothing beats using a cable you have put together yourself ;-)

So, the Samsung Galaxy S2 and S3 - other than the Galaxy Nexus and the Nexus 7 - seem to support externally powered host mode out of the box, with the default kernel (likely triggered by a specific sense pin resistor, I assume). My questions to owners of such devices: what happens if you pull the external power when in externally powered host mode (while the battery is charging)? Will the device switch to OTG (self powered) host mode quick enough so you can continue using your slave device(s) as if nothing happened?


----------



## dmexs

Timur said:


> It displays "charging".
> 
> One arm of the Y-cable, the one going to the slave device(s), needs to have all four wires connected. And the other arm needs to have just two wires connected, those for 5V external power. And, of course, sense pin needs to be short against mass, to put the device into host mode. I guess all advertised Y-cables will just work. Of course, nothing beats using a cable you have put together yourself ;-)
> 
> So, the Samsung Galaxy S2 and S3 - other than the Galaxy Nexus and the Nexus 7 - seem to support externally powered host mode out of the box, with the default kernel (likely triggered by a specific sense pin resistor, I assume). My questions to owners of such devices: what happens if you pull the external power when in externally powered host mode (while the battery is charging)? Will the device switch to OTG (self powered) host mode quick enough so you can continue using your slave device(s) as if nothing happened?


Thanks for the reply Timur. I was very close to working on another much more roundabout alternative. (Since I'm doing a car install, I'm looking to add OTG storage and charge. I was going to use a NAS enabled wireless router and network mount the additional storage.)

I'll splice in the power lines from a male USB cable in to the OTG cable I have and give it a try after work. You may have just saved me $80, significant boot time, and another layer of complexity. Thanks!


----------



## dmexs

Timur said:


> It displays "charging".
> 
> One arm of the Y-cable, the one going to the slave device(s), needs to have all four wires connected. And the other arm needs to have just two wires connected, those for 5V external power. And, of course, sense pin needs to be short against mass, to put the device into host mode. I guess all advertised Y-cables will just work. Of course, nothing beats using a cable you have put together yourself ;-)
> 
> So, the Samsung Galaxy S2 and S3 - other than the Galaxy Nexus and the Nexus 7 - seem to support externally powered host mode out of the box, with the default kernel (likely triggered by a specific sense pin resistor, I assume). My questions to owners of such devices: what happens if you pull the external power when in externally powered host mode (while the battery is charging)? Will the device switch to OTG (self powered) host mode quick enough so you can continue using your slave device(s) as if nothing happened?


This is what I see when I plug in my cable after flashing your modified kernel. For my cable I took a normal OTG cable and cut the 5+ lines and soldered them to the 5+ lines of a male USB cable connected to the stock Nexus 7 charger. The battery percentage is certainly rising, but it doesn't say "charging" which is important for me to be able to wake the device with Tasker.

Do you mind directing me to the exact cable you're using?


----------



## mentose457

I received my Y cables today and they work on my N7 with PA and the kernel that was posted earlier in this thread. Unlike others in this thread my tablet displays 'Discharging' yet still charges.


----------



## Andrew025

slugworth said:


> That's right, Roman.
> 
> I just got my 2nd cable with the female microUSB for charging (http://ebayitem.com/120980364117), and it also works for simultaneous USB-OTG and charging my phone, with the added benefit of being able to use any microUSB charger.


I received this cable today and tried it on my n7 and gnex with no luck. It can access the usb drive but it does not charge. 
It works on my wife's stock gs3 though. 
Both my devices are on Franco kernel... Probably why.


----------



## semperfi

Andrew025 said:


> I received this cable today and tried it on my n7 and gnex with no luck. It can access the usb drive but it does not charge.
> It works on my wife's stock gs3 though.
> Both my devices are on Franco kernel... Probably why.


Searching the net for this answer I stumbled upon this thread, I bought 2 of that cable. It doesn't charge the phone.

Battery status - checked, not charging
Leave a while with a charger connected + attaching wireless USB KB & Mouse - checked, not charging
Unplugged all device leaving the charger connected - checked, not charging

Phone: Gnex stock JB rooted

I have tried to re-read the thread as I might've missed something

Do you need a specific kernel for that? (based on the discussion = not needed)

Kindly advise & thanks......and Hi Guys 

________________________

Update : I got it work now, using a modified AOSP kernel.


----------



## Andrew025

I loaded up a different kernel (lean kernel) and no difference, still doesn't charge. So I don't know.


----------



## dmexs

semperfi said:


> Searching the net for this answer I stumbled upon this thread, I bought 2 of that cable. It doesn't charge the phone.
> 
> Battery status - checked, not charging
> Leave a while with a charger connected + attaching wireless USB KB & Mouse - checked, not charging
> Unplugged all device leaving the charger connected - checked, not charging
> 
> Phone: Gnex stock JB rooted
> 
> I have tried to re-read the thread as I might've missed something
> 
> Do you need a specific kernel for that? (based on the discussion = not needed)
> 
> Kindly advise & thanks......and Hi Guys
> 
> ________________________
> 
> Update : I got it work now, using a modified AOSP kernel.


It shows "Charging" now?


----------



## Timur

dmexs said:


> This is what I see when I plug in my cable after flashing your modified kernel. For my cable I took a normal OTG cable and cut the 5+ lines and soldered them to the 5+ lines of a male USB cable connected to the stock Nexus 7 charger. The battery percentage is certainly rising, but it doesn't say "charging" which is important for me to be able to wake the device with Tasker.
> 
> Do you mind directing me to the exact cable you're using?


It's not your cable. Actually, two kernel patches are needed. The 1st one enables external power operation + battery charging while in USB host mode. A 2nd patch is needed to make the N7 aware of the fact it's battery is actually being charged while in USB host mode. You will find both patches and an updated CM10 based boot image (Grouper kernel containing both patches) here: http://mehrvarz.github.com/otg-power-nexus7.html.
I am not saying this will solve your problem. But if possible, please test and lmk how it goes.
Maybe you can also elaborate on your use of "Tasker". Thank you.


----------



## journeyman

journeyman said:


> I've built a kernel from AOSP source for the Galaxy Nexus using your code and it's working great. Thanks so much for this!
> I've been participating in a thread at XDA Developers where I've posted the boot images for both yakju and takju. It's at http://forum.xda-dev...0&postcount=70.
> One thing of note is that my phone and external USB device (flash drive) are both definitely being powered by the USB charger now. But it doesn't look like the phone battery is actually being charged--the charge level never goes up. It could be that there just isn't enough power to charge the battery while also powering the external device, but that doesn't seem all that likely.
> Would there be some way in the kernel to actually turn on charging as well? It would be neat to have the phone battery topped off while using it in USB OTG mode.


I've been working more on the problem of having the Galaxy Nexus battery charge at the same time as it's being powered using the y-cable in USB OTG mode. I figured out how to do this, as well as have the phone choose between external power if a charger is present or standard USB OTG mode with power provided by the phone if no charger is present. The current boot images for takju and yakju based on the stock 4.1.1 kernel are available at the link in the quoted text above.


----------



## dmexs

Timur said:


> It's not your cable. Actually, two kernel patches are needed. The 1st one enables external power operation + battery charging while in USB host mode. A 2nd patch is needed to make the N7 aware of the fact it's battery is actually being charged while in USB host mode. You will find both patches and an updated CM10 based boot image (Grouper kernel containing both patches) here: http://mehrvarz.gith...wer-nexus7.html.
> I am not saying this will solve your problem. But if possible, please test and lmk how it goes.
> Maybe you can also elaborate on your use of "Tasker". Thank you.


That second patch did it for me! Thank you so much; PM me your PayPal and I'll buy you a beer!  My Nexus 7 now shows charging while in OTG mode!

As for my use of Tasker, I have two profiles set up.

1. AC/USB Charging - when the tablet senses it is being charged then it will: keep the screen on indefinitely, start google music, resume playing the playlist, turn on wifi and bluetooth.

2. No Charging - when the tablet loses power: it will shut off the screen, pause the currently playing song, and turn on airplane mode. I also have a timer defined that will completely shutdown the tablet if it is not turned on again before 24 hours.

So my tablet will be plugged in to 5V hidden behind the dash. So once the accessory line is on Tasker will turn on the tablet and start playing music. So now as you might understand, the fact that the tablet actually acknowledges the fact that it is charging is critical for these transitions. I don't mind sharing these Tasker profiles if anybody would like them!

My last piece of the puzzle that I have to look in to is how to overwrite the default charging screen that shows when the tablet is shut down. (You know, the one that shows the battery with the lightening bolt?) I'd like to overwrite it to just start the tablet in to full boot mode. This will stop me from having to wire an external power button at all and the tablet should always be on when it is receiving power. Here's some info that I'm looking in to right now, but I need to find the equivalent on the Nexus 7: http://forum.xda-developers.com/showthread.php?t=1815131 Let me know if you have any ideas!


----------



## semperfi

dmexs said:


> It shows "Charging" now?


yes it shows charging now...I get the modified boot image from the xda link provided and follow it from there.

I did a test though, I ran the phone and left the battery till around 25% and plug again the cable, it won't charge at all with the cable.

So I directly plug the charger and let it charge till about 50%.....and then tried again, this time it charges fine.

I don't know why but I thought other should be aware of this..nothing biggie


----------



## journeyman

semperfi said:


> yes it shows charging now...I get the modified boot image from the xda link provided and follow it from there.
> 
> I did a test though, I ran the phone and left the battery till around 25% and plug again the cable, it won't charge at all with the cable.
> 
> So I directly plug the charger and let it charge till about 50%.....and then tried again, this time it charges fine.
> 
> I don't know why but I thought other should be aware of this..nothing biggie


With the boot image from XDA, if you plug the USB OTG y-cable into the phone without power already attached, the phone will decide that it is a standard OTG cable and will not accept a charge--the phone is then waiting to power a USB device on the cable like a flash drive. You'll need to attach the charger to the y-cable before attaching it to the phone. Then the phone will be charged.


----------



## Timur

dmexs said:


> My last piece of the puzzle that I have to look in to is how to overwrite the default charging screen that shows when the tablet is shut down. (You know, the one that shows the battery with the lightening bolt?) I'd like to overwrite it to just start the tablet in to full boot mode. This will stop me from having to wire an external power button at all and the tablet should always be on when it is receiving power. Here's some info that I'm looking in to right now, but I need to find the equivalent on the Nexus 7: http://forum.xda-dev...d.php?t=1815131 Let me know if you have any ideas!


I agree, N7 boot-on-power would be nice. (I really hated my 2007 MBP for doing this to me all the time. But this is a different story.)


----------



## dmexs

I will note though, that even when using an externally powered harddrive, when I unplug the power to the Y-cable, the drive disconnects from the tablet. Is there anyway around this, or is this a limitation of the implementation?


----------



## Timur

Very much related to my Q from last week:



Timur said:


> So, the Samsung Galaxy S2 and S3 - other than the Galaxy Nexus and the Nexus 7 - seem to support externally powered host mode out of the box, with the default kernel (likely triggered by a specific sense pin resistor, I assume). My question to owners of such devices: what happens if you pull the external power when in externally powered host mode (while the battery is charging)? Will the device switch to OTG (self powered) host mode quick enough so you can continue using your slave device(s) as if nothing happened?


----------



## mvmacd

dmexs said:


> I will note though, that even when using an externally powered harddrive, when I unplug the power to the Y-cable, the drive disconnects from the tablet. Is there anyway around this, or is this a limitation of the implementation?


That is because the external harddrive sees no power to it, and thinks the host has powered off, so it turns off.









Also, *@Timur*, thank you for your work on this, I have a question though. I haven't tested anything yet because I don't have the Y cable yet









On XDA faux123 beta kernel, he says there is "otg charging." To enable it you have to echo 1 into some /proc/ file. Is there any way you can enable and disable otg charging mode? Or does this boot image automatically determine if you are using otg + charge, and thus are able to power flash drives by itself? And is it better to use this boot image, or should I use faux123's beta kernel?

And let me get this straight, I can use a combination of a OTG Micro USB and a regular USB Y cable? Or do I have buy a [more] expensive cable that's meant for OTG charging?

And lastly, is it possible to damage the N7 in the event you were trying to charge it, and at the same time the N7 is trying to give out power to the OTG device at the same time? Thanks


----------



## dmexs

mvmacd said:


> That is because the external harddrive sees no power to it, and thinks the host has powered off, so it turns off.


No, this is an externally powered harddrive.


----------



## mvmacd

dmexs said:


> No, this is an externally powered harddrive.


You mean you use a AC adapter to power it? That is what I thought when I posted. Anyway it still applies: the externally powered hard drive will turn off if there is no power to make it think the computer is on. Just like I said, if you plug your hard drive into a PC, it turns on. Now, power off your computer, and you will see the hard drive turn off, since the USB power to the externally powered has been turned off, it registers that you have turned off your computer, and turns off itself.


----------



## Timur

dmexs said:


> No, this is an externally powered harddrive.


Sounds like when the N7 is forced to switch from being charged to operate on battery, it will reset/forget it's knowledge about the USB host mode it was in. Hmm..

Edit: Due to overlap I didn't read the last post by mvmacd. This is certainly a possible cause as well.

About the power-off charging screen. This code runs even before the Android boot loader will load. Hard to fix. I am really starting to miss my bios setup options. To see what people do to implement boot-on-power on some other Android system, take a look at this: http://odroid.foros-phpbb.com/t1082-automatic-boot-on-power-up


----------



## antistase

romandesign said:


> SUCCESS!!! I can confirm that this USB OTG cable (http://ebayitem.com/190710044655) DOES CHARGE MY GALAXY S3! I wanted to doplicate your experience so I got the exact same cable. I plugged in USB cardreader with SD card into the phone through this cable (it lit up and card is fully readable), then plugged USB cable end into PC and phone showed a charging icon! Moreover, after waiting for 5 min. with screen off (cardreader still glowing blue and working) battery has gone up from %72 to %75 (and while I was writing this, to 78%), so it is indeed charging! Yay! It probably won't get up in the car, where just phone alone is "not discharging" at best from the car adapter, but at least it should allow me to listen to music with quality DAC and use navigation without (or with minimal) discharging.
> 
> I have not tested it with USB DAC that I intend to use for my car (Behringer UCA222), because I have to go out and buy it. Hopefully it works. Anyway, this cable definitely works with simultaneously charging my north-american Samsung Galaxy S3 (from Bell Canada) while powering USB cardreader!


Well... this ebay seller doesn't seem to sell to Europe at all.
I made an OPT cable out ou a normal USB one with the +_ wires connecting back to back and my S3 doesn't charge when plugged into a powered USB port.
I didn't try to cut the supply wires and power the phone with a separate charger, but it doesn't seem to me that will make any difference in eletrical terms provided the otg connection (id and neg shorted) is in place.
On the other side it seems a lot of people tried to find the right id-ground resistor to switch the S3 to OTG+charging without success seeming to indicate one of the two possibilities: either you need to use high precision resistors with the right value needed to trigger the right kernel state (maybe the ebay seller did that?) or you need to modify the kernel to match the resitor you use between id and ground.

Anyone willing to rip open this wander of otg connector for the education of the masses?


----------



## dmexs

Timur said:


> About the power-off charging screen. This code runs even before the Android boot loader will load. Hard to fix. I am really starting to miss my bios setup options. To see what people do to implement boot-on-power on some other Android system, take a look at this: http://odroid.foros-...oot-on-power-up


Sigh, perhaps externalizing the power button will be a more successful endeavor. Started a new thread:
http://forum.xda-developers.com/showthread.php?t=1945947


----------



## MetalMan

Hi all, first post here. First off, I want to add that I've had excellent luck with the most recent patch, and my N7 showing charging while having full functionality over a USB drive, keyboard, mouse, etc. I really appreciate all the work completed here!

However, one of the other items I'd like to connect to my N7, while charging + hosting USB, is a USB audio DAC. The DAC works great with other kernels (Faux123, poitee kernel), but it seems CM10 doesn't support USB audio. I've tried updating asound.conf in /system/etc/ but wasn't able to get USB audio (Behringer UCA222) working the CM10 + patch #2.

My question: has anybody here successfully hosted USB with a flash drive and DAC, and charged their N7 at the same time? As you can guess my target goal is an in-car installation.


----------



## rodneyr

Hey MetalMan,

Thanks for your above post at 9:12 am.

1. Could you post a direct link to the modification you're using, which I assume is CM10 + patch #2. Please.
2. In your physical configuration are you using a Y cable, or a USB hub, and which model(s)?

Please, and thank you.

Rodney


----------



## Timur

CONFIG_SND_USB_AUDIO is indeed not set for the default CM10 N7/grouper kernel. As can be seen here:

https://github.com/CyanogenMod/android_kernel_asus_grouper/blob/jellybean/arch/arm/configs/cyanogenmod_grouper_defconfig

Have turned this setting on for this boot image: https://github.com/mehrvarz/files/raw/master/boot-cm10-grouper-host-mode-power-2012-10-22.img
If this does not drive the Behringer, we need to find out what other setting(s) may be needed. I want to play with this, too. But haven't got the hw yet.

Also still looking for an elegant N7 boot-on-power solution. Growing a depression over it.


----------



## MetalMan

rodneyr said:


> CONFIG_SND_USB_AUDIO is indeed not set for the default CM10 N7/grouper kernel. As can be seen here:
> 
> https://github.com/C...ouper_defconfig
> 
> Have turned this setting on for this boot image: https://github.com/m...-2012-10-22.img
> If this does not drive the Behringer, we need to find out what other setting(s) may be needed. I want to play with this, too. But haven't got the hw yet.
> 
> Also still looking for an elegant N7 boot-on-power solution. Growing a depression over it.


You sir, are AMAZING. Installed that boot image, and now have audio coming through the speakers attached to my DAC, while the Nexus 7 displays it is charging! The only thing I could further ask for is a toggle to switch between OTG + charging and normal OTG hosting. The faux123 kernel < http://forum.xda-dev...hlight=charging > has this toggle, but I've found that every time I reboot my N7 the toggle switches back to the normal OTG method... and in order to get the USB DAC to work I have to boot up with it attached.

Thanks for your help!


----------



## mvmacd

Timur, do you think when the Nexus 10 is released, it will be relatively easy to patch the kernel--now that you figured it all out--to achieve OTG and charging on the Nexus 10 with the same setup?  I just bought the item MetalMan2 linked, and it should be here in roughly 2 weeks, since it's coming from china.

Even though I love my N7, I really am tempted by the 300 DPI display.. so I will most likely get it and sell my N7 unless the price is ridiculously high.


----------



## Timur

mvmacd said:


> Timur, do you think when the Nexus 10 is released, it will be relatively easy to patch the kernel--now that you figured it all out--to achieve OTG and charging on the Nexus 10 with the same setup?  I just bought the item MetalMan2 linked, and it should be here in roughly 2 weeks, since it's coming from china.
> 
> Even though I love my N7, I really am tempted by the 300 DPI display.. so I will most likely get it and sell my N7 unless the price is ridiculously high.


A 10" 300 DPI tablet may come with a separate power supply, no? That would solve the problem.
In the long run, I'm sure, tablets will provide two or more USB ports and come with full host mode out of the box.
This doesn't mean that there will be no functionality missing that couldn't easily be added


----------



## Batty

I've been following this concept on multiple sites, and so far I've only seen the OTG + charge exist in the single fastboot flash that mehrvarz hosts. Is it possible to lift the code directly from his github and incorporate it in any existing kernels? Just for example, could it be implemented in Clemsyn's kernel?

Sorry if this has been addressed, I did read over the thread but didn't see any indication of this.

Edit: looks like faux123 has already put this in his beta kernel. Hm...I wonder if anyone else might be able to do this.


----------



## MetalMan

Just thought I'd throw this out there: tonight I decided to try to see if Timur's newest patch (post #72) which allows USB audio / USB hosting / charging (all simultaneously) would work with Team EOS's nightly kernel/ROM.

Here's the process: go into Recovery, full wipe/factory reset/wipe cache and dalvik. Install Team EOS grouper nightly build, install latest GApps package. Reboot, set up Google account. At this point I installed Titanium Backup and restored all my crap.

THEN: Command Prompt with N7 attached through USB cable: adb devices; adb reboot bootloader; fastboot flash boot boot-cm10-grouper-host-mode-power-2012-10-22.img; fastboot reboot. It booted back up, and I checked the kernel version in settings. It still shows the EOS kernel!

Attached unpowered USB hub and special OTG y-cable with charger input. Stickmount popped up saying that a drive was mounted, and the battery indicated it was charging. Rebooted with USB DAC attached, and am currently playing Pandora on my tablet/DAC on my speakers while charging 

So what's the point of this? I am running the Team EOS ROM, which is my favorite on my Motorola Xoom, and I really like it on the Nexus 7 (far more than CM10, and prefer it over ParanoidAndroid).

HOWEVER: prior to installing the patch I could overclock the CPU to 1500MHz, and after installing the patch I cannot clock the CPU past the stock 1300MHz. Guessing this is because the patch is effectively a kernel install, and the CM10 kernel doesn't allow overclocking that I know of.


----------



## mvmacd

Timur said:


> A 10" 300 DPI tablet may come with a separate power supply, no? That would solve the problem.
> In the long run, I'm sure, tablets will provide two or more USB ports and come with full host mode out of the box.
> This doesn't mean that there will be no functionality missing that couldn't easily be added


Yeah I guess that would make more sense.. I guess I expected the Nexus 10 to be a giant Nexus 7 with updated hardware [and screen].. Didn't really think much about Samsung manufacturing it.

I still haven't even got my cable yet :S I'm definitely not buying the N10 at retail + 6.25% sales tax like I did my Nexus 7 [which was just devalued $50].. So I will keep an eye out [like a hawk  ] on Craigslist for someone wanting to trade their shiny Nexus 10 in for quick cash [at a discount, of course..]

So anyway, I'm a little confused, this 'boot image,' is it just entirely a kernel? or does it flash anything else? [bootloader?] And it is based off CM10 kernel? Is it compatible with 4.1.2? [I'm using ParanoidAndroid rom]


----------



## dcplaya

MetalMan said:


> Just thought I'd throw this out there: tonight I decided to try to see if Timur's newest patch (post #72) which allows USB audio / USB hosting / charging (all simultaneously) would work with Team EOS's nightly kernel/ROM.
> 
> Here's the process: go into Recovery, full wipe/factory reset/wipe cache and dalvik. Install Team EOS grouper nightly build, install latest GApps package. Reboot, set up Google account. At this point I installed Titanium Backup and restored all my crap.
> 
> THEN: Command Prompt with N7 attached through USB cable: adb devices; adb reboot bootloader; fastboot flash boot boot-cm10-grouper-host-mode-power-2012-10-22.img; fastboot reboot. It booted back up, and I checked the kernel version in settings. It still shows the EOS kernel!
> 
> Attached unpowered USB hub and special OTG y-cable with charger input. Stickmount popped up saying that a drive was mounted, and the battery indicated it was charging. Rebooted with USB DAC attached, and am currently playing Pandora on my tablet/DAC on my speakers while charging
> 
> So what's the point of this? I am running the Team EOS ROM, which is my favorite on my Motorola Xoom, and I really like it on the Nexus 7 (far more than CM10, and prefer it over ParanoidAndroid).
> 
> HOWEVER: prior to installing the patch I could overclock the CPU to 1500MHz, and after installing the patch I cannot clock the CPU past the stock 1300MHz. Guessing this is because the patch is effectively a kernel install, and the CM10 kernel doesn't allow overclocking that I know of.


What DAC are you using? And does changing the volume on the N7 change the volume at the speakers? Finally, is it charging at USB speeds or AC speeds? I never really saw a solid answer in previous posts about that.


----------



## jmcguire525

does the patch only work on CM10 based roms?


----------



## MetalMan

dcplaya said:


> What DAC are you using? And does changing the volume on the N7 change the volume at the speakers? Finally, is it charging at USB speeds or AC speeds? I never really saw a solid answer in previous posts about that.


Currently using the Behringer UCA222.
Yes I can change the volume at the speakers using the N7's volume controls.
Charging should occur at AC speeds. It is actually necessary to have an AC charger (or charger capable of 2A) plugged in while in OTG mode.


----------



## dcplaya

MetalMan said:


> Currently using the Behringer UCA222.
> Yes I can change the volume at the speakers using the N7's volume controls.
> Charging should occur at AC speeds. It is actually necessary to have an AC charger (or charger capable of 2A) plugged in while in OTG mode.


Awesome, that is exactly what I want to hear! My car tablet is back on track now I think!


----------



## Timur

> this 'boot image,' is it just entirely a kernel? or does it flash anything else? [bootloader?]

Just a kernel, no bootloader, no boot images (edit: in the sense of no boot animations). A bit more info about Android boot images and kernel packaging: 
http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack%2C_Edit%2C_and_Re-Pack_Boot_Images

tl;dr: if some update.zip installs a kernel, it does so via an embedded boot image.
Also: a bare boot image can be flashed from the comfort of your pc, no need to operate recovery menus or even touch the device.

> Is it compatible with 4.1.2?

You should be able to apply the two source code patches to any Nexus 7 kernel (stock, CM or else).

> does the patch only work on CM10 based roms?

The boot images I uploaded are based on 4.1.2 as in CM10.
The kernel may be compatible with stock JB. But this I didn't test.


----------



## jmcguire525

Thanks, got my car tablet project back on track too, I'll post a full video of the setup once I'm done. This has come a long way since I first posted on here asking a dev to help make this happen... and Poitee, I promised the first person to enable this in a kernel $50 and I'm still going to make good on that, just been busy and low on cash as a college student but its coming.


----------



## puffmais

Hi everybody,
i hope you will understand my bad englisch...
i saw the thread here in the forum, to charge the nexus 7 while it is in otg mode. ive used the latest "boot-cm10-grouper-host-mode-power-2012-10-22.img" and its working amazing with my usb dac. thank you very much for that timur!
i have only one thing, may someone can help me?
i want to install the nexus in my car, so when i turn on the ignition, the powered usb hub turned on and the nexus screen turned on and otg mode start so i can put in usb sticks and so on. but the usb dac works only when i restart the nexus 7 with turned on ignition...
it is possible that the sound comes always through the usb dac? so that when i go into the car i must not reboot?
thank you very much!

best regards
christoph


----------



## Timur

puffmais said:


> so when i turn on the ignition, the powered usb hub turned on and the nexus screen turned on and otg mode start so i can put in usb sticks and so on. but the usb dac works only when i restart the nexus 7 with turned on ignition...
> it is possible that the sound comes always through the usb dac? so that when i go into the car i must not reboot?


As far as the kernel is concerned, self-powered host and externally powered host are really separate modes. When you turn your car key (with your N7 already running, I assume), the kernel will need to switch modes. This doesn't happen instantly. I think I watched the complete mode switching taking 1700 ms or so. Maybe the DAC you are using comes up very quickly and advertises itself too briefly and only *before* the N7 has finished mode switching. Maybe your DAC needs it's power-up be delayed. Maybe some other DAC would not require this. What happens, if you unplug and re-plug the DAC, instead of restarting the tablet?

Edit: Ahh let me try that again: what if you plug your N7 first (switch to host), then wait 2s and then plug in your DAC?


----------



## puffmais

Well, thats curios! the hole evening i pluged in the dac, re-pluged it, an no sound comes trough it, ive tried many things, but only if i first reboot, it worked. but than one time the sound came direct through the dac after re-plug in! i dont made anything else?! than the next time it dont work... i tried it again and again, after several times and reboots now it seamed to work properly!
i used the programm tasker now: ignition on --> power to usb hub --> nexus 7 starts to charge --> display on --> wait 3 seconds --> play music --> sound comes through usb dac!
the other schedule: ignition off --> power off usb hub --> charging stops --> pause music --> wait 3 seconds --> display off

Edit: Damn it, 3 times it works, now it wont...!


----------



## jmcguire525

I'm getting similar results as you puff, one time the audio worked as soon as I plugged the power back in, most times it takes a few minutes (and some random clicking around), and other times I can't ever get it to work without a reboot. There seems to be some sort of handshake issue that is hit or miss and as Timur said may differ depending on the DAC.

Also mine charges at USB speeds but I thought it was supposed to be AC?


----------



## Timur

Does rebooting the tablet provide positive results *all* the time?

Pls try this: using the Y-cable, power up the DAC, wait 2s and then plug the tablet. (Opposite order of what I have described before.) Is the behavior consistent?
Does the DAC work every time, when plugged into a PC?

Do you know the DAC's specified average/peak power consumption?


----------



## puffmais

rebooting works all the time and dac work every time when plugged into pc!

i try: power up the usb hub -> plug in the dac -> put in otg kable -> no sound -> reboot -> sound through usb dac -> pull off otc kable with power on usb hub and re-insert otg kable -> sound through dac! i tried this several times and it worked...
i tried also put off otg kable and than power down the hub, repower the hub and put in otg kable...seamed to work also properly.
but only power down the hub and otg kable inside works only sometimes!

by the technical details of the dac stands only verly low power consumption.. i have the terratec aureon dual usb


----------



## mvmacd

Timur said:


> > this 'boot image,' is it just entirely a kernel? or does it flash anything else? [bootloader?]
> 
> Just a kernel, no bootloader, no boot images (edit: in the sense of no boot animations). A bit more info about Android boot images and kernel packaging:
> http://android-dls.c...ack_Boot_Images
> 
> tl;dr: if some update.zip installs a kernel, it does so via an embedded boot image.
> Also: a bare boot image can be flashed from the comfort of your pc, no need to operate recovery menus or even touch the device.
> 
> > Is it compatible with 4.1.2?
> 
> You should be able to apply the two source code patches to any Nexus 7 kernel (stock, CM or else).
> 
> > does the patch only work on CM10 based roms?
> 
> The boot images I uploaded are based on 4.1.2 as in CM10.
> The kernel may be compatible with stock JB. But this I didn't test.


ok, thanks for clarifying [though that is what I suspected, you confirmed it].

one thing, how often does the CM10 kernel get updated? often, or once in a while? because when I update my rom [PA, cm10 base], and then flash this kernel, I wonder if the kernel is outdated, or if there are improvements made that I don't have because the kernel is [sort of] old.
how hard is it to patch a kernel and compile it?


----------



## jmcguire525

puffmais said:


> rebooting works all the time and dac work every time when plugged into pc!
> 
> i try: power up the usb hub -> plug in the dac -> put in otg kable -> no sound -> reboot -> sound through usb dac -> pull off otc kable with power on usb hub and re-insert otg kable -> sound through dac! i tried this several times and it worked...
> i tried also put off otg kable and than power down the hub, repower the hub and put in otg kable...seamed to work also properly.
> but only power down the hub and otg kable inside works only sometimes!
> 
> by the technical details of the dac stands only verly low power consumption.. i have the terratec aureon dual usb


Try a Y cable, it is working for me every time after reboot with everything plugged in, if I unplug power and reattach I have to change to a new song or something similar but so far it is picking it back up once the audio source starts and stops (it worked 5 out of 5 times last night)


----------



## puffmais

I tried it with a Y-cable. it worked only sometimes. I tried the whole evening...but I think I now know when it works and when not:
if i power down the hub and re-power it and the tablet screen is always on, than the sound comes always through the usb dac. but if i power down the hub, push power button for lock screen, re-power the hub, lock screen off and than start music, no sound comes through usb dac! only if i reboot, or re-plug usb cable!


----------



## Timur

Just trying to rephrase what you said.
1) By powering down the DAC and by putting the tablet to sleep, both at the *same* time, you can establish the error condition.
2) You can fix the error condition by restarting the tablet.
3) But you don't *have* to restart the tablet. You can also fix the error condition in all cases by simply unplugging and re-plugging the DAC's USB cable.
4) Restarting the DAC while the tablet stays full on will *not* establish the error condition.
Pls confirm.

I'd like to suggest connecting your DAC to a Linux kernel on a different device (say a Ubuntu box), play around with it, put that machine to sleep, etc.
The problem you are experiencing may not be Android specific.

> how often does the CM10 kernel get updated? often, or once in a while?
Not often: https://github.com/C...mmits/jellybean

Edit: fixed typo


----------



## puffmais

1) must not at the same time, also an error condition when first tablet is in sleep and then power down the dac.
2) yes
3) yes, but only unplugging and replugging when tablet is not in sleep! unplugging and replugging while tablet is in sleep wont work!
4) yes, this always works

okay thank you, i dont know anything about linux or ubuntu systems, i have to learn first an i try it then.


----------



## Timur

puffmais said:


> 3) yes, but only unplugging and replugging when tablet is not in sleep! unplugging and replugging while tablet is in sleep wont work!


Indeed there seems to be an issue switching N7 (Grouper) to USB host mode, while it rests in sleep mode.
I'm not able to provide a proper solution at this time. But I would like to report the following outstanding kernel messages which seem to be related to this issue:

tegra-i2c tegra-i2c.2: I2c error status 0x00000008
tegra-i2c tegra-i2c.2: no acknowledge from address 0x28
tegra-i2c tegra-i2c.2: Packet status 0x00010009
pn544_dev_write : i2c_master_send returned -121

For the time being, I would suggest to plug a host mode (OTG) adapter only after waking the N7 from sleep.


----------



## besjr69

Long Post, but I wanted to provide as much detail as possible to facilitate the discussion:

I am using the N7 as the headunit in my vehicle. My goal is to take my entire media collection with me on the road. After reading a few articles about OTG i ordered the standard cable, but the OTG does not provide enough power to turn on and recognize my WD 320GB portable HDD. Then I found this thread. I got my OTG Y cable about a week ago and successfully hooked it up to my N7. I can stream MP3s and videos off the device. The problem is when I power down the device and resume.

After turning off the ignition, I lose AC power to the N7 and the external HDD. According to this thread, the N7 goes into normal OTG mode when no power is applied. This causes an error (improper unmount) and when I reapply power, the drive is no longer recognized. After some troubleshooting I found that if I were to unplug the micro USB from the N7 and later plug it back in everything works fine again. This got me to thinking (bad thing). What is the difference? If the cable is removed, the N7 cannot go to an OTG state. So what if I were to expose the "Sense" pin and control it via relay? My thinking is that it would power down the external HDD and take the N7 out of OTG mode. When power is reapplied, it would power the HDD and put the N7 back in OTG charging mode.

Before I go prototypying this circuit, is there anyway to do this via a Kernel MOD. Is there anyway to tell the N7 to disable OTG when no power is applies and then re-enable it when power is applied. I believe this would solve the issues with external storage and the USB DAC issues. They appear to be the same issue just on two different devices.

Bobby


----------



## Timur

My initial solution for the powered USB host mode "unplug issue". Patch 3 (see below) contains modified Android platform code. This is why I am providing a full update.zip type installer, including boot.img (kernel) + system image. The installer is based on the final CM10 (as of 20121115) and in addition contains:

- patch 1: enable externally powered USB host mode operations (unchanged from 10/2012)
- patch 2: enable charging in USB host mode (unchanged from 10/2012)
- patch 3: fix unplug-issue while in externally powered USB host mode (new/tbc)
- enabled USB sound (unchanged from 10/2012)
- enabled CIFS (new/tbc)

Install: You are a real die hard, willing to use untested software. Use at your own risk. Please make sure to backup your device, so you can revert back to what you have. Store cm-10-20121115-mehrvarz-grouper.zip file on your /sdcard and install via recovery.

Download: http://timur.mobi/files/cm-10-20121115-mehrvarz-grouper.zip
(If this link doesn't work, look further down.)

Patch 3 documented: https://github.com/mehrvarz/android_frameworks_base/commit/80cf66c44855ca421d2a57aab0033205e287f88c

Note that *before* you unplug or power down a USB flash drive or hard disk, you need to manually unmount all mounted filesystems.

Edit: new download link


----------



## puffmais

Hi Timur,
sounds really nice! thank you very much for your help!
I want to try it, but when i click on download: "Error: blob is too big"


----------



## Timur

puffmais said:


> "Error: blob is too big"


fixed - with apologies


----------



## puffmais

I installed the zip, but on reboot the nexus7 it stucks on cyanogen mod bootlogo...


----------



## Timur

puffmais said:


> I installed the zip, but on reboot the nexus7 it stucks on cyanogen mod bootlogo...


You may need to "wipe data / factory reset" in the recovery. If this doesn't work, pls try "adb logcat" and lmk what you see.


----------



## puffmais

with [background=rgb(245, 245, 245)]wipe data / factory [/background]reset it worked...but the problem is still there :-/
no sound trough usb dac when repower while lockscreen is on...


----------



## Timur

Unplugging USB in powered host mode before patch 3 resulted in a platform code exception. This prevented flash drives and hard disks from becoming mountable later, even if the filesystem was correctly unmounted before unpluging. For me, this problem is resolved with patch 3. Too bad the DAC issue is not yet resolved.
I would be happy to take a look at some adb logcat of the DAC unplug issue, if someone can produce this. (Ideally both in wake and sleep mode.)


----------



## jmcguire525

tell me how to get you the logcat info and I'll try to get it posted up for you


----------



## besjr69

I applied Patch #3. Works as disucssed, but it killed my GPS. I've noticed this issues with several of the CM10 nightlies. No issue with Experimentals. Restored back to Patch #2 nandroid. Is there a fix for the GPS or can the zip be just the patch only. I tried flashing over this with the 10/19 EXPERIMENTAL with no luck.


----------



## kevincat3556

Just thought I'd throw this out there. I made this and it actually charges with a controller hooked up!

The blue USB cable is cut up and has no data pins. Just the 5V and Ground wires. I took an old USB hub and wired the Motorola cable up with data and power to the USB labeled port, and the power pins to the POWER labeled port. Works wonders when I plug the blue cable into the charger!
Sent from my Galaxy Nexus using RootzWiki


----------



## kevincat3556

Oops..... Thought this was a galaxy nexus thread. Oh well. This should work.

Sent from my Galaxy Nexus using RootzWiki


----------



## Timur

jmcguire525 said:


> tell me how to get you the logcat info and I'll try to get it posted up for you


Thank you for the kind offer. However, I just bought a little USB DAC device, so I am finally able to look at this myself. I'm able to get sound out of the DAC, but only after rebooting with the DAC hooked up. I cannot get sound out of it, when I only connect the DAC "at runtime". In this respect, DAC audio does NOT behave like, say, Bluetooth audio. I assume this is the problem you guys are talking about. Let's see...

OK, how to log with the USB cable pulled (just in case): Enable "Keep Wi-Fi on during sleep" (under Wi-fi / Advanced). Then connect to your access point. Then enable "ADB over network" (under Dev. options). Now you can use the shown dynamic ip address to enter the following on the PC: 1. "adb connect x.x.x.x" and 2. "adb -s x.x.x.x:5555 logcat".

> CM10 ... but it killed my GPS

Q: Internal or external GPS?


----------



## besjr69

I am referring to the internal GPS. I do not have WiFi available at all times and I have my Maps setup for offline navigation. As stated, I've run into this issue with a lot of the CM10 nightlies. The only CM10 that works without killing GPS so for is the last "EXPERIMENTAL-M2" version. I've tried Wiping Dalvik, Cache, and Data. I've also tried flashing Path #3 on top of the M2 and vice versa all to no avail.

Bobby


----------



## jmcguire525

Timur, from what I have found the DAC will NEVER connect unless it is booted up with everything connected, and for me and the other people wanting this to work for car audio I don't think that is really a problem. The real issue is once you boot up with the DAC connected you should be able to disconnect the DAC and reconnect easily, I say you should b/c once you disconnect the DAC the audio is never routed back to the internal speakers. The N7 still is being told to use USB audio, it seems to just have a handshaking problem with the DAC. I wish I had a dozen different DAC's to try out b/c there may be a few that don't cause this problem.


----------



## Timur

Can I ask what you have found out?


----------



## RWNube

If I unplug my Fiio E 17 with Patch 2 (haven't tried Patch 3 yet), I can plug it back in and it plays totally fine as long as I start the song over or play something else. 
Same exact thing if I unplug the USB charger from the OTG Y cable and plug the charger back in.

Sent from my ADR6425LVW using Tapatalk 2


----------



## jmcguire525

RWNube said:


> If I unplug my Fiio E 17 with Patch 2 (haven't tried Patch 3 yet), I can plug it back in and it plays totally fine as long as I start the song over or play something else.
> Same exact thing if I unplug the USB charger from the OTG Y cable and plug the charger back in.
> 
> Sent from my ADR6425LVW using Tapatalk 2


I've had the same experience five times in a row before, but then tried it the next day and it didn't work.


----------



## nexus-fan

Hi all,
Sorry for my english.

First timur, thank you so much for your efforts.

The problem i found is that when i disconnect the charge cable i must reboot the
nexus, in all other case i can plug\unplug the dac but
in this situation we have a big problem (for Car) because its
not a problem to charge the nexus all the time but
to "stay awake" all the time i dont think so "healthy".

the current solution is to download toggle widget that change stay-awake mode on\off,

btw, i plan to purchase the nexus 4G in the future so the question is if the
CM10 for regular nexus and patches should working on the new device???


----------



## puffmais

with patch 3 installed i found out yesterday, that i can power down the usb hub with dac is connected and a song is still playing in the background, that when i repower the hub when nexus 7 lockscreen is on, and than pause the song and after few seconds i can play the song and the sound comes trough usb dac!

but if i power down the hub, song is stopped playing and lockscreen get on, than after repowering no sound comes through usb dac until i reboot or disconnect otg cable.


----------



## jmcguire525

I think I have a solution that will work on the hardware side. The picture should be self explanatory, V&G are your power and ground +&- are your data wires. This should allow the DAC to stay on at all times by being connected to the hot wire in the car and the tablet will be connected so that it only has power when the car is running.


----------



## kevincat3556

jmcguire525 said:


> I think I have a solution that will work on the hardware side. The picture should be self explanatory, V&G are your power and ground +&- are your data wires. This should allow the DAC to stay on at all times by being connected to the hot wire in the car and the tablet will be connected so that it only has power when the car is running.


As long as there is a shared ground somewhere, that should work.


----------



## jmcguire525

I tested it but didn't have any luck, maybe the DAC needs to get power and data at the same time to turn on. When you say there should be a shared ground can you elaborate?


----------



## Timur

I now better understand what is going on with the USB DAC and the N7. It's actually trivial. My findings:

* usbaudio is NOT enabled by default in JB/CM10, but can be enabled easily.
* usbaudio can be enabled as a static kernel component only. It does not seem to work when enabled as a loadable module. (Probably due to the fact that everything else is also statically bound.)
* usbaudio only checks for a USB DAC being connected during boot. Switching between USB DAC and internal sound card always requires a system reboot. (A N7 with faster flash, booting in under 15 seconds, might be an advantage 
* Once a USB DAC device is detected during boot, it's USB cable can be pulled and plugged any number of times, it will always be rediscovered. This is, until the Android device was restarted without the DAC being connected.
* The behavior of usbaudio is NOT in any way changed or degraded by my patches for powered host mode and charging.
* The behavior of usbaudio is NOT in any way changed or degraded by the Android device being awake, in lock screen or in sleep mode.

I would argue, that "allowing the DAC to stay on at all times by being connected to the hot wire in the car" as described further up, will not provide any real benefits. Once you have connected the DAC to your Android device, you can keep the DAC running or shut it down - as you like - it will always play back audio again when turned on, for as long as the Android device has not been restarted in between. So, for example, over night, I would suggest to disconnect both devices from power. I assume the N7 will stay on in sleep mode for many days or weeks and your DAC experience will be available the next time, as soon as you start the ignition.

The N7 is a little too large for my car. Might give my old Nexus S a try for this purpose...

Edit: typos

Edit2: If you want a patched N7 kernel based on CM10 final but without the full system image (see: msg #98), you can find it here: https://github.com/mehrvarz/files/raw/master/boot-cm10-grouper-host-mode-power-2012-11-15.img


----------



## jmcguire525

[background=rgb(245, 245, 245)]* Once a USB DAC device is detected during boot, it's USB cable can be pulled and plugged any number of times, it will always be rediscovered. This is, until the Android device was restarted without the DAC being connected.[/background]
[background=rgb(245, 245, 245)]This is the only problem, I can boot with the DAC connected and it will work fine but once I disconnect there is no way to know if it will be detected again. It is almost always detected again but usually not right away, most of the time changing a song or something similar will make the audio kick back on and sometimes it takes up to 10 mins to detect the DAC and start outputting audio to it again. AFAIK the Galaxy S3 does not have this problem stock and does not have to be rebooted to detect a DAC, is there anyway to make the N7 work the way the S3 does here.... [/background]


----------



## nexus-fan

so, as far as i understand there is no solution to this issue and
i have to charge the N7 all the time or restart the device every ride..? :-(


----------



## MetalMan

Timur said:


> Edit2: If you want a patched N7 kernel based on CM10 final but without the full system image (see: msg #98), you can find it here: https://github.com/m...-2012-11-15.img


This is what I've been waiting for, thanks! Personally I can't stand CM10 ROM, much prefer Team EOS ROM. So this patch enables me to use Team EOS ROM with OTG + charge + USB DAC


----------



## Timur

jmcguire525 said:


> [background=rgb(245, 245, 245)]sometimes it takes up to 10 mins to detect the DAC [/background]


Now I see why you want to keep your DAC powered all the time. Please note that my cheapo DAC does not do that. I have to stop/start a song, too. But it always plays after a second or two. You might want to consider testing another DAC?

I took a brief look at the S3 kernel. Samsung has added very significant amount of custom code there under the /sound/soc. Where in the case of the N7 we are taking advantage of a standard (none-Asus) Linux kernel driver for usbaudio. It may be a good idea to investigate the N10 for it's usbaudio capabilities.


----------



## GoldMembr

Timur

Someone else has asked this already but it was never answered. Is the a way to make a new img where it has USB OTG + Charging with a Y-Cable as well as normal USB OTG when you don't want to charge? As it is right now normal OTG does not work only with a charging cable. ie. In other words, to have the kernel auto-detects if there is a charger attached via a y-cable and uses it to power the external device and charge, ONLY if it's found.

Same as here
http://forum.xda-dev...50&postcount=70


----------



## kevincat3556

GoldMembr said:


> Timur
> 
> Someone else has asked this already but it was never answered. Is the a way to make a new img where it has USB OTG + Charging with a Y-Cable as well as normal USB OTG when you don't want to charge? As it is right now normal OTG does not work only with a charging cable. ie. In other words, to have the kernel auto-detects if there is a charger attached via a y-cable and uses it to power the external device and charge, ONLY if it's found.
> 
> Same as here
> http://forum.xda-dev...50&postcount=70


The fifth pin on the USB on the device(nexus 7 or gnexus) is for OTG. Connect the fifth pin to ground and the device goes into host mode. you could run a small switch from the micro USB plug and put it outside of the cable i guess. When i get home, ill draw some stuff out


----------



## nexus-fan

hi kevin,
i think you mean to the 4th "sense" leg that
you have to short with the fifth leg (ground),
is it correct?

USB OTH SCHEME


----------



## puffmais

Timur said:


> ... I have to stop/start a song, too. But it always plays after a second or two....


Did it also play evertytime when you: stop music, put tablet in lock screen, plug off dac, wait few seconds, plug on dac, put lockscreen off, and than start to play music??


----------



## mentose457

Timur, will your boot image work on 4.2? I suspect It will not but thought id ask anyway.


----------



## kevincat3556

nexus-fan said:


> hi kevin,
> i think you mean to the 4th "sense" leg that
> you have to short with the fifth leg (ground),
> is it correct?
> 
> USB OTH SCHEME


Yes. I made my own OTG cable from a chopped up Motorola charger for my GNexus. Same thing applies here. The extra 'sense' pin, is usually unused. so just connect it to a little toggle switch and make it togglable. lol. sorry. hard to concentrate here, the teacher is INSANE!

what i mean is, take the sense pin, and instead of just shorting it out, run it outside of the plug and you can toggle OTG mode WITHOUT having to take the cable out! lol. it actually charges my power-hungry nexus with a controller and HDD hooked up playing GTA3, so it should DEFINITELY charge the Nexus 7, which i will be getting for christmas. i can do more testing when i get home tomorrow.


----------



## ddxfish

They make a special cable for this called an MHL Cable

http://www.sfcable.com/10U2-W3MHL-10.html?utm_medium=shoppingengine&utm_source=googlebase&cvsfa=3023&cvsfe=2&cvsfhu=313055322d57334d484c2d3130&gclid=CJrZzPHi3rMCFcXb4AodEmcARg

It has a micro usb to HDMI/USB

It allows charging, HDMI video, and USB connectivity.


----------



## kevincat3556

ddxfish said:


> They make a special cable for this called an MHL Cable
> 
> http://www.sfcable.c...CFcXb4AodEmcARg
> 
> It has a micro usb to HDMI/USB
> 
> It allows charging, HDMI video, and USB connectivity.


I thought the N7 didn't have the hardware for MHL? and my nexus drains when plugged into the TV... But you guys should make what i did. ill rip it apart and take pictures in a while.


----------



## MetalMan

kevincat3556 said:


> Yes. I made my own OTG cable from a chopped up Motorola charger for my GNexus. Same thing applies here. The extra 'sense' pin, is usually unused. so just connect it to a little toggle switch and make it togglable. lol. sorry. hard to concentrate here, the teacher is INSANE!
> 
> what i mean is, take the sense pin, and instead of just shorting it out, run it outside of the plug and you can toggle OTG mode WITHOUT having to take the cable out! lol. it actually charges my power-hungry nexus with a controller and HDD hooked up playing GTA3, so it should DEFINITELY charge the Nexus 7, which i will be getting for christmas. i can do more testing when i get home tomorrow.


kevincat3556: You're misunderstanding the question that GoldMembr posed. He asked about toggling between OTG + charging (charger powers any USB peripherals) and regular OTG (Nexus 7 powers the USB peripherals). This has nothing to do with the sense pin, because in both configurations the sense pin must be shorted to ground.

What you're talking about, with toggling the sense pin, would be switching between OTG host mode and fast charge mode.


----------



## GoldMembr

MetalMan said:


> kevincat3556: You're misunderstanding the question that GoldMembr posed. He asked about toggling between OTG + charging (charger powers any USB peripherals) and regular OTG (Nexus 7 powers the USB peripherals). This has nothing to do with the sense pin, because in both configurations the sense pin must be shorted to ground.
> 
> What you're talking about, with toggling the sense pin, would be switching between OTG host mode and fast charge mode.


Yes exactly. As it is right now it kind of stinks having to power every single USB device by external charger alone. I think people want to charge only when they have to . I don't think it's good for the battery to always be charging either. Even for a game pad you have to always have external charger so it kind of defeats the purpose if there isn't a way for the device to be able to distinguish between internaly powering USB when there isn't an external source detected. I'm hoping Timur may have a solution to the problem. Don't get me wrong Charging + USB OTG is awsome but not at the expense of normal operation as well, at least for my needs anyway.


----------



## Timur

mentose457 said:


> Timur, will your boot image work on 4.2? I suspect It will not but thought id ask anyway.


Well, it does. Referenced below is a modified Nexus 7 (grouper/wifi) kernel for stock JB 4.2. It is based on 3.1.10-gb980927 and includes the known changes:
- externally powered USB host mode operations (patch 1)
- charging in USB host mode (patch 2)
- enabled USB sound + CIFS
In short: functionality should be identical in both variants.

JB4.2: https://github.com/mehrvarz/files/raw/master/boot-jb42-grouper-host-mode-power-usb-audio-2012-11-21.img
CM10: https://github.com/mehrvarz/files/raw/master/boot-cm10-grouper-host-mode-power-2012-11-15.img

Backup your stuff. Use at your own risk.


----------



## GoldMembr

Timur said:


> Well, it does. Referenced below is a modified Nexus 7 (grouper/wifi) kernel for stock JB 4.2. It is based on 3.1.10-gb980927 and includes the known changes:
> - externally powered USB host mode operations (patch 1)
> - charging in USB host mode (patch 2)
> - enabled USB sound + CIFS
> In short: functionality should be identical in both variants.
> 
> JB4.2: https://github.com/m...-2012-11-21.img
> CM10: https://github.com/m...-2012-11-15.img
> 
> Backup your stuff. Use at your own risk.


Thanks for the new images. So i guess there is no way to have it distinguish between external and internal power then?


----------



## dmexs

Timur, which USB DAC are you using? The Behringer UCA222 looks pretty nice right now. I didn't see the need for one initially, but I'm starting to feel like the audio in my car isn't as clean as it could be.

Thanks again for all your hard work!


----------



## Timur

jmcguire525, on 18 November 2012 - 02:54 PM, said:
[background=rgb(245, 245, 245)]sometimes it takes up to 10 mins to detect the DAC [/background]



Timur said:


> Now I see why you want to keep your DAC powered all the time. Please note that my cheapo DAC does not do that. I have to stop/start a song, too. But it always plays after a second or two. You might want to consider testing another DAC?


I think I know what is going on here. IF I unplug my DAC, while audio is streaming to it, I do afterwards get some small delays. Something in the area of up to 5 or 10 seconds. I normally pause playback before I unplug the DAC, in which case there are no delays (after reconnecting). Your much longer delays may have something to do with the amount of memory your DAC provides for buffering. Maybe you can verify this analysis?

Edit: @dmexs: Can't really help you with this. I'm currently using a very basic "DAC" the size of a 4GB flash drive. From the usbaudio driver point of view, it looks just like the big audiophile devices. (I will probably go the Behringer route as well soon.)


----------



## Timur

GoldMembr said:


> ...to have the kernel auto-detects if there is a charger attached via a y-cable and uses it to power the external device and charge, ONLY if it's found.


Hi GoldMembr,
yes it is possible. More on this coming very shortly.

Here a little survey for you Nexus 7 owners: on what system would you rather see USB host mode updates becoming available?

a. JB 4.1.x stock
b. JB 4.2 stock
c. CM10
d. CM10.1

Edit: damn smilies


----------



## RWNube

I am very happy to report that I now have USB OTG + Charging enabled with CIFS shares mounting properly. Thanks to Timur, and possibly others, I now can use the ROM of my choice (running Cookie's 'N Cream) and still have USB OTG + Charging + CIFS. I flashed the kernel found in post 120 by Timur.
The USB Audio settings stick until reboot, so I can unplug and plug the DAC, tablet, and charging cable any number of times and USB Audio still works.

Does anybody know how I can convert that IMG kernel file to a flashable zip so I can swap back and forth between Trinity kernel and this USB OTG+Charge kernel in Recovery instead of fastboot via computer?


----------



## nexus-fan

Very strange... because for anyone else it doesnt works...
when i unplug the charge cable for 2 min (N7 in sleep mode) i must restart the tablet
for using DAC. (even if i plug it again).


----------



## GoldMembr

Timur said:


> Hi GoldMembr,
> yes it is possible. More on this coming very shortly.
> 
> Here a little survey for you Nexus 7 owners: on what system would you rather see USB host mode updates becoming available?
> 
> a. JB 4.1.x stock
> b. JB 4.2 stock
> c. CM10
> d. CM10.1
> 
> Edit: damn smilies


That is awsome news. I vote for stock 4.1.2 and cm10.


----------



## Timur

RWNube said:


> Does anybody know how I can convert that IMG kernel file to a flashable zip so I can swap back and forth between Trinity kernel and this USB OTG+Charge kernel in Recovery instead of fastboot via computer?


Here an alternative: backup both installations in CWM. Then switch between kernels by selecting "advanced restore" and by then picking only to restore the boot partition of choice.

What DAC are you using?


----------



## RWNube

Timur said:


> Here an alternative: backup both installations in CWM. Then switch between kernels by selecting "advanced restore" and by then picking only to restore the boot partition of choice.
> 
> What DAC are you using?


Hm, it seems I'll have to migrate from TWRP, but that sounds like a good idea. I am using the Fiio E17, which works with Trinity kernel as well as this OTG + Charge kernel. I can use the Fiio E17 with the USB Charge setting (in the E17's menu options) enabled or disabled... on both kernels. This is cool because I know that the power draw from the E17 doesn't cause issues with the Nexus 7. In my car, I'll use the OTG + Charge cable, when I am traveling, I'll probably use Trinity kernel, as I won't need to provide power to anything and I can run on the DAC and Nexus 7 batteries.
It seems that the Galaxy Note II won't support the E17







I may be looking at the E18 down the road, but for now at least the Nexus 7 is gonna rock it in the rock and beyond! I'm using a Netbook in the car with infrastructure mode enabled to stream music to the Nexus 7.
If anybody is interested, check this out: 



I made batch files to start and stop the infrastructure access point on the netbook. Remember, this requires Windows 7 (dunno about Windows 8).

P.S. Because of this kernel, I can now plug my 2TB My Passport Western Digital hard drive into the Nexus 7. I just have to ensure that I am providing power to the USB OTG Y-Cable and then I connect the Nexus 7. Stickmount allows me to access the entire contents of the drive. It is formatted as NTFS. I have Paragon installed, but it is frozen via Titanium Backup. All I know is that it mounts and I can stream content from the hard drive. I will likely pick up a power pack like this one: http://www.androidpolice.com/2012/11/23/deal-alert-get-a-12000mah-new-trent-portable-charge-for-just-53-50/

Thanks Timur, you da man!


----------



## dmexs

Timur said:


> Hi GoldMembr,
> yes it is possible. More on this coming very shortly.
> 
> Here a little survey for you Nexus 7 owners: on what system would you rather see USB host mode updates becoming available?
> 
> a. JB 4.1.x stock
> b. JB 4.2 stock
> c. CM10
> d. CM10.1
> 
> Edit: damn smilies


B and D. Is there any reason why one would want to stay with the older versions?

My current issue: I haven't done extensive testing yet but it seems when my N7 is doing intense work (i.e. Navigation via Google Maps) the battery drains (maybe only about 3%/hour). It says charging but says USB instead of AC. This is even though the car power supply I'm using is offering up 3A of 5V to my Y-cable. (I'm using a CNX-P2140 from carnetix/mp3car, on the secondary channel) However, when I plug the whole setup, Y-cable, harddrive and all in to the stock N7 charger, it charges much faster and the battery settings page says Charging AC. Any thoughts?

My current (pun not intended ) is that perhaps the voltage on the car's power supply is running just a little under 5V, maybe due to running such a long length of wire from the trunk to the dash? I'm going to test the voltages on the stock charger and the car power supply and report back.


----------



## goatcatcher

nexus-fan said:


> Very strange... because for anyone else it doesnt works...
> when i unplug the charge cable for 2 min (N7 in sleep mode) i must restart the tablet
> for using DAC. (even if i plug it again).


+1
When power is removed from the hub powering the DAC and the N7 (ie simulating ignition off in vehicle) and the tablet is put into sleep for any period of time, on wake and re-power of the hub the DAC is not re-connected until reboot. I've spent hours experimenting with the order of events, cables, timing etc, but this always happens.
Running Paranoid Android 2.52 with Shek H1 DAC.

@RWNube - can you confirm this doesn't happen for you?


----------



## GoldMembr

dmexs said:


> My current issue: I haven't done extensive testing yet but it seems when my N7 is doing intense work (i.e. Navigation via Google Maps) the battery drains (maybe only about 3%/hour). It says charging but says USB instead of AC. This is even though the car power supply I'm using is offering up 3A of 5V to my Y-cable. (I'm using a CNX-P2140 from carnetix/mp3car, on the secondary channel) However, when I plug the whole setup, Y-cable, harddrive and all in to the stock N7 charger, it charges much faster and the battery settings page says Charging AC. Any thoughts?
> 
> My current (pun not intended ) is that perhaps the voltage on the car's power supply is running just a little under 5V, maybe due to running such a long length of wire from the trunk to the dash? I'm going to test the voltages on the stock charger and the car power supply and report back.


The reason i chose Stock 4.1.2 and CM 10.0.0 is because of the issuse and restrictions people seem to be having with the upgraded JB 4.2 that are not present in JB 4.1.2


----------



## dmexs

GoldMembr said:


> The reason i chose Stock 4.1.2 and CM 10.0.0 is because of the issuse and restrictions people seem to be having with the upgraded JB 4.2 that are not present in JB 4.1.2


Oh, interesting. Which restrictions do you speak of?


----------



## kevincat3556

I have an idea. disconnect the +5v from the usb cable between the N7 and the usb device, and put the N7 +5v on to the charger, and use an external power source for the USB devices. but make sure the ground is shared. or rig a diode in the line


----------



## Timur

Hi. I just made a brand new "USB host mode power management" kernel available for download to your Nexus 7. It can be found here: http://mehrvarz.gith...ent-nexus7.html
This is for use with stock Android 4.2. The USB power management extension is fully rewritten and now supports automatic transitions of power modes. Such as from externally powered host mode to OTG host mode.
My impression is that 4.2 kernel is the best choice going forward. It has a great number of fixes added to it and seems to be very stable. Want to get an impression on the number of patches incorporated between 4.1 and now? Take a look at this: https://github.com/m...grouper/network
Move left to mid June and then follow the dotted pink line towards the right. My work is based on the Nov 2 branch "android-tegra3-grouper-3.1-jb-mr1".
I hope this will let you use your USB devices more smoothly.


----------



## GoldMembr

Timur said:


> Hi. I just made a brand new "USB host mode power management" kernel available for download to your Nexus 7. It can be found here: http://mehrvarz.gith...ent-nexus7.html
> This is for use with stock Android 4.2. The USB power management extension is fully rewritten and now supports automatic transitions of power modes. Such as from externally powered host mode to OTG host mode.
> My impression is that 4.2 kernel is the best choice going forward. It has a great number of fixes added to it and seems to be very stable. Want to get an impression on the number of patches incorporated between 4.1 and now? Take a look at this: https://github.com/m...grouper/network
> Move left to mid June and then follow the dotted pink line towards the right. My work is based on the Nov 2 branch "android-tegra3-grouper-3.1-jb-mr1".
> I hope this will let you use your USB devices more smoothly.


Now i'm bummed out i can't use this. I'm on CM 10.0 4.1.2 and plan to stay there so i guess i'm bonned unless you deside to find it in your hart to do it for 4.1.2 as well. Thanks either way.


----------



## nexus-fan

Hi Timur,
Thanks for the new kernel, so for use it should i install the Grouper kernel and then flash your new image?


----------



## Timur

nexus-fan said:


> Hi Timur,
> Thanks for the new kernel, so for use it should i install the Grouper kernel and then flash your new image?


You need to have full stock 4.2 installed on your N7.
Then you can flash the new kernel via boot-jb42-grouper-host-mode-power-usb-audio-2012-11-25.img from msg #150.

@GoldMembr: I will provide a CM10.1 compatible kernel containing the new implementation as soon as possible. Are you going to upgrade to CM10.1 when it becomes available?

@dmxs: About "USB vs. AC charging". When in host mode, the system cannot distinguish between the two. It'll say "USB charging", even if there is more than 500mA incoming. When using a Y-cable, all your USB devices are directly driven by the external power source, not through the N7. So the N7 can use whatever power is incoming for it's own needs. 3%/hr battery drain hmm... are you sure there are at least 500mA left over by the other devices?

Edit: Just added an "update.zip"-type installer alternative to download page: http://mehrvarz.github.com/host-mode-power-management-nexus7.html


----------



## GoldMembr

Timur said:


> You need to have full stock 4.2 installed on your N7.
> Then you can flash the new kernel via boot-jb42-grouper-host-mode-power-usb-audio-2012-11-25.img from msg #150.
> 
> @GoldMembr: I will provide a CM10.1 compatible kernel containing the new implementation as soon as possible. Are you going to upgrade to CM10.1 when it becomes available?
> 
> @dmxs: About "USB vs. AC charging". When in host mode, the system cannot distinguish between the two. It'll say "USB charging", even if there is more than 500mA incoming. When using a Y-cable, all your USB devices are directly driven by the external power source, not through the N7. So the N7 can use whatever power is incoming for it's own needs. 3%/hr battery drain hmm... are you sure there are at least 500mA left over by the other devices?
> 
> Edit: Just added an "update.zip"-type installer alternative to download page: http://mehrvarz.gith...ent-nexus7.html


If CM 10.1 is on Jb 4.2 then no i won't be upgrading to it. I like 4.1.2 better than 4.2. Why is 4.1.2 not compatible with the new upgrade you made?


----------



## jmcguire525

Timur, I assume the new kernel still has USB audio?


----------



## nexus-fan

jmcguire525 said:


> Timur, I assume the new kernel still has USB audio?


I can confirm that !


----------



## jmcguire525

Working just as you described but damn it messes up what I was planning. Great work tho Timur, the problem for me and anyone else using this for a car head unit is that now when the car is off the tablet switched back to normal OTG and starts to drain battery since it is powering the DAC. It is also iffy about charging again with the Y cable once it gets power back from the car it is still hanging up in OTG without charging.


----------



## besjr69

jmcguire525,

Seems that it would be best if you reverted back to patch #3 and not the newest IMG. I'm also using my N7 for my mobile auto entertainment setup. My plans are to toggle the OTG via hardware. I'm testing a simple relay circuit that applies GND to the sense pin #4 and power to pin #1 when the ignition is turned on. The reason I'm going this route is because I have an external HDD setup and it doesn't reconnect automatically. I will have power applies to the hub at all times to keep pwr on all of the USB peripherals. I've verified that it works best this way with the external drive. My test is centered around battery drain.

Bobby


----------



## jmcguire525

I did go back. I am about 90% satisfied with everything, other than having to pause before removing the power source and play again once it is reconnected everything is great. I haven't used tasker but I wonder if there is a way to tell the tablet to pause audio, no matter what app it is coming from, when power is disconnected, and to turn it back on when reconnected. Even if it were to pause right after being unplugged it hasn't given me any problems.


----------



## besjr69

My Tasker profile is to 1) Car Mode On and go Home, 2) WiFi On, 3) BT On and 4) Media Control Play with "Simulate Media Control" and reverse for the exit task. It works great. I've not tried it with external drive yet. I do not like the whole mount/dismount thing. I want something that requires no interaction when I turn off the ignition.


----------



## nexus-fan

after install the JB 4.2 with timur great image its working amazing except one thing,
the option "Stay awake when charge" doesnt works.,
any android app that should do the same neither works, any solution??


----------



## kevincat3556

Not trying to hijack this thread lol, but how can i do USB audio on the GNexus? Thanks. Ill try to come up with more ways to charge and OTG at the same time


----------



## Timur

jmcguire525 said:


> ...the problem for me and anyone else using this for a car head unit is that now when the car is off the tablet switched back to normal OTG and starts to drain battery since it is powering the DAC.


Let me say that the new kernel (2012-11-25) implements the "correct" behavior for mobile devices. It gives powered host mode, without taking away standard OTG mode. People have asked for this.

Now, it is really not my intention to disregard fixed installation needs. For this reason I have created a special "fixed installation" variant of the latest kernel. This alternative variant continues to implement the correct power management behavior for when the OTG adapter is being pulled and plugged. But as long as the OTG adapter remains plugged, it will *not* start charging slave devices when external power goes away. This is the only difference. You can find this alternative kernel here: http://timur.mobi/files/ (take note of "-fi-" in the file name).

more 1: I will probably look into the audio buffer issue. Pls note that so far, I did not touch the audio subsystem (other than enabling it).

more 2: I have posted a fix for the "external HDD doesn't reconnect automatically" issue before ("patch 4"). Unfortunately this is a system bug. And I think we all agree that providing a complete ROM, only to fix such a small bug, is not practical. It may be sensible to ask for this patch to go into the CM codebase.


----------



## jmcguire525

Thanks, I reverted back to patch 2 but will flash this today


----------



## Timur

nexus-fan said:


> after install the JB 4.2 with timur great image its working amazing except one thing,
> the option "Stay awake when charge" doesnt works.,


Fixed with update 2012-11-28; same dl loc: http://mehrvarz.github.com/host-mode-power-management-nexus7.html


----------



## nexus-fan

Timur said:


> Fixed with update 2012-11-28; same dl loc: http://mehrvarz.gith...ent-nexus7.html


Doesnt works for me, even wipe\install all again.


----------



## sadde

Timur said:


> Fixed with update 2012-11-28; same dl loc: http://mehrvarz.gith...ent-nexus7.html


hi , i can only see the "2012-11-25.img" where is the 2012-11-28 one? thank you for a great kernel


----------



## dmexs

Timur said:


> @dmxs: About "USB vs. AC charging". When in host mode, the system cannot distinguish between the two. It'll say "USB charging", even if there is more than 500mA incoming. When using a Y-cable, all your USB devices are directly driven by the external power source, not through the N7. So the N7 can use whatever power is incoming for it's own needs. 3%/hr battery drain hmm... are you sure there are at least 500mA left over by the other devices?


It does in fact distinguish between USB vs. AC charging. The reason I know this is because I took the male USB charging end and plugged it in to the stock wall charger overnight so I could sync my google music without draining the car battery. When it's connected to a wall charger instead of the car power supply it identifies it as AC charger, even while in host mode for my externally powered USB HDD.

Would a logcat show the difference sensed by the tablet between these two power modes? As for how much current is still available after the other devices, I assume plenty since the USB HDD is externally powered and the line is supposed to supply 3A, a full amp higher than the stock charger. But to be honest, I'm not entirely sure how to test that with my voltmeter.

And if anybody is interested, I've also been able to successfully cleanly mount/dismount my usb HDD. The clutch to this though is being able to signal the N7 to start the dismount process before power is taken away from the charging end of the Y-cable. If power is taken away earlier then the HDD dismounts uncleanly. For me this solution was to use my P2140 with a shutdown timer. Perhaps Timur's latest work that allows a graceful transition from OTG+charging to just OTG will help.


----------



## besjr69

dmexs,

Storage is the only drawback to using a tablet over a CarPC and it has been my primary focus since switching to the N7. I've been able to mount/dismount my external drive by shutting down Google Play Music first. The problem I have is the indexing after I re-mount. I have 110GB of MP3 and another 80GB of movies that I store on my 320GB WD Passport USB HDD. It takes forever to index that many MP3s (when connected with StickMount). And the static while indexing is ANNOYING. I tried Nexus Media Importer and things indexed a little faster, but it still takes a while. I've been thinking of an idea that may work to fix the mounting and indexing.

Patch #4 enables OTG + charging and standard OTG when power is removed. I'm going modify the OTG Y-cable by removing pins 1 and 4 on the slave connector leaving only the data pins 2 and 3. The male end will still go to switched USB power. I will connect the OTG slave connector to a continuously powered USB hub where the HDD and mouse are connected. Removing the power pins will prevent the N7 from powering slave devices (battery drain) when switched power is removed.

My only worry is the vehicle battery drain. I don't know how much drain an idle device and HDD will have. I don't expect it to be much as my tasker profile stops music when power is turned off so there shouldn't be any read/write to the HDD. I hope this works. If this doesn't work I think I'm going to hang it up and go to a tethering/google cloud solution. Fingers crossed.

Bobby


----------



## RWNube

besjr69 said:


> dmexs,
> 
> Storage is the only drawback to using a tablet over a CarPC and it has been my primary focus since switching to the N7. I've been able to mount/dismount my external drive by shutting down Google Play Music first. The problem I have is the indexing after I re-mount. I have 110GB of MP3 and another 80GB of movies that I store on my 320GB WD Passport USB HDD. It takes forever to index that many MP3s (when connected with StickMount). And the static while indexing is ANNOYING. I tried Nexus Media Importer and things indexed a little faster, but it still takes a while. I've been thinking of an idea that may work to fix the mounting and indexing.
> 
> Patch #4 enables OTG + charging and standard OTG when power is removed. I'm going modify the OTG Y-cable by removing pins 1 and 4 on the slave connector leaving only the data pins 2 and 3. The male end will still go to switched USB power. I will connect the OTG slave connector to a continuously powered USB hub where the HDD and mouse are connected. Removing the power pins will prevent the N7 from powering slave devices (battery drain) when switched power is removed.
> 
> My only worry is the vehicle battery drain. I don't know how much drain an idle device and HDD will have. I don't expect it to be much as my tasker profile stops music when power is turned off so there shouldn't be any read/write to the HDD. I hope this works. If this doesn't work I think I'm going to hang it up and go to a tethering/google cloud solution. Fingers crossed.
> You should look into my posts in this thread about CIFS and virtual wifi adapters. My net book provides an infrastructure access point that my Nexus 7 connects to, then I mount the entire media folder to the tablet with CIFS.
> Bobby


Sent from my ADR6425LVW using Tapatalk 2


----------



## Timur

dmexs said:


> Perhaps Timur's latest work that allows a graceful transition from OTG+charging to just OTG will help.


Yes, but... The kernel will start sending power to slave devices when a power loss has been detected. But there will be a gap. Slave devices will be without power for some period of time (~1s). Not a serious issue for stateless devices, like keyboard and mouse. They will come right back. But the gap will cause a problem for mounted drives.

I recently bought a small portable USB stereo cabinet. This device comes with batteries. But they are only being used, when the USB cable stops providing power to the device. So it works like a UPS. I think you need something like this, but in the form of a hard disk enclosure. (Hey, an old iPod should work!!) When loss of external power is detected, you make the N7 trigger a graceful shutdown of the drive. And when external power comes back*, the drive will spin up, advertise itself and will be remounted.

(*You would want to use the "fixed installation" variant of the kernel, so the N7 will not spin up the drive.)


----------



## kevincat3556

I'm flashing Timur's kernel when I get my Nexus 7

Sent from my Galaxy Nexus using RootzWiki


----------



## nexus-fan

is there anyone that tried to use active USB HUB??, its make a problems for me... when i using passive its working well but as
some people said, it takes time to mount the drive again.

BTW, Teralink usb audio has external input power (9V-15V), so its quality usb extractor (i recommend) and also
great for our purpose (car media)., the cost 70$ on ebay.


----------



## besjr69

RWNube, thanks for the tip. I'll see if I can set it up at home. I've never played with CIFS. One question though, if I'm on CIFS can I simultaneously be on another WiFi network with internet access? Or would it be best to use a router? I saw an article similar to what you are talking about on mp3car.com except he's using DLNA. Don't know the difference.


----------



## wave_is

Timur said:


> Hi. I just made a brand new "USB host mode power management" kernel available for download to your Nexus 7. It can be found here: http://mehrvarz.gith...ent-nexus7.html
> This is for use with stock Android 4.2. The USB power management extension is fully rewritten and now supports automatic transitions of power modes. Such as from externally powered host mode to OTG host mode.
> My impression is that 4.2 kernel is the best choice going forward. It has a great number of fixes added to it and seems to be very stable. Want to get an impression on the number of patches incorporated between 4.1 and now? Take a look at this: https://github.com/m...grouper/network
> Move left to mid June and then follow the dotted pink line towards the right. My work is based on the Nov 2 branch "android-tegra3-grouper-3.1-jb-mr1".
> I hope this will let you use your USB devices more smoothly.


And could you draw a scheme your Y-USB cable? I would like to make the cable by myself.


----------



## wave_is

besjr69 said:


> My Tasker profile is to 1) Car Mode On and go Home, 2) WiFi On, 3) BT On and 4) Media Control Play with "Simulate Media Control" and reverse for the exit task. It works great. I've not tried it with external drive yet. I do not like the whole mount/dismount thing. I want something that requires no interaction when I turn off the ignition.


Can you share your profile for tasker?


----------



## Timur

wave_is said:


> And could you draw a scheme your Y-USB cable? I would like to make the cable by myself.


This is all you need:
http://cdn.head-fi.org/7/78/500x1000px-LL-781bd011_Y_OTG_CABLE.png

One other thing. I would like to see some photos of peoples dashboard setups.
In particular I'm interested to find out, how permanent (or non-permanent) your Nexus 7 in-car setups are. And how they look.
What about reflections? Are you not having issues with that?


----------



## besjr69

wave_is,

I don't know how to share my Tasker Profile and my N7 is in the Car.

1) Open Tasker and create a new profile. I named mine CarPC
2) Select Power state and select ANY option
3) Add a new Task. I called mine StartUp
4) Add the following actions
a. Display|Car Mode|ON (Go Home checked)
b. Net|WiFi|ON
c. Net|Bluetooth|ON
d. Media Control|Play (Simulate Media... checked)
5. Save this Task
6. Long Press this task (StartUp) and select "Exit Task"
7. Select "Add New Task". I named mine "Shutdown"
8. Add the following actions
a. Media Control|Pause (Simulate Media... checked)
b. Net|Bluetooth|OFF
c. Net|WiFi|OFF
d. Display|Car Mode|OFF (Go Home checked)
9. Save this task

Optionally, you can use "Airplane Mode ON" in the shutdown task. That's it.

Bobby


----------



## nexus-fan

Hi,
My N7 made update to 4.2.1 and the usb-audio doesnt works any more...
i also tried to flash the timur image and still not working.

("Stay away when charge" working on 4.2.1!)

Please help.
-------------------------------------------
EDIT: Root the device again solved the problem.

-------------------------------------------
EDIT 2: The N7 doesnt recognize charging (just in case you connect the N7 direct to charger).
i connected the OTG+Charging cable and the USB-Audio working just fine but no charging...


----------



## agung_gitaris86

make it work for 4.1.2 plzz...

coz.. in 4.2 Directory bind not work anymore...

setup :
Nexus 7 4.1.2 + OTG Y Cable + SD CARD 64gb + PS3 Wireless Controller + Charging Patch by Timur = Amazing Gaming Tab


----------



## wave_is

Timur said:


> This is all you need:
> http://cdn.head-fi.o...Y_OTG_CABLE.png


I flash your firmware. I bought on ebay y cable. I checked the cable. Resistance of 100 ohms soldered 5m contact rather than 4m.
All work fine.


----------



## wave_is

besjr69 said:


> 1) Open Tasker and create a new profile. I named mine CarPC
> 2) Select Power state and select ANY option
> 3) Add a new Task. I called mine StartUp
> 4) Add the following actions
> a. Display|Car Mode|ON (Go Home checked)
> b. Net|WiFi|ON
> c. Net|Bluetooth|ON
> d. Media Control|Play (Simulate Media... checked)
> 5. Save this Task
> 6. Long Press this task (StartUp) and select "Exit Task"
> 7. Select "Add New Task". I named mine "Shutdown"
> 8. Add the following actions
> a. Media Control|Pause (Simulate Media... checked)
> b. Net|Bluetooth|OFF
> c. Net|WiFi|OFF
> d. Display|Car Mode|OFF (Go Home checked)
> 9. Save this task
> 
> Optionally, you can use "Airplane Mode ON" in the shutdown task. That's it.
> 
> Bobby


Thank you. How the program Tasker know that you drowned car and should work normally SHUTDOWN?


----------



## Timur

dmexs said:


> It does in fact distinguish between USB vs. AC charging. The reason I know this is because I took the male USB charging end and plugged it in to the stock wall charger overnight so I could sync my google music without draining the car battery. When it's connected to a wall charger instead of the car power supply it identifies it as AC charger, even while in host mode for my externally powered USB HDD.


Interesting: "If you desire to have 'AC Charging' be displayed on your Nexus 7, short the data wires/pins. Remember, this has no effect on the charging rate." http://forum.xda-dev...d.php?t=1823377

Edit: However, this seems to be in conflict with this persons observations: http://forum.xda-developers.com/showpost.php?p=33309013&postcount=126

The N7, it seems, will draw more power (and charge faster), with shorted USB data wires. Unfortunately, this works against using a Y-cable in the 1st place, where you want to charge AND communicate with slave devices in parallel.


----------



## goatcatcher

Thanks Timur for all the great work you're doing on this. I've just loaded 4.2 and flashed the latest fixed install patch. The DAC/USB storage reconnects as expected when power is re-applied and the Nexus 7 has been in sleep.

However, this only happens after the Y splitter plug to the tablet is removed and re-inserted after the tablet has been woken from sleep. This seems to be the same as with the non-fixed install patch.

In fact, I notice that when I remove power from the hub, the power light on the DAC goes off and comes back on as if USB host mode is enabled and the tablet is powering the DAC, even though at that stage the y splitter to the tablet has not been removed.

Does this make sense for the fixed install patch? Obviously, when I get this as a fixed install in the car I won't be able to plug/unplug like this. Any help you can give would be great.


----------



## agung_gitaris86

i use your boot image in my Stock ROM 4.1.2, it charging well, but when i detach the charger it's not the OTG

can you fix this ??


----------



## nexus-fan

hi Timur,
is it possible to make the firmware works on 4.2.1?


----------



## Timur

goatcatcher said:


> In fact, I notice that when I remove power from the hub, the power light on the DAC goes off and comes back on as if USB host mode is enabled and the tablet is powering the DAC, even though at that stage the y splitter to the tablet has not been removed. Does this make sense for the fixed install patch?


Are you sure about this observation? You are describing the behavior of the default kernel mod for mobile devices [1]. The fixed installation variant [2] is NOT supposed to switch to self-powered OTG mode. Here, USB slave device should stay off, when external power drops. The fixed installation kernel is supposed to self-power slave devices only, when you re-plug the OTG adapter without external power. For this reason, when you use the fixed installation variant, you should make sure external power is available before you plug the Y-cable adapter.

Edit: I just realize you mentioned removing power from the "hub". Can you detail your setup?

@agung_gitaris86: I created installable kernel binaries with the automatic power mode switching feature based on 3.1.x kernel code for use with Android 4.2.x. If you need this functionality in older Android versions, you can take my source code and create a back port. Sorry, I am not able to do this for you. Please note that many of the charging problems reported in the xda thread referenced in msg #183 are due to bugs (or shortcomings) in the 4.1.x kernel.

@nexus-fan: My current kernel binaries (2012-11-28) are supposed to work with 4.2.0 and 4.2.1. (I'm currently using the kernel used in 4.2.1, which seems to work well in 4.2.0 also.)

[1] http://mehrvarz.github.com/usb-host-mode-power-management-nexus7
[2] http://timur.mobi/files


----------



## wave_is

strange. I finished the battery on the tablet. firmware 4.2 I can not turn it on. While the tablet is not on, the charging process is shown. I turn the tablet, it says that the battery is low. connect the charger on and off. ;(


----------



## nexus-fan

hi Timur,
because my english is poor i will try to describe the problem step by step:
- Turn on (power) the tablet. (The charger+OTG connected via special charger OTG cable).
- check the USB audio working and also that the N7 in charging mode.
- unplug the charge cable from OTG cable.
- let the tablet go sleep for 20 min.	(in my N7 the option "stay awake when charge" is enabled so when i unplug power, its go sleep after 15 seconds by default)
- connect the charge cable again.
- as you can see the tablet wont "wake up".
- wake up it manually with the side button.
- now you can see that USB audio still working but it doesnt recognize the charge cable.

-*** if you unplug the OTG cable and connect it again the N7 will charge but no USB audio...

I hope it helpful.


----------



## Timur

> - Turn on (power) the tablet. (The charger+OTG connected via special charger OTG cable).
> - check the USB audio working and also that the N7 in charging mode.

You got two features working already that are not available in the stock kernel. Excellent!

> - unplug the charge cable from OTG cable.

The kernel will detect the power loss and will switch to drive the USB slave device(s) from the internal battery. Did you try to use your usbaudio device at this point? It should work.

> - let the tablet go sleep for 20 min. (in my N7 the option "stay awake when charge" is enabled so when i unplug power, its go sleep after 15 seconds by default)
> - connect the charge cable again.
> - as you can see the tablet wont "wake up".

Yes, since the tablet is now powering the USB slave device, it is no longer able to detect when power is coming in on the same wires.

> - wake up it manually with the side button.
>- now you can see that USB audio still working but it doesnt recognize the charge cable.

I'd implement automatic switch back to external power. But I think it is physically not possible. You need to pull/plug the OTG adapter. (When in OTG host mode, no event is triggered when external power comes back up.) By using the fixed installation variant of the kernel, you can prevent the system from switching to battery driven OTG mode. This will allow the system to detect and make use of external power coming back. But the -fi- variant will not allow you to use your USB slave device(s) without external power.

> -*** if you unplug the OTG cable and connect it again the N7 will charge but no USB audio...

Well, this could be the temporary audio buffer overrun issue we have discussed earlier. Music playback should be possible after some time (depending on the size of audio buffers involved, 5-10 seconds in my case). You can prevent this issue (which btw has not anything to do with my code), by stopping audio playback before losing external power.


----------



## nexus-fan

Timur said:


> ...
> I'd implement automatic switch back to external power. But I think it is physically not possible. You need to pull/plug the OTG adapter. (When in OTG host mode, no event is triggered when external power comes back up.) By using the fixed installation variant of the kernel, you can prevent the system from switching to battery driven OTG mode. This will allow the system to detect and make use of external power coming back. But the -fi- variant will not allow you to use your USB slave device(s) without external power.
> ...


Im using external PSU for USB-Audio , thats isnt problem at all,
but i dont understand how to prevent the system switching to battery driven..? please explain


----------



## Timur

nexus-fan said:


> please explain


See msg #163. Or #187.


----------



## postmaxin

I've been hacking on linux for over 15 years now, but haven't tried rolling my own android linux kernel yet.. I was looking to solve this exact problem and found that you all have been working on it over the past few months which is awesome 

I just tried the Galaxy Nexus fix and it's working pretty good... I can go for long car drives listening to music off of my USB stick with no battery drain. I want to dive deeper into this but I've got a few basic questions first,

1) There's a "better" OTG kernel available for the Nexus 7, that actually charges (instead of just maintaining charge) and shows charge state. Have y'all tried to backport this to the Galaxy Nexus? Is there something stopping this from working, or has it just not been done yet?

2) My daughter has a Nexus 10. We've got a 16-hour drive ahead of us to go back home to visit family for Christmas and I'd love for her tablet to work, powered, with external media on the long drive. Has anybody tried to get this working on the Nexus 10 yet? Is applying the patch to the N10's kernel tree a reasonable place to start?


----------



## goatcatcher

Timur said:


> Are you sure about this observation?


Yes, absolutely. I just tested it again to triple check using a simple set-up without the hub.: Y-splitter one end to USB DAC, other end to wallwart power. The power light on the DAC goes off briefly after I remove the power, then comes back on and is accompanied by a speaker thump. The DAC is definitely being powered from the tablet.

This behaviour, as you say, is what I experienced with the default kernel [1].

I started off installing the FI kernel [1] that I downloaded from the dropbox site. It didn't *seem* to work as expected so I downloaded and flashed the default version via recovery. This behaved the same so I re-read the notes on your web page about removing and re-inserting the plug. I did this and it worked.

So I went back and installed the FI boot image (I can't have accidentally done the wrong one because that is the only one on the PC - the flashable kernel I downloaded to the tablet itself). On removing and re-inserting the plug this version also worked, so I'm confused.

Is there any way of checking which kernel is loaded to be sure I'm doing the right thing?

BTW, this is my setup (roughly sketched). The intention is that I can remove power to the hub when the ignition is off so that none of the peripherals are drawing power from the car battery and the nexus 7 is asleep and running on battery. Then that the nexus 7 wakes and is powered, along with the peripherals when ignition power is restored. It's all working great apart from having to plug/unplug the y-splitter from the tablet on wake to reconnect the DAC and USB stick. Am I dreaming?


----------



## Kookie_Monster

Guys... I need some help.

I'm installing a Nexus 7 on my Chevrolet Cruze (fixed instalation). Flashed Timur's kernel and UI is almost ready.

Now it's time to start thinking seriously about the hardware. I know I have to get a Micro USB Y Cable, to be able to charge it and connect a usb pen, for instance, at the same time, like this one:

Micro USB Y cable

The problem is I don't have much space behind the fascia, so I would have to install with some sort of adapter such as this:

Micro USB Angle Adapter

My only doubt is... will the adapter override the Y cable? I'm guessing it won't, right?


----------



## Timur

goatcatcher said:


> It's all working great apart from having to plug/unplug the y-splitter from the tablet on wake to reconnect the DAC and USB stick. Am I dreaming?


Hey goatcatcher (and nexus-fan), I uploaded a new version of the fixed installation kernel to: http://timur.mobi/files/ Pls look for "boot-jb42-grouper-host-mode-power-usb-audio-fi-2012-12-03.img" and lmk if it works. The older one does in fact not behave correctly. Sorry!

@Kookie_Monster: Yes, the "Micro USB Angle Adapter" you are linking to will most likely "override" the functionality of an OTG adapter. I'm also looking for an Angle Adapter with OTG functionality. Couldn't find one yet.

@postmaxin: Don't you think *developers* should get a hold of the 1st batch of Nexus 10's, I mean before... daughters? Well, here is a question for her: the N10 has a dedicated power plug. Should it not be possible to charge and access external media via USB socket in parallel - without any kernel mods? I'd be very interested to learn.


----------



## Kookie_Monster

Timur said:


> @Kookie_Monster: Yes, the "Micro USB Angle Adapter" you are linking to will most likely "override" the functionality of an OTG adapter. I'm also looking for an Angle Adapter with OTG functionality. Couldn't find one yet.


Uhm.... I found this: http://www.ebay.co.u...=item27bc0b1e99

Guess it wouldn't be hard to cut off the micro usb tip on the y cable and make a proper connection using this plug.

Edit: Taking a closer look at the Y cable scheme: http://cdn.head-fi.o...Y_OTG_CABLE.png

It seems like only the host is 5-pinned. This probably means the angle cable wouldn't override the Y cable, since it's just an extension of the male connector, am I right?

Edit2: Timur, could you please have a look at my thread about booting the nexus on power? Here's the link. Thanks mate! 
http://rootzwiki.com...lugged-powered/d
Nevermind... I just read your answer to user "dmexs" on the same subject. Guess I'll have to externalize the button then! Sucks! :|


----------



## wave_is

Timur said:


> Hey goatcatcher (and nexus-fan), I uploaded a new version of the fixed installation kernel to: http://timur.mobi/files/ Pls look for "boot-jb42-grouper-host-mode-power-usb-audio-fi-2012-12-03.img" and lmk if it works. The older one does in fact not behave correctly. Sorry!


Thank you,
Do you have this file for CWM?

-----
add
I did it: http://depositfiles.com/files/xuxca8k4j


----------



## Dohnut

Timur, anyone help with a quick question? I think I understand what is required but am not sure of one thing, and can't seem to find a quick answer.

I rooted my nexus 7 using nexus nexus root toolkit, (so is bootloader unlocked and rooted). Does this mean I can apply these kernel files to this stock 4.2.1 build, and enjoy USB audio, charge and OTG storage, etc goodness, or do I need to reflash some other build, and therefore wiping my tablet yet again? If I need to wipe it then fine, cos I want this stuff working, but if I can do it without wiping then great cos I have since reinstalled all my apps and got widgets, etc all set up again.

Still think it's pretty poor that google/asus decided to not support any of this stuff out of the box.


----------



## wave_is

Dohnut said:


> Timur, anyone help with a quick question? I think I understand what is required but am not sure of one thing, and can't seem to find a quick answer.
> 
> I rooted my nexus 7 using nexus nexus root toolkit, (so is bootloader unlocked and rooted). Does this mean I can apply these kernel files to this stock 4.2.1 build, and enjoy USB audio, charge and OTG storage, etc goodness, or do I need to reflash some other build, and therefore wiping my tablet yet again? If I need to wipe it then fine, cos I want this stuff working, but if I can do it without wiping then great cos I have since reinstalled all my apps and got widgets, etc all set up again.
> 
> Still think it's pretty poor that google/asus decided to not support any of this stuff out of the box.


I think, that you can use you own stock 4.2.1 build =)


----------



## nexus-fan

hi Timur, Thanks as always, your efforts are*nt* obviously, im really appreciate it.

about last update, whats the different between the prev (28.11) and the new (3.12)?

unfortunately i have the same problem with the new that when i unplug the power its doesnt recognize it again.
( or maybe i have to wipe the N7 and install all again? )


----------



## Kookie_Monster

wave_is said:


> I think, that you can use you own stock 4.2.1 build =)


Yep... that's my setup right now. Timur's kernel on stock 4.2.1.


----------



## aFR

Hey Timur, Just played around with the 2012-12-03.img and noticed that it crashes when going into Settings -> Security.

Have been using previous versions successfully on the Wi-Fi only N7. This is my first N7 w/3G. Haven't tested 2012-12-03.img on the Wi-Fi only yet.

Just FYI.

Rolled back to 2012-11-25.img without any problems.


----------



## Timur

Use this only, if you want to help me track down the FIXED INSTALLATION variant issue: new boot-jb42-grouper-host-mode-power-usb-audio-fi-2012-12-04.img now in my dropbox: http://timur.mobi/files/. This is supposed to make rediscovery of external power more robust.

@nexus-fan: Don't worry, replacing a kernel does not require any kind of wipe. Does it make a difference, if you pause music, before you pull power?

@Dohnut: A rooted N7 with stock 4.2 or 4.2.1 is fully adequate. No other requirements.

@aFR: Thx for the info. Is anyone else having problems with the N7-3G? Does it require a different kernel? Going into Settings -> Security is not a problem on my N7.


----------



## nexus-fan

I flashed the 04-12 , its doesnt matter if you play music before or not (BTW, i always pause\stop the music before unplug power), 
if you unplug the power cable the N7 wont recognize it again., i hope you will find solution for this.


----------



## goatcatcher

Hi Timur,

Thanks for the new builds. Didn't try 12-03, but just had a play with 12-04 and I reckon we're nearly there, but for a couple of things. Here are my findings.

[1] After boot with DAC connected via hub, tablet powered via hub and power applied (as per previous drawing), tablet shows as On battery and does not charge, although the DAC works.

[2] In this state removing power from the hub does not power off the DAC, which appears to continue to get power from the tablet. The DAC still plays music.

[3] On replacing power to the hub, the tablet still does not begin charging. DAC still works.

[4] On removing and replacing the Y-splitter, the tablet begins charging. The DAC continues to work.

[5] Now, when removing power from the hub the DAC powers off

[6] On reconnecting the power to the hub, the tablet wakes (if asleep) and begins to charge, the DAC powers up, and on resuming playback, the music plays in < 5 secs.

After that first plug & unplug of the Y-splitter, this behaviour seems reliable and repeatable.

However, if the power is left disconnected from the hub for more than about 30 secs the DAC powers back up of its own accord consistently inside 60 secs. This happens every time regardless of whether the tablet is asleep or awake. After this happens:

[7] Re-powering the hub does not start charging the tablet, although the DAC continues to work. It seems we're back in the state of [1] to [3] above.

[8] Removing and re-connecting the Y-splitter seems then to restore the [5] & [6] behaviour above.

I hope this diagnosis hasn't been too long-winded and helps you diagnose the remaining issues. If there are any logs etc I can send you that would be useful I'd be happy to do so.


----------



## Timur

goatcatcher said:


> I hope this diagnosis hasn't been too long-winded and helps you diagnose the remaining issues. If there are any logs etc I can send you that would be useful I'd be happy to do so.


Thank you very much. I will take a deep look at this tonight. Yes, logs would be even more helpful. I created a little blog about this topic, just in case you (or others) want to help me out further. You need to learn about how to create kernel logs, while your USB port is occupied doing host mode stuff. This is not really super simple. But it's doable. We are only interested in Android kernel logs. System logs (easier to get to) will not help. Pls take a look at this and let's talk again later: http://mehrvarz.gith...debug-sans-usb/

Edit: goatcatcher, nexus-fan: was your wifi turned on before the undesired/unexpected from sleep wake-up? My impression is, that the wifi driver bcmsdh_sdmmc.c could be - for some reason or another - holding a wake lock. And actively forcing the wake-up. Just a funny thought: one of the "Keep wifi on during sleep" options is named "Only when plugged in". I mean, they didn't phrase it "Only when power is detected". Can you replicate the issue with wifi being turned off? Or with "Keep wifi on during sleep" set to "never"? If you didn't have wifi on, then pls look for something else. Bluetooth? Maybe some funny app (or service!) is keeping some funny wake lock?


----------



## Kookie_Monster

Timur, sorry to bother you about this again. Did you check my link on post #197?

http://www.ebay.co.uk/itm/5x-Angle-USB-Male-plug-Connector-Micro-5pin-with-Cover-/170658569881?pt=LH_DefaultDomain_0&hash=item27bc0b1e99

Would this help?


----------



## Timur

Kookie_Monster said:


> Timur, sorry to bother you about this again. Did you check my link on post #197?
> 
> http://www.ebay.co.u...=item27bc0b1e99
> 
> Would this help?


This looks small. Almost half the length of a regular micro USB plug. It's not OTG, but it has 5 pins. You would need to bridge two pins yourself. I give it a 75% chance. (I'm not sure but I think you will not need a resistor for the N7. Just a bridge.)


----------



## Kookie_Monster

Timur said:


> This looks small. Almost half the length of a regular micro USB plug. It's not OTG, but it has 5 pins. You would need to bridge two pins yourself. I give it a 75% chance. (I'm not sure but I think you will not need a resistor for the N7. Just a bridge.)


What do you mean by "small"? The metal tip? The idea was to cut off the tip on the OTG cable and use this plug instead.


----------



## Timur

Small in the most positive sense. As in short. You should give it a try.


----------



## Kookie_Monster

I will as soon as I get the chance and then I'll report back. Who knows... might come in handy to someone else. 

Sent from my Transformer Pad using Tapatalk 2


----------



## Timur

goatcatcher said:


> [1] After boot with DAC connected via hub, tablet powered via hub and power applied (as per previous drawing), tablet shows as On battery and does not charge,


I was not yet able to replicate this. When I boot... DAC connected via hub, tablet powered via hub and power (already) applied... my tablet always shows "charging" or "Full", but not discharging.


----------



## Dohnut

Anyone know of anywhere in the UK to buy these Y cables with USB OTG and allow charging? I did buy one off ebay which will probably be ages before it arrives, but I am also a bit worried it might not work, there is already feedback there saying something along the lines of took ages to arrive and didn't work. Could be he was using it wrong, but this could delay my car build by a month waiting on another one to arrive!


----------



## nexus-fan

Hi Timur,
The new patch (05/12) solved the delay of sleep.,
but still ,its not possible to unplug power (from OTG charge cable) and plug it again,
I really dont want to be rude but please ,make it happened.


----------



## Timur

nexus-fan, I need more info. Can you answer my Q from #207?
Are you using Wifi? Or some other hw/app/service/driver that may be different from my setup and could be keeping a wake lock?


----------



## goatcatcher

Timur said:


> was your wifi turned on before the undesired/unexpected from sleep wake-up?


Yes, it was. My tasker script is set to turn wifi off when the power is removed but I didn't have it running when testing this. In fact, I won't need bluetooth or wifi enabled at all in the final install.

I'll try it again with wifi off to see what happens. Interestingly, although the DAC powered up from the tablet after 30-50 secs, the nexus itself did not obviously wake from sleep (ie screen stayed off).

EDIT: I notice a new version I'll load and try this evening


----------



## jmcguire525

Please everyone working on a DAC solution check this out http://rootzwiki.com/topic/37176-mod-cm10-usb-audio-support/


----------



## dlbogdan

The only reason I've registered here is to ask Timur for a paypal account. I simply need to thank this guy for the work.
I've yet to test anything but I'm reading this thread long before I even bought the Nexus 7. One of the key points in my purchasing decision for the Nexus 7 was Timur's work. So Asus should thank him too 
The project for me is simple: Replacement for my current (crappy) navi VW RNS2. The tablet will not be used for anything else.
Timur, mate, please set up that paypal account so I (and maybe others too) can thank you from time to time.


----------



## postmaxin

Also, Timur, if you come up with images that work on the Nexus 10, I'll give you money for saving me hours of work. And if you come up with images that actually charged the Galaxy (instead of just maintaining a charge), I will give you more money.

I'm not sure that money motivates you ... but if it doesn't, do it for the love of the sport!



dlbogdan said:


> The only reason I've registered here is to ask Timur for a paypal account. I simply need to thank this guy for the work.
> I've yet to test anything but I'm reading this thread long before I even bought the Nexus 7. One of the key points in my purchasing decision for the Nexus 7 was Timur's work. So Asus should thank him too
> The project for me is simple: Replacement for my current (crappy) navi VW RNS2. The tablet will not be used for anything else.
> Timur, mate, please set up that paypal account so I (and maybe others too) can thank you from time to time.


----------



## jmcguire525

Timur, could you possibly start a new thread in the development section, that way you could have all the information listed in the first post and be able to update that post as needed. I've read thru this a good bit and have used a few of your patches, but things are getting rather hard to follow with img/zip files and the different patches for those using for car installs and normal OTG uses.

I would do this myself but I'm having a hard time figuring out what problem is being reported for each patch (hence writing this post).


----------



## Bonger

Timur,

I also have issues with the security option force closing on the newer flashes, 12-03, 12-04, and 12-05. 11-28 works well except now it's bugging out my gps signal. can't hardly lock onto a gps signal. Anyways, thought it might be my app itself, but no go. switched back to stock kernel and gps works great. flash yours and gps wigs out. don't know if anyone else is having this issue.


----------



## kodiack99

Thanks Timur,
I installed 12-05 today ,I'm just in the testing now.I have it in a car install with an extension going to the glove box for a usb stick.
I have noticed that if I uplug the usb stick it wont mount again unless I reboot is this normal?
Im more concerned about the power being stable for tasker etc.so its a minor problem,poweramp also seems a little buggy with it as well.It loses connection at times and gives me a multiple failed files error.
Cheers mate,good work as always.


----------



## Timur

Bonger said:


> I also have issues with the security option force closing on the newer flashes, 12-03, 12-04, and 12-05. 11-28 works well except now it's bugging out my gps signal. can't hardly lock onto a gps signal.


Bonger, you are the 2nd person reporting these two issues. I will look into this. But so far I was unable to reproduce them. Are you using 4.2 or 4.2.1? I am using plain AOSP 4.2.1 without Gapps. I'm mentioning this because I also never experienced the "Currents issue" that initially led people to believe 4.2 was slow or buggy.

Edit: "security option force closing", this sounds like system level and can probably be logged easily with adb logcat, if you find a chance.

(Regarding one other open issue: I am now able to reliably reproduce the fixed-installation sleep/wake issue, which was reported here two weeks ago. I will come back to this. Hopefully soon. I also want to thank the kind people further up the thread for sending kind posts, thanks


----------



## nexus-fan

According to the question in post #207, in the last version 5/12 i didnt found any problem with "wake lock" (its doesnt matter if BT or WIFI ON\OFF) also
the default of "Keep WIFI during sleep" turn to only when plugged in.

These problems were occurs in 4/12 version.


----------



## Bonger

Timur said:


> Bonger, you are the 2nd person reporting these two issues. I will look into this. But so far I was unable to reproduce them. Are you using 4.2 or 4.2.1? I am using plain AOSP 4.2.1 without Gapps. I'm mentioning this because I also never experienced the "Currents issue" that initially led people to believe 4.2 was slow or buggy.
> 
> Edit: "security option force closing", this sounds like system level and can probably be logged easily with adb logcat, if you find a chance.
> 
> (Regarding one other open issue: I am now able to reliably reproduce the fixed-installation sleep/wake issue, which was reported here two weeks ago. I will come back to this. Hopefully soon. I also want to thank the kind people further up the thread for sending kind posts, thanks


I am on stock rooted 4.2.1. just wanted the otg/charging your kernels offered without having to apply a script everytime I reboot, like with other kernels. also, I didn't have any issues with currents because i've uninstalled all that bloatware when i got my n7. anyways, I'll pm you my logs.

Thanks Timur..


----------



## Timur

Bonger said:


> I'll pm you my logs.


The bare stack trace for reference:

12-07 08:43:17.286 I/ActivityManager( 451): Displayed com.android.settings/.Settings: +542ms (total +5s848ms)
12-07 08:43:18.556 I/ActivityManager( 451): START u0 {act=android.intent.action.MAIN cmp=com.android.settings/.SubSettings (has extras)} from pid 4849
12-07 08:43:18.696 D/AndroidRuntime( 4849): Shutting down VM
12-07 08:43:18.696 E/AndroidRuntime( 4849): FATAL EXCEPTION: main
12-07 08:43:18.696 E/AndroidRuntime( 4849): java.lang.AssertionError: 5
12-07 08:43:18.696 E/AndroidRuntime( 4849): at android.security.KeyStore.state(KeyStore.java:70)
12-07 08:43:18.696 E/AndroidRuntime( 4849): at com.android.settings.SecuritySettings.onResume(SecuritySettings.java:410)

There is an identical stack trace here: http://forum.xda-developers.com/showpost.php?p=35127626&postcount=1316 
Unrelated to my work, but also based on AOSP 4.2.1. I'll let you know when I find out more.


----------



## dlbogdan

Timur,
Please.. I need your paypal account man. And i'm sure many others do.


----------



## kodiack99

I too like Nexus fan am having the power issue.
I have a fixed install in my Genesis, setup through ignition power to come on and sleep when ignition off along with airplane mode on/off etc.
But like him when power is cut the n7 must go to native otg providing power to usb device from n7 and when power is put back on it doesnt revert back to provide power to tablet.I dont want the n7 to power the usb when power is not on,my setup sounds pretty sweet so I dont need a usb dac the headphone jack to aux sounds fine to me.
My n7 is just a wifi (no 3g) 16 GB on stock rooted 4.2.1 and its a pita to pull it out and replug the power cable and even a reboot with power on doesnt reset the power/otg problem.
PS:I flashed the 12-5 img , are they all intergrated now or do I need to flash multiple files? And we need a paypal like requested to buy you a frosty for all your hard work.


----------



## nexus-fan

as kodiack99 says the power problem is main issue for who want fixed install in car. (without plug\unplug or restart everytime)

and.... whats is your paypal address? let me buy a drink.


----------



## kodiack99

I just checked all my settings there nothing set to wake it or keep it awake that I can see my wifi and bluetooth is shut down on power off with tasker using command through secure settings and tasker helper.As mentioned earlier my security setting also crashes on opening maybe there is something in there making it do it that I can access?
Here is what the install looks like hence the issue of unplugging and plugging it in.
http://imageshack.us...0929121654.jpg/
http://imageshack.us/photo/my-images/6/20120929122456.jpg/


----------



## dlbogdan

kodiack99 said:


> I just checked all my settings there nothing set to wake it or keep it awake that I can see my wifi and bluetooth is shut down on power off with tasker using command through secure settings and tasker helper.As mentioned earlier my security setting also crashes on opening maybe there is something in there making it do it that I can access?
> Here is what the install looks like hence the issue of unplugging and plugging it in.
> http://imageshack.us...0929121654.jpg/
> http://imageshack.us...0929122456.jpg/


I'm thinking of doing the same thing to my VW Golf with my Nexus 7  The RNS head unit is awful.
I've built my cable and been testing around simulating situations in car.
Well, for fixed installations this is not working quite right (having to unplug the otg cable or restart the nexus to make it all work again).
I think the best (if possible) for this particular scenario (nexus 7 tablet forever embedded in car) the microUSB should only function as a OTG host and never even try to provide power, it should just expect external power and expect external usb device.
I'll test the thing with a powered USB HUB and in it plugged a 3G modem and a HDD. I'll test a super slim usb dvd drive later because I'd like to retain the CD/DVD music playback too.


----------



## dlbogdan

Oh, and when everything is working perfectly, I'm going to build this to retain the steering wheel commands.
http://hackaday.com/...button-presses/ and http://www.wire2wire.org/Can_sniffer/Can_sniffer.html (may be limited to VW cars, at least the firmware of this thing)
I'll need a keyboard emulator (bluetooth or usb) to connect to that and the nexus. I'll also need a kernel that would allow me to modify volume for USB DAC (i've seen one somewhere).
All that plus an ELM 327 and Torque app (or dashcommmand) and I'm set 
I'm making a list to people I need to donate to.


----------



## nexus-fan

Hi kodiack99,
Your install looks really nice, its fits like OEM








but i think you have to extend the power button.

2) In current situation, do you restart the tablet every ride?


----------



## Timur

An update on those fixed installation issues. Yes, it's not a single issue.

1. host device not going into deep sleep or sporadically waking up from sleep without user interaction
2. host device not waking up from deep sleep when power is reapplied after sudden power loss
3. host unable to communicate with USB slave devices after waking up from deep sleep

Issues 1 + 2 are caused by our modified host mode power configuration. More tegra3 kernel driver code was found to be not prepared to see power floating towards the host in host mode, instead of towards slave devices. (Host mode is being called OTG throughout the code. Go figure.) Issue 1 takes place when the host is trying to transition from light sleep to deep sleep. In other words, the host will wake up, when deep sleep fails. Issue 2 takes place when the host does actually wake up as needed, but is then unable to detect the external power source and therefor chooses to fall right back into sleep mode without ever switching on the screen.

I think I might be able to provide fixes for 1 + 2. I am struggling with no. 3, which is similar to an old issue, dating back as far as 2005. I think everyone has run into "device not accepting address xx, error -71" at some point. Pls read https://bugzilla.red...g.cgi?id=770704 to recall the issue. Towards the end of this thread it says that the problem still exists in kernel 3.3.1-5, but may have been solved in 3.3.2-1. Not sure if this is true, but your N7 is running on 3.1.10. In any case, we need a fix for issue 3, because without it, all fixing of 1 + 2 will not make you happy.

@jmcguire525: I like your proposal from #221 and will consider once a solution is available for these issues.


----------



## kodiack99

I do have a power button in the top left of the bezel,I used a pen clicky thing for it with an internal sleeve directing it.
I removed the otg cable for now,It was causing me too many headaches.
I had a acer A100 in for a time but the touch screen didnt like the cold and would go crazy.I dont ever shut it off it wakes on power and goes to sleep on disconnect.


----------



## kodiack99

Timur,do you think issue 3 could be solved with a command script run by taker at power up?


----------



## Dohnut

Looks like I'm going to need to wait til all the little issues are sorted out first. My n7 will be going in the car as a fixed install and the weather is delaying me anyway, but I want to hear everything working first.

Also want to send Timur money for a few beers though for his efforts.


----------



## dlbogdan

So i've been testing around with timur's 28.11 kernel on stock rom.
The only problem when using the tablet in the car as of now is that when the external power is no more, it triggers the nexus 7 to change otg mode and supply power for the usb device. Doing that, it will never be able to detect again external power and resume charging.

I'm getting this:


Code:


<br />
<br />
<4>[ 6894.395435] inok_isr_work_function power loss/gain lastOtgState=1 lastExternalPowerState=1 lastChargeSlaveDevicesState=0 xxxxxxxxxxxxxxxxx<br />
<4>[ 6894.395897] inok_isr_work_function lost external power in host mode; [b]trying to continue host mode by self-charging slave devices[/b] xxxxx<br />
<4>[ 6894.396065] smb347_otg_status to=9 from=9 lastOtgState=1 lastExternalPowerState=1 lastChargeSlaveDevicesState=0 xxxxxxxxx<br />
<6>[ 6894.396179] INOK=H<br />
<4>[ 6894.396238] ========================================================<br />
<4>[ 6894.396298] battery_callback  usb_cable_state = 0<br />
<4>[ 6894.396406] ========================================================<br />
<4>[ 6894.396466] battery_callback cable_wake_lock 5 sec...<br />
<4>[ 6894.396469]<br />
<6>[ 6894.396651] elan-ktf3k 1-0010: Update power source to 0<br />
<4>[ 6894.397040] smb347_otg_status change use of external power to 0 xxxxxxxxxxxxxxxxxxxxxxxxxx<br />
<4>[ 6894.397479][b] smb347_configure_charger disable external power[/b] xxxxxxxxxxxxxxxxx<br />
<5>[ 6894.398873] bq27541_get_capacity = 71% ret= 72<br />
<4>[ 6894.399183] smb347_configure_otg INOK to be active high xxxxxxxxxxxxxxxxx<br />
<5>[ 6894.400129] bq27541_get_psp voltage_now= 3956000 uV<br />
<4>[ 6894.400367] smb347_configure_otg charge slaves 250mA xxxxxxxxxxxxxxxxx<br />
<4>[ 6894.419187] smb347_configure_otg charge slaves 750mA xxxxxxxxxxxxxxxxx<br />
<5>[ 6894.420281] bq27541_get_psp temperature= 290 (0.1¢XC)<br />
<4>[ 6894.421037] smb347_otg_status done lastOtgState=1 externalPowerState=0 chargeSlaveDevicesState=1 xxxxxxxxxxxxxxxxxxxxxx<br />
<5>[ 6894.423357] bq27541_get_psp status: Not charging ret= 0x0100<br />
<3>[ 6894.587022] init: untracked pid 7462 exited<br />
<6>[ 6894.685573] usb 2-1: new high speed USB device number 3 using tegra-ehci<br />
<3>[ 6894.694529] init: untracked pid 7477 exited<br />
<6>[ 6894.765765] usb 2-1: New USB device found, idVendor=058f, idProduct=6387<br />
<6>[ 6894.765887] usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3<br />
<6>[ 6894.765997] usb 2-1: Product: Mass Storage<br />
<6>[ 6894.766058] usb 2-1: Manufacturer: Generic<br />
<6>[ 6894.766118] usb 2-1: SerialNumber: 174B0A1A<br />
<6>[ 6894.767329] scsi22 : usb-storage 2-1:1.0<br />
<4>[ 6894.995435] inok_isr_work_function power loss/gain lastOtgState=1 lastExternalPowerState=0 lastChargeSlaveDevicesState=1 xxxxxxxxxxxxxxxxx<br />
<6>[ 6894.995565] INOK=L<br />
<5>[ 6894.995829] smb347_charger: [cable_type_detect] Reg39 : 0x11<br />
<5>[ 6894.996131] smb347_charger: [cable_type_detect] Reg3F : 0x00<br />
<6>[ 6894.996193] USBIN=0<br />
<4>[ 6894.996301] inok_isr_work_function wait for external power detection ... xxxxxxxxx<br />
<3>[ 6895.145826] init: untracked pid 7484 exited<br />
<6>[ 6895.295384] INOK=L<br />
<5>[ 6895.295646] smb347_charger: [cable_type_detect] Reg39 : 0x11<br />
<5>[ 6895.295889] smb347_charger: [cable_type_detect] Reg3F : 0x00<br />
<6>[ 6895.295999] USBIN=0<br />

At line #2 we see it clearly.. "*trying to continue host mode by self-charging slave devices*"
I've been reading through sources but I can't figure out how to PERMANENTLY DISABLE (even hardcoded from source, i don't care) this mode change and make the nexus device to never try to provide power for usb devices.
So, Timur, or maybe others.. your help would be greatly appreciated.


----------



## dlbogdan

Another find... maybe not important, but here are the regs change between

*otg mode and nexus 7 charging:*
[email protected]:/sys/bus/i2c/drivers/smb347/4-006a # cat ./reg_status
Reg[06h]=0x71 Reg[08h]=0x08 Reg[30h]=0x12 Reg[31h]=0x00 Reg[39h]=0x10 Reg[3dh]=0x05 Reg[3eh]=0x0e Reg[3fh]=0x93

*and otg mode with nexus 7 powering the usb device:*
[email protected]:/sys/bus/i2c/drivers/smb347/4-006a # cat ./reg_status
Reg[06h]=0x71 Reg[08h]=0x09 Reg[30h]=0x10 Reg[31h]=0x00 Reg[39h]=0x11 Reg[3dh]=0x00 Reg[3eh]=0x00 Reg[3fh]=0x00

from source we have these defined: 

#define smb347_PIN_CTRL 0x06
#define smb347_SYSOK_USB3 0x08
/* Command registers */
#define smb347_CMD_REG 0x30
#define smb347_CMD_REG_B 0x31
#define smb347_INTR_STS_E 0x39
/* Status registers */
#define smb347_STS_REG_C 0x3D
#define smb347_STS_REG_D 0x3E
#define smb347_STS_REG_E 0x3F


----------



## dlbogdan

I give up. While I do know my way around linux in general, it is clear that this issue is not something I'm able to solve by myself. It's been a loong day with absolutely no results, so I'll let the android gurus handle this.
So please, if someone has any ideea about how to completely disable mode switching (i.e. disabling the mode that lets nexus 7 supply power to a usb device connected with an otg cable).
This would be perfect for car installation projects where you'd normally supply power to devices and the nexus externally.


----------



## kodiack99

I wish I had the skills to help but Im a hadware guy,messing with code wouldnt be productive for me.
Thanks for your effort,sounds like maybe you have opened up a door for someone else.
Cheers


----------



## dlbogdan

it seems I'm just retarded because Timur already did this back here: http://rootzwiki.com/topic/30615-can-you-charge-usb-host-mode-simultaneously/page__st__130#entry1030535
I just flashed the wrong kernel all along (the one with both modes from 28.11).

I'll test the 21.11 version in depth and then begin car permanent installation.


----------



## Timur

dlbogdan said:


> ...disabling the mode that lets nexus 7 supply power to a usb device connected with an otg cable


This has been fixed already. But due to the other issues mentioned in #235, I did not release this yet.

In regard to issue 3 "host unable to communicate with USB slave devices after waking up from deep sleep": it looks like this communication problem is caused by Tegra3 specific driver code being invoked during wake up from deep sleep. I assume this situation was not extensively tested, because normally, while in OTG host mode, the N7 kernel will not allow itself to sleep deep. This is not an issue with the generic kernel code being part of 3.1.10. It's just very similar to problems that have been solved there some time ago.

I have enabled USB_DEBUG. This is what I see during wake up from light sleep (where there are no communication issues):
[ 147.615933] usb usb2: usb wakeup-resume
[ 147.616014] usb usb2: usb auto-resume
[ 147.618652] tegra-ehci tegra-ehci.0: reset command 0018006 PPCEE(park)=0 ithresh=1 period=512 Reset HALT

This is what I see during wake up from deep sleep (followed by "device not accepting address xx, error -71"):
[ 274.871590] usb usb1: usb resume
[ 274.874318] tegra-ehci tegra-ehci.1: reset command 0080b02 park=3 ithresh=8 period=1024 Reset HALT
[ 274.874588] tegra-ehci tegra-ehci.1: resume root hub
[ 276.099238] usb usb2: usb resume
[ 276.099454] tegra-ehci tegra-ehci.0: reset command 0080b02 park=3 ithresh=8 period=1024 Reset HALT
[ 276.099727] tegra-ehci tegra-ehci.0: resume root hub

Both cases are triggered by a sudden power loss. The DAC will be switched off completely in both cases. I find it suspicious that it is being treated differently in the wake from deep sleep case.


----------



## dlbogdan

i'd rather have no deep sleep on the tablet. If the nexus 7 would know how to boot without power button pushed I would have ripped the battery out and just let it boot up on every ignition start.

edit: 21.11 version behaves erratic unfortunately








I'm selling the device if I'm unable to achieve this task.


----------



## wave_is

Has anyone Installed Nexus in the car? Whether there is anything to do with the decision on and off the tablet according to the ignition?
I wanted to do this:
- The tablet is always in the state of charge
- Installed in the car wi-fi access point. It is connected to the ignition, the car.
- When the tablet sees the access point, it will turn on.

- When the access point is switched off, the tablet goes to sleep (screen off, turn off GPS, etc.)
But I could not implement it. Tasker could not control my tablet.
Maybe I just do not know how to properly configure Tasker.

My venture possible to implement?

Sorry for my english.

PS Is there a topic somewhere where people would describe their projects to install Nexus 7 in the car?


----------



## dlbogdan

tasker should work with your setup. if you don't need any usb devices plugged in the nexus, things should be easy for you, but if you do, stay tuned to this thread because right now things aren't perfectly smooth.
see this thread: http://rootzwiki.com/topic/36230-nexus-7-the-ultimate-car-stereo/
and there are a lot of people doing permanent mounts in cars on youtube.


----------



## wave_is

dlbogdan said:


> tasker should work with your setup. if you don't need any usb devices plugged in the nexus, things should be easy for you, but if you do, stay tuned to this thread because right now things aren't perfectly smooth.
> see this thread: http://rootzwiki.com...ate-car-stereo/
> and there are a lot of people doing permanent mounts in cars on youtube.


I use a usb flash drive, as well as planning to connect a usb web camera.


----------



## dlbogdan

Update:
I've made a simple tasker automation to reboot on usb plug in to make it work smoothly when I turn on the engine, till Timur solves the bug  no stress mate...
On usb unplug (turn ignition off) the tasker takes down wifi, bluetooth and puts the tablet on standby. I hope I'll not end up with a dead battery because then I'll have to dismantle the dash frame just to push the power button for the tablet too boot ... EEEK...
One problem (serious)
The security settings doesn't work (unexpectedly closes every time).
Currently using boot-jb42-grouper-host-mode-power-usb-audio-fi-2012-12-05.img


----------



## wave_is

dlbogdan said:


> Update:
> I've made a simple tasker automation to reboot on usb plug in to make it work smoothly when I turn on the engine, till Timur solves the bug  no stress mate...
> On usb unplug (turn ignition off) the tasker takes down wifi, bluetooth and puts the tablet on standby. I hope I'll not end up with a dead battery because then I'll have to dismantle the dash frame just to push the power button for the tablet too boot ... EEEK...
> One problem (serious)
> The security settings doesn't work (unexpectedly closes every time).
> Currently using boot-jb42-grouper-host-mode-power-usb-audio-fi-2012-12-05.img


prompt settings of your profile Tasker.

How do you turn the tablet with the ignition?


----------



## dlbogdan

wave_is said:


> prompt settings of your profile Tasker.
> 
> How do you turn the tablet with the ignition?


Here is my tasker exported as description:



Code:


<br />
Profile: Setflag (3)<br />
Event: Device Boot<br />
Enter: CarMode (4)<br />
A1: Variable Set [ [URL=Name:%REBOOTED]Name:%REBOOTED[/URL] [URL=To:1]To:1[/URL] Do [URL=Maths:Off]Maths:Off[/URL] [URL=Append:Off]Append:Off[/URL] ]<br />
A2: Airplane Mode [ [URL=Set:Off]Set:Off[/URL] ]<br />
A3: Bluetooth [ [URL=Set:On]Set:On[/URL] ]<br />
A4: WiFi [ [URL=Set:On]Set:On[/URL] ]<br />
A5: Car Mode [ [URL=Set:On]Set:On[/URL] Go [URL=Home:Off]Home:Off[/URL] ]<br />
A6: Night Mode [ [URL=Mode:Auto]Mode:Auto[/URL] ]<br />
<br />
Profile: Usbunplug (11)<br />
State: Not Power [ [URL=Source:USB]Source:USB[/URL] ]<br />
Enter: Standby (10)<br />
A1: Variable Set [ [URL=Name:%REBOOTED]Name:%REBOOTED[/URL] [URL=To:0]To:0[/URL] Do [URL=Maths:Off]Maths:Off[/URL] [URL=Append:Off]Append:Off[/URL] ]<br />
A2: Airplane Mode [ [URL=Set:On]Set:On[/URL] ]<br />
A3: Bluetooth [ [URL=Set:Off]Set:Off[/URL] ]<br />
A4: WiFi [ [URL=Set:Off]Set:Off[/URL] ]<br />
A5: System Lock<br />
<br />
Profile: Usbplug (12)<br />
State: Power [ [URL=Source:USB]Source:USB[/URL] ]<br />
Enter: Reboot (6)<br />
A1: Wait [ [URL=MS:0]MS:0[/URL] [URL=Seconds:2]Seconds:2[/URL] [URL=Minutes:0]Minutes:0[/URL] [URL=Hours:0]Hours:0[/URL] [URL=Days:0]Days:0[/URL] ]<br />
A2: Reboot [ [URL=Type:Normal]Type:Normal[/URL] ] If [ %REBOOTED = 0 ]<br />

The tablet is on standby when I'm not in the car and the usb power naturally wakes it up on ignition (and then tasker makes its move and reboots it).


----------



## thejevans

I just installed the 12-05 img, and I can't seem to get any sound to come out of my DAC (Creative X-Fi USB). The volume knob on the DAC works every time I boot up, but no sound. I have tried:

-Booting the Tablet up with the DAC off, but connected. This makes the DAC power up with the tablet.
-Unplugging and Replugging in the USB power to get the DAC to power up before turning on the tablet.

Any help would be greatly appreciated. Thanks.


----------



## Timur

thejevans said:


> I can't seem to get any sound to come out of my DAC (Creative X-Fi USB)


I have no experience with this device, sorry. Are you using a OTG Y-cable to power both devices? Because if you would, your DAC should be powered up, even without the N7 being connected (or booted)... I think. Did you try your device on a Linux desktop system?
The N7 in host mode is a little difficult to debug. You may want to give this a try: http://mehrvarz.github.com/android-debug-sans-usb/
And if possible, please use the release version from http://mehrvarz.github.com/usb-host-mode-power-management-nexus7 (dated 2012-11-28).
Those builds in my dropbox folder are only experimental.


----------



## jmcguire525

thejevans said:


> I just installed the 12-05 img, and I can't seem to get any sound to come out of my DAC (Creative X-Fi USB). The volume knob on the DAC works every time I boot up, but no sound. I have tried:
> 
> -Booting the Tablet up with the DAC off, but connected. This makes the DAC power up with the tablet.
> -Unplugging and Replugging in the USB power to get the DAC to power up before turning on the tablet.
> 
> Any help would be greatly appreciated. Thanks.


I doubt you will be able to make it work, I looked into the X-Fi DACs and they seems to need a mac or pc with the correct drivers.


----------



## wave_is

strange. When I connect the charger to the tablet directly, the tablet is turned on. When I connect the charger to the tablet via Y cable, it will not turn on. I have the wrong firmware or wrong cable?

Where to find the latest Timur's firmware in ZIP format?


----------



## kodiack99

You have to plug the otg cable into the tablet with the chager in it but the usb device not,when it detects power then plug the usb into the otg.That way the tablet doesnt revert to otg and supply power to the usb device .The usb device get power from the charger on the otg not the tablet itself.The link for the latest non experimental zip is post 253,The permanent install beta Timur is worker on isnt in zip that Im aware of ,it has to be installed from ADB using command or a tool kit to the boot sector.Did you install it already,if you are unsure check your kernal version in setting ,about and it will say if its Timurs or not.


----------



## wave_is

I have 
3.1.10-g8182f09-dirty kernel
[email protected] #21
and
android 4.2


----------



## wave_is

kodiack99 said:


> You have to plug the otg cable into the tablet with the chager in it but the usb device not,when it detects power then plug the usb into the otg.That way the tablet doesnt revert to otg and supply power to the usb device .The usb device get power from the charger on the otg not the tablet itself.The link for the latest non experimental zip is post 253,The permanent install beta Timur is worker on isnt in zip that Im aware of ,it has to be installed from ADB using command or a tool kit to the boot sector.Did you install it already,if you are unsure check your kernal version in setting ,about and it will say if its Timurs or not.


* Download for Android 4.2.x*

A boot.img containig the modified kernel for Nexus 7:
boot-jb42-grouper-host-mode-power-usb-audio-2012-11-28.img
To flash enter: fastboot flash boot [filename]

Same kernel as update zip: update-boot-jb42-grouper-host-mode-power-usb-audio-2012-11-28.zip
Copy this zip file to your sd-card and install via recovery.
--------------

This is correct files?


----------



## kodiack99

yup thats the latest ,you can flash the zip from twrp or cwm .
Make sure you do a full nandroid backup first in case you have any issues.


----------



## wave_is

I plugged the Y cable without USB flash drive. The tablet does not see charging.
------
when I disconnect the cable and re-turn of the tablet.
tablet begins to see charging.
------
If I unplug the power cable from the Y, and then on again, then again, no longer see the tablet charging. And again I have to disconnect the cable from the tablet. , (
We all have the same situation?

Sorry for my english.


----------



## wave_is

dlbogdan said:


> Update:
> I've made a simple tasker automation to reboot on usb plug in to make it work smoothly when I turn on the engine, till Timur solves the bug  no stress mate...
> On usb unplug (turn ignition off) the tasker takes down wifi, bluetooth and puts the tablet on standby. I hope I'll not end up with a dead battery because then I'll have to dismantle the dash frame just to push the power button for the tablet too boot ... EEEK...
> One problem (serious)
> The security settings doesn't work (unexpectedly closes every time).
> Currently using boot-jb42-grouper-host-mode-power-usb-audio-fi-2012-12-05.img


do you use y cable? usb hub or other usb device?


----------



## Timur

@wave_is: 
To charge the N7, you should always first connect power to the Y-cable. After that plug the OTG end into your N7. In case of a power loss, the kernel will switch to operate your USB slave device from it's internal battery. The kernel will then not be able to automatically switch back to external power source, if it becomes available again. (Because, when it is serving battery power into the USB cable, it cannot detect external power.) To switch back to external power, you need to briefly disconnect and reconnect your OTG adapter. Hope that makes sense.


----------



## wave_is

Thanks for your explanation.

I'm trying to build my tablet in the car. I do not know how best to connect the power to the tablet.
I want to do that when the ignition is switched on the tablet, too, and when the ignition is switched off the tablet too.
But, I do not know how.


----------



## wave_is

I want to connect the usb cable to the tablet via a relay.
If the car ignition is turned off, USB cable is not connected. When the car ignition is on, the relay is energized and activates USB cable.
What kind of wire is better unlock relay in such a scheme?
I think that would be right off the red switch wire (12 volts).

Will this scheme work?


----------



## kodiack99

I dont think a relay will work,I think it senses the cable connect via some switch.That is why simply unplugging the usb device before power off doesnt work to keep power from otg cable.But I could be wrong.We need a permanent way to turn off power going to the usb device via otg so that power can always be detected going inot the tablet,We only want the power adapter side of the otg powering the usb device,I dont believe anyone has found a way to reliablly do this yet.


----------



## aFR

Timur said:


> @aFR: Thx for the info. Is anyone else having problems with the N7-3G? Does it require a different kernel? Going into Settings -> Security is not a problem on my N7.


I don't know if it needs a different kernel. I can check happily if you'll point me in the right direction.

Also, I shot you an email a week ago to request your paypal address. Just FYI.


----------



## dmexs

I was also looking to send some monetary thanks your way Timur. Want to PM your PayPal address?


----------



## nexus-fan

hi Timur, im so curious, any progress??


----------



## dlbogdan

Timur said:


> ...
> And if possible, please use the release version from http://mehrvarz.gith...nagement-nexus7 (dated 2012-11-28).
> Those builds in my dropbox folder are only experimental.


Timur,
Would you please point me to the right kernel (non experimental maybe) that disables (in any situation) powering the usb device by the nexus 7 (so it will never be in a situation of not being able to detect external power, thus-> always being able to charge and always being able to host externally powered devices... )
Also, the settings->security not opening is a bit of an inconvenience..
And please don't ignore our need to give you some money for your hard work. You deserve it.


----------



## thejevans

Timur said:


> I doubt you will be able to make it work, I looked into the X-Fi DACs and they seems to need a mac or pc with the correct drivers.


Thanks for the info. I'm thinking about going a different route all together.

http://www.amazon.com/JayBird-uSport-Bluetooth-Adapter-Devices/dp/B002PU9U0E

After talking with a few people, this seems to be the best bluetooth adapter I can get. What are your opinions on this? I've used bluetooth before (built in toyota head unit) to stream audio to my car, and the quality seemed adequate. If I understand correctly, the tablet uses A2DP to stream digitally, and the bluetooth adapter has a DAC in it that converts it. Do you all think it will be any good? I'm hoping this way it will be a more stable solution.


----------



## oakleyguy89

Hey guys, I am currently running the latest version of RasBeanJelly and Trinity kernel alpha0. I really would love to have charging and USB OTG, is there support for CyanogenMod 10.1 yet?


----------



## besjr69

I've been away for a little while and looks like there's been a lot of work to resolve the fixed installation issue. Frankly I do not believe this can be done thru firm-/software alone. It seems the device reverts to normal OTG when power is removed and the issues come when you try to go back to OTG+Charge. Would it not make since thru hardware to take the device out of OTG before the N7 goes to sleep? Essentially this is what you are doing when you removed the Y-cable from the N7, plug it back in and it recognizes the USB device. I have not verified this theory. My plans are to toggle the SENSE pin thru the ignition. I simple DPST relay for power and SENSE - I believe - will resolve the issue regardless of Kernel. When I get my micro USB male plug I will build, test and report back.

Bobby


----------



## nexus-fan

Hi Bobby, i already tried it, doesnt works for me.


----------



## dlbogdan

thejevans said:


> Good to know. Thanks.
> 
> Thanks for the info. I'm thinking about going a different route all together.
> 
> http://www.amazon.co...s/dp/B002PU9U0E
> 
> After talking with a few people, this seems to be the best bluetooth adapter I can get. What are your opinions on this? I've used bluetooth before (built in toyota head unit) to stream audio to my car, and the quality seemed adequate. If I understand correctly, the tablet uses A2DP to stream digitally, and the bluetooth adapter has a DAC in it that converts it. Do you all think it will be any good? I'm hoping this way it will be a more stable solution.


Watch out about this adapter. Here's a comment from an amazon user: 


> This is basically all I could ask for in a "universal" bluetooth adapter - small and flat, light, long battery life, good transmit range, reasonably intuitive controls and support for apt-x. There's just one thing to be cautious of: *if you use it while the USB power adapter is plugged in you may get some nasty-sounding noise and static over your music* (it's obvious if you pause and just crank up the volume). I got this static when plugging the USB end into any of my computer's USB ports but it went away when I used one of those universal AC/DC adapters with interchangeable connectors (one of them a female USB) plugged into the wall. I guess some power sources are "dirty" and the electrical noise leaks into the transmission.


The best way to solve this is getting a 1-DIN Sony (or whatever) player with A2DP support and just put it in the back of the tablet (forever set to A2DP).
This way you can just set the tablet to transmit by a2dp bluetooth to the 1-din player and you'll be able to use it with the phone handsfree too (it will automatically mute/unmute the music).
I think I might just go this way to escape the USB DAC problems.


----------



## nexus-fan

You cant compare between external dac and BT quality.


----------



## Timur

oakleyguy89 said:


> I really would love to have charging and USB OTG, is there support for CyanogenMod 10.1 yet?


Yes. I just uploaded a kernel image for Nexus 7 running CM-10.1 to my dropbox at http://timur.mobi/files. This kernel should provide the same charging and USB OTG functionality as "release 11-28" does for stock Android 4.2.x. To flash, enter "fastboot flash boot boot-cm10.1-....img". DO NOT USE WITH STOCK ANDROID!

If this works well, I will create an update.zip type installer for CM-10.1 and add that to my release page http://mehrvarz.github.com/usb-host-mode-power-management-nexus7 soon. Until then, pls consider this experimental.

Sorry, there is no dedicated "fixed installation" support available yet. See: #235.

@aFR: I'm still not sure about N7-3G support. However, I can see references to 3G hardware in the existing kernel source. So it might just work. Before you try, pls backup your current kernel.


----------



## dlbogdan

nexus-fan said:


> You cant compare between external dac and BT quality.


It's a car.. if you are actually using the car for its purpose you'd definitely be more concerned about the engine and traffic noise (music quality wise) much more about the DAC quality.
BT A2DP is perfectly fine in a car. Undeniable.

Where the h3ll is [background=rgb(247, 247, 247)] CyanogenMod 10.1 for Nexus 7 ? [/background]
[background=rgb(247, 247, 247)]edit: Found it here: [/background]http://code.google.c.../downloads/list


----------



## aFR

Timur said:


> I'm still not sure about N7-3G support. However, I can see references to 3G hardware in the existing kernel source. So it might just work. Before you try, pls backup your current kernel.


I have been successful with the N7-3G with the 11-25 build, the 12-03 build gave me problems with the security settings menu.

Any reason for me to move to 11-28 from 11-25 if I don't care about audio and only power + host mode?


----------



## RWNube

besjr69 said:


> RWNube, thanks for the tip. I'll see if I can set it up at home. I've never played with CIFS. One question though, if I'm on CIFS can I simultaneously be on another WiFi network with internet access? Or would it be best to use a router? I saw an article similar to what you are talking about on mp3car.com except he's using DLNA. Don't know the difference.


Sorry about the delay. CIFS is just a sharing system that works over a network . You just need to be able to ping the IP address of sharing device. There are various ways to go about it, but if the devices are on the same WIFI, it makes it easier. 
Sent from my ADR6425LVW using Tapatalk 2


----------



## Rezl

I'm attempting to setup Timur's Kernel on my Nexus 7 (Not 3G), but have been unsuccessful.

I have CM10.0.0-grouper, Android version 4.1.2, and Kernel version 3.1.10-g830e42f (Timur's 11-28 build). I'm using this model USB-Y cable.
I've connected a standard wall charger to the OTG cable first, and then connected the OTG into the tablet. Although, it still indicates it is discharging. The OTG works normally with a standard USB mouse, but only when the power is not connected to it.

I'm know I'm missing something obvious, but I'm sick of lurking.


----------



## mbc0

[background=rgb(245, 245, 245)]Hi Guys,[/background]

[background=rgb(245, 245, 245)]I am a complete noob when it comes to roms & Kernals.... I have read EVERY page of this post along with many other threads on XDA Developers and more & am still unsure of the best way forward.... Can someone please help me in a spoonfed kind of way with what I need to do?[/background]

[background=rgb(245, 245, 245)]My sole purpose for this tablet is to have it installed in the car, I dock the tablet using a Brodit Car Mount and I have successfully rooted my Nexus 7 3G and installed Stickmount and am able to use my 1TB Samsung S3 Portable drive and have the audio connected through the headphone jack (not interested in DAC) but obviously suffering very fast battery drain (about 4 hours) All I want to do is have the same configuration but with the ability to charge from my 2A USB Charger in the car [/background]

[background=rgb(245, 245, 245)]I really cannot understand what I need to do with the roms & kernals and what I need to do with making a cable (impossible to buy one of these "Y" Cables in the UK anywhere![/background]

[background=rgb(245, 245, 245)]I know I must be a pain in the A** to you experienced guys but if one of you could find the time to help me understand, I will in turn pass this information onto my friends that are in the same boat[/background]

[background=rgb(245, 245, 245)]Many Thanks to everyone who has supplied so much information on this subject I just need the few pieces of the "understanding" puzzle put together for me...[/background]


----------



## dlbogdan

mbc0 said:


> [background=rgb(245, 245, 245)]Hi Guys,[/background]
> 
> [background=rgb(245, 245, 245)]I am a complete noob when it comes to roms & Kern*e*ls.... I have read EVERY page of this post along with many other threads on XDA Developers and more & am still unsure of the best way forward.... Can someone please help me in a spoonfed kind of way with what I need to do?[/background]
> 
> [background=rgb(245, 245, 245)]...[/background]
> 
> [background=rgb(245, 245, 245)].... and what I need to do with making a cable (impossible to buy one of these "Y" Cables in the UK anywhere![/background]


Hi,

Here is my setup, the picture is self explicit. The microUSB plug i got from a standard device cable and the T usb cable from a HDD. The USB female ended cable I've got from an old USB header used on some motherboards.
There is a schematic picture on some page back for the connections to the microUSB plug but anyway, it's simple. You just have to solder the sense pin to ground and everything else is standard.

You may want to hot glue the solder points when finished to give it strength ( i.e. you DON'T want to have the possibility of short circuit in a car... )

If you don't own a solder station I highly recommend the cheap chinese ATTEN (sometimes branded [background=rgb(240, 244, 247)]Aoyue) [/background] 937b. I've got mine for about 20 euros and its performance blows my mind (for the price..)


----------



## dlbogdan

Timur said:


> ....
> 
> If this works well, I will create an update.zip type installer for CM-10.1 and add that to my release page http://mehrvarz.gith...nagement-nexus7 soon. Until then, pls consider this experimental.
> 
> Sorry, there is no dedicated "fixed installation" support available yet. See: #235.
> 
> ....


With CM10.1 and this kernel It's no longer working with my 3G modem (detects it with PPP widget but can't connect) . Never tried with the CM10.1 original kernel though.
My 3G stick isn't working anymore on anything.. so it's not because of CM10.1 or the kernel..


----------



## nexus-fan

I didnt found official CM10.1 for nexus 7 , is it possible to post the download link?

Edit: I found it, Thanks!


----------



## dlbogdan

i posted it earlier..


----------



## mbc0

dlbogdan said:


> Hi,
> 
> Here is my setup, the picture is self explicit. The microUSB plug i got from a standard device cable and the T usb cable from a HDD. The USB female ended cable I've got from an old USB header used on some motherboards.
> There is a schematic picture on some page back for the connections to the microUSB plug but anyway, it's simple. You just have to solder the sense pin to ground and everything else is standard.
> 
> You may want to hot glue the solder points when finished to give it strength ( i.e. you DON'T want to have the possibility of short circuit in a car... )
> 
> If you don't own a solder station I highly recommend the cheap chinese ATTEN (sometimes branded [background=rgb(240, 244, 247)]Aoyue) [/background] 937b. I've got mine for about 20 euros and its performance blows my mind (for the price..)


Many thanks for this, I do own a wellar solder station which was about £2000 but my company bought it for me years ago 

I am good to go on the cable, but I am not clear on what I need to do with the Rom/Kernel side of things also it looks like it doesn't even support 3G yet???

Thanks for the help


----------



## dlbogdan

It works with _some_ 3G modems and the PPP widget ( although i'd reallllly like something much more like stock 3G configuration and of course automatic and silent connection.... And the same goes for usb mounting, btw is there something like that?).
For the kernel part is easy but the results are not perfect as you may have already read in this thread. You just unlock, write a custom recovery and root the tablet and then you write Timur's kernel. Most of these operations are done from the PC with fastboot.exe ( from the SDK ). You'll find tons of tutorials for that.


----------



## mbc0

dlbogdan said:


> It works with _some_ 3G modems and the PPP widget ( although i'd reallllly like something much more like stock 3G configuration and of course automatic and silent connection.... And the same goes for usb mounting, btw is there something like that?).
> For the kernel part is easy but the results are not perfect as you may have already read in this thread. You just unlock, write a custom recovery and root the tablet and then you write Timur's kernel. Most of these operations are done from the PC with fastboot.exe ( from the SDK ). You'll find tons of tutorials for that.


Thanks for the info... From what I can make out, I have to downloand the ROM from http://mehrvarz.github.com/usb-host-mode-power-management-nexus7/ to make the charging work which is something I am not sure about doing as terrified I will lose my 3G or wreck my tablet, Do I need a Kernel as well as this?

Thanks for your help..


----------



## dlbogdan

.. oh if your tablet is the 3G model you won't lose it. I was talking about the wifi model and a 3G modem on usb...
and it's not a rom you are downloading there.. it's just a kernel ready to be flashed with fastboot over your oficial rom/firmware.


----------



## dlbogdan

while waiting for the eventual fix from Timur's genius hands, I'm now building the PCB for the CAN BUS to Bluetooth HID (keyboard emulator) for sending the steering wheel keys to the tablet via bluetooth by emulating standard bluetooth key presses. I'll post the entire project when it's ready. I'm not really sure it will work flawlessly at this stage. I might change my mind and replace bluetooth hid with standard usb hid. We'll see.


----------



## Timur

A "fixed installation" kernel update is maybe coming. But to recap: we currently have a modified kernel (http://mehrvarz.github.com/usb-host-mode-power-management-nexus7), making it possible to operate and charge the Nexus 7 while in USB host mode. This modified kernel works quite well for a device that is being carried around (you know, like a mobile device). It is possible to switch between OTG host mode (driven by the internal battery) and USB host mode (driven by external power). But some want to do a fully "fixed installation". Like using USB DAC's and flash drives with the N7 in a car dash installation. Unfortunately, in this scenario a shortcomings of the N7 kernel come in the way. The use of USB slave devices will become impossible, once the N7 has gone through a deep sleep phase (LP0), which is usually triggered by power loss and the device going into sleep for 300 seconds, or more. Last week I had a conversation about this (http://thread.gmane.org/gmane.linux.usb.general/76212) with two original contributors to the Linux USB subsystem. Unfortunately I was not pointed to a patch or some other type of solution. In fact, I now think the issue may still be in the newer kernels. More coming soon.

About A2DP. The problem with it is that, even in the best case scenario (quality audio source, no interference), the resulting audio quality is lower than what a medium-to-good MP3 will sounds like. And if you send some already compressed audio over A2DP, what you end up with is basically a medium-to-low quality encoding being added on top of your original encoding. The outcome will not be very good. Not even for driving. It might even cause accidents.


----------



## nexus-fan

Just one thing, Thanks!


----------



## dlbogdan

Timur, I agree, the quality is not on par with wired music but is not that bad...
According to this at least: http://soundexpert.o...io-quality-a2dp
512 328 kbps should sound very good even if it's encoding an already encoded waveform.
Anyway, I'll try first because I already have an A2DP receiver and if I don't like it I'll use a USB DAC.


----------



## Timur

You'd be thinking less about low quality alternatives, if using Android + USB DAC was more trouble free.


----------



## dlbogdan

Timur said:


> You'd be thinking less about low quality alternatives, if using Android + USB DAC was more trouble free.


Exactly!
And it is weird too, because you'd think that an open platform like Android should behave nicely with a simple thing like USB DACs.. Apple iPad on the other hand handles this perfectly out of the box.


----------



## smitty67

Hi Timur,

Thanks for all your hard work. I have installed the 11-28 kernel on stock 4.2.1.. OTG, usb ethernet, keyboard, and charging work fine. My USB DAC is having problems. No Sound.. It is the Creative Blaster X-fi. Are we hit or miss on DAC support today?

Thanks again..

Dave


----------



## Timur

Pls see #253 + #254: http://rootzwiki.com/topic/30615-can-you-charge-usb-host-mode-simultaneously/page__st__250#entry1051107


----------



## joltman

http://cgi.ebay.com/...em=130815045315 That is the cable I purchased. I was plugging the microUSB power end into the N7 charger, or a Samsung 1A charger I have. Then in the standard sized USB end, I plugged in a microSD USB adapter. I did _not_ get a light on the adapter like I should. What charger are people using to test??

EDIT: I take it back. This didn't work on the Trinity Kernel, but I can now see the microSD Card on my Nexus 7 under Root Explorer. Charging shows as USB. I'm using the default Nexus 7 charger @ 2A. Timur, does your kernel enable USB Fast Charge? I would think that's a necessity if someone wants to mount this as their full/part time vehincle device.


----------



## Timur

Pls see #256 and #262 http://rootzwiki.com/topic/30615-can-you-charge-usb-host-mode-simultaneously/page__st__250#entry1051610


----------



## joltman

Timur said:


> Pls see #256 and #262 http://rootzwiki.com...50#entry1051610


So I got my hands on a USB hub. I plugged everything into the hub, power, microSD-USB adapter and a Pantech UML290 Verizon 4G LTE stick. Then I got power plugged into the USB OTG Y adapter and the hub plugged into the Y adapter. Finally, I plugged in the N7 (using Timur's 11-28-2012 kernel) and the the devices on the hub were found! Exciting! My Turtle Beach USB DAC-Optical adapter is in the mail. Should be here after Christmas. Can't wait to put it all together!


----------



## Timur

The following issues have been fully resolved:



Timur said:


> 1. host device not going into deep sleep or sporadically waking up from sleep without user interaction
> 2. host device not waking up from deep sleep when power is reapplied after sudden power loss
> 3. host unable to communicate with USB slave devices after waking up from deep sleep


I will make a new kernel available soon. Please stay tuned.


----------



## dlbogdan

How exciting!


----------



## nexus-fan

The man (timur) is lifesaving !


----------



## kodiack99

I ran an advanced copy......seems to be just what we need.
Seems stable so far.

Timur is da man!


----------



## Timur

dlbogdan said:


> One problem (serious)
> The security settings doesn't work (unexpectedly closes every time).


This issue has also been resolved now. Some background: I was building the kernel image and installer using tools based on the latest AOSP. This code base (aka master) got ahead of 4.2.1 at some point, thus causing the issue. This is also why I wasn't seeing it. (Still my mistake.) Also why it didn't apply to CM-10.1. The new kernels will be released tomorrow. So, just in time.


----------



## dlbogdan

Timur rulez!!!


----------



## Timur

I just released the latest kernels. Download links can be found in the new discussion thread over here: http://rootzwiki.com/topic/37755-timurs-kernel-robust-usb-host-power-management - To those upgrading right away, please be so kind and leave a report, explaining (in more detail), what you are doing and why you are using this particular kernel. Do so in the new thread. And think of people reading this, who are just about starting with USB host mode on the N7. Thank you very much. 
Happy holidays everyone.


----------



## dmexs

Timur said:


> A "fixed installation" kernel update is maybe coming. But to recap: we currently have a modified kernel (http://mehrvarz.gith...nagement-nexus7), making it possible to operate and charge the Nexus 7 while in USB host mode. This modified kernel works quite well for a device that is being carried around (you know, like a mobile device). It is possible to switch between OTG host mode (driven by the internal battery) and USB host mode (driven by external power). But some want to do a fully "fixed installation". Like using USB DAC's and flash drives with the N7 in a car dash installation. Unfortunately, in this scenario a shortcomings of the N7 kernel come in the way. The use of USB slave devices will become impossible, once the N7 has gone through a deep sleep phase (LP0), which is usually triggered by power loss and the device going into sleep for 300 seconds, or more. Last week I had a conversation about this (http://thread.gmane....b.general/76212) with two original contributors to the Linux USB subsystem. Unfortunately I was not pointed to a patch or some other type of solution. In fact, I now think the issue may still be in the newer kernels. More coming soon.


I experience the problem with the deep sleep. When I come back to my car after a period longer than 5+ minutes the USB device object (/dev/block/hda1,2,3,etc) isn't recreated. Thus I have to restart the device. What I've done to work around this is create a timer with Tasker that keeps the N7 awake (screen off, but prevents it from entering a deep sleep) for an hour and then shuts it down afterwards. This seems to help. If I get in the car after an hour I have to cold boot the tablet, which takes about ~30 seconds. Two areas of interest for me:

1. Are there any low hanging fruit in terms of shortening the boot time of the device? Right now, from device boot to hdd mounted and music playing, it's about ~30 seconds.

2. I'd be very interested to hear if you make any progress on the deep sleep/remounting issue. *EDIT:* Looking at your kernel thread, does this mean the issue has been solved?

With or without those two things, I'm very grateful for your help. PM me if you decide to accept the donation I've been hinting at for a while now. Finally found a PayPal link on your download page, nm, hope my change helps make your holidays all the merrier!







Happy Holidays!


----------



## Timur

dmexs said:


> I'd be very interested to hear if you make any progress on the deep sleep/remounting issue.


The deep sleep issue (affecting any type of USB slave device) and the remounting issue (affecting only file systems) are actually two separate issues. The deep sleep issue is a kernel issue that I consider completely solved. The remounting issue does not seem to be a kernel, but a system issue. I don't think it can be fixed by only touching the kernel. I'm not yet sure how to go about it.

But let's continue on the new thread, will you? http://rootzwiki.com/topic/37755-timurs-kernel-robust-usb-host-power-management


----------



## besjr69

Timur,

I'd like to thank you for all the hard work you've been doing for us. I was primarily interested in this to expand my device storage. I figured out another way using a wireless NAS. Again thanks for all your hard work.

Bobby


----------



## dlbogdan

Could you come back with reports about how's that working out ? Is it reliable? Does it need any monkey buttons pressing once you get in the car? The reason I'm avoiding a wireless NAS is that I fear it would complicate everything too much. I just want to be as close to what it is with stock stereo, like getting in, ignition on and drive... Everything should just power on and resume on itself.


----------



## besjr69

It works great. Don't want to hijack this forum. I'll try and PM you later.

Sent from my Galaxy Nexus using Tapatalk 2


----------



## Timur

The latest USB host mode + charging development can be found here:
rootzwiki.com/topic/37755-timurs-kernel-for-nexus-7-robust-usb-host-power-management http://rootzwiki.com/topic/37755-timurs-kernel-for-nexus-7-robust-usb-host-power-management/page__st__60


----------



## iriki

Howdy dear gentleman,

I'm sorry to post in this thread, but I could really use some help from you Timur and the others, in order to do the same in my cheap Rockchip 3006 tablet.

Please, it'll only take a min or so of your time. Thanks!
http://forum.xda-developers.com/showthread.php?p=37333409


----------



## jj77669

Any love for an HTC owner? I have a One x and have been trying to accomplish otg + charging ever since I got my phone stock rooted with 4.1.1. Could someone please point me in the right direction to enable this? (I fell like putting my head through a wall)


----------



## Irishboym4

You can safely use 5.25 volts with USB (at the connectors), One thing that must be taken into account is the resistance of the wires and connectors. My PSU output at its terminals is 5.3-5.5 volts depending on the amount of current being sourced. Its setup so that the higher the current draw the higher the voltage goes. This compensates for the resistance and maintains about 5.23 volts at the nexus charge port and 5.1 at the usb hub output connectors. If anyone wants to design their own psu and wants help building let me know.


----------



## rvdee

Excuse me. Will this work on my future Nexus 7? N7>otg> 1tb hard drive and External dac while charging the N7? Will use my N7 for audio only. 
This is my Dac = http://www.ifi-audio.com/en/iDAC.html
This dac has its own power supply.


----------

