yashsingh1/xdaforums huggingface dataset:
[Nexus 4 Original Android Development] EDV11:
As much as I would like to have Slimport + OTG working at the same time, I think it is not possible by design.

Here is the spec sheet for ANX7808: http://www.analogix.com/pdf/ANX7808_PB.pdf. It says

So when slimport is connected, the transmitter blocks the USB signal. I have even tried it to connect to the computer while connected to Slimport (USB from computer-Slimport adapter-phone), but only charging is working.

Also

OTG goes through by default, but when Slimport is connected, it will switch into video output.

Here is a message from Analogix stating that Slimport and OTG will not work together right now. I tried to get more clarification on this, as they say it is planned but I don't know if it will be available for ANX7808 or it will need a different transmitter (probably the latest).

Now, this is a diagram for the communication

Do you think the configuration for this resides in the Slimport transmitter, or is it inside kernel?
[Nexus 4 Original Android Development] sga999:
ziddey, I've gotten the update zip to work on stock 4.2.2 I changed otgmod.sh to stdout the output of the results of the ./zip command into a file so that I could see it later. Also, I changed the option -rf to -rfv (v for verbose). The output said "res/xml/storage_list.xml up to date."

Then I tried changing the option -rf to leave out 'f' (also with v for verbose so that I could see the results again), i.e. no freshening. That worked for me! I would imagine leaving out the freshening is not going to accomplish what you're trying to do for all cases. But at least this gets around the problem for stock. Maybe someone else who has had problems can give this a try too. (I had been recompiling, so I was already getting around this problem, but I wanted to know what was going wrong).

Has this problem been seen on roms other than stock? I know I could go back through all the posts, but if someone can just tell me, that would be great.

NOTE: This does nothing to fix the problem of the wrong string being displayed instead of USB STORAGE. That's due to storage_list,xml and strings.xml "incompatibility" due to being from different roms.
[Nexus 4 Original Android Development] ziddey:
Huh! Thanks. I'll change that for the next release. I thought about removing the freshen flag anyway now that the script simply assumes the .1 backup is good and doesn't using zip in an if condition anymore (was figuring that might have not been completely kosher). Don't know why that would make any difference though.
[Nexus 4 Original Android Development] simobile:
Ziddey, I totally agree.

I looked over those files and they really have borked this thing! The only way to get voltage out that I see is spoofing Slimport to send it. It is already enabled to output usb 5volt, 500ma but the trick would be getting that power but keeping it disabled. May or may not ever happen. My head hurts from looking over so many files. I'm a hardware guy by trade (silicon valley robotics) and software only interest me enough to get my hardware to work the way I want it to. If I run across anything else that may be helpful, I'll post it up here. Keep up the good work!
[Nexus 4 Original Android Development] ziddey:
Where are you seeing 5v 500ma from slimport?

Working with drivers/misc/slimport_anx7808/slimport.c, I've been trying to do some testing to see if I could get enough power to get a usb device working (power from phone, data to computer, since I haven't figured out how to prevent the data pins from being switched for slimport use). I've been able to get 3.1v by forcing slimport, but I haven't tested how much current I can draw before it trips the overcurrent. Of course, usb is 5v, so this requires a device that can either run on 3.1v, or actually is a 3.3v with whatever regulation to step down 5v to 3.3v, in which case it could be modded.

So far, I haven't gotten anywhere. I haven't modded my usb sticks, but they seem to not get enough power. My usb hub seems to trip the overcurrent, losing vbus entirely. I got a few Kingston G2 microsd-usb adapters to play around with ($3 each from http://www.staples.com/Kingston-G2-USB-20-microSDHC-Flash-Memory-Card-Reader-FCR-MRG2/product_651710Staples[/url]. I figure sd is 3.3v/1.8v, so if the controller can work with 3.3v and slimport power can provide enough current, it may be a viable solution (provided we can figure out how to prevent the data pins from switching over).

I remember reading somewhere that the spec for slimport power was 4-50mA @ 3.3V, which may not be enough for sustained operation / initial power-up. That said, a capacitor might allow it to function under most situations..

Anyway, if you want to do some testing, this is the relevant code executed when slimport is connected (slimport_cable_plug_proc()):

sp_tx_pd_mode = 0; // not exactly needed for our purposes
sp_tx_hardware_poweron();
sp_tx_power_on(SP_TX_PWR_REG);
sp_tx_power_on(SP_TX_PWR_TOTAL);
//hdmi_rx_initialization();
//sp_tx_initialization();
sp_tx_vbus_poweron();

The initialization functions aren't required, but the others look to be essential for now. Basically, I commented out the code in anx7808_cbl_det_isr() and stuffed that in its place.

I'm not sure what the slimport resistance between the id pin and ground is, but either way, an otg cable (id grounded) will not trigger the cable detect. Unplugging it will though, so that's what I've been doing to get things rolling. From there, I've hacked up a cable so that the usb port gets power from the phone, but has the data wires going to my pc. Now to mod up one of these things and test it..
[Nexus 4 Original Android Development] simobile:
Slimport is a DisplayPort VESA technology. So it must follow their rules. Your right, about 3.3volts@100milliwatts is what Analogix claims. I'm not sure I believe that current figure as it has to run a dongle IC but whatever. That 3.3volts comes from an onboard regulator on the Slimport IC.I ran into some Slimport power files last night that said it's permitted to receive up to 5 volts from another regulator. Basically, the one that powers the Slimport IC, should be powering our USBOTG.

Not sure if it can be diverted or not.

Thanks for the code. I'll run some test and see what I can come up with.

Lucky Goldstar, she is a cruel mistress.
[Nexus 4 Original Android Development] Kodam:
Ziddey, could you make an otg enabled matr1x kernel?

Franco kernel is really slow for me and reboot really often, but i'd like to use my usb drives.

Thanks,

Kodam
[Nexus 4 Original Android Development] ziddey:
All my changes are provided in the 2nd post (github for msm_otg.c). Feel free to apply and compile matr1x kernel with them.
[Nexus 4 Original Android Development] adidas007:
+1. I too have no idea about compiling kernels and stuff. Don't want to mess around with this beauty!

It would be really grateful if you could enable usb otg on matr1x kernel whenever you get time.
[Nexus 4 Original Android Development] forcedairinduction:
Ziddey you da man : ). I've been waiting patiently for my y cable to arrive from China (about a month lol). I'd previously bought a5v power pack & today downloaded your kernel & its all worked silky smooth for otg.

Thanks a million mate. It may have been discussed previously but instead of trawling through milliond of posts.....ill ask anyway

Do you intend to make other kernels (particularly trinity & stock carbon) comparable with otg so I don't have to keep re flashing????

Cheeeeers. Mark.
[Nexus 4 Original Android Development] EDV11:
You just have to read two posts over yours

Enviado desde mi Nexus 4
[Nexus 4 Original Android Development] forcedairinduction:
Wow just had a look at ziddeys link. Im a Psychiatric nurse, not a programmer unfortunately. It scared the pants off me just rooting phone, couldn't trust myself to do actual fiddling about with it. Its beyond me I'm afraid : (
[Nexus 4 Original Android Development] baltac:
Maybe that may help you. :) http://www.xda-developers.com/android/step-by-step-tutorial-on-how-to-compile-kernels-from-source/

All that you need is reading a bit. This can make you stronger. ;) The wrost thing that can happen, is that you need to reflash a stock kernel or the modded one by ziddey.
[Nexus 4 Original Android Development] forcedairinduction:
Much appreciated mate. This is all new to me but maybe its time I 'bit the bullet' & tried. Main fear us buggering up my phone o_O

---------- Post added at 09:07 PM ---------- Previous post was at 09:03 PM ----------

Ouch! Call me a noon but that looks pretty complex. My nexus has responded by going up to 63° surely this is a sign lol. Maybe I'll just stick to the ziddey kernel and be grateful for what I've got : )
[Nexus 4 Original Android Development] SlyRder83:
Awesome work man! Just wondering if anyone can write to NTFS? I can't get it to work, I've done countless searches of people getting it to work. Maybe its just an N4 thing maybe?
[Nexus 4 Original Android Development] ziddey:
There is no native NTFS support (at least write support) in Android. You will need to use third party tools for that.
[Nexus 4 Original Android Development] SlyRder83:
Yeah I've been looking at a lot of apps but none seem to work, any recommendations?
[Nexus 4 Original Android Development] bitmonkey:
Hi everyone,

