Software Setup

This guide picks up where the PlatformDetect guide left off, so make sure to follow that first if you haven't.

The first thing we will need to do is decide on the GPIO library we will be using. If there is a manufacturer specific library available such as RPi.GPIO or Jetson.GPIO, then that is preferred, since the access times are much better. However, if that option isn't available, then we will turn to libgpiod which is available for a huge number of boards as it is built into the Linux Kernel.

For the Pine64, although RPi.GPIO was ported over, I ran into an unresolved issue, so we decided to go with libgpiod. Generally libgpiod is available as an installable package, but it's possible that you may need to compile it from source. For the Pine64, it was available as a package.

Installing the libgpiod as a package

First we want to check if it's available. To do this, we run the following command:

  • sudo apt-cache search gpiod

It should output something similar to the following:

The items of interest in this list are libgpiod2, python3-libgpiod, and gpiod. libgpiod2 is the actual libgpiod, python3-libgpiod is the Python binding that allows us to make use of the library through Python, and gpiod contains the tools that we'll need to figure out which microprocessor pins are the correct ones. Let's go ahead and install all three with the following command:

  • sudo apt-get install libgpiod2 python3-libgpiod gpiod

Installing libgpiod from source

Normally compiling libgpiod from source can be complicated. We have a script available that will do just about everything for you. To run it, you need to start by becoming root, so type sudo bash. Then run the following commands:

  • cd ~
  • wget https://raw.githubusercontent.com/adafruit/Raspberry-Pi-Installer-Scripts/master/libgpiod.sh
  • chmod +x libgpiod.sh
  • ./libgpiod.sh

This will take a few minutes to run.

Testing the libgpiod installation

After installation you should be able to import gpiod from within Python3

Install I2C Tools

To test I2C, you will want to install the I2C Tools with the following commands. If your username is different than pi, change it as appropriate:

  • sudo apt-get install -y python3-smbus python3-dev i2c-tools
  • sudo adduser pi i2c

Getting a copy of the code

Step 1 - Fork Blinka to your GitHub account

If you don't already have the code from Adafruit_Blinka forked to your local GitHub repository, you'll want to start off by doing that. If you are not sure how to use GitHub, we have an excellent guide available on using Git and GitHub.

Step 2 - git clone the Blinka fork to your single board computer

Once you have forked it, you can clone the repository both onto your local computer and onto your SBC. By using your local repository as a copy point, this makes things really easy. If you'd prefer to just edit right on your SBC and commit from there, you can do that too. In this guide, we'll assume you cloned it to your home directory on your SBC.

Some other options for copying over the files include using SFTP and an FTP client such as FileZilla or SCP. However, you decide to do it, the guide will assume that you have a copy of the repository in your home directory and that it is located inside the folder ~/Adafruit_Blinka.

This guide was first published on Apr 01, 2020. It was last updated on Apr 01, 2020.
This page (Software Setup) was last updated on Jun 17, 2020.