Manual USB OTG working

Search This thread

Noc2

Member
Feb 14, 2013
36
35
www.andock.com
I just found out that it won't be possible to use SlimPort and USB devices at the same time.
Video and USB are switch at the connector.
 

Murukesh

Senior Member
Jan 12, 2013
55
7
Chennai
mouses generally have a lower consumption than Keyboards, for obvious reasons.
:confused: What obvious reasons? Personal experience with three different sets of wireless mice+keyboard combos suggest different to me.
But if a step up transformer would do, then maybe a cell wouldn't be needed, right? A college kid could build one from components from his labs.
 

SSMI

Senior Member
Aug 25, 2010
122
6
Do we know if it outputs any kind of voltage right now? I would be willing to try the step us with some flash memory over the next few weeks but don't know what kinds of changes we would need to make in the kernel.

Sent from my Nexus 4 using Tapatalk 2
 

memebr

Member
Oct 13, 2012
40
15
:confused: What obvious reasons? Personal experience with three different sets of wireless mice+keyboard combos suggest different to me.
But if a step up transformer would do, then maybe a cell wouldn't be needed, right? A college kid could build one from components from his labs.

USB mouses consumption is lower than keyboards due the size of the circuits, usually keyboards uses a larger micro-controller, some of them with macro capability and other stuff even have external memory

Based on my actual and previews USB Keyboard and Mouse set, usually the keyboard consumes near to 500mA and the mouse near 120mA

for the step-up question, yes, if the phone spits out something trough the USB_VCC, a cell will not be needed. its cheap to built a step-up circuit, if the guy have a protoboard the sky is the limit! but i don't think he can do one as tiny like pololu does

the size of the circuit itself is ridiculous:

0J4102.600.jpg


and its cheap, i ordered 2 to play a lil bit with it and see what i can do, but since i don't live in the US i don't know how long till it arrives.

Do we know if it outputs any kind of voltage right now? I would be willing to try the step us with some flash memory over the next few weeks but don't know what kinds of changes we would need to make in the kernel.

Sent from my Nexus 4 using Tapatalk 2

For what i was reading in this topic, some one said that the phone output on the USB_VCC is the same output of the battery, 3.7~3.8V

But that step-up booster works in a range starting from 0.8V to the max output (5V)
 
Last edited:
  • Like
Reactions: gie62001

MrWulf

Senior Member
Sep 6, 2010
68
9
Yes. This! A battery powered USB OTG cable!

To OP, are you planning to develop a kernel and maintain it or just the develop the OTG functions?

For the auto-enabling OTG support, maybe make an app to manually enable it? Or we could persuade Stickmount's developers to incorporate an "enable OTG" button.
I like the idea. Might be a little niche for a hardware company to develop it though. It might not be as elegant as a OTG cable with a battery imbedded, but I'm sure you could just connect an external battery via micro USB to the Y cable and thus you have something portable without the need for a power outlet. Please correct me if I am wrong on this, I've never tested it myself.
 
Last edited:

Murukesh

Senior Member
Jan 12, 2013
55
7
Chennai
Damned expensive watches. A quick Google shows one worth $77000, and yes, I didn't forget the decimal point.

Sent from my Nexusthulhu II via the xda-developers app.
 

sga999

Senior Member
Mar 13, 2012
968
165
I'm having a problem setting this up, and I wonder if anyone has some advice.

I successfully set this up (see post #11) with a USB OTG cable and a powered hub. But I wanted to set it up exactly as CaptainMuon suggested, i.e. with the Y-cable. It just came today, and it's not working. As CaptainMuon said in a later post, there are lots of cables out there, good and bad, so who knows if mine is good.

Here is the cable listing on ebay, not that anyone will be able to tell if it's good or not!
http://www.ebay.com/itm/USB-2-0-A-F...091?pt=LH_DefaultDomain_0&hash=item3cc23945d3

I connected everything just as CaptainMuon suggested:
- Y cable power plug (typically red) to the PC or adapter
- Other Y cable plug into the OTG cable
- OTG cable into the phone
- USB device into the Y cable socket

I am connecting to my laptop to get power. The only questionable part was which part of the Y-cable had power...my Y-cable did not have a red plug (male USB A). So I'm using the "skinnier" one, and it must be the right one. I say that because if I try hooking the other male USB plug to my laptop, I am able to see the phone as my E: drive. That tells me that is the data cable.

When I issue "lsusb" before the "echo host" command, there are 2 entries. IThe "echo host" command always adds a 3rd entry. On my successful try (with the USB powered hub instead of the Y-cable), 2 more entries show for the actual device(USB microsd adapter) that I inserted into the hub. But in this unsuccessful try, only the 3 entries show for "lsusb", and the device will not work. I try to mount it with stickmount, but there is no point in that....the fact that no new entries show for the device means the stickmount will not work.

So...I guess this means I have a bad Y-cable. Does someone have a suggestion for a simple way to prove the Y-cable does or doesn't supply power? I mean, something that doesn't involve the phone at all. I hope that isn't too vague!

EDIT: Well, a thumbdrive is working fine with the Y-cable. This is the opposite of what occurred with the USB powered hub. I could get the microsd adapter with a microsd card to work fine. But I could not get a thumbdrive to work. So I'm confused, yet I'm very happy to see that my Y-cable is working fine. So I apologize for the long post!

EDIT2: About a month later, I got another Y-cable. It works well. The Y-cable mentioned above obviously had some capability, but it must have been flawed. The new one allows charging to occur also.
 
Last edited:

sga999

Senior Member
Mar 13, 2012
968
165
Just for demonstration:
https://docs.google.com/file/d/0B9iCmVd0p0sdWFZ3V1hEdHZEbUE/edit?usp=sharing

But for me is it kind of useless without SlimPort.
Your photo shows a "Powerbank". Did you actually get this working with it? Or since you said "demo", was this just a picture without actually having used the powerbank in a test with your Nexus 4?

I'm asking because I bought a cheap Power Bank from ebay.
http://www.ebay.com/itm/5000mah-2-U...ablet_eReader_Accessories&hash=item35c17a088f

I had asked in post #30 about external battery pack or chargers and whether they would work instead of the powered USB hub that I had already used. No one answered, so I went ahead and bought that power bank. But it isn't working. It seems to give power for about 20 seconds to a thumbdrive or a mouse. Then it just turns itself off.

So....I'm wondering what type of "power bank" might work. It looks like maybe this 5000mah one is only for charging, not really powering a device? It will stay on when charging my Nexus 4. And it stays on if I just plug a laptop cooler's USB male plug into it. But as I said, it won't do that for any of the devices I want it to!

Does anyone know if one of these power banks with higher mah would work? Or do I need something completely different to supply the external power? My goal is to have "small" battery power for this setup rather than a powered USB hub.

Noc2, if your Powerbank is actually working, what type is it (brand, how many mah, etc.)? Thanks.
 
Last edited:

Noc2

Member
Feb 14, 2013
36
35
www.andock.com
AW: Manual USB OTG working

I have 4.2.2 and usb is working fine here. You can see the cursor on the picture in my previous posts. Maybe I will make a video later.

Edit:
Oh maybe you are referring to the call problem. I must admit I didn't try it.

Sent from my Nexus 4 using xda app-developers app
 
Last edited:

sga999

Senior Member
Mar 13, 2012
968
165
No it's not just a picture. It's actually working without any external power source. It's a 2200 mAh Powerbank by Treckstore

http://www.amazon.de/gp/aw/d/B007HJGH54/ref=mp_s_a_1?qid=1361698196&sr=8-1&pi=SL75

Sent from my Nexus 4 using xda app-developers app
Noc2, I'm trying to figure out why my setup isn't working with the power bank. It's not the same as your Trekstor, but I would think it should be working similarly. So I need to see what else is different. For the USB OTG cable, are you using one like osi13 mentioned in post #40 (it is like OTG and Y-cable combined), or are you using a "standard" OTG cable, connected to a separate Y-cable (like the OP mentioned originally)?

I wonder if you could take another picture where I could see the entire cables and how they are attached, etc. I don't seem to be very good at visualizing this stuff without seeing it all. Thanks.
 
Jul 29, 2009
39
32
someone got this working with a custome kernel like the one from franco?
I added the line "motg->pdata->otg_control = OTG_USER_CONTROL;" and i can see the file "mode" but i wasn't able to change the value from "none" to "host" or "peripheral". It seems the kernel overwrites the file if it is changed (the date of the file changed).
Another info would be helpful - must "USB_OTG" enabled in the kernel-config? I tried this also but at this time i wasn't able to compile the kernel (error at usb host or somthing) :(

thx
 
  • Like
Reactions: ziddey

Noc2

Member
Feb 14, 2013
36
35
www.andock.com
AW: Manual USB OTG working

I wonder if you could take another picture where I could see the entire cables and how they are attached, etc. I don't seem to be very good at visualizing this stuff without seeing it all. Thanks.

I'm currently not at home. But I will take another picture tomorrow. I don't use any Y-cable. The powerbank is directly plugged into the usb hub with a micro usb female to usb male adapter.

Sent from my Nexus 4 using xda app-developers app
 

sga999

Senior Member
Mar 13, 2012
968
165
I'm currently not at home. But I will take another picture tomorrow. I don't use any Y-cable. The powerbank is directly plugged into the usb hub with a micro usb female to usb male adapter.

Sent from my Nexus 4 using xda app-developers app
Thanks, Noc2, I really appreciate it. I'm baffled as to why my setup with the power bank isn't working. It does work with a powered usb hub. Maybe when I see your next picture, I'll see another way to try.
 

Noc2

Member
Feb 14, 2013
36
35
www.andock.com
Okay here are two more pictures:

This one shows the whole setup with cables
https://docs.google.com/file/d/0B9iCmVd0p0sdMHZGbnJ3SHptQXc/edit?usp=sharing

I used the following:
DELOCK Kabel USB micro-B St 90 Grad
DELOCK Adapter USB micro-A+B
Hama USB 2.0 Hub ( it's a powered usb hub, but as you can see in the pictures i used it as a normal hub)
TrekStor Power-Bank 2200

The second one shows that the phone is even charging while its connected to the usb hub
https://docs.google.com/file/d/0B9iCmVd0p0sdd3FiUldJcXZkN00/edit?usp=sharing

I even tried to use an usb flash drive, but it didn't work.

And here is a crappy video:
 

Attachments

  • USB3.JPG
    USB3.JPG
    91.5 KB · Views: 484
  • USB2.JPG
    USB2.JPG
    79.5 KB · Views: 453
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 147
    Hi,

    As you know, the Nexus 4 doesn't support USB OTG, meaning you can't use it with USB drives, gamepads, etc.. One reason is that the device doesn't seem to provide the neccessary 5V, the other reason is that it's not supported by the kernel.

    So, I've been digging a bit, and now I can claim partial success! It's possible to supply the 5V yourself, and then activate USB host mode manually. It's a bit cumbersome, but for the beginning better than nothing. I tried a mouse and USB drives.

    I should warn you that this is just a proof of concept and nothing that you'll want to use on a daily basis. Regular USB doesn't work properly while running this kernel, and I haven't checked battery consumption. Also this is based on Android 4.2.1, and if you have 4.2.2 you might not be able to make calls. That shouldn't be a problem as this is for testing only, though. Just let me say, I can't guarantee for anything, and I'm not responsible if you brick or blow up your phone.

    You'll need:

    - A USB OTG cable
    - A USB Y cable to provide the 5V (It has two USB-A plugs and one USB-A socket.)
    - My custom kernel
    - Unlocked bootloader
    - Android developer tools (adb, fastboot)

    Load the boot image on your phone (this is not permantent):
    Code:
    $ fastboot boot myboot.img

    Connect everything as follows (should be obvious):
    - Y cable power plug (typically red) to the PC or adapter
    - Other Y cable plug into the OTG cable
    - OTG cable into the phone
    - USB device into the Y cable socket

    You need a remote shell on your device. Use adbWireless or similar to enable ADB over WiFi, then do:
    Code:
    $ adb connect 192.168.0.108:5555
    (or whatever your phone's IP is)
    $ adb shell
    Now you should be on your phone. Do
    Code:
    shell@android:/ $ ls /sys/kernel/debug/msm_otg/
    and you should see 'mode' if the new kernel works. Now become superuser and enable USB host mode:
    Code:
    shell@android:/ $ su
    root@android:/ $ echo host > /sys/kernel/debug/msm_otg/mode
    To disable USB host mode, use "none" or "peripheral". Note that at this point, I couldn't get it to go into regular USB mode. This means that MTP and adb over USB doesn't work yet.

    Connect a device, and you should see more than two entries under "lsusb". Congratulations, your Nexus 4 has just recognized it's first USB device! If you install Stickmount (you have to sideload it since it's marked as not compatible), you can mount USB flash drives. Nexus Media Importer doesn't seem to work, though.

    How does this work?
    Basically, I just added the following line to the beginning of msm_otg_debugfs_init in msm_otg.c:
    Code:
    motg->pdata->otg_control = OTG_USER_CONTROL;

    This enables the mode file in debugfs I use for mode switching. The next step would be to enable manual mode switching while keeping regular USB support, which shouldn't be too hard. Later down the line we can think about switching automatically on cable insertion, and maybe event getting 5V out of the device, but that would be a lot harder.

    So, try it out, let me know if it works for you, and feel free to tinker around and improve what I've got!
    32
    You are a genius. :good:
    Just connected a powered USB-HUB and a mouse to my OTG cable, flashed the kernel and typed the commands directly with a terminal app on the device.
    It simply works !!!

    20
    you should post this to development section ;
    Didn't have enought posts to post there :). Next kernel will be in the development section.

    So what did you change in the kernel?
    Basically only the one line in the OP, and I used the default config. The kernel also writes a bit of debug info to dmesg (lines with '(jm)'). It does nothing functional, but helped me figure out what to edit. If you want the diff, I can post it here, but it's really not so interesting.

    I'm pretty busy with work the next couple of days, but hope I'll be able to continue this soon.

    (Oh, and @ everybody, thanks for the thanks. Nice to see my work is appreciated.)
    9
    This is so awesome! It's working perfectly with the Y-cable seen here. I was able to mount a USB flash drive with Stickmount, and play back a .flac file from the drive via Poweramp. The Nexus 4 also says that it's charging, and I'm pretty sure that it actually is. My phone was at 9% battery life when I flashed an older PA 4.2.1 build, and then booted OP's kernel. If the Y-cable wasn't supplying any power, my phone would be dead.

    Anyway, here's a picture of my current set up. It's great to see some progress.





    RHjtjM4l.png
    4
    I tried a different method of creating a boot.img but got the same results.

    From how I understand it, it should be possible to simply fastboot boot zImage.
    Code:
    fastboot boot zImage
    creating boot image...
    creating boot image - 4421632 bytes
    downloading 'boot.img'...
    OKAY [  0.272s]
    booting...
    OKAY [  0.121s]
    finished. total time: 0.393s
    fastboot takes the zImage and creates a boot.img, and especially since it's simply being booted, it should be able to use the existing ramdisk?

    I believe Franco uses Google's 4.7 toolchain, which is what I've been trying now. With regards to the mismatch:

    "Yes. Go to arch/arm/kernel/auto_hotplug.c check for __cpuinit string in some of the function declarations (just for a ctrl+f and search for __cpuinit) remove those strings, and you're good to go. "


    I removed __cpuinit from auto_hotplug_late_resume() and it compiled successfully seemingly.. I did kill __cpuinit from all function declarations but that threw errors for all the other functions..

    I'm using android-ndk-r8d/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86/bin for my toolchain which I'm assuming is the right one?

    Also, my size values reported in the last post were the resulting "boot.img" created by fastboot. The size seems appropriate (my zImage + ramdisk pulled from official franco is approximately franco's boot.img).

    It stays on the Google screen..


    Will try to experiment with abootimg, but I seem to be missing blkid.h even though I have e2fsprogs. Will look into it further tomorrow.

    edit: hah didn't realize it was in the repository.. looks like we may have a successful boot.


    edit: we have lift off. seems to be extremely glitchy as of now, but all I've done is remove the condition motg->pdata->otg_control == OTG_USER_CONTROL originally required for the debug mode.



    Code:
    root@android:/ # df
    Filesystem               Size     Used     Free   Blksize
    /dev                   936.2M    32K   936.2M   4096
    /mnt/secure            936.2M     0K   936.2M   4096
    /mnt/asec              936.2M     0K   936.2M   4096
    /mnt/obb               936.2M     0K   936.2M   4096
    /system                827.8M   397.8M   430M   4096
    /cache                 551.7M    70.6M   481.2M   4096
    /data                    5.7G     3.8G     1.8G   4096
    /persist                15.8M     4.2M    11.6M   4096
    /firmware               64M    53.2M    10.8M   16384
    /mnt/shell/emulated      5.7G     3.8G     1.8G   4096
    /mnt/shell/emulated/0    14.6G    24K    14.6G   8192
    root@android:/ # mount | grep emulated
    /dev/fuse /mnt/shell/emulated fuse rw,nosuid,nodev,relatime,user_id=1023,group_id=1023,default_permissions,allow_other 0 0
    /dev/block/vold/8:1 /mnt/shell/emulated/0 vfat rw,dirsync,nosuid,nodev,noexec,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0

    Not sure how it got automatically mounted at /mnt/shell/emulated/0, but it obviously causes chaos (although /dev/block/vold/8:1 is internal?? which is so strange why/how it was actually the sd card).

    Unmounting it (/mnt/shell/emulated/0) and using Stickmount to remount results in:

    Code:
    /dev/block/sda1 /data/media/0/usbStorage/sda1 vfat rw,dirsync,nosuid,nodev,relatime,uid=1000,gid=1015,fmask=0702,dmask=0702,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 0


    http://d-h.st/4Qb

    Obviously as much a test build as OP and only worth flashing for proof-of-concept purposes, but figure there's some of you out there running cm10.1 and can't use OP's kernel.


    Will start to dig in more tomorrow hopefully. It's almost 9am now. Goodnight.