A20-OLinuXino-LIME/LIME2/MICRO LCD Touch Screen Setup HowTo

Olimex offers several LCD and resistive touch LCD displays. The touch displays go from 4.3 inch to 10 inch, and the no-touch up to 15.6 inch. The resolution is up to 1920x1080 for the 15.6 15.6FHD LCD. They can all be connected to the A20-OLinuXino and A13-OLinuXino systems but the 10 and 15.6 inch displays are not recommented for the A13-OLinuXino because of its lower computing power.

The article will explain
  • Which parts are needed to connect an LCD touch display to the A20-OLinuXino-MICRO and A20-OLinuXino-LIME/LIME2 and to get it running
  • Connecting the (touch) screen to the OLinuXino
  • Why to better buy the system without 4GB NAND Flash
  • Installing Android on NAND Flash
  • Installing Android on SD Card
  • First steps with Android
  • Installing Debian on SD Card
  • First steps with Debian
  • Expanding the Debian root Partition

Needed parts

The assumption here is that you already have an OLinuXino, further a 4 GB (or larger) class 10 micro SD card, and a strong enough power supply. If you do not have a power supply, you can try to power the OLinuXino and display by connecting the USB-OTG connector of the OLinuXino with your PC. (See the Olimex wiki for which power supply is needed for your board.)
If you do not already have one, you can find the new Olimex (touch) LCD displays here. The new ones have a connector for the MICRO as the old ones but additionally a connector for the LIME2 and LIME_new_GPIO. The new ones are not more expensive than the old ones. You can find the old ones here and here. Be advised, at least for the LIME2, there are currently only Android Images for some display resolutions. This manual assumes that for Android, there is already an Image for your display resolution available. For Debian, there is always one Image for all resolutions and the resolution is changed later, as described below.
For the A20-OLinuXino-MICRO you will need the CABLE-IDC40-15cm cable to connect to the (touch) screen.
The situation with the A20-OLinuXino-LIME/LIME2 is now a bit more complicated because there are two versions of GPIO connectors as explained here. All LIMEs have the pins closer together (0.05" pitch vs 0.1" pitch). However the LIME2 now has the GPIO pins mirrored, in comparison to the old LIME, to make the layout correct. Olimex will also release a new version of the LIME with the same GPIO layout as the LIME2. I will call this version LIME_new_GPIO although it is not released yet. For the LIME2 and the LIME_new_GPIO you do not need an adapter board but you can connect it directly to the new display which also has a 0.1" pitch connector. You only need the the CABLE-40-40-10CM cable. For the initial version of the A20-LIME, you will need the A10-OLinuXino-LIME-UEXT adapter board, the CABLE-40-40-10CM cable to connect to the LIME and the CABLE-IDC40-15cm cable to connect to the (touch) screen.
Optionally you may need a frame as the LCD7-FRAMEKIT or double sided tape might be useful to fix the touch panel to the LCD.
If you have onboard flash, then you will need a Mini-USB cable to connect your PC to the OLinuXino USB-OTG connector in order to upgrade the Android image.
An ethernet network cable to be connected to your router is assumed.
A USB mouse, USB keyboard and HDMI monitor are not required but make certain tasks easier.
You can control the resistive touch panel with your hands but then a rather firm touch is needed. Much more convenient is using a pen for a resistive touch panel.

Connecting the parts

To connect the touch-screen to the display, pull the black holder a few millimeters out, then plug the cable in, then push the black holder back in again. (See the following picture)

If you have the MICRO, then just connect the display with the connector that has a label 'LCD' next to it.
If you have a LIME2 or LIME_new_GPIO and one of the new displays with 0.05" pitch connector, then just connect the display with the connector that has a label 'LCD' next to it.
If you have the LIME, then you can attach the two cables to the adapter as in the following picture. Note the following warning from this Olimex site:

the cable and the 0.05 connectors are very fragile - if you attempt to disconnect the setup by pulling the cable it might break! Furthermore - you might bend the pins! Use pliers or other suitable object to disconnect the connectors carefully!"

Now the touch panel should be fixed to the display. Since I did not have the frame kit and no double sided tape, I used Sellotape/Scotch Tape on the edges.

Why to better buy the system without 4GB NAND Flash

Onboard flash seems to have the advantage that the SD card slot is not blocked but memory cards can be inserted while the system is running. However for the OLinuXino there are, currently, two reasons not to choose the version with onboard flash memory.
First (currently) only Android is supported to be installed onboard not Debian. (See here) Second the installation will be destroyed immediately or after some time if you do not shutdown the system with the command sequence "sync", "reboot -p". So one accidental power loss can destroy your data on the NAND Flash. (See here) If that happens you need to reinstall the image.

Installing Android on NAND Flash

If you got the version with 4GB NAND Flash onboard (as I did) then you can download the newest NAND flash image for your display resolution from here for LIME, here for LIME2 and here for MICRO to the onboard memory as already explained here for the LIME, here for LIME2 and here for the MICRO. The manual worked for me using Windows 8, except that I held the RECOVERY button until power AND the USB connector were connected. When asked by PhoenixSuit I chose "format upgrade mode". One more note, during the PhoenixSuit installation, I got the message "Cannot Complete the Device Driver Installation" but it still worked. After the scrollbar that shows the Firmware Upgrade status finishes, the system will automatically boot. This may take SEVERAL minutes during which the display is black.

Installing Android on SD Card

You can download the newest Image for Micro SD card for your display resolution from here for LIME, here for LIME2 and here for MICRO
If you are using Windows, you can copy the Unzipped Image to the SD card with Win32 Disk Imager. While the file is copied the writing speed is displayed. It should be above 10 MB/s if you have a class 10 SD card.
Now insert the SD card and hold the power button for 3 seconds to start the system.

First steps with Android

After the initial boot, the touch panel must be calibrated. The resistive touch panel needs, other than most mobile phone capacitive touch panels, a rather firm push if you use your hand. Using a pen for resistive touch displays is more convenient.
On the SD card image the touch screen was already calibrated correctly for my 7" display. On the NAND image the x axis was inverted so that to press a button on the right side you need to press on the left side. So if you use the NAND image, I recommend to plug in a USB mouse and use it to start the Calibration App.
After calibration, the Ethernet Network can simply be activated under "Settings, Wireless & Network, More..., Ethernet, Use Ethernet".
One would expect that powering off the system is simply holding the power button for 3 seconds and then selecting "Power off". But this is only true if you installed the system on a SD card. If however you installed it on NAND flash, then you should use the command sequence "sync", "reboot -p". (See here) To execute those commands you need a terminal and be able to execute commands as super user. The first can be achieved by installing the Android Terminal Emulator app and the second can be achieved by installing the SuperSU app. Now open the SuperSU app and let it configure your system. Then open the Android Terminal Emulator app and type sync then on a new line su and then on a new line reboot -p. Now your system should power off. You can also use the Android Terminal Emulator app as shutdown app by opening it --> preferences --> Initial command. And then enter: sync && su -c "reboot -p".
To start the system, press the power button for about 3 seconds and then wait about 30 seconds during which the screen is black.
There is an A-20 Tools app to control the GPIO pins. It can be downloaded from GitHub and is described here.

Installing Debian on SD Card

Debian will not install on the onboard NAND flash. So the procedure is the same whether or not your system has onboard flash memory. If the SD card is inserted, then the system will try to boot from it instead from the onboard NAND flash.
You can download the Debian Image here for LIME, here for LIME2 and here for the MICRO.
If you are using Windows, you can copy the Unzipped Image to the SD card with Win32 Disk Imager. While the file is copied the writing speed is displayed. It should be above 10 MB/s if you have a class 10 SD card.
Now insert the SD card and hold the power button for 3 seconds to start the system.
Initially, the Debian Image is configured for HDMI displays and Ethernet Network is disabled. See the next section on how to setup Ethernet Network and the touch screen.

First steps with Debian

For the following steps you will need the initial password for the root user. It is olimex. The user olimex has the initial password olimex. The default host name is a20-OLinuXino.
The first step is to enable Ethernet Network in order to connect to the OLinuXino with a SSH terminal connection. Ethernet Network is disabled by default because the booting takes a long time if it is enabled and no Ethernet cable is connected.
To enable Ethernet, connect the OLinuXino with your router via Ethernet cable and change the section under auto eth0 in the /etc/network/interfaces file as follows.


auto eth0  
#iface eth0 inet dhcp
iface eth0 inet static  


auto eth0  
iface eth0 inet dhcp  
#iface eth0 inet static

Editing the interfaces file can be achieved in several ways.
First, if you have a HDMI display connected and a USB keyboard and mouse, then you can just start the OLinuXino, open a terminal and edit the file with sudo nano /etc/network/interfaces.
Second, if you cannot use the first approach, then you can use a serial debug cable to get a terminal prompt.
Third, if you also do not have a serial debug cable, then you can modify the interfaces file directly on the SD card. Since Windows cannot read or edit the EXT3 file system you can use a Linux VM to do this. The free VM Ware Player can be downloaded from here and the Ubuntu Image from here to edit the interfaces file on the Micro-SD card. I assume that there is no need for step-by-step instructions on how to install a virtual machine.
After you modified the interfaces file, the second step is to change the display type from HDMI to LCD.
To change the display to LCD, create a SSH connection to the OLinuXino. On Windows, you can use PuTTY and connect to the host: a20-OLinuXino as user root with password olimex. Then type ./change_display_* which is a script in the root user's home directory that will start the screen configuration. After you configured the LCD display and restarted, the touch LCD display should show the Linux desktop.
To calibrate the display open a terminal window with the touch screen. Then, if you do not have a USB keyboard attached, open the virtual Keyboard under Accessories. It is important to execute the following command as user olimex because the X environment runs as user olimex. To be sure type su olimex (password is olimex) then sudo ts_calibrate. The calibration will only take effect after a restart, so you may restart with sudo reboot.

Expanding the Debian root Partition

To be able to use not only 4 GB of the SD card but all the space in the root partition, the file system must be expanded. There is a safe and a quick way to do this. The safe way is to insert the SD card in another PC and to resize the partition there with the gparted program. For example from a Virtual Machine running Ubuntu as described above.
The quick way, which worked for me, is as follows. Be warned, that you might have to reinstall the Image if something fails.

fdisk /dev/mmcblk0

In fdisk type p to display the partition table. It should look like this.

Then type d to delete a partition and then type 2 to choose the second partition. Actually the data will not be deleted because we will create a new partition at the same location.
Then type n to create a new partition and then type p0 to create a primary extended partition. Then type two times enter to accept the default for first sector and last sector. Now type p to display the partition table again.

Note that only the columns End and Blocks of the second partition changed. If everything is OK, type w to write the changes.
Reboot with sudo reboot.
After the reboot execute the following command resize2fs /dev/mmcblk0p2. Now all the space on the SD card should be available. You can check this with df /.