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

The first thing you will need to do is decide on the GPIO library you 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 you will want to 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 I 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 libgpiod as a package

First you want to check if it's available. To do this, you 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 which is the actual libgpiod
  • python3-libgpiod which is the Python binding that allows us to make use of the library through Python
  • gpiod which contains the tools that you'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

If libgpiod isn't available on the OS for the board you are configuring, you can also compile from source. Normally compiling libgpiod from source can be complicated. There is a script available that will do just about everything for you. To run it, you need to use the following commands:

cd ~
sudo pip3 install --upgrade adafruit-python-shell click
sudo python3

This will take a few minutes to run. If you get an error, try adding the -l or --legacy flag to the last command.

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, it assumes 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 May 25, 2024.

This page (Software Setup) was last updated on Mar 08, 2024.

Text editor powered by tinymce.