|
1 | 1 |  |
2 | 2 | # Running Mbed Crypto examples on Mbed OS |
3 | | -This repository contains a set of examples demonstrating the compilation and use of Mbed Crypto on Mbed OS. |
4 | | - |
5 | | -List of examples contained within this repository: |
6 | | -* Example code snippets for using the library, with [documentation](https://github.com/ARMmbed/mbed-crypto/blob/development/docs/getting_started.md). |
| 3 | +This repository contains an example demonstrating the compilation and use of PSA Crypto on Mbed OS. |
7 | 4 |
|
8 | 5 | ## Prerequisites |
9 | | -* Install <a href='https://github.com/ARMmbed/mbed-cli#installing-mbed-cli'>Mbed CLI</a> |
| 6 | +This example requires the PSA Crypto API: |
| 7 | +* On TF-M targets, this API is provided by TF-M and always enabled. |
| 8 | +* On other targets, Mbed OS PSA can be enabled by adding `target.extra_labels_add": ["MBED_PSA_SRV"]` |
| 9 | +to `target_overrides` in [`getting-started/mbed_app.json`](./getting-started/mbed_app.json). Note that |
| 10 | +this cannot coexist with TF-M. |
| 11 | + |
| 12 | +## Mbed OS build tools |
| 13 | + |
| 14 | +### Mbed CLI 2 |
| 15 | +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](#mbed-cli-1). |
| 16 | +1. [Install Mbed CLI 2](https://os.mbed.com/docs/mbed-os/latest/build-tools/install-or-upgrade.html). |
| 17 | +1. From the command-line, import the example: `mbed-tools import mbed-os-example-mbed-crypto` |
| 18 | + |
| 19 | +### Mbed CLI 1 |
| 20 | +1. [Install Mbed CLI 1](https://os.mbed.com/docs/mbed-os/latest/quick-start/offline-with-mbed-cli.html). |
| 21 | +1. From the command-line, import the example: `mbed import mbed-os-example-mbed-crypto` |
| 22 | + |
| 23 | +## Building and running |
| 24 | + |
| 25 | +1. Change the current directory to `mbed-os-example-mbed-crypto/getting-started`. |
| 26 | +1. Connect a USB cable between the USB port on the board and the host computer. |
| 27 | +1. Run the following command to build the example project, program the microcontroller flash memory and open a serial monitor: |
10 | 28 |
|
11 | | -## Import |
12 | | -The following are the steps required to install the application: |
13 | | -1. Clone the repository: `git clone https://github.com/ARMmbed/mbed-os-example-mbed-crypto.git` |
14 | | -1. Navigate to the "getting-started" example: `cd mbed-os-example-mbed-crypto/getting-started` |
15 | | -1. Deploy the Mbed OS project: `mbed deploy` |
| 29 | + * Mbed CLI 2 |
16 | 30 |
|
17 | | -## Compile |
18 | | -To compile the example program use `mbed compile` while specifying the target platform and the compiler. |
19 | | -For example, in order to compile using the ARM GCC compiler and a K64F target platform use: `mbed compile -m K64F -t GCC_ARM`. |
| 31 | + ```bash |
| 32 | + $ mbed-tools compile -m <TARGET> -t <TOOLCHAIN> --flash --sterm |
| 33 | + ``` |
20 | 34 |
|
21 | | -Once the compilation is completed successfully a binary file will be created: `./BUILD/K64F/GCC_ARM/getting-started.bin` |
| 35 | + * Mbed CLI 1 |
22 | 36 |
|
23 | | -## Program your board |
24 | | -1. Connect your Mbed device to the computer over USB. |
25 | | -1. Copy the binary file (`getting-started.bin`) to the Mbed device. |
| 37 | + ```bash |
| 38 | + $ mbed compile -m <TARGET> -t <TOOLCHAIN> --flash --sterm |
| 39 | + ``` |
26 | 40 |
|
27 | | -## Run |
28 | | -1. Connect to the Mbed Device using a serial client application of your choice. |
29 | | -1. Press the reset button on the Mbed device to run the program. |
| 41 | +Your PC may take a few minutes to compile your code. |
30 | 42 |
|
31 | | -The expected output from the first successful execution of the example program should be as follows: |
| 43 | +## Expected output |
32 | 44 | ``` |
33 | 45 | -- Begin Mbed Crypto Getting Started -- |
34 | 46 |
|
|
0 commit comments