- Overview
- Knowledge Pack Deployment
- Knowledge Pack Library Compilation
- Knowledge Pack Integration
- Knowledge Pack API
This repository contains instructions for deploying a SensiML SensiML Analytics Studio project to any xc8, xc16, or xc32 supported platform. Users of the SAMD21 ML Eval Kit (i.e. EV45Y33A or EV18H79A) should visit the SAMD21 SensiML Template repository which contains a complete firmware implementation.
- MPLAB® X IDE (https://microchip.com/mplab/mplab-x-ide)
To deploy a knowledge pack from the SensiML Analytics Studio:
-
Open up your SensiML project in the Analytics Studio and navigate to the Download Model tab.
-
Select
Microchip SAMD21 ML Eval Kit
from the HW Platform options.- Although SAMD21 ML Eval Kit is specified as the hardware platform, the Source format option will generate code that should be compatible with any xc compiler platform.
-
Select one of Binary, Library, or Source from the Format options.
- Note that the Source format is only available for upper tier SensiML customers.
-
Select the appropriate sensor configuration for your project from the Data Source options.
-
Note that this configuration should match the one you used to capture the data your model was trained with.
-
This step is only relevant for the SAMD21 ML Eval Kit - in all other cases you will have to manually verify your sensor configuration
-
-
Click the Download button to download the model.
Deployment from the Analytics Studio
The following steps cover the process of manually compiling the SensiML source code into a static library object. This step is not required for integration, but is typically less problematic than integrating source code directly.
-
(For Windows users only) Install Git Bash.
-
Install MPLAB X version 6.00 or greater.
-
Install a DFP for the target device family (e.g. AVR-Dx). DFPs can be installed from MPLAB X or manually from https://packs.download.microchip.com/.
-
Extract the library archive from the step above directly into this folder. The zip file should contain a folder named
knowledgepack
where the SensiML source code is located. -
(Optional) Open
options.ini
and modify as needed. -
Set the environment variables
MPLABX_VERSION XC_NUMBER_BITS XC_VERSION
as desired, then runbuild.sh
to generate the library object. For example:MPLABX_VERSION=6.00 XC_VERSION=4.00 XC_NUMBER_BITS=32 ./build.sh ATSAME54P20A libsensiml .
By default
build.sh
will select the latest program versions found on your system in the default install locations. If MPLAB X or the XC compiler are in non-default install locations, manually set the corresponding path directly through theMPLABX_PATH
and/orXC_PATH
environment variables. -
See the integration instructions below to integrate the library with your MPLAB X project.
For convenience, docker_build.sh
is provided which contains a full example for
building the docker image and generating the SensiML library/project. This
script can be run by passing the target name and the corresponding .args file e.g.:
./docker_build.sh ATSAME54P20A args/SAME54.args
The output of the build process will be placed in a folder named dist/
under
your current working directory.
Note: The .args
files included in this repository may not always be up to
date. Check
packs.download.microchip.com for the
most up to date device family pack listings.
*.options.ini
can be modified to set additional project options; for help call the MPLAB scriptprjMakefilesGenerator -setoptions=@ -help
- NB: all relative paths are considered relative to the project root folder (.X folder)
*.project.ini
is just a placeholder - the languageToolchain and device variables are replaced when building the project - others will take default values if unspecified.
At the time of this writing this option is only supported for the SAMD21 ML Eval Kit
If you deployed a knowledge pack in the Binary format, the archive should contain the binary file which can be written directly to the evaluation board.
Below are instructions for a SensiML library object into an MPLAB X project. For guidance on compiling source code into a library object refer to Knowledge Pack Library Compilation.
-
Add the library object from the step above into an existing MPLAB project as shown below.
-
Extract the SensiML deployment archive somewhere into your project directory.
-
Add the path to the
inc
folder from the SensiML deployment archive (e.g.../knowledgepack/sensiml/inc
) into your XC compiler include path in the Project Properties.
Follow the steps below to directly integrate the SensiML source code into your MPLAB X project. Alternatively, you may use the included build scripts to build the source code into a library object before integration.
-
In MPLAB X, open up the .X project folder under the
firmware
folder of this repository. -
In the Projects pane, right click the Header Files folder and select Add Existing Items from Folders from the options.
Adding knowledge pack header files to your project -
In the resulting window that opens, click the Add Folder button.
-
In the new dialog, select Header Files from the Files of Type dropdown, then navigate to the project's
firmware
directory and select theknowledgepack
directory. Click the Select button to add the directory.Recursively add header files (.h) under the knowledgepack
folder -
Back in the Add Files window, click the Add button to finish adding the necessary header files and close the dialog.
-
Right click the Source Files folder in the Projects pane and select Add Existing Items from Folders from the menu. Repeat steps 4-6 to add all source files (.c files) from the
knowledgepack
folder. -
Add the path to the
inc
folder from the SensiML deployment archive (e.g.../knowledgepack/sensiml/inc
) into your XC compiler include path in the Project Properties.
Once the library has been integrated, you just need to add a few hooks into your
project to perform inferencing with the SensiML model's API; the src/main.c
file provides a skeleton implementation which you can use as a template for your
own project.
For more detailed information on the SensiML API visit the SensiML Documentation.