Just ordered an N4 and want to run this kernel, so I went to pre-download some of the stuff I want, and noticed that TWRP is now at v2.5 since 08/04, but the OP specifically mentions TWRP 2.4.4.0, and looking through the thread since the 8th of April no-one has mentioned the new TWRP release.

Can anyone give any feedback from experience flashing this kernel with TWRP 2.5, or at least suggest whether I'm likely to experience any problems if I use the latest TWRP? (Sorry if it's a simple question, I'm basically pretty much an android noob).

thanks
[Nexus 4 Original Android Development] ziddey:
I'll look into ntfs write support again in a few days, but I remember being hesitant to include it in the past because of potential risks of data corruption (to the NTFS drive, not Android itself).

For the time being, you could try Stickmount. The OP mentions adding the ntfs-3g zip to the sdcard root, although I haven't tested it. I searched the thread for ntfs and found this post: http://xdaforums.com/showthread.php?p=32729381#post32729381

There is a good chance that native mounting (read only) will interfere with Stickmount, so it's probably necessary to goto settings->storage and unmount it before mounting with stickmount.
[Nexus 4 Original Android Development] ziddey:
Works fine with TWRP 2.5.0.0. Issue may be unrelated to recovery, but I haven't been able to reproduce it on my end, so I don't know what's broken.
[Nexus 4 Original Android Development] sga999:
I'm not sure if we're thinking about the same problem, but I discovered that zip with -rf was causing a problem with the stock rom. The framework-res.apk was not being updated because of this issue. ziddey, you were going to remove the f (freshen) in the next release. I don't think the recovery version has anything to do with this issue.

Maybe you're talking about a completely different problem.
[Nexus 4 Original Android Development] SlyRder83:
Sweet thanks man your awesome! It mount to internal SD card though instead of usbdisk0. Is that bad?
[Nexus 4 Original Android Development] RussianBear:
works beautifully! i can finally use this phone as a true dashcam! haha

thanks for all the hard work, ziddey!
[Nexus 4 Original Android Development] RussianBear:
Here's a screenshot of it charging the phone and showing the drive at the same time:
[Nexus 4 Original Android Development] mhanis:
Can someone give me a link to download? I cannot download link from OP

Edit: Already download using pc, but i only can mount using stickmount app. Nevermind, it works, thanks a lot.
[Nexus 4 Original Android Development] davebuk:
Hi all

I made myself an OTG cable today and flashed the kernel using TWRP 2.4 with stock 4.2.2. All seems to be working and I can see USB drive within ES File Explorer. I can read and write files.

I do not see the fact that there is a device in the storage section under settings, and cannot then unmount. I guess there is still an issue with this patch and stock 4.2.2?

Can any of the above help me out? I'm still quite new to the whole android hacking scene :) Cheers.
[Nexus 4 Original Android Development] ziddey:
Yes, try what sga999 suggested-- remove the 'f' flag for the zip command in tmp/otgmod.sh, and reflash.

I've been waiting to include the fix in the next update, which will probably just be to update the base kernel to Franco's upcoming M2. I did want to see if there would be a way to differentiate between a proprietary charger and a usb device, but I haven't had much free time lately.
[Nexus 4 Original Android Development] EDV11:
You mean using a non powered OTG cable?

Enviado desde mi Nexus 4
[Nexus 4 Original Android Development] ziddey:
No.

From the first post: "A "proprietary" charger is detected when the phone sees voltage on the data pins (from a usb device in our situation). This is only required for charging Apple garbage. However, a lot of battery packs / car chargers have implemented this for compliance (see http://voltaicsystems.com/blog/choos...nes-and-ipads/). Unfortunately, since we are switching to host mode when an actual proprietary charger is detected, and there is raw voltage instead of an actual usb device, the usb host freaks out (luckily it doesn't get damaged...). Using a Y-cable's auxiliary power plug would allow the phone to draw 500mA (USB charger mode) since the data pins are isolated."
[Nexus 4 Original Android Development] davebuk:
Yep, that all worked fine. It does show up as 'HDMI' rather than 'USB Storage', but like you said in OP, thats cosmetic.

