Uncategorized

MGD Blog ILI9341 Screen Setup Notes

ggg

Getting an ILI9341 SPI screen working on the RaspberryPI

I recently bought a small SPI screen from ebay which uses the ILI9341 controller.
The screen is identical to the one made by ElecFreaks (This one!).
Although I got mine really cheap from eBay….

I decided to use notro drivers since they are flexible and already provide a driver for the ILI9341. You can find the source code and install instructions here.
I actually compiled a custom kernel where I added his drivers.
After compilation and module installation I just had to figure out the parameters I needed to use.
But first we still need to hook it up to the RaspPI 🙂
I used the following connections, also from notro’s Wiki
I used the wiring schema for an Adafruit LCD, check the original table here.
Display Driver gpio name Raspberry Pi Remark
BL led GPIO18
SCK SCLK
MISO Used by SD-card
MOSI MOSI
CS CE0 Chip Select
SDCS SD-card Chip Select
RST reset GPIO25
D/C dc GPIO24
VIN 3.3V
GND GND

Aside from a normal SPI connection, please notice the BL(led), RST(reset) and D/C(dc) pins since these will be used as parameters for the module.

Once you have everything hooked up, compiled and installed you can test out the screen by loading the module:

sudo modprobe fbtft_device custom name=fb_ili9341  gpios=reset:25,dc:24,led:18 speed=16000000 rotate=90 bgr=1

If you change one of the pins above, please change the gpios parameter accordingly.
Also, you have the rotate option to put the screen in landscape mode, by default it will be in portrait mode.
The bgr=1 option is to exchange the blue and red colors, by default the colors don’t appear correctly and this option is necessary.
Once you load the module nothing will happen on your screen (this made think it wasn’t working…) you can test it out by either sending the console to the framebuffer with:

con2fbmap 1 1

(it means, send console 1 to framebuffer 1)

or using X

FRAMEBUFFER=/dev/fb1 startx

If you want to make the module load automatically, add the following line to /etc/modules:
fbtft_device custom name=fb_ili9341  gpios=reset:25,dc:24,led:18 speed=16000000 rotate=90 bgr=1

EDIT: For the built-in version, you can add this to the kernel command line:
fbtft_device.name=fb_ili9341 fbtft_device.gpios=reset:25,dc:24,led:18 fbtft_device.speed=16000000 fbtft_device.rotate=90 fbtft_device.bgr=1 fbtft_device.custom=1

Hope you find this useful.

