Skip to content

Commit e9b4f57

Browse files
authored
Merge pull request #95 from LDong-Arm/tfm_support
Support PSA Crypto from TF-M
2 parents f204f89 + 6f83f7c commit e9b4f57

File tree

5 files changed

+87
-164
lines changed

5 files changed

+87
-164
lines changed

.travis.yml

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,7 @@
1616

1717
language: sh
1818
os: linux
19-
dist: xenial
20-
21-
env:
22-
global:
23-
- PROFILE=develop
19+
dist: focal
2420

2521
cache:
2622
pip: true
@@ -33,9 +29,8 @@ cache:
3329
addons:
3430
apt:
3531
sources:
36-
- sourceline: 'deb https://apt.kitware.com/ubuntu/ xenial main'
32+
- sourceline: 'deb https://apt.kitware.com/ubuntu/ focal main'
3733
key_url: 'https://apt.kitware.com/keys/kitware-archive-latest.asc'
38-
- sourceline: 'deb https://apt.kitware.com/ubuntu/ xenial-rc main'
3934
packages:
4035
- cmake
4136
- ninja-build
@@ -45,7 +40,7 @@ matrix:
4540

4641
- &cmake-build-test
4742
stage: "CMake"
48-
name: "CMake Mbed Crypto example - develop (K64F)"
43+
name: "CMake PSA Crypto example - develop (K64F)"
4944
env: NAME=cmake_test TARGET_NAME=K64F PROFILE=develop CACHE_NAME=develop-K64F
5045
language: python
5146
python: 3.8
@@ -74,22 +69,30 @@ matrix:
7469
# version, we must instead delete the Travis copy of CMake.
7570
- sudo rm -rf /usr/local/cmake*
7671
- pip install --upgrade mbed-tools
77-
- pip install prettytable==0.7.2
78-
- pip install future==0.16.0
79-
- pip install "Jinja2>=2.10.1,<2.11"
80-
- pip install "intelhex>=1.3,<=2.2.1"
81-
script:
8272
- cd getting-started
83-
- mbedtools checkout
84-
- echo mbedtools build -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE}
85-
- mbedtools build -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE}
73+
- mbedtools deploy
74+
- pip install -r mbed-os/requirements.txt
75+
script:
76+
- echo mbedtools compile -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE}
77+
- mbedtools compile -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE}
8678
- ccache -s
87-
- cd ..
8879

8980
- <<: *cmake-build-test
90-
name: "CMake Mbed Crypto example - release (K64F)"
81+
name: "CMake PSA Crypto example - release (K64F)"
9182
env: NAME=cmake_test TARGET_NAME=K64F PROFILE=release CACHE_NAME=release-K64F
9283

9384
- <<: *cmake-build-test
94-
name: "CMake Mbed Crypto example - debug (K64F)"
85+
name: "CMake PSA Crypto example - debug (K64F)"
9586
env: NAME=cmake_test TARGET_NAME=K64F PROFILE=debug CACHE_NAME=debug-K64F
87+
88+
- <<: *cmake-build-test
89+
name: "CMake PSA Crypto example - develop (ARM_MUSCA_S1)"
90+
env: NAME=cmake_test TARGET_NAME=ARM_MUSCA_S1 PROFILE=develop CACHE_NAME=develop-ARM_MUSCA_S1
91+
92+
- <<: *cmake-build-test
93+
name: "CMake PSA Crypto example - release (ARM_MUSCA_S1)"
94+
env: NAME=cmake_test TARGET_NAME=ARM_MUSCA_S1 PROFILE=release CACHE_NAME=release-ARM_MUSCA_S1
95+
96+
- <<: *cmake-build-test
97+
name: "CMake PSA Crypto example - debug (ARM_MUSCA_S1)"
98+
env: NAME=cmake_test TARGET_NAME=ARM_MUSCA_S1 PROFILE=debug CACHE_NAME=debug-ARM_MUSCA_S1

README.md

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,48 @@
11
![](./resources/official_armmbed_example_badge.png)
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).
2+
# Running PSA Crypto examples on Mbed OS
3+
This repository contains an example demonstrating the compilation and use of PSA Crypto on Mbed OS.
74

85
## 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:
1028

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
1630

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+
```
2034

21-
Once the compilation is completed successfully a binary file will be created: `./BUILD/K64F/GCC_ARM/getting-started.bin`
35+
* Mbed CLI 1
2236

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+
```
2640

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.
3042

31-
The expected output from the first successful execution of the example program should be as follows:
43+
## Expected output
3244
```
33-
-- Begin Mbed Crypto Getting Started --
45+
-- Begin PSA Crypto Getting Started --
3446

3547
Import an AES key... Imported a key
3648
Sign a message... Signed a message
@@ -44,7 +56,7 @@ Authenticate encrypt... Authenticated and encrypted
4456
Authenticate decrypt... Authenticated and decrypted
4557
Generate a key pair... Exported a public key
4658

47-
-- End Mbed Crypto Getting Started --
59+
-- End PSA Crypto Getting Started --
4860
```
4961
5062
## Troubleshooting

0 commit comments

Comments
 (0)