UART

A UART or serial console is absolutely essential when doing bootloader or kernel development on any computer. Due to the lack of a standard PC BIOS and the VESA BIOS that goes with it, access to the serial console on ARM devices is even more important than on the PC. Even if you do not intend to do much u-boot or kernel work, access to the serial console will be a life-saver when anything goes wrong. =UART-USB dongle= Currently, all of the available sunxi hardware requires a 3.3V UART. If you buy a voltage stepper module you might get away with attaching it to the serial port of your IBM PC (RS232), but this is rather cumbersome. It is much much easier to just buy a 3.3V USB UART module. Popular chips for such modules are the Silicon Labs CP2102 and the Prolific PL2303HX which are both cheap and relatively easy to find.

Unfortunaltely, many TTL adaptors are very poorly documented. The actual available voltage level (1.8/3.3/5/..V) is either switchable or fixed to arbitrary value depending on adaptor design. Also adaptors with the board embedded inside a case tend to have just wires sticking at one end with no documentation regarding which wire is which. If in doubt use a multimeter.

Sample measured values (against USB shell when connected to USB only):

Original cubietech adaptor (board SJ-019 V3.0) or this (board SJ-019 V6.0) white (RX) floating, green (TX) 3.5V, black (gnd) 0V, red (5V) 4.9V. When connected to CB/CT and the board is powered off the power led on the board is dim (not off completely).

DX this or this board SJ-039 V1.0 3V3 3.5V, GND 0V, TXD 3.5V, RXD 1.8V, 5V 4.9V. When connected to CB/CT and the board is powered off the RX LED is lit. The power led on the board also lights up slightly. Have yet to find an UART adaptor that does not leak enough current this way to not power on parts of the board.

Some PL2303HX 5V TTL USB adaptor - board USB-STC-ISP GND 0V, RX 4.6V, TX 4.9V, 5V 5V, 3.3V 3.4V - this won't work - the voltage is too high for cubieboard and would probably damage it. Untested due to lack of 5V uart.

=Using the serial console=

Once you hook up your usb module to your host, you should see the following, amongst others, appear in your syslog: usb 1-1.3: cp210x converter now attached to ttyUSB0

Now you know what tty your UART is connected to, and you can now use it through, for instance, screen: screen /dev/ttyUSB0 115200

Be sure to set the baudrate to the maximum of 115200, otherwise your console might not function reliably.

=Attaching the UART=

With a UART connector available
If you are using a development board, or a device like the Mele A1000, you should have a nice connector available for attaching your UART module to. If you are extremely lucky, the pin functions will even be printed on your board. Many will not be so lucky, especially with tablets. How to deal with those tougher cases is described below.

Your USB UART module should have the GND (ground), RX (receive) and TX (transmit) pins clearly labeled. These are the only three pins that you should connect to your device. Do not connect the VCC or 3.3V/5V pin, as that will damage your device!

If it is not clear which pins are which on your target, use a multimeter to determine GND and Vcc. You can do this by measuring the voltage difference between, for instance, shielding of a USB connector, and the UART pins, on a running device.

If you have wired things up correctly, you should now be able to type into your serial console (ie. screen) and see at least your own typing echoed back to you. If this does not work, try swapping RX/TX around. If you are lucky, you might have access to a shell straight away. If not, it pays to reboot to see the initial u-boot messages scroll past.

Without a UART connector
Finding the UART pins on a device not meant for development might get quite tricky. It involves disassembling your device with great care, some basic (logical) troubleshouting, some soldering, and then some creativity to be able to export your serial connection to the outside world.

'''You will be seriously voiding your warranty here. The likelihood of being left with a damaged device is very high. You might even totally destroy your device. So you need to be extremely careful.'''

'''Like with everything on this wiki, you yourself are responsible for the actions you take. If you do damage or destroy your device, it's your own fault.'''

If you do want to risk damaging or destroying your device, then this howto is not for you. If you are not comfortable with disassembling your device, soldering wires to it, or are lacking some of the necessary equipment, get someone else to do it for you, or don't do it at all.

Necessary tools and skills
You need some very basic electronics equipment. A multimeter, your usual collection of banana plug cables, probes and hirschmann clamps, a fine soldering iron (temperature controlled preferred), good solder and flux.

