Skip to content

Commit 789b9f5

Browse files
authored
Merge pull request #293 from wernerlewis/update-cli2
Remove deprecated CMake and add CLI2 instructions
2 parents af62dfa + 2665fa1 commit 789b9f5

File tree

6 files changed

+69
-35
lines changed

6 files changed

+69
-35
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ matrix:
8080
- pip install "intelhex>=1.3,<=2.2.1"
8181
script:
8282
- examples=( authcrypt benchmark hashing tls-client ) ;
83-
- for i in "${examples[@]}" ; do cd $i ; echo cd $i ; mbedtools checkout ; echo mbedtools build -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE} ; mbedtools build -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE} || exit 1 ; cd .. ; done
83+
- for i in "${examples[@]}" ; do cd $i ; echo cd $i ; mbedtools deploy ; echo mbedtools compile -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE} ; mbedtools compile -t GCC_ARM -m ${TARGET_NAME} -b ${PROFILE} || exit 1 ; cd .. ; done
8484
- ccache -s
8585

8686
- <<: *cmake-build-test

README.md

Lines changed: 67 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,86 @@
11
![](./resources/official_armmbed_example_badge.png)
22
# Mbed TLS Examples on Mbed OS
33

4-
This repository contains a collection of Mbed TLS example applications based on Mbed OS. Each subdirectory contains a separate example meant for building as an executable.
4+
The example project is part of the [Arm Mbed OS Official Examples](https://os.mbed.com/code/). This repository contains a collection of Mbed TLS example applications based on Mbed OS. Each subdirectory contains a separate example meant for building as an executable.
55

66
# Getting started
77

88
## Required hardware
9-
* Any Mbed OS capable development board such as those listed [here](https://os.mbed.com/platforms/), which have an entropy source integrated into Mbed TLS. The single example that does not need an entropy source is `hashing`. The `tls-client` example should also have a network interface supported on your board.
10-
* A micro-USB cable.
9+
* Any Mbed OS capable development board such as those listed [here](https://os.mbed.com/platforms/), which have an entropy source integrated into Mbed TLS. The single example that does not need an entropy source is `hashing`. To use the `tls-client` example you should also have a network interface supported on your board.
1110

1211
If your board has no hardware entropy source or its entropy source is not integrated with Mbed TLS, but you want to try these examples anyway, then you may want to consider compiling Mbed TLS without real entropy sources.
1312

1413
*Warning!* Without entropy sources Mbed TLS does not provide any security whatsoever. If you still want to compile Mbed TLS without entropy sources, then consult the section "How to test without entropy sources" in the Mbed TLS Porting Guide.
1514

1615
## Required software
17-
* [Mbed CLI](https://github.com/ARMmbed/mbed-cli) - to build the example program. To learn how to build Mbed OS applications with Mbed CLI, see the [user guide](https://github.com/ARMmbed/mbed-cli/blob/master/README.md)
18-
* [Serial port monitor](https://os.mbed.com/handbook/SerialPC#host-interface-and-terminal-applications).
16+
17+
* [Mbed CLI](https://github.com/ARMmbed/mbed-cli) or [Mbed CLI 2](https://github.com/ARMmbed/mbed-tools). This will be used to configure and build the project.
1918

2019
An alternative to Mbed CLI is to use the [Mbed Online Compiler](https://os.mbed.com/compiler/). In this case, you need to import the example projects from [Mbed developer](https://os.mbed.com/) to your Mbed Online Compiler session using the links below:
2120
* [authcrypt](https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-tls-authcrypt)
2221
* [benchmark](https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-tls-benchmark)
2322
* [hashing](https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-tls-hashing)
2423
* [tls-client](https://os.mbed.com/teams/mbed-os-examples/code/mbed-os-example-tls-tls-client)
2524

26-
## Building and running the examples
25+
## Mbed OS build tools
26+
27+
### Mbed CLI 2
28+
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).
29+
30+
[Install Mbed CLI 2](https://os.mbed.com/docs/mbed-os/latest/build-tools/install-or-upgrade.html)
2731

28-
The following example shows how to build and run on FRDM-K64F, but it should work on any Mbed OS capable device.
32+
### Mbed CLI 1
33+
[Install Mbed CLI 1](https://os.mbed.com/docs/mbed-os/latest/quick-start/offline-with-mbed-cli.html)
34+
35+
## Building and running the examples
2936

3037
1. Clone the repository containing the collection of examples:
31-
```
38+
```bash
3239
$ git clone https://github.com/ARMmbed/mbed-os-example-tls
3340
```
3441

3542
1. Open a command line tool and navigate to one of the project’s subdirectories.
3643

37-
1. Update `mbed-os` sources using the `mbed deploy` command.
44+
1. Update the source tree:
3845

39-
1. Build the application by selecting the board and build toolchain using the command `mbed compile -m K64F -t GCC_ARM`. mbed-cli builds a binary file under the project’s `BUILD` directory.
46+
* Mbed CLI 2
47+
```bash
48+
$ mbed-tools deploy
49+
```
50+
51+
* Mbed CLI 1
52+
```bash
53+
$ mbed deploy
54+
```
4055

41-
1. Connect the FRDM-K64F to the computer with the micro-USB cable, being careful to use the **OpenSDA** connector on the target board. The board is listed as a mass-storage device.
56+
1. Connect a USB cable between the USB port on the board and the host computer.
57+
1. Run the following command to build the example project, program the microcontroller flash memory, and open a serial terminal to the device:
4258

43-
1. Drag the binary `BUILD/K64F/GCC_ARM/<EXAMPLE>.bin` to the board to flash the application.
59+
* Mbed CLI 2
4460

45-
1. The board is automatically programmed with the new binary. A flashing LED on it indicates that it is still working. When the LED stops blinking, the board is ready to work.
61+
```bash
62+
$ mbed-tools compile -m <TARGET> -t <TOOLCHAIN> --flash --sterm
63+
```
64+
65+
* Mbed CLI 1
66+
67+
```bash
68+
$ mbed compile -m <TARGET> -t <TOOLCHAIN> --flash --sterm
69+
```
4670

4771
1. Press the **RESET** button on the board to run the program.
4872

73+
74+
Your PC may take a few minutes to compile your code.
75+
76+
The binary will be located in the following directory:
77+
* **Mbed CLI 2** - `./cmake_build/<TARGET>/develop/<TOOLCHAIN>/`
78+
* **Mbed CLI 1** - `./BUILD/<TARGET>/<TOOLCHAIN>/`
79+
80+
You can manually copy the binary to the target, which gets mounted on the host computer through USB, rather than using the `--flash` option.
81+
82+
You can also open a serial terminal separately, as explained below, rather than using the `--sterm` option.
83+
4984
## Monitoring the application
5085

5186
Please browse the subdirectories for specific documentation.
@@ -54,11 +89,26 @@ Please browse the subdirectories for specific documentation.
5489
* [hashing](./hashing/README.md): performs hashing of a buffer with SHA-256 using various APIs.
5590
* [tls-client](./tls-client/README.md): downloads a file from an HTTPS server (os.mbed.com) and looks for a specific string in that file.
5691

57-
The application prints debug messages over the serial port, so you can monitor its activity with a serial terminal emulator. Start the [serial terminal emulator](https://os.mbed.com/handbook/Terminals) and connect to the [virtual serial port](https://os.mbed.com/handbook/SerialPC#host-interface-and-terminal-applications) presented by your board. Use the following settings:
92+
The application prints debug messages over the serial port, so you can monitor its activity with a
93+
serial terminal emulator. The default serial baudrate has been set to 9600 for these examples.
94+
If not using the `--sterm` option when flashing, have a client open and connected to board. You may use:
5895

59-
* 9600 baud.
60-
* 8N1.
61-
* No flow control.
96+
- Mbed CLI 2
97+
```bash
98+
$ mbed-tools sterm
99+
```
100+
101+
- Mbed CLI 1
102+
```bash
103+
$ mbed sterm
104+
```
105+
106+
- [Tera Term](https://ttssh2.osdn.jp/index.html.en) for Windows
107+
108+
- screen or minicom for Linux
109+
```bash
110+
$ screen /dev/serial/<your board> 9600
111+
```
62112

63113
After pressing the **RESET** button on the board, you should be able to observe the application's output.
64114

authcrypt/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ add_subdirectory(${MBED_PATH})
1313

1414
add_executable(${APP_TARGET})
1515

16-
mbed_configure_app_target(${APP_TARGET})
17-
18-
mbed_set_mbed_target_linker_script(${APP_TARGET})
19-
2016
project(${APP_TARGET})
2117

2218
target_include_directories(${APP_TARGET}

benchmark/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ add_subdirectory(${MBED_PATH})
1313

1414
add_executable(${APP_TARGET})
1515

16-
mbed_configure_app_target(${APP_TARGET})
17-
18-
mbed_set_mbed_target_linker_script(${APP_TARGET})
19-
2016
project(${APP_TARGET})
2117

2218
target_include_directories(${APP_TARGET}

hashing/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ add_subdirectory(${MBED_PATH})
1313

1414
add_executable(${APP_TARGET})
1515

16-
mbed_configure_app_target(${APP_TARGET})
17-
18-
mbed_set_mbed_target_linker_script(${APP_TARGET})
19-
2016
project(${APP_TARGET})
2117

2218

tls-client/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,14 @@ cmake_minimum_required(VERSION 3.19.0 FATAL_ERROR)
55

66
set(MBED_PATH ${CMAKE_CURRENT_SOURCE_DIR}/mbed-os CACHE INTERNAL "")
77
set(MBED_CONFIG_PATH ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
8-
set(APP_TARGET benchmark)
8+
set(APP_TARGET tls-client)
99

1010
include(${MBED_PATH}/tools/cmake/app.cmake)
1111

1212
add_subdirectory(${MBED_PATH})
1313

1414
add_executable(${APP_TARGET})
1515

16-
mbed_configure_app_target(${APP_TARGET})
17-
18-
mbed_set_mbed_target_linker_script(${APP_TARGET})
19-
2016
project(${APP_TARGET})
2117

2218
target_include_directories(${APP_TARGET}

0 commit comments

Comments
 (0)