Join the Ben Heck team every week for amazing hacks! Watch them build and mod community-inspired projects using electronics!
|The Learning Circuit|
|See All Episodes|
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:
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 126.96.36.199.*
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.