FORUMS
Remove All Ads from XDA

OTG + Charging using USB ACA (Accessory charging adaptor) on my Moto G (XT1032)

46 posts
Thanks Meter: 92
 
By tal.aloni, Member on 3rd August 2016, 10:02 AM
Post Reply Email Thread
I was interested in getting USB OTG + Charging to work, and discovered that an "Accessory charging adaptor" was designed to serve such a purpose, the adapter is described in "Battery Charging Specification" Revision 1.2.

Here is a simple diagram of such an adapter (this design does not fully comply to the specifications):
USB ACA Cable

The code in 'drivers\usb\otg\msm_otg.c' suggests that the device can operate in the following 3 modes:
ID_FLOAT: Configure device to act as peripheral and allow charging if VBUS is present, else move it to LPM (low power mode).
ID_GROUND: Configure device to act as host and supply VBUS.
ID_A: Configure device to act as host and don't supply VBUS. In this state the device can charge as well.


So I built the adapter, and compiled my XT1032 kernel with CONFIG_USB_MSM_ACA,
unfortunately, (as far as I can tell) the hardware cannot detect the 124K resistor (so it does not automatically switch to ID_A).

Plan B:
It is possible however to modify 'msm_otg.c' and force ID_A (OTG + Charging mode), I was able to find an automatic method that works for me:
If you connect the ACA cable to a power source and a peripheral device and THEN connect your phone, the adapter will be detected as USB_PROPRIETARY_CHARGER (a dedicated charging port shorts the D+ and D- pins, and a flash drive does not),
so I simply assumed that USB_PROPRIETARY_CHARGER should activate ID_A.

I tested the patch (attached) using two Moto G XT1032 phones:
One manufactured in 2013-12-19 and have BOOTLOADER = 0x3 (with fastboot 41.13)
The other was manufactured in 2015-02-13 and have BOOTLOADER = 0x2 (with fastboot 41.18).
(the latest BOOTLOADER version is 0x4 with fastboot 41.1A, you can read the BOOTLOADER fuse using 'fastboot oem read_sv')

Other than the bootloader and MF date, the phones are Identical, same kernel, same system.
oddly, each behaved differently with the modified kernel and ACA cable:
With both phones, most USB peripheral devices were able to work when connected through a cheap (unpowered) USB 2.0 hub, this is the only hub out of the 3 tested that worked properly with the ACA cable.

The newer phone (but not the older one) had connectivity issues when devices were connected directly to the ACA cable.