Now if we could only suck a bit more current from that Slimport chip and use a 3.3V-5V convertor (http://www.linear.com/product/LT1300) we would home and dry :)

Cheers for the work so far.
[Nexus 4 Original Android Development] parkedraccoon:
Any chance of adding compatibility for Logitech controllers? (I myself have an F310) Earlier today I saw that it worked natively on a classmate's GNex, but after adding joystick kl files, no luck. It appears some kernel modules such as these need to be added, but compiled for this kernel.

One of the main hopes I had for OTG on this phone was to be able to use this controller with it-it would be greatly appreciated! Otherwise, I'm really enjoying attaching random USB devices to my phone and using it like a micro-sized tablet.
[Nexus 4 Original Android Development] ziddey:
Try these. I have no way of testing. I just set CONFIG_INPUT_FF_MEMLESS and CONFIG_HID_LOGITECH to m and built them. Not a flashable zip, but xda doesn't allow attaching .ko files. Not sure how to create the .kl files..

edit: modules broken. removed.
[Nexus 4 Original Android Development] parkedraccoon:
I tried copying them to data/local/modules and insmod-ing them, but got an error.

View attachment 1917081

It's a different error than what I get with trying the Asus modules; I get a Exec format error, because they're not compiled for N4.

I noticed that the modules you compiled were a lot smaller than the ones in the Asus thread-perhaps this has something to do with it?
[Nexus 4 Original Android Development] ziddey:
Alright, not exactly sure what the deal is, but I found this: https://groups.google.com/forum/?fromgroups=#!topic/android-kernel/dzEIOVuxtEo

make -j8 EXTRA_CFLAGS=-fno-pic modules

They insmod fine for me now:

# lsmod
hid_logitech 5306 0 - Live 0x00000000
ff_memless 4285 0 - Live 0x00000000
[Nexus 4 Original Android Development] elRei:
I seem to be having trouble here, I had the extra cables so decided to make a homemade Y-OTG Cable and it works perfectly (made sure everything worked) but once I flashed the file it wouldn't read the USB itself. Tried two different USB's, I know its connected because the light on the USB turns on but it wont mount onto my phone and the option within Settings isn't turned on. Any ideas to what the issue could be? Thank in advance
[Nexus 4 Original Android Development] ziddey:
How did you design your cable? If you aren't also providing power to the phone you'll need to manually enable host mode.
[Nexus 4 Original Android Development] elRei:
providing power via power outlet, will be making one for portable use when I have this one working
[Nexus 4 Original Android Development] parkedraccoon:
They insmod properly for me as well. But it still doesn't work natively in Android-I did a bit more research and it seems like there may be a need for xpad.ko (the controller is in Xinput mode after all). Not sure what the kernel build command for it is though.

Thanks for replying quickly!
[Nexus 4 Original Android Development] ziddey:
I compiled xpad.ko with rumble+led support, and recompiled hid-logitech.ko with force feedback support (now 24KB). For some reason, I had a x360 controller lying around but it's wireless, so I can't test it still. Good luck.
[Nexus 4 Original Android Development] parkedraccoon:
oh. mah. gawd. It works! :D

Thank you so much for making it work!
[Nexus 4 Original Android Development] matanp:
does your patch support franco's M2 kernel?
[Nexus 4 Original Android Development] Snargaflab:
It doesn't now but hopefully he will rebase it on it soon
[Nexus 4 Original Android Development] alsheron:
Is there a quick way or just a procedure I can follow to patch Franco's nightly kernels myself? Is it just a case of replacing files (msm_otg.c for eg) or are there other dependencies to take into account? I know the M2 release is available and I'm guessing the milestone releases will be "patched" but I'm hoping there's a way of doing it for the nightlies also? :)
[Nexus 4 Original Android Development] spadie:
it works 4 me in CM10, in PA has bad work...

But i connect any xbox gamepad, and android doesn't reconoce it.. and USB media works fine.

nice work!
[Nexus 4 Original Android Development] forcedairinduction:
I was just thinking exactly the same thing : )
[Nexus 4 Original Android Development] materoprodutions:
this thing works perfect. I can mount usb disk, sd cards and card readers. and in my case it reads also NTFS usb sticks and I can play 8gb movies....One only problem that I have, and it's very very weird is that I can't copy anything on the phone if I plugged directly on the PC. I can see the internal usb storage of the phone but it doesn't let me copy anything to it.....any ideas? Thank you so so much

---------- Post added at 01:38 PM ---------- Previous post was at 01:34 PM ----------