You will also need some jumper wires, which are easily scrounged off of an old PC case. Preferably black, green and white, in a triple housing.

Disassembling the device
Disassembling your device is outside of the scope of this document. By using google, you might be able to find someone who has already taken your device apart, and see the process documented on some android forum. Failing that, there are tons of tablet disassembly guides on the likes of youtube. But do use a plastic tool instead of a screwdriver for prying your device open.

You probably need to be able to access the backside of the motherboard as well, so make sure that the board is free. Do not cut any wires, you will need your device to work, even when all of it has been laid bare.

Inspect the mainboard
Often times, you can get lucky, and the UART can be spotted easily. The Hyundai A7HD is a great example of that as it has a full serial port on big pre-tinned pads available. In case of the Coby MID7042, due to the limited number of testpads, and the way they were grouped, it was also clear which were the UART pins.

When you are not so lucky, you get presented with a motherboard with a big load of test-pads. This leaves you no option but to systematically try each one of them.

Regardless of whether the connections are easy to find or not, you still pretty much need to run through the procedure as listed below.

Attaching the UART module
Boot your device, and get the original OS running.

Attach your UART module to your host PC and run your console program on it.

Connect GND of the UART module to a convenient ground location on your board, and attach a probe to RX of the UART module.

If you now touch the probe to ground, you should see some broken characters appear on your console program. If not, check whether GND is wired up correctly, or swap RX/TX around on the module side.

Make some noise
Normally, your device will only sporadically send data out the serial bus, so the chances of seeing any text scroll past on the console, is pretty low.

A small tool called serial_noise is available, and it is statically compiled and verified to run on many android systems (source code is available here). Download it to your device, and run it.

When serial_noise has successfully started, and has found serial consoles in /dev/, it says: Flooding serial consoles with text... It will then be sending the /dev/ device names out to all the detected serial consoles on the system.

Find TX
You can now go and carefully touch the testpads with your probe, for a few seconds each until you see a device name scroll past. From time to time, verify that your setup is still working by sending some garbage to your hosts console program by touching ground with your probe.

Find RX
If or when you have found TX, you should find RX nearby.

Attach a second probe to the TX pin of the UART module.

With the other probe on the TX pad on the device still, you can now go and probe for the RX pad.

The easiest way to verify this is to touch a pad with the probe, and then typing things into the console program on your host computer. If you see your characters echoed back, then you have successfully located the RX pad.

Cable routing
Before you solder on the jumper wires, figure out how to get your serial connection available to the outside world.

With space at a premium in any mobile device, it is not easy to find a good solution here. The punishment for bad routing is quite severe. Your device might not close anymore, and there might be pressure on your devices LCD, leading to uneven backlighting and colours. So do care take care at this stage.

A good example of bad routing and the damage that it causes can be seen on the Hyundai A7HD page.

Make a point of clearly marking which wire is GND by using a brown or black wire for it. If you use jumper wires from an old PC case, try use a triple connector to make life easier in future.

Soldering the jumper wires
The usual recommendations for small electronics soldering apply.

Reassemble your device
And if all goes well, you should now have a tablet with something strange hanging out. You should be able to attach your UART module to it directly, fire up your console program and immediately get a console.

Now you can do low level development on your tablet, even when on the move. Just don't bring it up in a conversation with normal people if you still want them to respect you afterwards.

= Common Pitfalls =

Serial output stops when kernel uart driver is loaded
If you have working serial output with u-boot, but the output stops just after loading the kernel uart driver, like so: <6>Serial: 8250/16550 driver, 8 ports, IRQ sharing disabled <6>[uart]: used uart info.: 0x01 <6>[uart]: serial probe 0 irq 33 mapbase 0x01c28000 <6>sunxi-uart.0: ttyS0 at MMIO 0x1c28000 (irq = 33) is a U6_16550A

Then there might be something wrong with your kernel commandline.

Please verify that you have "console=ttyS0,115200" in your commandline, for instance in your U-Boot boot.cmd:

setenv bootargs console=ttyS0,115200 root=/dev/mmcblk0p2 rootwait panic=10 ${extra}

Make sure that the baudrate is provided as well.