To sum it up: I was able to use USB devices and charge at the same time using this patch.
maybe using two power adapters would have solved some of the minor issues I encountered (e.g. I could see the USB hub LED brightness fluctuate in some cases - it's not supposed to happen)

p.s. Using this patch, the phone exits ID_A mode once the charger is disconnected, and will provide power to OTG devices, so the patch does not interfere with the regular operation of the phone (unless you happen to have a real "USB_PROPRIETARY_CHARGER").

Charging Moto G and OTG at the same time

Components for the adapter:
USB 2.0 Male To Female Extension Cable
124K Ohm resistor (optional)
Micro USB Male to Female Extension Cable

Update:
I have bought the Acasis H027 and together with my patch I can use USB peripheral devices (connected to the hub) + charge at the same time.

p.s. USB Device Info shows the connected USB devices
Attached Files
File Type: patch detect_usb_aca.patch - [Click for QR Code] (842 Bytes, 1354 views)
The Following User Says Thank You to tal.aloni For This Useful Post: [ View ] Gift tal.aloni Ad-Free
 
 
21st March 2017, 04:10 AM |#2  
Senior Member
Thanks Meter: 10
 
More
This is great info! I'm a complete rookie when it comes to developing but I've jumped in. I'm trying to get my XT1060 (2013 Motorola Moto X Verizon Developer Edition) to do OTG and charging at the same time. I've downloaded the source from Motorola (here) and tried to enable ACA in the menu but I couldn't get it to compile. I then tried using source from @tycoo and @army9000 and their modified kernel (here) to enable this and recompile but again, I'm getting errors. I must be doing something wrong, either not enabling other items in the menuconfig that are required or I'm missing a lot more of the actual "meat" of the mods and just enabling an item in menuconfig. I know I've got my Ubuntu and toolchain all set up right because I can successfully recompile (using msm8960_defconfig only for some reason, msm8960-perf_defconfig and full_msm8960-perf_defconfig fail compile, some error about "this error is dumb" and acpulock-krait?) the source kernels (after a lot of work!) Think you could help me out? I'd greatly appreciate it.

I have a Nexus 7 tablet running Timur's USB Host kernel and a custom made USB OTG cable with power spliced it. Works great on the Nexus 7 but need it for the Moto X!

Unrelated to this topic, also trying to enable CIFS filesystem so I can mount a Windows network share in the device. Can't get that to work either I thought just enabling it in menuconfig.

Thanks,
Mike
22nd March 2017, 08:55 AM |#3  
OP Member
Thanks Meter: 92
 
More
Hey Mike, Did you unpack an existing boot image using Android Image Kitchen and replaced the kernel binary (zImage) with the one you built? that's the way to go.
Even with the XT1032 I'm having a few compilation errors that needs fixing due to different build environment, use the official source and search for solution to the compilation issues.
You don't have to change anything in the menuconfig at all.
The Following User Says Thank You to tal.aloni For This Useful Post: [ View ] Gift tal.aloni Ad-Free
22nd March 2017, 02:14 PM |#4  
Senior Member
Thanks Meter: 10
 
More
Yes, I'm using the zip file from @army9000 kernel and replacing the zimage and modules to flash my recompiled kernels, works well!

I'm using source, both stock from Motorola as well as the one from @army9000, to build from. I'll have to see if I can figure out a solution with the info from your patch.
23rd March 2017, 05:00 AM |#5  
Senior Member
Thanks Meter: 10
 
More
Yes! I can't believe my dumb arse got this working! Thanks so much @tal.aloni for your patch. I had to tweak it and I just manually edited my msm_otg.c file because I was afraid the patch would work with fuzz because the reference lines weren't the same. Like you said, I didn't change a single thing in menuconfig, just tweaked msm_otg.c and recompiled and flashed! The one thing I noticed is that it says its charging on USB, not AC. Hopefully the device doesn't slowly drain the battery due to lack of charging current, will have to troubleshoot. Thanks so much! And thanks @army9000 and @tycoo for the source to work with!

I have no idea how to use git and repositories, but credit goes to the above XDA members. Attached is the modified msm_otg.c file that has @tal.aloni's patch in it but modified for the Verizon Wireless XT1060 Developer Edition Motorola Moto X that I used to compile @army9000's 5.1 kernel (here).

Also, no idea why, but this seems to be the "process" for me to get my Moto X to properly do OTG and charging.
1. Boot up the Moto X
2. With powered OTG cable NOT powered, plug micro-B USB into phone
3. Plug in OTG device (usb-to-ethernet)
4. Plug in ethernet cable to adapter
5. NOW plug in USB power charger for power
6. Unplug micro-B USB from phone
7. Plug in micro-B USB to phone
8. Phone should have ethernet AND be charging (USB)

FYI, I'm also trying to get CIFS support working with this same kernel in the post for that (here).
Attached Files
File Type: c msm_otg-MODIFIED-FOR-ACA-03-22-2017.c - [Click for QR Code] (108.4 KB, 328 views)
20th March 2019, 06:00 AM |#6  
Junior Member
Thanks Meter: 0
 
More
OTG+CHARGING at same time
dear
tal.aloni and Mike7143,
thanks for your post and reply,
i am trying to do the same,
I am using
Kernel: github.com/akhilnarang/whyred
it does not has /usb/otg/ folder, so where to look for "otg+charging"

i try and test otg+charging on redmi note 4 (codename:MIDO) on lineage14.1
but i did not change anything in kernel,
just using instructables.com/id/DIY-Cable-to-Use-OTG-and-Simultaneously-Charge-the/
and it works fine,
*weblink is not allowed so i remove www
please guide.
thanks and regards.
22nd March 2019, 01:05 AM |#7  
Senior Member
Thanks Meter: 10
 
More
Quote:
Originally Posted by jacob19

dear
tal.aloni and Mike7143,
thanks for your post and reply,
i am trying to do the same,
I am using
Kernel: github.com/akhilnarang/whyred
it does not has /usb/otg/ folder, so where to look for "otg+charging"

i try and test otg+charging on redmi note 4 (codename:MIDO) on lineage14.1
but i did not change anything in kernel,
just using instructables.com/id/DIY-Cable-to-Use-OTG-and-Simultaneously-Charge-the/
and it works fine,
*weblink is not allowed so i remove www
please guide.
thanks and regards.

I don't know why there's no /drivers/usb/otg folder. Paging @akhilnarang to the thread, perhaps he can help you? Heck, maybe he can help improve the hack job I did for the XT1060 so my Wifi works and maybe CIFs as well! Doesn't hurt to ask!
22nd March 2019, 11:29 AM |#8  
Junior Member
Thanks Meter: 0
 
More
thanks for quick reply dear,
I try and test
github.com/LineageOS/android_kernel_xiaomi_msm8953/tree/cm-14.1
for MIDO(xiaomi redmi note 4), it also has not usb/otg folder,
i did not change anything in kernel, but still it supports charging+otg ,
but then also it works,
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes