Remote control of the target

The FPGA target can be connected to the PC via UART. Many development boards, such as the Digilent Arty7, include a convenient USB-to-UART port for this purpose.

Establish connection to the hardware

On Linux, access to the /dev/ttyUSB* device requires membership in the dialout or plugdev group, depending on the distribution. The PySerial Python module must also be installed, as detailed in the requirements section.

By default, the Python scripts open the /dev/ttyUSB1 device. If the target is mapped to a different peripheral, copy the settings.py.in file to settings.py and modify the tty variable 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.