Nevermind sorry, I rebooted the phone and changed the usb port on my pc and now I have no problems. Sorry again. Thank you
[Nexus 4 Original Android Development] alsheron:
Anyone? I'm trying to figure out how to create a flashable zip by modifying the latest kernels from Franco. Would appreciate any help/guide as this thread is becoming dead.
[Nexus 4 Original Android Development] ismethajametovic:
I know this may seem asshole-ish, but USB OTG on the Neuxs 4 is pointless since we have to provide a 5v power source. What's the point of plugging it into a wall charger? You'd might as well carry a laptop. Damn you, LG hardware! (yeah, I'll probably get flamed/chewed at for stating my opinion, but IDGAF, LOL. :good:)
[Nexus 4 Original Android Development] BIade:
Hello my friends :)

Is is possible to use this patch on other phones? (prob. not) I've got a HTC DesireZ/G2/Vision and bought an OTG-Cable.

While reading this thread, I really need this paradise of Patch :D

:good:BIG thx ziddey, its an awesome work you did.

P.S.:Please dont flame me for not having a nexus 4...
[Nexus 4 Original Android Development] vikas_toad:
Will this design work as a simple plug and play solution?

power source would be a battery pack

will this charge the phone and the usb stick at the same time?

since it will be a battery pack.. i don't want the phone to charge at the same time..

just that when i plug in the usb.. it should detect and mount thus: plug and play, no terminal stuff
[Nexus 4 Original Android Development] ziddey:
Franco's milestone branch on his github wasn't updated to reflect M2. The nightlies branch looks to be current and beyond M2 already.

That said, I feel I need to take a minute to apologize to Franco and address some confusion that has arisen with regards to this "patch". I've been a little busy with some other stuff recently (not phone related), and didn't take notice of some of the posts in Franco's thread. Doing a search for "otg", I see that it's frequently brought up. It was never my intention to put any pressure on Franco to officially support these modifications. Unfortunately, I see that there have been numerous requests for him to implement "otg" in his nightlies, as well as confusion over why it's not working (even saw a guy thank Franco for OTG support). I chose to work with Franco's kernel as a base because it's what I use personally.

The issue is that msm_otg is compiled into the kernel, and so there is no way to alter it without building the entire kernel. So in that sense, it's not so much a patch as it is a modified kernel. Therefore, it's not possible to flash my zip and then a newer/different kernel on top. The "patch" aspect is more applicable to changes to the ROM-side of things, although that's more or less trivial compared to the msm_otg.c modifications.

Beyond that, I've met a very helpful individual on IRC, who shared a way of potentially building the msm_otg hacks into a module (oversimplifying a bit). However, this would only be useful if the module could somehow be loaded on any kernel. I'll have to do more research, but this seems like the best option down the road.

Annnnnnnnyway, as it stands, it's still a "dirty hack" and as such, most devs are reluctant to include it in their kernels/roms. I'll try to release a version with an updated kernel in the next few days.
[Nexus 4 Original Android Development] ziddey:
Since ID pin detection is broken, usb host mode is being forced after a charger is detected.. If you don't want the phone to charge, perhaps a diode or something would help..
[Nexus 4 Original Android Development] hellrokr:
Just one doubt,

I see the compatibility list is still not fully clear. So will this work with my xbox controller? My phone is yet to come (maybe a week or two) or else I would have already tried.

Let me know, if someone tried.

Thanks!
[Nexus 4 Original Android Development] vikas_toad:
So basically for automatic host, instead of providing +5v, gnd on the voltage pins, i have to supply those only to data pins, or to data pins and voltage pins both?

As i understand from the op, automatic host mode is enabled by 5v on data pin(any of the two data pin?) This makes the phone think a proprietary charger is connected which inturn triggers the host mode automatically..

Now since it has detected a proprietary charger is connected the phone starts charging through he voltage pins.. That leads me to the conclusion that 5v has to be applied to all the pins?
[Nexus 4 Original Android Development] ashishv:
I dont think data transfer would be possible then.:cool:
[Nexus 4 Original Android Development] ziddey:
No, you don't supply 5V to the data pins.. They become "powered" when the usb device is powered. The data signal leads to the detection of a proprietary charger (and in our case, switching to usb host mode).

Your design is fine for "plug-n-play". The issue is that it will charge the phone.