54 comments:

  1. Thank you ! It works ! 🙂

    Reply

  2. Please let me know how to install and do it work on my Raspberry…

    I’m still a rookie. I can not find the installation instructions.

    Reply

  3. No problem, just check out notro’s Wiki:
    https://github.com/notro/fbtft/wiki#wiki-install

    You need to follow the instructions on that page in order to be able to use the modules.
    Once you have the modules loaded and the screen connected everything should work fine.

  4. Awesome! Thanks for sharing!

    Reply

  5. Thankyou! You got me up and going.
    Im trying to get X to boot in fullscreen 1:1
    I followed :

    HOWTO: Boot your Raspberry Pi into a fullscreen browser kiosk


    with some modifications I have it working, but its scaled. I’ve tried a bunch of different things.

    Thanks

    Reply

  6. Hi, Glad I could help!. What resolution are trying to use?

  7. Hello,
    thank you so much for your advices, it appeared that I have been able to fix a lot of issues thanks to you. Yet I am stuck after hitting enter on the ‘sudo modprobe fbtft_device custom…’ command line since there is no fb1 which appears in the /dev folder…
    Am I missing something obvious ?
    I am pretty sure of my wiring, unless we ought to add resistor between peculiar pins, maybe ?

    Reply

  8. Hi,
    did you install notro’s modules?After you do the sudo modprobe command, what are the last lines of the output from the following command:
    sudo dmesg

    Reply

  9. Yes, I have choosen the builtin version, I have flashed an sdcard with it, I have followed the repository installation and the update and here are the last line of “sudo dmesg” before having hitting the “sudo modprobe” command :

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    [ 7.595394] ieee80211 phy0: rt2x00_set_rt: Info – RT chipset 5390, rev 0502 detected
    [ 7.627455] ieee80211 phy0: rt2x00_set_rf: Info – RF chipset 5370 detected
    [ 7.692536] ieee80211 phy0: Selected rate control algorithm ‘minstrel_ht’
    [ 7.699860] usbcore: registered new interface driver rt2800usb
    [ 10.543666] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
    [ 11.001351] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
    [ 17.180017] FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
    [ 20.091356] ieee80211 phy0: rt2x00lib_request_firmware: Info – Loading firmware file ‘rt2870.bin’
    [ 20.105693] ieee80211 phy0: rt2x00lib_request_firmware: Info – Firmware detected – version: 0.29
    [ 23.749561] wlan0: authenticate with 7a:e8:b6:f8:84:d5
    [ 23.803597] wlan0: send auth to 7a:e8:b6:f8:84:d5 (try 1/3)
    [ 23.807273] wlan0: authenticated
    [ 23.814715] wlan0: associate with 7a:e8:b6:f8:84:d5 (try 1/3)
    [ 23.820407] wlan0: RX AssocResp from 7a:e8:b6:f8:84:d5 (capab=0x431 status=0 aid=1)
    [ 23.829930] wlan0: associated
    [ 25.954874] Adding 102396k swap on /var/swap. Priority:-1 extents:3 across:2122364k SSFS
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    Here are the last line of the same command after the “sudo modprobe” command :
    [ 7.595394] ieee80211 phy0: rt2x00_set_rt: Info – RT chipset 5390, rev 0502 detected
    [ 7.627455] ieee80211 phy0: rt2x00_set_rf: Info – RF chipset 5370 detected
    [ 7.692536] ieee80211 phy0: Selected rate control algorithm ‘minstrel_ht’
    [ 7.699860] usbcore: registered new interface driver rt2800usb
    [ 10.543666] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
    [ 11.001351] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
    [ 17.180017] FAT-fs (mmcblk0p1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.
    [ 20.091356] ieee80211 phy0: rt2x00lib_request_firmware: Info – Loading firmware file ‘rt2870.bin’
    [ 20.105693] ieee80211 phy0: rt2x00lib_request_firmware: Info – Firmware detected – version: 0.29
    [ 23.749561] wlan0: authenticate with 7a:e8:b6:f8:84:d5
    [ 23.803597] wlan0: send auth to 7a:e8:b6:f8:84:d5 (try 1/3)
    [ 23.807273] wlan0: authenticated
    [ 23.814715] wlan0: associate with 7a:e8:b6:f8:84:d5 (try 1/3)
    [ 23.820407] wlan0: RX AssocResp from 7a:e8:b6:f8:84:d5 (capab=0x431 status=0 aid=1)
    [ 23.829930] wlan0: associated
    [ 25.954874] Adding 102396k swap on /var/swap. Priority:-1 extents:3 across:2122364k SSFS

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    It seems that nothing have changed…

    I’ve done it with a remoted command line through ssh, since I have stricly no access to any kind of VGA display or any other display kind…
    Given that there is no display of any kind, apart from the ILI341 SPI screen that we are dealing with, that is wired to the rasPi, how come that there is a fb0 in the /dev folder ?

  10. If you’re using the built in version you won’t be able to load the module since it is already built in to the kernel.
    You need to change your kernel command line by editing the
    /boot/cmdline.txt
    file.
    You should append the folowing information to the kernel command line:

    fbtft_device.name=fb_ili9341 fbtft_device.gpios=reset:25,dc:24,led:18 fbtft_device.speed=16000000 fbtft_device.rotate=90 fbtft_device.bgr=1

    Check the info on notro’s wiki here:
    https://github.com/notro/rpi-firmware/wiki/branch:-builtin

    Hope this solves your issues.

  11. Thank you, I am going to try it right now if I succeed to access remotely to my pi…
    I haven’t been able to write it directly to the sdcard via a sdcard reader on my pc, the file appears to be in “read only”…

  12. Alright, if I enter fb_ili9341 as device’s name, I get nothing, the screen’s led doesn’t go on, nothing.
    But when I try rpi-display, the same as it is suggested in notro’s wiki, the led goes on.

    So I have mixed a bit both suggestions : your suggestion with rpi-display as device name. The led goes on but nothing else happens.
    When I try con2fbmap 1 1 : I do not get the error that I had before but nothing else happen.
    When I try FRAMEBUFFER=/dev/fb1 startx : now that there is an fb1 in the dev folder, yet nothing happen.

    I beg you, have you any other ideas, please ?

    Reply

  13. Here is the log of the startx command which appears to freeze :

    X.Org X Server 1.12.4
    Release Date: 2012-08-27
    X Protocol Version 11, Revision 0
    Build Operating System: Linux 3.2.0-2-mx5 armv7l Debian
    Current Operating System: Linux raspberrypi 3.12.25+ #1 PREEMPT Sat Aug 2 19:08:33 CEST 2014 armv6l
    Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708.boardrev=0x8 bcm2708.serial=0x7938f1c8 smsc95xx.macaddr=B8:27:EB:38:F1:C8 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0xec00000 vc_mem.mem_size=0x10000000 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait fbtft_device.name=rpi-display fbtft_device.gpios=reset:25,dc:24,led:18 fbtft_device.speed=16000000 fbtft_device.rotate=90 fbtft_device.bgr=1
    Build Date: 18 December 2013 05:20:52PM
    xorg-server 2:1.12.4-6+deb7u2 (Julien Cristau )
    Current version of pixman: 0.29.3
    Before reporting problems, check http://wiki.x.org
    to make sure that you have the latest version.
    Markers: (–) probed, (**) from config file, (==) default setting,
    (++) from command line, (!!) notice, (II) informational,
    (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
    (==) Log file: “/var/log/Xorg.0.log”, Time: Mon Aug 4 21:50:53 2014
    (==) Using config directory: “/etc/X11/xorg.conf.d”
    (==) Using system config directory “/usr/share/X11/xorg.conf.d”
    FATAL: Module g2d_23 not found.

    Reply

  14. Hi,
    try this:
    fbtft_device.name=fb_ili9341 fbtft_device.gpios=reset:25,dc:24,led:18 fbtft_device.speed=16000000 fbtft_device.rotate=90 fbtft_device.bgr=1 fbtft_device.custom=1

    I forgot the custom parameter!

    Reply

  15. OMGA ! It works !

    I am sorry, I had the reset wire that was not working apparently…. As I changed it the led goes on but the screen was black instead of white and finally when I hit con2fbmap 1 1, it displayed the console :)!!!

    Thank you so much !!!! (I am sorry still if I have made you lose a bit of your time…)

    Reply

  16. That’s great!!
    What was the final command line you used?

    Reply

  17. I hadn’t seen your previous message so I have tried this :
    fbtft_device.name=rpi-display fbtft_device.gpios=reset:25,dc:24,led:18 fbtft_device.speed32000000 fbtft_device.rotate90 fbtft_device.bgr=1

    And it appears to work perfectly, anyway i am going to try right one your last suggestion.

    Reply

  18. Sorry I’ve forgotten, I added these options too :
    fbcon=map:10 fbcon=font:VGA8x8

    Your options appears to work perfectly too ;).
    Why is it that both 16000000 and 32000000 speed works ?
    I think I’ll try the 48000000…

    Reply

  19. I think that is the speed at which the data is sent through the SPI bus.
    Don’t set it too high or you might have issues.

    Reply

  20. Alright.
    Thank you so much !
    Good continuation with whatever else you’ve indulged into !

    Reply

  21. Hello all.

    Nice to be here and read the blog. If you allow me i would like to ask a question.
    Is any1 who made success with 3.2″ screen as a second screen?
    Im on it but i cannot do this right now. if any1 can help me i would be very thanksfull

    Regards Balazs

    Reply

  22. Hello all.

    Nice to be here and read the blog. If you allow me i would like to ask a question.
    Is any1 who made success with 3.2″ screen as a second screen?
    Im on it but i cannot do this right now. if any1 can help me i would be very thanksfull

    Regards Balazs

    Reply

  23. Hi,
    Do you mean using HDMI and a SPI screen or using 2 SPI screens?
    Either way, you can do it, but you need to export a diferent FRAMEBUFFER variable depending on where you want the application to start.

    Reply

  24. Hello David,
    I try to make my own primary display in that ILI9341 based TFT LCD, exactly same product with the one you show in this post. I have installed notro’s driver too in my raspberry pi but I still cannot make the display show the desktop. The LCD just turn on the backlight when I did the ‘modprobe’ thing. Is there any step that I miss? and how to exactly test, if the driver notro has provided, was installed properly in my raspberry pi?

    Looking forward your opinion about this David. Thanks.

    Reply

  25. What happens when you run the command:

    con2fbmap 1 1

    Does it stay the same?

    After you run the modprobe can you do a

    dmesg|tail -n 25

    and post the output?

  26. when i use “dmesg” it show me Failed to start Load Kernel Modules. how to fix it? thank you

    Reply

  27. Could you please post the last 20 lines of dmesg after you try to load the module?
    You can get them with:

    dmesg|tail -n20

  28. pi@raspberrypi ~ $ dmesg|tail -n20
    [ 5.162103] systemd[1]: Time has been changed
    [ 5.312004] systemd[1]: Started udev Coldplug all Devices.
    [ 5.522831] systemd[1]: Starting Create Static Device Nodes in /dev…
    [ 5.540486] systemd[1]: Starting Apply Kernel Variables…
    [ 5.577943] systemd[1]: Mounting Configuration File System…
    [ 5.620096] systemd[1]: Mounting FUSE Control File System…
    [ 5.724976] systemd[1]: Starting Syslog Socket.
    [ 5.728127] systemd[1]: Listening on Syslog Socket.
    [ 5.728443] systemd[1]: Starting Journal Service…
    [ 5.775105] systemd[1]: Started Journal Service.
    [ 6.146508] systemd-udevd[95]: starting version 215
    [ 8.083315] EXT4-fs (mmcblk0p2): re-mounted. Opts: (null)
    [ 10.537619] random: nonblocking pool is initialized
    [ 10.545557] smsc95xx 1-1.1:1.0 eth0: hardware isn’t capable of remote wakeup
    [ 10.546371] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
    [ 10.673830] systemd-journald[93]: Received request to flush runtime journal from PID 1
    [ 12.219148] smsc95xx 1-1.1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
    [ 12.230442] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
    [ 13.741547] cfg80211: Calling CRDA to update world regulatory domain
    [ 16.499976] Adding 102396k swap on /var/swap. Priority:-1 extents:5 across:573436k SSFS

  29. 1.open SPI
    2.sudo REPO_URI=https://github.com/notro/rpi-firmware rpi-update
    3.sudo nano /etc/modules ->fbtft_device name=tm022hdh26
    4. sudo nano /usr/share/X11/xorg.conf.d/99-fbturbo.conf -> fb0 to fb1
    5.sudo /boot/cmdline.txt -> fbcon=map:10
    it now work for me Fail Kernal Modules
    but when i use sudo modprobe fbtft_device name=tm022hdh26 it work but when reboot it not auto load after reboot must use modprobe fbtft_device name tm022hdh26 again

    what i miss?
    thank you

    Reply

  30. Hi Sunny,

    that should be enough.

    Do you mind trying with the line in my post in /etc/modules:

    fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24,led:18 speed=16000000 rotate=90 bgr=1

    Reply

  31. Hi!

    Could You help me?

    View in my is resized. I mean console doesn’t take whole surface of screen. Furthermore view is flipped. All is reflected like in mirror.

    I use ILI9341 and RPi 2.

    dmesg:
    [ 566.658693] fbtft: module is from the staging directory, the quality is unknown, you have been warned.
    [ 566.663868] fbtft_device: module is from the staging directory, the quality is unknown, you have been warned.
    [ 566.665117] fbtft_device: SPI devices registered:
    [ 566.665144] fbtft_device: spidev spi0.0 500kHz 8 bits mode=0x00
    [ 566.665160] fbtft_device: spidev spi0.1 500kHz 8 bits mode=0x00
    [ 566.665171] fbtft_device: ‘fb’ Platform devices registered:
    [ 566.665201] fbtft_device: soc:fb id=-1 pdata? no
    [ 566.665260] fbtft_device: Deleting spi0.0
    [ 566.665712] spi spi0.0: setting up native-CS0 as GPIO 8
    [ 566.665860] fbtft_device: GPIOS used by ‘adafruit22’:
    [ 566.665874] fbtft_device: ‘reset’ = GPIO25
    [ 566.665886] fbtft_device: ‘dc’ = GPIO24
    [ 566.665897] fbtft_device: ‘led’ = GPIO18
    [ 566.665906] fbtft_device: SPI devices registered:
    [ 566.665921] fbtft_device: spidev spi0.1 500kHz 8 bits mode=0x00
    [ 566.665936] fbtft_device: fb_hx8340bn spi0.0 16000kHz 8 bits mode=0x00
    [ 566.682589] fb_hx8340bn: module is from the staging directory, the quality is unknown, you have been warned.
    [ 567.045765] graphics fb1: fb_hx8340bn frame buffer, 220×176, 75 KiB video memory, 16 KiB DMA buffer memory, fps=20, spi0.0 at 16 MHz

    Reply

  32. Hi,
    It seems you are using the wrong module:
    …fb_hx8340bn frame buffer,…

    Can you let me know how you are setting the screen up?

    Are you using the fbtft_device.name=fb_ili9341 parameter?

  33. I tried again.
    dmesg
    http://ideone.com/rt3EBN
    It’s possible that I made some mistakes in installation…

  34. Hi,

    From the ouput of dmesg it seems that either you didn’t load the module or you’re using the builtin version.

    The configuration depends on how you are setting this up.
    If you’re using the built in version you need to change the kernel command line. There is an example in the comments here.

    But if you still need help, I’m afraid I need more information on how you’re setting this up.

  35. Hi! I’m trying to set this in the pi 2 running raspbian. I’m doint this:

    pi@raspberrypi:~ $ sudo modprobe fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24,led:18 speed=16000000 rotate=90 bgr=1
    pi@raspberrypi:~ $ FRAMEBUFFER=/dev/fb1
    pi@raspberrypi:~ $ FRAMEBUFFER=/dev/fb1 startx

    X: user not authorized to run the X server, aborting.
    ^Cxinit: giving up
    xinit: unable to connect to X server: Connection refused
    xinit: unexpected signal 2
    pi@raspberrypi:~ $ sudo FRAMEBUFFER=/dev/fb1 startx

    X.Org X Server 1.17.2
    Release Date: 2015-06-16
    X Protocol Version 11, Revision 0
    Build Operating System: Linux 3.8.11-2-ARCH armv7l Raspbian
    Current Operating System: Linux raspberrypi 4.1.17-v7+ #840 SMP Sat Feb 13 15:19:36 GMT 2016 armv7l
    Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=1776 bcm2708_fb.fbheight=952 bcm2709.boardrev=0xa01041 bcm2709.serial=0x200e9a0c smsc95xx.macaddr=B8:27:EB:0E:9A:0C bcm2708_fb.fbswap=1 bcm2709.uart_clock=3000000 bcm2709.disk_led_gpio=47 bcm2709.disk_led_active_low=0 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
    Build Date: 11 January 2016 01:32:44PM
    xorg-server 2:1.17.2-1+rpi1 (http://www.debian.org/support)
    Current version of pixman: 0.33.3
    Before reporting problems, check http://wiki.x.org
    to make sure that you have the latest version.
    Markers: (–) probed, (**) from config file, (==) default setting,
    (++) from command line, (!!) notice, (II) informational,
    (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
    (==) Log file: “/var/log/Xorg.1.log”, Time: Sun Feb 14 08:52:40 2016
    (==) Using system config directory “/usr/share/X11/xorg.conf.d”
    modprobe: FATAL: Module g2d_23 not found.
    The XKEYBOARD keymap compiler (xkbcomp) reports:
    > Warning: Type “ONE_LEVEL” has 1 levels, but has 2 symbols
    > Ignoring extra symbols
    Errors from xkbcomp are not fatal to the X server

    What can I do?

    Thanks!

    Reply

  36. Hi,
    it seems you already have an X server running on a different screen.

    Do you have an HDMI connection setup as well?

    If you are trying to setup a dual monitor setup, have a look at this thread:
    https://www.raspberrypi.org/forums/viewtopic.php?f=44&t=91764

    If not, then try to stop the running Xorg server:

    sudo killall -9 Xorg

    sudo FRAMEBUFFER=/dev/fb1 startx

    Let me know if it works!

  37. Hi!

    I’ve tried this but there is no output. I’m using the pi2… I don’t know if that changes something.

    Thanks

    pi@raspberrypi:~ $ sudo modprobe fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24,led:18 speed=16000000 rotate=90 bgr=1
    pi@raspberrypi:~ $ con2fbmap 1 1
    pi@raspberrypi:~ $ sudo FRAMEBUFFER=/dev/fb1 startx
    xauth: file /root/.Xauthority does not exist

    X.Org X Server 1.17.2
    Release Date: 2015-06-16
    X Protocol Version 11, Revision 0
    Build Operating System: Linux 3.8.11-2-ARCH armv7l Raspbian
    Current Operating System: Linux raspberrypi 4.1.17-v7+ #840 SMP Sat Feb 13 15:19:36 GMT 2016 armv7l
    Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=592 bcm2708_fb.fbheight=448 bcm2709.boardrev=0xa01041 bcm2709.serial=0x200e9a0c smsc95xx.macaddr=B8:27:EB:0E:9A:0C bcm2708_fb.fbswap=1 bcm2709.uart_clock=3000000 bcm2709.disk_led_gpio=47 bcm2709.disk_led_active_low=0 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
    Build Date: 11 January 2016 01:32:44PM
    xorg-server 2:1.17.2-1+rpi1 (http://www.debian.org/support)
    Current version of pixman: 0.33.3
    Before reporting problems, check http://wiki.x.org
    to make sure that you have the latest version.
    Markers: (–) probed, (**) from config file, (==) default setting,
    (++) from command line, (!!) notice, (II) informational,
    (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
    (==) Log file: “/var/log/Xorg.1.log”, Time: Mon Feb 15 22:02:56 2016
    (==) Using system config directory “/usr/share/X11/xorg.conf.d”
    modprobe: FATAL: Module g2d_23 not found.
    ^Cxinit: connection to X server lost

    waiting for X server to shut down (II) Server terminated successfully (0). Closing log file.

    xinit: unexpected signal 2
    pi@raspberrypi:~ $ sudo killall -9 Xorg
    pi@raspberrypi:~ $ sudo FRAMEBUFFER=/dev/fb1 startx

    X.Org X Server 1.17.2
    Release Date: 2015-06-16
    X Protocol Version 11, Revision 0
    Build Operating System: Linux 3.8.11-2-ARCH armv7l Raspbian
    Current Operating System: Linux raspberrypi 4.1.17-v7+ #840 SMP Sat Feb 13 15:19:36 GMT 2016 armv7l
    Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=592 bcm2708_fb.fbheight=448 bcm2709.boardrev=0xa01041 bcm2709.serial=0x200e9a0c smsc95xx.macaddr=B8:27:EB:0E:9A:0C bcm2708_fb.fbswap=1 bcm2709.uart_clock=3000000 bcm2709.disk_led_gpio=47 bcm2709.disk_led_active_low=0 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
    Build Date: 11 January 2016 01:32:44PM
    xorg-server 2:1.17.2-1+rpi1 (http://www.debian.org/support)
    Current version of pixman: 0.33.3
    Before reporting problems, check http://wiki.x.org
    to make sure that you have the latest version.
    Markers: (–) probed, (**) from config file, (==) default setting,
    (++) from command line, (!!) notice, (II) informational,
    (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
    (==) Log file: “/var/log/Xorg.1.log”, Time: Mon Feb 15 22:04:11 2016
    (==) Using system config directory “/usr/share/X11/xorg.conf.d”
    modprobe: FATAL: Module g2d_23 not found.

    Reply

  38. Hi,
    It seems you already have an Xorg server running.
    Could please try to configure the pi to boot in console mode:
    sudo raspi-config

    Then Reboot.

    StartX with the following command:

    sudo FRAMEBUFFER=/dev/fb1 startx &

    If that doesn’t work can you send me the last 30 lines of /var/log/Xorg.0.log and /var/log/Xorg.1.log

    Thank you!

    If it doesn’t work, can you attach the last 30 lines of

  39. Hi!

    I’ve been able to run it, but … this is kind weird!!

    I’ve modified /etc/modules. This is the file:

    # /etc/modules: kernel modules to load at boot time.
    #
    # This file contains the names of kernel modules that should be loaded
    # at boot time, one per line. Lines beginning with “#” are ignored.

    i2c-dev
    fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24,led:18 speed=16000000 rotate=90 bgr=1

    but this happens:

    sudo con2fbmap 1 1
    ioctl FBIOPUT_CON2FBMAP: Invalid argument

    when I write:

    sudo modprobe fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24,led:18 speed=16000000 rotate=90 bgr=1

    and then:

    sudo con2fbmap 1 1

    it runs!!!

    When I try to start x-server, it says:

    sudo FRAMEBUFFER=/dev/fb1 startx &
    [1] 1134
    pi@raspberrypi:~ $

    X.Org X Server 1.17.2
    Release Date: 2015-06-16
    X Protocol Version 11, Revision 0
    Build Operating System: Linux 3.8.11-2-ARCH armv7l Raspbian
    Current Operating System: Linux raspberrypi 4.1.17-v7+ #840 SMP Sat Feb 13 15:19:36 GMT 2016 armv7l
    Kernel command line: dma.dmachans=0x7f35 bcm2708_fb.fbwidth=592 bcm2708_fb.fbheight=448 bcm2709.boardrev=0xa01041 bcm2709.serial=0x200e9a0c smsc95xx.macaddr=B8:27:EB:0E:9A:0C bcm2708_fb.fbswap=1 bcm2709.uart_clock=3000000 bcm2709.disk_led_gpio=47 bcm2709.disk_led_active_low=0 sdhci-bcm2708.emmc_clock_freq=250000000 vc_mem.mem_base=0x3dc00000 vc_mem.mem_size=0x3f000000 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p7 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait fbcon=map:10 fbcon=rotate:4 fbcon=font:VGA8x8
    Build Date: 11 January 2016 01:32:44PM
    xorg-server 2:1.17.2-1+rpi1 (http://www.debian.org/support)
    Current version of pixman: 0.33.3
    Before reporting problems, check http://wiki.x.org
    to make sure that you have the latest version.
    Markers: (–) probed, (**) from config file, (==) default setting,
    (++) from command line, (!!) notice, (II) informational,
    (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
    (==) Log file: “/var/log/Xorg.0.log”, Time: Tue Feb 16 19:43:07 2016
    (==) Using system config directory “/usr/share/X11/xorg.conf.d”
    modprobe: FATAL: Module g2d_23 not found.

    and the terminal outputs stays there, but there is no x server on the screen 😦

    the output of /var/log/Xorg.0.log is in here: https://gist.github.com/LuisDiazUgena/73f8398d67c7a7e8ef81
    and the output from /var/log/Xorg.1.log is in here: https://gist.github.com/LuisDiazUgena/619b259c947919bf4ed6

    Thanks for your support 🙂

    Reply

  40. It is a bit weird. 🙂

    I was looking in Notro’s Wiki: https://github.com/notro/fbtft/wiki

    This caught my attention.

    Note: You might need to move an xorg config out of the way if X doesn’t start:

    sudo mv /usr/share/X11/xorg.conf.d/99-fbturbo.conf ~

    It also describes how to auto load the module:


    Add to file /etc/modules-load.d/fbtft.conf
    spi-bcm2835
    fbtft_device

    Add to file /etc/modprobe.d/fbtft.conf

    options fbtft_device custom name=fb_ili9341 gpios=reset:25,dc:24,led:18 speed=16000000 rotate=90 bgr=1

    Hope it works now! 😀

  41. It wooorkeeeeeeeeeeeeeeeeed!!!!! Now the screen boots into the terminal mode and can start the x server! Now, with this screen the windows seems to be a greater size of the screen. It’s possible to make it fit the screen automatically?

    I’ve changed fbcon=font:7×14 in cmdline.txt to make the cmd text fits in the screen as say in this video (https://www.youtube.com/watch?v=wxJpWRPKe-g). Do you think if it is possible to make the text look a little bigger?

    Thanks so much for all your help!

  42. Glad to hear you got it working! 😀

    To get the screen t the proper size, you can try adding.

    framebuffer_width=320
    framebuffer_height=240

    to the cmdline.txt file on the SD card (switch the values for portrait mode).

    The resolution of the screen is very low so don’t expect miracles, most Apps can’t cope with low resolution and that’s probably why you’re having issues.

    You could also try starting X with a different DPI:

    FRAMEBUFFER=/dev/fb1 startx — -dpi 30 &

    Have fun!

  43. Thank you! Will try this afternoon when I get home.

    Grettings!

  44. This comment has been removed by a blog administrator.

    Reply

  45. I saw in data sheet that dpi[2:0] is used to select representation of the pixel by either 16-bit or 18-bit, here my doubt is why we need two types of representations and what is difference in 16-bit notation compared to 18-bit notation. what is the advantages compared one with other?

    Reply

  46. Hi Ravi,
    I’m not 100% sure on this but here a my best guesses.

    16bit uses a 5 bit representation for Red and Blue and 6 bits for green (https://en.wikipedia.org/wiki/List_of_monochrome_and_RGB_palettes#16-bit_RGB)

    18bit uses 6 bits for Red, Green and Blue.
    https://en.wikipedia.org/wiki/List_of_monochrome_and_RGB_palettes#18-bit_RGB

    It basically defines the amount of colours you can display.
    16bit=65,536 colours
    18bit=262,144 colours

    There are a few things to keep in mind:
    1 – more colours = more memory – since you need an extra 2 bits per pixels will need a larger buffer to keep all the screen information. This is irrelevant with a RaspPI, since there is plenty of memory, but important in micro-controllers or embedded devices where memory is very constraint.
    Remember you need 18bit for each pixel, so if you have a 320×240 resolution this means:
    320*240*18~168kB VS 320*240*16~150kB, that 18KB difference might seem small but in micro-controller world it is actually huge 😀

    2 – Also, the screen you are using needs to be able to represent all the colours in the format you’re using. For instance, if you use a 18bit pallete but the screen is only able to display 65536 colours then there is no point in using the 18bit format.

    So, in summary, for the RaspPI it doesn’t really make a difference.
    If you were using an Arduino it’s a different story.
    However, since the datasheet needs to supply all the relevant information for all use cases, they list those options as well and the chip supports both formats.

    Hope this clears it up for you!

    Cheers,
    MD

  47. My TFT 2.2 ili9341 displays OK but how can I configure/wire the TFT screen to use CE1 intead of the default CE0? In the suggestions above for “modprobe” no reference is made to a value for ‘cs’ so I guess that channel 0 is the default. Also placing cs:7 or cs:07 or cs:CE1, in the line fbtft_device custom name=fb_ili9341 gpios=reset:25,cs:7,dc:24,led:18 speed=16000000 rotate=90 bgr=1 does not change the settings show in dmesg | grep fbtft when the CS pin is connected to CE1 and displays a white screen.

    Reply

  48. Hello, i’ve done all your recomended steps

    [ 46.950383] spidev spi0.0: Deleting spi0.0
    [ 46.951728] fbtft_device: GPIOS used by ‘fb_ili9341’:
    [ 46.951742] fbtft_device: ‘reset’ = GPIO23
    [ 46.951751] fbtft_device: ‘dc’ = GPIO24
    [ 46.951759] fbtft_device: ‘led’ = GPIO18
    [ 46.951775] spidev spi0.1: spidev spi0.1 500kHz 8 bits mode=0x00
    [ 46.951790] spi spi0.0: fb_ili9341 spi0.0 16000kHz 8 bits mode=0x00
    [ 46.957365] fb_ili9341: module is from the staging directory, the quality is unknown, you have been warned.
    [ 47.284612] graphics fb1: fb_ili9341 frame buffer, 320×240, 150 KiB video memory, 16 KiB DMA buffer memory, fps=20, spi0.0 at 16 MHz
    i think the display should work, but i dosen’t
    when i type in con2fbmap 1 1 nothing happen, the screen is white.
    when i type in sudo FRAMEBUFFER=/dev/fb1 startx the screen is for 1 second black then it change to white again.

    i would appreciate your help.

    Reply

  49. cat /dev/urandom > /dev/fb1
    also don’t work. i have also changed the display.

  50. Does this work with the ILI9341 with a screen of 2.8”?

    Thanks in advance.

    Reply

  51. Hi Gabriel,
    It should work. You might need to adjust the rotation if the screen isn’t exactly the same. But as long as the chipset and resolution are the same, it should work.

    Cheers

  52. This worked great! Thanks

    One thing to note, on a few of my displays the pin names were a little different: most notably “bl” was labeled “led”

    Reply

  53. Good to hear!
    BL stands for BackLight so LED will do the same 🙂

  54. Hello, anyone tried to set this up with dual ili9341?
    Any advice?

    Reply

.END

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.