element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
sudo Sergeant
  • Challenges & Projects
  • element14 presents
  • sudo Sergeant
  • More
  • Cancel
sudo Sergeant
Documents sudo Sergeant 13: Driving a TFT Screen Using GPIO
  • Documents
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join sudo Sergeant to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Engagement
  • Author Author: tariq.ahmad
  • Date Created: 28 Feb 2018 8:54 PM Date Created
  • Last Updated Last Updated: 13 Aug 2018 10:56 PM
  • Views 1244 views
  • Likes 4 likes
  • Comments 3 comments
Related
Recommended

sudo Sergeant 13: Driving a TFT Screen Using GPIO

image

element14's The Ben Heck Show

Join the Ben Heck team every week for amazing hacks! Watch them build and mod community-inspired projects using electronics!

Back to The Ben Heck Show homepage image

sudo Sergeant
The Learning Circuit
See All Episodes

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

Felix shows you how to install retropie through terminal and how to drive a TFT screen with the GPIO of a Raspberry Pi. He configures SSH to login and modify some files, adds a custom device tree source file, compiles the device tree source file, and adds some additional lines to the config.txt file in order to get the kernel and operating system working together to drive the TFT screen with GPIO.

 

 

The first thing you want to do is download your disk image of retropie at https://retropie.org.uk/.  You’ll have two different downloads to chose from.  One is for the Raspberry Pi Zero or the first Raspberry Pi and the other is for Raspberry Pi 2 and 3. Felix downloads the version for Raspberry Pi Zero.  Once it downloads Felix takes a look at it in terminal. It will show up in the image directory of terminal as retropie-4.3-rp1_zero.img.gz.  The gz extension at the end means it is a compressed file.  To expand it to an uncompressed file:

$  gunzip -k -v retropie-4.3-rpi1_zero.img.gz

Felix shows a comparison between the compressed and the uncompressed file in terminal.  To find out where the SD card is he uses:

$ lsblk

He uses the dd utility for converting and copying a file.  He goes over the man page for the dd utility to go over the various operands he needs to send to it.  He enters the following in terminal:

$ sudo ./retropie=4.3-rpi1_zero.img of=/dev/sdd bs=10M status=progress

Felix suggests leaving off sudo initially to make sure you’re not writing to the wrong disk.  You’ll see the progress of the operating system moving to the SD card through terminal. Now that the operating system is in the SD card they can attach it to the Raspberry Pi.  As this is the Pi 1,  he’ll also hook it up a USB hub with Ethernet on it, before connecting the hub to a keyboard. Once Retropie boots on the Pi, press F4 and that will take you to terminal.  In terminal you will enter: $ sudo raspi –config This will take you into the configuration menu. Go to interfacing Options.   From there go down to SSH and enable it.  Next go into localization options and change local. You’re going to want to switch it to whatever your local region is.  Felix finds and selects the region code for the US. He also goes over how to set your Timezone, Keyboard Layout, and Wi Fi country.  Next, Felix goes into the Advanced Options where he selects the option to Expand the file system to ensure that all of the SD card storage is available to the OS. After you do all that, reboot the Pi. Felix consults the man page for nmap and uses the nmap utility to find the ip address of the Raspberry Pi through terminal.   In his case it looks like:

$ nmap 102.1.48.1.*

This will scan the network and spit back what it finds. The nmap utiplity reports that the device is connected to the network.  He’s scanning for devices that have SSH Open and there is only one device listed.  Before connecting to the IP address he’ll need to modify the default SSH. To do this he logs in as Pi and edits the SSH config so that he can login as root.  The reason he needs to login as root is so that he can remotely access files on the root directory.  He uses the following command:

$ sudo nano /etc/ssh/sshd_config

He uncomments the option to permit root access.  Now that he’s modified the SSH config file, he’ll need to restart the SSH service:

$ sudo systemctl restart ssh.service He’ll also $ sudo systemctl restart sshswitch.service

Before logging in as root he’ll need to login as pi and set the password for root:

$ sudo passwd root

Once this is done he logs back in as root. The reason he wants to login as root is so that he can use the dolphin file browser and transfer files to the root directory.  Once he logs in as Pi he goes to the boot directory and edits the config.txt file. You’ll need to do this in order to add some custom lines for the TFT screen.  The TFT screen is going to be driven by a device tree overlay.  You can find documentation on the device tree overlay at https://www.raspberrypi.org/documentation/configuration/device-tree.md.  There you can read up on device tree overlays and parameters.  The device tree overlay will be compiled in the boot directory.  On Felix’s local machine he’s able to login the Raspberry Pi over the fish protocol which uses SSH on the backend.

Since he’s logged in as root he can drag and edit files in the boot directory.  He drag over are the gpio-tft-16bit-565.dts which is the source file that once compiled will create the DT –blob.bin file. When the system boots the config.txt file has some configuration lines that refer to the DT –blob.bin file and that enables the Raspberry Pi to drive the TFT screen directly with the GPIO.   Felix walks you through the process of setting that up. Once he’s copied the lines he needs he goes back into terminal to edit the config file.  At the bottom of the file he pastes the lines that he’s copied. He’s commented a compile script which he also drags over to the Pi. He compiles the DTS file and that produces a bin file.  The bin file tells the kernel, the operating system, and everything how to interface with the TFT screen over the GPIO.   At this point you should be able to reboot the Raspberry Pi and the TFT screen should be working.

  • dts file
  • sudo sergeant
  • terminal
  • tft screen
  • compile
  • gpio
  • rpibeginner
  • raspberry pi zero
  • ssh
  • raspberry pi
  • rpiexpert
  • retropie
  • boot
  • device tree overlay
  • sudo
  • sudosergeant
  • linux
  • man pages
  • Share
  • History
  • More
  • Cancel
  • Sign in to reply
  • lasseknudsen
    lasseknudsen over 7 years ago

    Hi,

    It would be greatly appriciated, if you could tell us the model of the TFT you are using, i have not been able to find the model, and the video is partially useless if we dont know what TFT you are using. If you add an schematic that would be even better.

    -lasse

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Sean_Miller
    Sean_Miller over 7 years ago

    Thanks for focusing on this.  It would be nice to have a follow-up showing the hardware side of things as well for a few cheap screens on the market.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • dgjohnson
    dgjohnson over 7 years ago

    which tft screen will this work with and what pins are used to connect the gpio to the tft?

    ...it's not obvious to me.

    thanks,

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube