hello@pi0cket.com

Menu

Tiny Software for TinyPi

So your TinyPi is all built, but your going to need something on that SD Card for it to really shine!!

I have made a basic RetroPie image for speedy deployment. It can be found here and is basically a simple RetroPie image modified to use the screen and the buttons.

There is a TinyPi edition of PicoPie in the pipes, and as soon as it is available I will update this guide. Until then, you can build your own using raspbian lite as its base, and following the same guide below.

So if you want to make your own build, I will guide you down the rabbit hole 🙂

Your first job is to go and get yourself a base image. You can try here for RetroPie, or here if you want Raspbian Lite for some pico-8 goodness.

Once you have downloaded the image, you need to ‘burn’ it to the SD Card. There is much more info here and its probably best to let the pro’s explain it!!

Now your SD card is ready, you have 2 options. You can either reach for a keyboard and monitor and connect to the pi directly, or use SSH to control your TinyPi remotely. The rest of the commands in the guide will still work in the same way. Now the keyboard and monitor option is simpler, and the ssh option is more advanced, however if your willing to build your own TinyPi image, then maybe ssh is commonplace to you.

So by this point in the guide I am assuming that you have your build, and you are connected via your method of choice, lets start off by doing some housekeeping. Firstly lets make sure linux is up to date by typing these commands

sudo apt-get update sudo apt-get upgrade

with the last command, you may be prompted to confirm the installation of the update. Simply enter ‘Y’ and it will continue. It may take a few moments to complete and get back to the command prompt. Next up we need to adjust some of the pi settings by typing

sudo raspi-config

here you will be presented with a nice menu system where we can tweak a few things.

  • First one to check is ‘expand file system’ to ensure that all your SD card is being used for storage. This should run automagically on first boot, but there is no harm in checking.
  • Next up is to enable ‘SPI’ inside ‘Advanced Options’ and then ‘SPI’. You will simply get a yes/no option for the ‘SPI’ setting.
  • Now you want to make some audio adjustments. Back in the ‘Advanced Options’ section, select ‘Audio’, which will allow you to decide where the sound goes. In here, you need to select ‘Force 3.5mm (‘headphone’) jack’ to make sure the correct part of the Pi is being used for the audio.
  • One final change in the ‘Advanced Options’ section is ‘Overscan’. When asked ‘Would you like to enable compensation for displays with overscan?’ you can select No, which will disable overscan.

Now that these settings have been altered, its probably best to restart. The raspi-config menu may ask anyway when you exit, but if not, there is a reboot command

sudo reboot

So you have everything set ready, its time to get that tiny screen working. We start by enabling some modules, and so need to edit a config file. If you type the command

sudo nano /etc/modules

you will be presented with the ‘nano’ text editor, which you will be quite familiar with by the end of this guide! now there may already be some text in this file, and it may have comments, which start with the hash symbol ‘#’. if you add the following into the file (if the lines are not already there)

spi-bcm2835 fbtft_device

the first line is to make sure the SPI connection for the screen is up and running, and the seconds command is to actually start the screen. You will need to save your newly edited file. The command for this is to hold the ‘ctrl’ key on the keyboard, and press the letter ‘o’. you will get a prompt to confirm the filename which you can just press enter on. Now to close the file and get back to the command prompt, you can press ‘ctrl+x’. Now that we are telling the Pi to start the screen, we need to make sure that the Pi knows what kind of screen we are using. Have no fear, there is a config file for that!! Try typing this

sudo nano /etc/modprobe.d/fbtft.conf

Now this file will be blank by default, so we will need to fill it with some text

options fbtft_device name=fb_ili9163 gpios=reset:25,dc:24 speed=40000000 bgr=1 fps=60 custom=1

now this file sets the type of screen in use (ili9163), specifies some of the additional gpio pins in use, sets the speed of comunication, sets the colour mode (bgr = blue/green/red), fps sets the target update speed, and custom says that we have tweaked a few settings. Press ‘ctrl+o’ to save the file (with enter to confirm the filename) and ‘ctrl+x’ to close the file. Now this should be enough to get the screen working, but now we need to give the screen a way to display whats going on. First off, we need to add some tools to work with

sudo apt-get install cmake git

and now we have the tools, we can grab the code from github, and build it

cd ~ git clone https://github.com/tasanakorn/rpi-fbcp cd rpi-fbcp/ mkdir build cd build/ cmake .. make sudo install fbcp /usr/local/bin/fbcp

With that installed, we can move on to making the buttons work. Lets grab some more stuff from adafruit on there github

cd ~ git clone https://github.com/adafruit/Adafruit-Retrogame cd Adafruit-Retrogame/ sudo make install

Now the retrogame program needs an additional config file to make it work properly, so we will need to create that by typing

sudo nano /etc/udev/rules.d/10-retrogame.rules

And then furnish this file with the following information

SUBSYSTEM==”input”, ATTRS{name}==”retrogame”, ENV{ID_INPUT_KEYBOARD}=”1″

Save the file (‘ctrl+o’ and then enter) then close the file (‘ctrl+x’) and we are on the home straight!! We have one more config file left to change now, and this is the file that sets what happens while your TinyPi is booting. So type this

sudo nano /etc/rc.local

There will be something in this file, so we need to take care where we start typing. Basically there is a section that will print your IP address to the terminal, then a gap, then an exit command. In that gap, you want to add a few lines, then insert the following commands

fbcp& sudo retrogame&

Now these 2 commands have some meaning. The first one is fbcp and is the first program we installed. This is the program that copies the game output to the tft screen. the ampersand is there to force the command to run in the background so the next line of code can run. This next line of code is the retrogame code. This will read the status of your TinyPi buttons and will convert them into something that the games will understand. This one seems to need the addition of the sudo command for some reason. Your files should look something like this

_IP=$(hostname -I) || true if [ “$_IP” ]; then printf “My IP address is %s\n” “$_IP” fi fbcp& sudo retrogame& exit 0

save your file (‘ctrl+o’ and then return) and then close the file (‘ctrl+x’) then take a deep breath!! You have only one step left, but we now need a computer for this!! Shut your pi down by typing

sudo shutdown -h now

and wait for it to properly shut down (the activity led will flash 3 times then go off) cut the power, and remove the SD card. Place this SD card into the computer and open the ‘boot’ folder that should appear from inserting the card. Once in this folder you will see there are plenty of files. The file we are interested in here is called ‘config.txt’. If you open this file, you will see there are lots of commands and settings here. Scroll to the bottom of the file and add the following lines

dtoverlay=pwm-2chan,pin=18,func=2,pin2=13,func2=4 hdmi_force_hotplug=1 hdmi_cvt=128 128 60 1 0 0 0 hdmi_group=2 hdmi_mode=1 hdmi_mode=87 display_rotate=2

The first line is to set the audio correctly, and the rest is associated with the screen. We are forcing the HDMI port to be active, setting the screen size and resolution, setting some other screen parameters, and finally flipping the screen, as by default the screen likes to work upside down!! Save this file, and close it, and then there is only one job left!! There is a config file that the restogame program needs to make it know which pin from the pi is associated with which button. This file is called ‘retrogame.cfg’, and while you could create one yourself, i have done the job for you!! Simply copy the file from here and drop it into the boot folder, alongside the config.text file you edited before. Safely remove your SD card, and give yourself a pat on the back!! You can drop the card back into your TinyPi and fire it up and enjoy some gaming !!! 🙂

13 thoughts on “Tiny Software for TinyPi”

  1. Rienen says:

    I have a solid green line across the top of the screen. Any idea how to fix that?

    1. admin says:

      Hi there

      Sorry for the delay in replying, getting a lot of spam on the site!!

      the green line is a battery gauge, it will get shorter, and turn to red as the battery runs down. We have been asked a few times to remove it, so we are investigating that.

  2. brainstewdgeek says:

    Hey! The Pi keeps crashing and turning off and or what looks like a memory issue. Wondering if it’s the image itself or the PCB board – or something else.

    1. admin says:

      Hi there. Have you enabled the overclock in the config.txt? This has caused similar issues in the past

  3. brainstewdgeek says:

    I had not – should I just use the values commented out? Or are there specific values

    1. admin says:

      Overclocking is a little unstable on it pi0. Do you have access to another pi?

  4. brainstewdgeek says:

    I do – I can try a different pi

  5. brainstewdgeek says:

    To clarify, should I not enable the overclock?

  6. Nathan97 says:

    Help! i did everything as it follows, but now my screen is blank. Got no video.
    And the HDMI isn’t working as well

    What could i have done wrong?

    1. admin says:

      Hi There

      you can try booting the pi on its own, and see if the activity light flickers. if it doesnt, then your sd card might not have burnt right.

      if thats ok, then check the pins are the right way round, and are sitting flush to the pi. You can also check the recesses that the boards sit into, make sure there is no printing dust in the way.

      The HDMI wont work by default, the resolution is forced to 240×240 pixels, which most hdmi monitors can not accept

  7. pattycakes98 says:

    Hello!

    At this juncture here “cmake .. make sudo install fbcp /usr/local/bin/fbcp” I get this message:

    “CMake Error: The source directory “/usr/local/bin/fbcp” does not appear ro contain CheckLists.txt.

    Any suggestions on what I could do to fix this problem? Thanks!

    1. pattycakes98 says:

      *to contain CMakeLists.txt

      My apologies

  8. kasus says:

    Hi!

    Got a question – everything seems to work just fine, but it ends up at login prompt with RPi logo, somehow retrogame does not start on RPi. I run RPi headless, so no keyboard is attached – is there a way to start up this retrogame without external keyboard? Thanks in advance!

Leave a Reply