Skip to content

Commit 9017254

Browse files
Merge pull request #1529 from RonanSynnottArm/mlek
Updated MLEK to Corstone-320 and removed AVH
2 parents 089ab88 + dc9d7b2 commit 9017254

File tree

4 files changed

+152
-125
lines changed

4 files changed

+152
-125
lines changed

content/learning-paths/embedded-and-microcontrollers/mlek/_index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ title: Build and run the Arm Machine Learning Evaluation Kit examples
33

44
minutes_to_complete: 30
55

6-
who_is_this_for: This is an introductory topic for embedded software developers interested in learning about machine learning.
6+
who_is_this_for: This is an introductory topic for embedded software developers interested in machine learning applications.
77

88
learning_objectives:
99
- Build examples from Machine Learning Evaluation Kit (MLEK)
10-
- Run the examples on Corstone-320 FVP or Virtual Hardware
10+
- Run the examples on Arm Ecosystem FVP
1111

1212
prerequisites:
1313
- Some familiarity with embedded programming
14-
- Either a Linux machine running Ubuntu, or an AWS account to use [Arm Virtual Hardware](https://www.arm.com/products/development-tools/simulation/virtual-hardware)
14+
- A Linux host machine running Ubuntu
1515

1616
author_primary: Ronan Synnott
1717

1818
### RS: Learning Path hidden until AWS instance updated
19-
draft: true
19+
draft: false
2020
cascade:
21-
draft: true
21+
draft: false
2222

2323

2424
### Tags

content/learning-paths/embedded-and-microcontrollers/mlek/build.md

Lines changed: 14 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ You can use the MLEK source code to build sample applications and run them on th
1313

1414
## Before you begin
1515

16-
You can use your own Ubuntu Linux host machine or use [Arm Virtual Hardware (AVH)](https://www.arm.com/products/development-tools/simulation/virtual-hardware) for this Learning Path.
17-
18-
The Ubuntu version should be 20.04 or 22.04. These instructions have been tested on the `x86_64` architecture. You will need a way to interact visually with your machine to run the FVP, because it opens graphical windows for input and output from the software applications.
19-
20-
If you want to use Arm Virtual Hardware the [Arm Virtual Hardware install guide](/install-guides/avh#corstone) provides setup instructions.
16+
It is recommended to use an Ubuntu Linux host machine. The Ubuntu version should be 20.04 or 22.04. These instructions have been tested on the `x86_64` architecture.
2117

2218
## Build the example application
2319

@@ -52,9 +48,6 @@ You can review the installation guides for further details.
5248

5349
{{% /notice %}}
5450

55-
56-
Both compilers are pre-installed in Arm Virtual Hardware.
57-
5851
### Clone the repository
5952

6053
Clone the ML Evaluation Kit repository, and navigate into the new directory:
@@ -69,76 +62,36 @@ git submodule update --init
6962

7063
The default build is Ethos-U55 and Corstone-300. The default build for Ethos-U85 is Corstone-320. Use the `npu-config-name` flag to set Ethos-U85.
7164

72-
The default compiler is `gcc`, but `armclang` can also be used. Number after `ethos-u85-*` is number of MACs, 128-2048 (2^n).
65+
The default compiler is `gcc`, but `armclang` can also be used. Number after `ethos-u85-*` is the number of MACs, 128-2048 (2^n).
66+
67+
Use `--make-jobs` to specify `make -j` value.
7368

7469
You can select either compiler to build applications. You can also try them both and compare the results.
7570

76-
- Build with Arm GNU Toolchain (`gcc`)
71+
- Build with Arm GNU Toolchain (`gcc`):
7772

7873
```
79-
./build_default.py --npu-config-name ethos-u85-256 --toolchain gnu
74+
./build_default.py --npu-config-name ethos-u85-256 --toolchain gnu --make-jobs 8
8075
```
8176

82-
- Build with Arm Compiler for Embedded (`armclang`)
77+
- Build with Arm Compiler for Embedded (`armclang`):
8378

8479
```console
85-
./build_default.py --npu-config-name ethos-u85-256 --toolchain arm
86-
```
87-
88-
The build will take a few minutes.
89-
90-
When the build is complete, you will find the examples (`.axf` files) in the `cmake-build-*/bin` directory. The `cmake-build` directory names are specific to the compiler used and Ethos-U85 configuration. Verify that the files have been created by observing the output of the `ls` command
91-
92-
```bash
93-
ls cmake-build-mps4-sse-320-ethos-u85-256-gnu/bin/
80+
./build_default.py --npu-config-name ethos-u85-256 --toolchain arm --make-jobs 8
9481
```
9582

96-
The next step is to install the FVP and run it with these example audio clips.
97-
98-
99-
## Corstone-320 FVP {#fvp}
100-
101-
This section describes installation of the Corstone-320 to run on your local machine. If you are using Arm Virtual Hardware, that comes with the Corstone-300 FVP pre-installed, and you can move on to the next section. You can review Arm's full FVP offer and general installation steps in the [Fast Model and Fixed Virtual Platform](/install-guides/fm_fvp) install guides.
83+
{{% notice Tip %}}
84+
Use `./build_default.py --help` for additional information.
10285

103-
{{% notice Note %}}
104-
The rest of the steps for the Corstone-320 need to be run in a new terminal window.
10586
{{% /notice %}}
10687

107-
Open a **new terminal window** and download the Corstone-320 archive.
108-
109-
```bash
110-
cd $HOME
111-
wget https://developer.arm.com/-/cdn-downloads/permalink/FVPs-Corstone-IoT/Corstone-320/FVP_Corstone_SSE-320_11.27_25_Linux64.tgz
112-
```
113-
114-
Unpack it with `tar`, run the setup script and export the binary paths to the `PATH` environment variable.
115-
116-
```bash
117-
tar -xf FVP_Corstone_SSE-320_11.27_25_Linux64.tgz
118-
./FVP_Corstone_SSE-320.sh --i-agree-to-the-contained-eula --no-interactive -q
119-
export PATH=$HOME/FVP_Corstone_SSE-320/models/Linux64_GCC-9.3:$PATH
120-
```
121-
122-
The FVP requires an additional dependency, `libpython3.9.so.1.0`, which can be installed using a script. Note that this will tinkle with the python installation for the current terminal window, so make sure to open a new one for the next step.
123-
124-
```bash
125-
source $HOME/FVP_Corstone_SSE-320/scripts/runtime.sh
126-
```
88+
The build will take a few minutes.
12789

128-
Verify that the FVP was successfully installed by comparing your output from below command.
90+
When the build is complete, you will find the examples (`.axf` files) in the `cmake-build-*/bin` directory. The `cmake-build` directory names are specific to the compiler used and Ethos-U85 configuration. Verify that the files have been created by observing the output of the `ls` command
12991

13092
```bash
131-
FVP_Corstone_SSE-320
132-
```
133-
134-
```output
135-
telnetterminal0: Listening for serial connection on port 5000
136-
telnetterminal1: Listening for serial connection on port 5001
137-
telnetterminal2: Listening for serial connection on port 5002
138-
telnetterminal5: Listening for serial connection on port 5003
139-
93+
ls cmake-build-mps4-sse-320-ethos-u85-256-gnu/bin/
14094
```
14195

142-
143-
Now you are ready to test the application with the FVP.
96+
The next step is to install the FVP and run the built example applications.
14497

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
# User change
3+
title: "Install Arm Ecosystem FVP"
4+
5+
weight: 3 # 1 is first, 2 is second, etc.
6+
7+
# Do not modify these elements
8+
layout: "learningpathall"
9+
---
10+
## Corstone-320 FVP {#fvp}
11+
12+
This section describes installation of the [Corstone-320 FVP](https://developer.arm.com/Tools%20and%20Software/Fixed%20Virtual%20Platforms/IoT%20FVPs) to run on your local machine. Similar instructions would apply for other platforms.
13+
14+
Arm provides a selection of free to use Fixed Virtual Platforms (FVPs) that can be downloaded from the [Arm Developer](https://developer.arm.com/Tools%20and%20Software/Fixed%20Virtual%20Platforms#Downloads) website.
15+
16+
You can review Arm's full FVP offering and general installation steps in the [Fast Model and Fixed Virtual Platform](/install-guides/fm_fvp) install guide.
17+
18+
{{% notice Note %}}
19+
It is recommended to perform these steps in a new terminal window.
20+
{{% /notice %}}
21+
22+
Download the Corstone-320 Ecosystem FVP archive:
23+
24+
```bash
25+
cd $HOME
26+
wget https://developer.arm.com/-/cdn-downloads/permalink/FVPs-Corstone-IoT/Corstone-320/FVP_Corstone_SSE-320_11.27_25_Linux64.tgz
27+
```
28+
29+
Unpack it with `tar`, run the installation script, and add the path to the FVP executable to the `PATH` environment variable.
30+
31+
```bash
32+
tar -xf FVP_Corstone_SSE-320_11.27_25_Linux64.tgz
33+
34+
./FVP_Corstone_SSE-320.sh --i-agree-to-the-contained-eula --no-interactive -q
35+
36+
export PATH=$HOME/FVP_Corstone_SSE-320/models/Linux64_GCC-9.3:$PATH
37+
```
38+
39+
The FVP requires an additional dependency, `libpython3.9.so.1.0`, which can be installed using a supplied script.
40+
41+
```bash
42+
source $HOME/FVP_Corstone_SSE-320/scripts/runtime.sh
43+
```
44+
45+
Run the executable:
46+
47+
```bash
48+
FVP_Corstone_SSE-320
49+
```
50+
51+
You will observe output similar to the following:
52+
53+
```output
54+
telnetterminal0: Listening for serial connection on port 5000
55+
telnetterminal1: Listening for serial connection on port 5001
56+
telnetterminal2: Listening for serial connection on port 5002
57+
telnetterminal5: Listening for serial connection on port 5003
58+
```
59+
60+
If you encounter graphics driver errors, you can disable the development board and LCD visualization with additional command options:
61+
62+
```bash
63+
FVP_Corstone_SSE-320 \
64+
-C mps4_board.visualisation.disable-visualisation=1 \
65+
-C vis_hdlcd.disable_visualisation=1
66+
```
67+
68+
Stop the executable with `Ctrl+C`.
69+
70+
Now you are ready to run the MLEK applications on the FVP.

content/learning-paths/embedded-and-microcontrollers/mlek/run.md

Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,32 @@
22
# User change
33
title: "Run the examples on the FVP"
44

5-
weight: 3 # 1 is first, 2 is second, etc.
5+
weight: 4 # 1 is first, 2 is second, etc.
66

77
# Do not modify these elements
88
layout: "learningpathall"
99
---
1010
## Run an example
1111

12-
Now you are ready to combine the FVP installation and the example application. Navigate to the evaluation kit repository.
12+
Navigate to the evaluation kit repository.
1313

1414
```bash
1515
cd ml-embedded-evaluation-kit/
1616
```
1717

18-
To run an example on the Corstone-320 FVP target, launch the FVP executable with `-a` to specify the software application.
18+
The built examples (`.axf` files) will be located in a `cmake-*/bin` folder based on the build configuration used.
1919

20-
To run the key word spotting example `ethos-u-kws.axf` compiled with `gcc` use one of the two options below.
20+
Navigate into that folder, and list the images. For example:
2121

22-
## Option 1: On your computer with the FVP installed
22+
```bash
23+
cd cmake-build-mps4-sse-320-ethos-u85-256-gnu/bin/
24+
25+
ls *.axf
26+
```
2327

24-
Run the FVP.
28+
Use `-a` to specify the application to load to the FVP.
2529

26-
```console
27-
FVP_Corstone_SSE-320 \
28-
-C mps4_board.subsystem.ethosu.num_macs=256 \
29-
-C mps4_board.visualisation.disable-visualisation=1 \
30-
-C vis_hdlcd.disable_visualisation=1 \
31-
-a cmake-build-mps4-sse-320-ethos-u85-256-gnu/bin/ethos-u-kws.axf
32-
```
30+
Use `-C mps4_board.subsystem.ethosu.num_macs` to configure the Ethos-U component of the model.
3331

3432
{{% notice Note %}}
3533
The number of NPU MACs specified in the build MUST match the number specified in the FVP. Else an error similar to the below will be emitted.
@@ -39,81 +37,87 @@ E: NPU config mismatch. npu.macs_per_cc=E: NPU config mismatch..
3937
```
4038
{{% /notice %}}
4139

42-
## Option 2: On Arm Virtual Hardware
40+
You can list all available parameters by running the FVP executable with the `--list-params` option, for example:
4341

4442
```console
45-
VHT_Corstone_SSE-300_Ethos-U55 -a cmake-build-mps3-sse-300-ethos-u55-128-gnu/bin/ethos-u-kws.axf
43+
FVP_Corstone_SSE-320 --list-params > parameters.txt
4644
```
47-
When the example is running, a telnet instance will open allowing you to interact with the example.
4845

49-
{{% notice Note %}}
50-
It may take some time to initialize the terminal, please be patient.
5146

52-
If you see warnings regarding loading the image, these can likely be ignored.
53-
{{% /notice %}}
47+
### Run the application
5448

55-
## Interact with the application
49+
```console
50+
FVP_Corstone_SSE-320 \
51+
-C mps4_board.subsystem.ethosu.num_macs=256 \
52+
-C mps4_board.visualisation.disable-visualisation=1 \
53+
-C vis_hdlcd.disable_visualisation=1 \
54+
-a ethos-u-kws.axf
55+
```
5656

57-
Use the menu to control the application. For the key word spotting application enter 1 to classify the next audio clip.
57+
If adding configuration options becomes cumbersome, it can be easier to specify them in a configuration file (remove the `-C` option) and then use that on the command line (`-f`).
5858

59-
![terminal #center](term.png)
59+
#### config.txt
60+
```
61+
mps4_board.subsystem.ethosu.num_macs=256
62+
mps4_board.visualisation.disable-visualisation=1
63+
vis_hdlcd.disable_visualisation=1
64+
```
6065

61-
The results of the classification will appear in the visualization window of the FVP.
66+
The command line becomes:
67+
```console
68+
FVP_Corstone_SSE-320 -f config.txt -a ethos-u-kws.axf
69+
```
6270

63-
The display shows a 98% chance of the audio clips sound was down.
71+
The application executes and identifies words spoken within audio files.
6472

65-
![visualization #center](vis.png)
73+
Repeat with any of the other built applications.
6674

67-
End the simulation by pressing Control-C in the terminal where to started the FVP.
75+
Full instructions are provided in the evaluation kit [documentation](https://review.mlplatform.org/plugins/gitiles/ml/ethos-u/ml-embedded-evaluation-kit/+/HEAD/docs/quick_start.md).
6876

69-
You now have the ML Evaluation Kit examples running. Experiment with the different examples provided.
7077

71-
## Addendum: Setting model parameters
78+
## Addendum: Speed up FVP execution
7279

73-
You can specify additional parameters to configure certain aspects of the simulated Corstone-300.
80+
By default, the examples are built with Ethos-U timing enabled. This provides benchmarking information, but the result is that the FVP executes relatively slowly.
7481

75-
### List parameters
82+
The build system has a macro `-DETHOS_U_NPU_TIMING_ADAPTER_ENABLED` defined to control this.
7683

77-
List the available parameters by running the FVP executable with the `--list-params` option, for example:
84+
Modify the command `build_default.py` passes to `cmake` to include this setting (`OFF`). Search for `cmake_command` and modify as follows:
7885

79-
```console
80-
FVP_Corstone_SSE-320 --list-params > parameters.txt
86+
#### build_default.py
8187
```
82-
83-
{{% notice Note %}}
84-
If you are running with Arm Virtual Hardware substitute `VHT_Corstone_SSE-300_Ethos-U55` as the executable name.
85-
{{% /notice %}}
86-
87-
Open the file `parameters.txt` to see all of the possible parameters and the default values.
88-
89-
### Set parameters
90-
91-
Individual parameters can be set with the `-C` command option.
92-
93-
For example, to put the Ethos-U component into fast execution mode:
94-
95-
```console
96-
FVP_Corstone_SSE-320 -a cmake-build-mps4-sse-320-ethos-u85-256-gnu/bin/ethos-u-kws.axf -C mps4_board.subsystem.ethosu.extra_args="--fast"
88+
cmake_command = (
89+
f"{cmake_path} -B {build_dir} -DTARGET_PLATFORM={target_platform}"
90+
f" -DTARGET_SUBSYSTEM={target_subsystem}"
91+
f" -DCMAKE_TOOLCHAIN_FILE={cmake_toolchain_file}"
92+
f" -DETHOS_U_NPU_ID={ethos_u_cfg.processor_id}"
93+
f" -DETHOS_U_NPU_CONFIG_ID={ethos_u_cfg.config_id}"
94+
" -DTENSORFLOW_LITE_MICRO_CLEAN_DOWNLOADS=ON"
95+
" -DETHOS_U_NPU_TIMING_ADAPTER_ENABLED=OFF"
96+
)
9797
```
98-
{{% notice Note %}}
99-
Do not use fast execution mode whilst benchmarking performance.
100-
{{% /notice %}}
10198

102-
To set multiple parameters it may be easier to list them in a text file (without `-C`) and use `-f` to specify the file.
99+
Rebuild the applications as before, for example:
100+
```
101+
./build_default.py --npu-config-name ethos-u85-256 --toolchain gnu --make-jobs 8
102+
```
103103

104-
For example, use a text editor to create a file named `options.txt` with the contents:
104+
Add additional configuration option (`mps4_board.subsystem.ethosu.extra_args`) to the FVP command line:
105105

106-
```console
106+
#### config.txt
107+
```
108+
mps4_board.subsystem.ethosu.num_macs=256
107109
mps4_board.visualisation.disable-visualisation=1
110+
vis_hdlcd.disable_visualisation=1
108111
mps4_board.subsystem.ethosu.extra_args="--fast"
109112
```
110113

111-
Run the FVP with the `-f` option and the `options.txt` file:
114+
Run the application again, and notice how much faster execution completes.
112115

113116
```console
114-
FVP_Corstone_SSE-320 -a cmake-build-mps4-sse-320-ethos-u85-256-gnu/bin/ethos-u-kws.axf -f options.txt
117+
FVP_Corstone_SSE-320 -f config.txt -a ethos-u-kws.axf
115118
```
116119

117-
Full instructions are provided in the evaluation kit [documentation](https://review.mlplatform.org/plugins/gitiles/ml/ethos-u/ml-embedded-evaluation-kit/+/HEAD/docs/quick_start.md).
120+
{{% notice Note %}}
121+
Do not use fast execution mode whilst benchmarking performance.
122+
{{% /notice %}}
118123

119-
You have now run an example application on an Arm Fixed Virtual Platform.

0 commit comments

Comments
 (0)