Arm Keil Microcontroller Development Kit (MDK) is created by Arm and is a complete C/C++ development tool suite for Arm processors. The Keil MDK offers device support for most of the ARM silicon and development boards and includes a rich set of build and debugging tools. In Edge Impulse studio you can deploy your model to the open standard CMSIS library format that can be imported into any Arm Keil MDK project with ease.
The Edge Impulse pack repository plays a crucial role in this process. It is continuously updated, ensuring that the .pack files, are automatically refreshed. This automation extends to PDSC (Pack Description) files, which are updated through the Keil MDK pack for our Edge Impulse SDK, providing a seamless integration experience.
To read more about the CMSIS standard, and our other CMSIS integrations, please visit our CMSIS documentation.
It is worth noting that when comparing the performance of the Arm Clang v16.9 and GCC 10.c compilers, the Arm Clang v16.9 compiler outperforms the GCC 10.c compiler in terms of DSP processing time and classification time. The Arm Clang v16.9 compiler is 24.25% faster in DSP processing time and 20.58% faster in classification time. This is a significant improvement in performance when using the Arm Clang v16.9 compiler.
Arm Clang v16.9 (Renesas EK-RA8D1)
DSP Time: 709 microseconds
Classification Time: 18908 microseconds
Anomaly Detection Time: 0 microseconds Detected Faces:
Face 1: Confidence 98.437% at [x: 80, y: 16, width: 8, height: 8]
Face 2: Confidence 85.156% at [x: 0, y: 32, width: 16, height: 16]
GCC 10.3 (Renesas EK-RA8D1)
DSP Time: 936 microseconds
Classification Time: 23807 microseconds
Anomaly Detection Time: 0 microseconds Detected Faces:
Face 1: Confidence 98.437% at [x: 80, y: 16, width: 8, height: 8]
Face 2: Confidence 85.156% at [x: 0, y: 32, width: 16, height: 16]
To get started with Arm Keil MDK, you will need to install one of the following tools:
First we will need the Edge Impulse SDK pack and an Edge Impulse project CMSIS-packs. You can download these from the deployment section of the Edge Impulse Studio.
In the deployment section of Edge Impulse Studio select the Open CMSIS pack option. Depending on your model optimization preferences you can enable the EON compiler and choose between Quantized and Unoptimized data format. Clicking Build will initiate the build process and, when finished, downloads a zip file containing the generated CMSIS Software Component packs. Two files are included in the zip file:
EdgeImpulse.project_name.x.y.z.pack
The first file is the Edge Impulse SDK pack, which contains the Edge Impulse library and the required dependencies. The second file is the project pack, which contains the project specific configuration and the trained model.
The Edge Impulse SDK pack contains the Edge Impulse library and the required dependencies. The pack will be listed under the EdgeImpulse::EI-SDK
category, and is now available from the Arm Keil Pack Installer.
The Edge Impulse SDK pack requires the following CMSIS packs:
CMSIS-NN 4.0.0 Focuses on optimizing ML operators for Cortex-M, targeting Edge AI applications.
CMSIS-DSP 1.15.0 A collection of DSP functions optimized for Cortex-M processors, suitable for DSP applications.
If you want to test the model on your target device, you can clone one of the example projects.
We have created standalone examples for the following boards:
These standalone example projects contains minimal code required to run the imported impulse on a STMicroelectronics MCU. This code is located in ei_main.cpp
. In this minimal code example, inference is run from a static buffer of input feature data. To verify that our embedded model achieves the exact same results as the model trained in Studio, we want to copy the same input features from Studio into the static buffer in ei_main.cpp
.
To do this, first head back to the studio and click on the Live classification tab. Then load a validation sample, and click on a row under 'Detailed result'.
To verify that the local application classifies the same result, we need the raw features for this timestamp. To do so click on the 'Copy to clipboard' button next to 'Raw features'. This will copy the raw input values from this validation file, before any signal processing or inferencing happened.
In ei_main.cpp
paste the raw features inside the static const float features[]
definition, for example:
The project once configured in the subsequent steps will repeatedly run inference on this buffer of raw features once built. This will show that the inference result is identical to the Live classification tab in Studio. From this starting point, the example project is fully compatible with existing SimpleLink SDK plugins, drivers or custom firmware. Use new sensor data collected in real time on the device to fill a buffer. From there, follow the same code used in ei_standalone.cpp
to run classification on live data.
We will now go through each of these steps in detail for µVision and finish with a brief overview of the VS Code integration, and demonstrate how to import the µVision project to VS Code
To run the standalone example, follow these steps:
The file extension is *.UVPROJ for MDK version 4, or *.UVPROJX for later versions.
First open the standalone example project in Arm Keil µVision and follow the steps below to import the Edge Impulse SDK pack into your project.
standalone_nucleo.uvguix.projx example-standalone-inferencing-stm32h747i-disco-CM7.uvprojx
The EI-SDK pack contains the Edge Impulse library and the required dependencies. The pack will be listed under the EdgeImpulse::EI-SDK
category, and is now available from the Arm Keil Pack Installer
To import the Edge Impulse SDK pack into Arm Keil µVision, from our examples, follow these steps:
Open Arm µVision project.
Select File->Import from Folder.
Select the EdgeImpulse.EI-SDK.x.y.z.pack file from the downloaded zip file.
Click Next and then Finish.
The Edge Impulse SDK pack is now imported into your project.
To import the Edge Impulse project pack into Arm Keil µVision, follow these steps:
Open Arm Keil µVision and select the project you want to import the Edge Impulse project pack into.
Select File->Import.
Select the EdgeImpulse.project_name.x.y.z.pack file from the downloaded zip file.
Accept the terms and conditions and click Next.
Click Finish to import the Edge Impulse project pack into your project.
To import the ML model and inference SDK follow these steps:
Place and unzip the downloaded library in the root folder of your project.
Open your project in Arm Keil µVision.
File->Import from Folder->Select the model pack from the downloaded folder.
If the import is successful, the library will be added to the project. You may see "Software Packs folder has been updated" in the console.
Reload Packs by selecting Project->Reload Software Packs
.
Select software packs and ensure that the model pack is listed under the EdgeImpulse::Motion_recognition
category and is set to latest version.
To configure the project to use the Edge Impulse SDK, follow these steps:
Open the project settings by selecting Project->Select Software Packs for the target
.
Select the Edge Impulse SDK pack from the list of available software packs. The pack will be listed under the EdgeImpulse::EI-SDK
category. Update Selection to latest version.
Select the Edge Impulse SDK pack from the list of available software packs. The pack will be listed under the EdgeImpulse::Motion_recognition
category. Update Selection to latest version.
To configure the Run-Time Environment to use the Edge Impulse SDK, follow these steps:
Open the project settings by selecting Project->Manage Run-Time Environment
.
Select the EdgeImpulse from the list of software components. Mark the checkbox to include the software component in the project.
Select model and Motion_recognition mark the checkbox to include the software component in the project.
Click OK to close the dialog.
To build the project, follow these steps:
Select Project->Build Target
.
The project will be built and the output will be displayed in the console.
To run the project, follow these steps:
Select Debug->Start/Stop Debug Session
.
The project will be built and the debugger will be started.
Once completed, the project will be configured to use the Edge Impulse SDK. You can now import the Edge Impulse µVision project to VS Code.
Adapting the procedure from the Arm Keil extension documentation.
These steps will install the VS Code extension:
1. Install Arm Keil Studio Extension and CMSIS extension for VS Code
Search for "Keil Studio" in the VS Code extensions marketplace and install it. vslink
Search for "CMSIS csolution" in the VS Code extensions marketplace and install it. vslink
2. Import Project Packs
Open VS Code and navigate to the >CMSIS: Packs view.
Choose to import an existing µVision project or start a new one.
Import the Edge Impulse SDK and project packs you've downloaded earlier.
3. Configure Project for Target Hardware
Access the project settings.
Set the target device and adjust settings specific to your hardware.
4. Add Edge Impulse SDK Pack to Project
Open VS Code and navigate to the ctl+shift+p >CMSIS: Manage Software Components.
Search for and install the EdgeImpulse SDK, accept the CMSIS-NN and CMSIS-DSP packs install the required packages.
Import the Edge Impulse project pack you've downloaded earlier.
Fist, you need to install the Keil Studio VS Code extension. You can find the extension in the VS Code Marketplace.
Now open your existing µVision project in VS Code and follow the steps below to import the Edge Impulse SDK pack into your project.
Open Arm Keil Studio and select the CMSIS Pack Installer extension.
Select the import existing µVision project option.
Select your existing µVision project.
Now install the Edge Impulse SDK pack into your project.
Open Arm Keil Studio and select the CMSIS Pack Installer extension.
Cmsis->Manage Software Components.->Software Packs:all packs->Search for EdgeImpulse SDK
Validate the installation of the Edge Impulse SDK pack.
Open Arm Keil Studio and select the CMSIS Pack Installer extension.
Cmsis->Manage Software Components.->Software Packs:all packs->Search for any pack and validate the installation of the EdgeImpulse SDK pack.
Accept the packages required for the project.
Congratulations! You have now successfully imported the Edge Impulse SDK and project pack into Arm Keil Studio IDE and configured the project to use the Edge Impulse SDK. You can now build and run the project to test the model on your target device.
You have now successfully imported the Edge Impulse SDK and project pack into Arm Keil Studio IDE and configured the project to use the Edge Impulse SDK. You can now build and run the project to test the model on your target device.
If you have any questions or need help, please visit our forum.
Metric | Improvement using Arm Clang v16.9 compiler |
---|---|
DSP Processing Time
24.25%
Classification Time
20.58%