There is an UART on the Nexus 4

20,815

Circuit Image

The Nexus 4 was chosen due to its traditionally open nature, exemplified by the availability of Ubuntu Touch images. Unexpectedly, it was discovered to be highly hackable. After packaging the Mako kernel on Mer OBS for a personal project, the package became available, although it did not boot properly. This experience rekindled memories of working on the Archos 5 IT with the openAOS project, leading to the idea of having a UART for debugging. A search on the internet yielded a lead from an XDA post, but it did not provide much assistance regarding the logic levels or which pins corresponded to the headphone socket. An initial check revealed no output from the port when attempting to pipe /dev/urandom to /dev/ttyHSL0. The circuit involved is a simple comparator with a reference voltage of 2.8V; if the input voltage exceeds this, the output switches to VCC (logic 1/true). This action triggers a switch that disables audio and activates a UART on R/RX and L/TX. A bench power supply was connected to the MIC and GND pins, set at 2.9V with a current limit of about 10mA, ensuring that GND was connected to + and MIC to -, resulting in -2.9V. The output was clean, although the RX port experienced some crosstalk. Unfortunately, incorrect cable connections during further experiments led to damaging the switch, rendering the UART unusable, though audio output remained functional. An update indicated that the MIC input should actually be +3V, which also appears to apply to other models. There is an invitation for others to try this on different Nexus devices. For those interested in building a cable, examples include a 3.5mm 4-pin and a 3.3V USB to Serial cable based on an FTDI chip.

The Nexus 4 device features a unique architecture that allows for extensive modifications and debugging capabilities. The UART (Universal Asynchronous Receiver-Transmitter) interface is particularly valuable for developers and enthusiasts looking to engage in low-level programming and diagnostics. The circuit design described includes a comparator that operates with a reference voltage of 2.8V. This comparator serves as a threshold detector, switching its output to VCC when the input voltage exceeds the reference level, thus enabling the UART functionality.

In practical terms, the UART is connected through the headphone socket, where the RX and TX lines are assigned to specific channels (R/RX and L/TX). The configuration of the circuit ensures that when the comparator activates, audio output is disabled, allowing the UART to take precedence. The application of a bench power supply to the MIC and GND pins is critical for proper operation, with the specified voltage of 2.9V ensuring that the logic levels are correctly interpreted.

However, it is important to note that incorrect wiring can lead to component failure, as experienced during the testing phase. The mention of crosstalk on the RX port highlights the need for careful circuit design and layout to minimize interference, which can affect data integrity during transmission.

The update regarding the MIC input voltage being +3V rather than -2.9V is crucial for replicating this setup on other devices. This voltage adjustment could significantly impact the performance and reliability of the UART functionality.

For those interested in replicating or extending this project, constructing a custom cable using a 3.5mm 4-pin connector or a 3.3V USB to Serial cable with an FTDI chip could facilitate easy connectivity to various devices, enhancing the debugging experience and providing a platform for further exploration of the Nexus 4's capabilities.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 avail

able (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.

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. 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. 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!) 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 🔗 External reference