nRF5340: nRF RPC Entropy

The nRF RPC Entropy sample demonstrates how to use the entropy driver in a dual core device such as nRF5340 DK.

The sample uses the entropy driver on the network core of an nRF5340 DK that generates random data, and the Remote procedure call library (nRF RPC) that sends the generated data to the application core using Remote Procedure Calls (RPC).

Requirements

The sample supports the following development kit:

Hardware platforms

PCA

Board name

Board target

nRF5340 DK

PCA10095

nrf5340dk

nrf5340dk/nrf5340/cpunet nrf5340dk/nrf5340/cpuapp

Overview

The entropy data is generated on the network core using the Random Number Generator (RNG) peripheral. The Remote procedure call library (nRF RPC) uses the zcbor to encode data, into the CBOR format, and transmits the data using the default RPMsg Messaging Protocol (part of OpenAMP) in the transport layer.

The application core uses serialized function calls such as entropy_remote_init() and entropy_remote_get() to control the entropy driver on the network core as follows:

  • The entropy_remote_init() function is used for initializing the entropy.

  • The entropy_remote_get() function is used for obtaining the entropy data.

When the sample starts, it displays the generated entropy data in the terminal at an interval of two seconds.

Network core

The network core runs the entropy drivers that use the RNG peripheral. When the network core receives the entropy_remote_get() remote function call, the following operations are performed:

  • The network core searches for function decoders in the decoders table and calls them.

  • The network core encodes the response data for the function call and sends the data back to the application core.

Application core

The application core runs a simple application that replaces the entropy driver functions and asynchronous events with the virtual implementation using the Remote procedure call library (nRF RPC).

Building and running

This sample can be found under samples/nrf_rpc/entropy_nrf53 in the nRF Connect SDK folder structure.

To build the sample, follow the instructions in Configuring and building an application for your preferred building environment. See also Programming an application for programming steps and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.

Note

When building repository applications in the SDK repositories, building with sysbuild is enabled by default. If you work with out-of-tree freestanding applications, you need to manually pass the --sysbuild parameter to every build command or configure west to always use it.

Testing

This sample consists of the following sample applications:

  • Application core sample: entropy_nrf53/cpuapp

  • Network core sample: entropy_nrf53/cpunet

Build and program both of these sample applications to the dual core device before testing. For details on building samples for a dual core device, see Building and programming with nRF53 Series.

After programming the sample applications to your development kit, complete the following steps to test this sample:

  1. Connect the dual core development kit to the computer using a USB cable. The development kit is assigned a COM port (Windows) or ttyACM device (Linux), which is visible in the Device Manager.

  2. Connect to the kit with a terminal emulator (for example, nRF Connect Serial Terminal). See Testing and optimization for the required settings and steps.

  3. Reset the development kit.

  4. Observe that the entropy data is displayed periodically in the terminal.

Sample output

The following output is displayed in the terminal:

Entropy sample started[APP Core].
 0x43  0xd1  0xd6  0x52  0x6d  0x22  0x46  0x58  0x8f  0x15
 0xcf  0xe1  0x1a  0xb5  0xa6  0xdb  0xe5  0xf7  0x7e  0x37

Dependencies

This sample uses the following sdk-nrfxlib library:

It also uses the following Zephyr library: