Installing pyftdi on Ubuntu 18.04 for FT232H and FT2232H boards

Why use  FT232H and FT2232H boards?

I wanted to use a FT232H board for some hardware hacking. The FTDI FTxxx family of devices and boards based on this chip is categorized as a Multi-Protocol Synchronous Serial Engine (MPSSE), which can be used to debug UART, I2C, SPI and JTAG devices.  I’ve used single-purpose devices, as well as the BusPirate, however there are limitations.

I like the BusPirate a lot. It’s fun to use and has many handy features. But it’s slow, and doesn’t support JTAG very well. The FT2xx family of chips do a much better job.

I have several boards that use this chip, including:

Others include:

I looked at some  libraries and software, but I wanted one that supported all the chips I have, including the  FT2232H-based TUMPA board. I also wanted to use python, a popular language for hardware hacking.

What’s the difference between the FT232H and FT2232H chips?

There are a few differences between FT232H and FT2232H boards.

  • The FT2232H supports two connections, so you can connect to two devices, or access two different protocols on the same target board. So you can access both SPI and I2C, or I2C and JTAG.
  • The FT232H has a 1KB Ring buffer, while the FT2232H has a 4KB buffer.
  • The FT2232H has 16 GPIO pins.

By the way, the FT4232H chip supports 4 channels, compared to the FT2232H’s 2 channels and the FT232H’s single channel. So think of the variations as a single, dual or quad version of the same MPSSE.

Preparing Ubuntu so that your normal (non-root) account can install python-based software

Before we install the software, there are a few options:

  • Install it as root. That is, do everything as root. Besides a potential security risk, this can cause problems if you combine installing software using other package managers, you can get inconsistencies and conflicts.
  • Install the files into non-standard locations. This is more difficult to set up, and if you have other packages, you may have to deal with multiple versions and locations
  • Give yourself the ability to install software as a non-root, but privileged user. This is the directions I took.

Ubuntu uses the group staff as the group that can work with installed files. In particular,  the directory /usr/local/lib/python3.6/dist-packages belongs to group staff. However, members of the group staff do not have write permission. This can be fixed using

sudo chmod g+w /usr/local/lib/python3.6/dist-packages

Also, the executable directory /usr/local/bin belongs to group root. We need to change this to group staff and make it group writable:

sudo chgrp staff /usr/local/bin
sudo chmod g+w /usr/local/bin

There is another step – add yourself to group staff.

sudo addgroup $USER staff

However, before you can install the software, you have to log out and log in. Use the command groups(1) to make sure you are in the group.

I decided to use this method, because:

  • I can easily install and debug utilities without becoming root.
  • Any changes I make are easily located (and removed) because I own the files, and not root. If another package re-installs the files and erases changed I make can be located.

Installing pyftdi

I started with a fairly clean version of Ubuntu. I downloaded the pyftdi source from the Github respository.  Note that the repository is likely more up-to-date. I had build errors untill I used the most recent version. The code uses python3, (you will get syntax errors if you use python 2) and you have to install the python setup tools if you haven’t already:

sudo apt-get install python3-setuptools

Now go to your repository and type the following:

python3 ./setup.py build
python3 ./setup.py install

That should be all you need to do. This will install the script i2cscan into /usr/local/bin. You can execute it to test the program.

I’ll describe i2cscan in another post.

 

 

 

 

 

Advertisements
This entry was posted in Hacking, Hardware Hacking, Linux and tagged , , , , , , , , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.