The idea for the TRNG sending code is very simple:
- Get TRNG data from Trust M
- Send TRNG data over USB CDC serial
- Repeat
There is currently only an Arduino library available for talking to the Trust M, so we'll do everything using Arduino.
The complete Arduino sketch code is provided later in this guide to allow customizing. Here we provide some pre-compiled examples in UF2 format. With these UF2 files, you can just drag-and-drop to the Trinkey QT2040 RPI-RP2 bootloader folder. The Arduino IDE does not even need to be installed.
Installing UF2 Examples
To install the UF2 files:
- Put the Trinkey QT2040 in bootloader mode by holding the BOOT button while pressing the RST (reset) button.
- A folder named RPI-RP2 should appear.
- Drag the UF2 file to the RPI-RP2 folder.
- Once copied, board should reset and code is now running.
Send Raw Bytes
This example sends a continuous stream of raw bytes. This behaves much like dumping /dev/random
on a linux machine. Here's the UF2:
With that running on the Trinkey QT2040, the serial output will look like this (screen was used to connect):
It's raw bytes, so will look like gibberish.
Want something more human readable? OK, let's try some formatted string output next.
With that running on the Trinkey QT2040, the serial output will look like this:
Send JSON Formatted Text
This example provides JavaScript Object Notation (JSON) formatted text. Here's the UF2:
With that running on the Trinkey QT2040, the serial output will look like this: