Device key example for Mbed OS
This is an example of an application that uses the DeviceKey APIs. The application injects a dummy root of trust (ROT) if true random number generator (TRNG) is not avalable. The application also invoke the derive key API several times in diffrent conditions and print the result.
- An mbed-os supported development board.
- A micro-USB cable.
Starting with version 6.5, Mbed OS uses Mbed CLI 2. It uses Ninja as a build system, and CMake to generate the build environment and manage the build process in a compiler-independent manner. If you are working with Mbed OS version prior to 6.5 then check the section Mbed CLI 1.
- Install Mbed CLI 2.
- From the command-line, import the example:
mbed-tools import mbed-os-example-devicekey
- Change the current directory to where the project was imported.
- Install Mbed CLI 1.
- From the command-line, import the example:
mbed import mbed-os-example-devicekey
- Change the current directory to where the project was imported.
-
Connect a USB cable between the USB port on the target and the host computer.
-
Run the following command to build the example project and program the microcontroller flash memory:
- Mbed CLI 2
$ mbed-tools compile -m <TARGET> -t <TOOLCHAIN> --flash --sterm
- Mbed CLI 1
$ mbed compile -m <TARGET> -t <TOOLCHAIN> --flash --sterm
Your PC may take a few minutes to compile your code.
The binary is located at:
-
Mbed CLI 2 -
./cmake_build/<TARGET>/develop/<TOOLCHAIN>/mbed-os-example-devicekey.bin
-
Mbed CLI 1 -
./BUILD/<TARGET>/<TOOLCHAIN>/mbed-os-example-devicekey.bin
.
You can manually copy the binary to the target, which gets mounted on the host
computer through USB, rather than using the --flash
option.
You can also open a serial terminal separately, rather than using the --sterm
option, with the following command:
-
Mbed CLI 2
$ mbed-tools sterm
-
Mbed CLI 1
$ mbed sterm
The expected log can be found in tests/devicekey.log
.
If you have problems, you can review the documentation for suggestions on what could be wrong and how to fix it.
The software is provided under Apache-2.0 license. Contributions to this project are accepted under the same license. Please see contributing.md for more info.
This project contains code from other projects. The original license text is included in those source files. They must comply with our license guide