Remote control of the target

The FPGA target can be connected to the PC through an UART. Convenient USB-UART port is provided with many development board such as for Digilent Arty7.

Establish connection to the hardware

On Linux you must be in the group dialout or plugdev (depending on your distribution) to access the /dev/ttyUSB* device. The PySerial python module must be installed as detailled in the requirement section.

By default, the Python scripts open the /dev/ttyUSB1 device, if your target is mapped to another peripheral, please copy the file settings.py.in to settings.py and modify the variable tty accordingly.

To test the connection to the target, use the script ping.py located in the directory remote.

$ cd remote
$ python ping.py
OpenTRNG board connection is OK!

Control scripts

Many scripts are provided in the directory remote. As instance, ring-oscillator frequencies can be measured with:

$ python frequency.py -i 0
Measured frequency for RO0: 102.103300MHz

Read 1000 random data generated by the PTRNG with COSO, data are interpreted as words since COSO outputs 32 bits counter values.

$ python readrng.py -count 1000

For more details on their parameters, call the scripts with -h.

Write your own scripts

You can also write your own scripts with the help of the fluart and regmap modules as illustrated in the example below.

import regmap as OpenTRNG
import fluart as Fluart

# Open the UART to the register map
interface = Fluart.CmdProc()
reg = OpenTRNG.RegMap(interface)

# Reset and check the board
reg.control_bf.reset = 1
interface.check(reg.id_bf.uid, reg.id_bf.rev)

# Enable RO0 and RO1
reg.ring_bf.en = 0x1 << 1 | 0x1

# Disable all the ROs
reg.ring_bf.enable = 0x00000000

Details on OpenTRNG/PTRNG’s register map and bit fields can be found here in the PTRNG repository.