Debugger-based On-Target Testing
External Test Equipment

By nature, the DOTT framework is open for the integration of arbitrary external test equipment as long as there are Python libraries available for interfacing the equipment. DOTT does not come with a pre-integrated set of such libraries. The section below about PIGPIO is just an example how to utilize a Raspberry Pi you might have anyway sitting on your desk as an USB to I2C (or SPI) bridge from within your tests. This setup is also shown and used in one of the examples shipped with DOTT.

Raspberry Pi with PIGPIOD

The PIGPIO Python library together with the PIGPIO daemon installed on a Raspberry Pi enables users to use a Raspberry PI as an I2C or SPI master from within the DOTT test framework. The following figure gives an overview of that setup. The test host, with installed DOTT framework and pigpio library, connects to the Raspberry PI via TCP/IP. There, the pigpio daemon receives these incoming calls and translates them to I2C, SPI, UART of simple GPIO transactions on the I/O pins of the Raspberry.

|------------| TCP/IP |---------------| I2C, SPI, ... |--------|
| TEST HOST | <----------> | RASPBERRY PI | <---------------> | TARGET |
| | | | | |
| DOTT with | | pigpio daemon | | |
| pigpio lib | | | | |
|------------| |---------------| |--------|

Pigpio is a public domain, 3rd party package which is available here of can be downloaded form GitHub. The pigpio Python library for the host is installed with. The setup procedure for the pigpio daemon on the RaspberryPi is provided in the next section.

Raspberry Pi Setup

  • Get a Raspberry Pi 3 (or 4) together with a reasonably fast MicroSD card (e.g., SanDisk Extreme) of at least 8GB
  • Install Raspberry Pi OS (formerly Raspbian)
  • Configure the system according to your likings and make sure that it can be reached from your test host via TCP/IP
  • Install PIGPIO:
# install pigpiod
$ sudo apt-get install pigpio
$ sudo systemctl enable pigpiod.service
$ sudo systemctl start pigpiod.service
# On Raspbian Stretch pigpiod per default only binds to IPv6.
# If you prefer IPv4 instead, execute the following steps:
# Open /etc/modprobe.d/ipv6.conf and add the following line at the bottom:
blacklist ipv6
# Edit the pigpiod service file /lib/systemd/system/pigpiod.service (remove the '-l' option for ExecStart):
[Unit]
Description=Daemon required to control GPIO pins via pigpio
[Service]
#ExecStart=/usr/bin/pigpiod -l
ExecStart=/usr/bin/pigpiod
ExecStop=/bin/systemctl kill pigpiod
Type=forking
[Install]
WantedBy=multi-user.target
# Next reboot your Raspberry.
$ sudo systemctl reboot
# After reboot check if pigpiod is now listening on port 8888 and is bound to IPv4:
$ netstat -ln | grep 8888
tcp 0 0 0.0.0.0:8888 0.0.0.0:* LISTEN

Basic Usage Example

Below is a simple Python code snippet which uses the pigpio library to connect to a Raspberry PI which is running a pigpiod instance. Connected to it is an I2C slave of which a register is written and read back.

import pigpio, logging
def test_RegWriteRead(self):
logging.getLogger().debug("Starting register write/read test.")
reg_addr = 0x40
# connect to Raspberry Pi
pi = pigpio.pi("10.10.171.82")
# open I2C bus 1, set I2C device slave address to 0x52
dev = pi.i2c_open(1, 0x52)
# clear and verify the register
pi.i2c_write_byte_data(dev, reg_addr, 0x0)
val = pi.i2c_read_byte_data(dev, reg_addr)
assert(0x0 == val), ("Clearing register 0x%x failed." % reg_addr)
# write and verify test value
pi.i2c_write_byte_data(dev, reg_addr, 0xa5)
val = pi.i2c_read_byte_data(dev, reg_addr)
assert(0xa5 == val), ("Writing test value to register 0x%x failed." % reg_addr)

PIGPIO Python Documentation

The full documentation for the Python pigpio library is available online.