sábado, 9 de abril de 2016

Installing a 3.9 inches mcufriend.com LCD module in a Raspberry PI B with Raspbian Jessie

I've found a  cheap 3.9 inches LCD module for the Raspberry Pi model B in Aliexpress (about US$ 8). It has the ili9488 controller and have a resolution of 320x480. There is no native support for it in the default Raspbian distribution.
After some digging in Internet, I installed the last Raspbian Jessie image available at the official download site and did the following procedure.

1. Extend the file system to open a room to install the new kernel:

 raspi-config --expand-rootfs

2. Install the rpi-update

 sudo apt-get install rpi-update
 sudo rpi-update

3. Install Xserver (if not already installed)

sudo apt-get install xserver-xorg-video-fbdev

4. Create  the file /etc/modules-load.d/fbtft.conf

sudo nano /etc/modules-load.d/fbtft.conf

spi-bcm2835
flexfb
fbtft_device


5. Create the file  /etc/modprobe.d/fbtft.conf  (only two lines beggining with "options", don't split the commands)
sudo nano  /etc/modprobe.d/fbtft.conf

options fbtft_device name=flexpfb rotate=180 fps=60 gpios=dc:18,reset:7,wr:17,cs:4,db00:22,db01:23,db02:24,db03:10,db04:25,db05:9,db06:11,db07:8 speed=48000000

options flexfb width=480 height=320 buswidth=8 init=-1,0xb0,0x0,-1,0x11,-2,120,-1,0x3A,0x55,-1,0xC2,0x33,-1,0xC5,0x00,0x1E,0x80,-1,0x36,0x28,-1,0xB1,0xB0,-1,0xE0,0x00,0x04,0x0E,0x08,0x17,0x0A,0x40,0x79,0x4D,0x07,0x0E,0x0A,0x1A,0x1D,0x0F,-1,0xE1,0x00,0x1B,0x1F,0x02,0x10,0x05,0x32,0x34,0x43,0x02,0x0A,0x09,0x33,0x37,0x0F,-1,0x11,-1,0x29,-3



6. Create the file /usr/share/X11/xorg.conf.d/99-fbdev.conf

sudo nano  /usr/share/X11/xorg.conf.d/99-fbdev.conf

Section "Device"
  Identifier "myfb"
  Driver "fbdev"
  Option "fbdev" "/dev/fb1"
EndSection


7. Overwrite the file  /boot/cmdline.txt to insert the statements "fbcon=map:10 fbcon=font:VGA8x8 FRAMEBUFFER=/dev/fb1" before the statement "rootwait"

sudo nano /boot/cmdline.txt

dwc_otg.lpm_enable=0 console=serial0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes fbcon=map:10 fbcon=font:VGA8x8 FRAMEBUFFER=/dev/fb1 rootwait


8. Reboot the Rasberry

sudo reboot

I noticed the LCD response is very lagging, but for some uses is enough.