I recently started hacking on bringing Mer and possibly Nemo to the Nexus 4 (aka Mako).
I chose the Nexus 4 as these devices are traditionally very open, as you can see in case of the Nexus 4 e.g. by the availability of Ubuntu Touch images. I didn’t expect however for it to be that hackable as I was about to find out on Saturday.
I had just completed packaging the Mako kernel on Mer OBS in my home project and the package is now available (it however doesn’t boot properly yet). So the memories from me hacking on the Archos 5 IT with the openAOS project came back and I thought, wouldn’t it be nice to have an UART available for debugging…
A few queries to the Internet search engine of my least distrust later I had a first lead in the form of an XDA post. This however didn’t help me much yet, which logic levels? which pins? really the headphone socket? I quickly checked and didn’t notice anything coming out of the port when piping out /dev/urandom to /dev/ttyHSL0.
Then I was lucky and found a more detailed description on another page (sadly the link got lost) and based on that drew a circuit schematic:
The circuit is basically a simple comparator with a reference Voltage of 2.8V. If the input voltage on the other pin exceeds this, then it switches its output to VCC (logic 1/true). This apparently triggers a switch that turns off audio and puts a UART on R/RX, L/TX.
As I later found out by trying it out, the polarity is actually so, that you need to apply -2.9V.(seems I was wrong?)
Here’s my test setup. I borrowed a scope and bench power supply to do this properly.
I had VLC running with a file of a 1kHz sine wave.
This is actually interesting. It looks suspiciously as if one of the channels is quite noisy? Anyone who can comment on this?
I then proceeded to attach the bench power supply to the MIC and GND pins. (Set at 2.9V and lowest possible current limit of about 10mA). Note that it’s connected so, that GND→+ and MIC→-, so -2,9V.
I then opened a terminal and ran this to get a continuous output:
cat /dev/zero >/dev/ttyHSL0
So, there you go, a nice and clean output. The RX port seems to suffer a bit from crosstalk though… (but note the different V/div settings! for both channels!)
Here you can see, that the signal is about 3V peak/peak, so I’d guess 3.3V reference should work for the serial converter. 1.8V might work too though.
I’d recommend to use a resistor in line with the 2.9V to further protect the circuit. (wasn’t shown in the pictures).
Sadly I then connected some cables wrongly during my further experiments and it seems like I have now fried the switch. Audio out works fine, I just can’t seem to be able to enable the UART anymore. I’m a sad panda, but at least now others can benefit from this.
Update: I received some additional information. Seems it should be +3V on the MIC in after all. And this seems to also apply to other models. Anyone want to try on e.g. some of the other Nexus devices? If someone wants to build a cable, here are some examples: 3.5mm 4pin and 3.3V USB to Serial cable based on a FTDI chip