This builds and runs an exported impulse locally on your machine.
-
Create an edge impulse account at edgeimpulse.com
-
Install the latest
Alif Security Toolkit
:- Navigate to the Alif Semiconductor Kit documentation page (you will need to register to create an account or log in). and download the latest
App Security Toolkit
(tested with version 0.54.0) for windows or linux. If you are using MacOS, download the linux version. - Extract archive and place
app-release
in the root of this repo - Follow the instructions in local the
Alif Security Toolkit Quickstart Guide
to finalize the installation.
- Navigate to the Alif Semiconductor Kit documentation page (you will need to register to create an account or log in). and download the latest
-
Install either arm gcc or arm clang:
Tested with:
gcc version 10.2.1 20201103 (release) (GNU Arm Embedded Toolchain 10-2020-q4-major)
ARM clang compiler and ensure it is added to your path:
which armclang
Using an Edge Impulse project with the Alif beta enabled, navigate to the Deployment tab. Here you should see an Ethos-U library
deployment option. Select this and click build to download a zip file of the contents.
Edge Impulse static examples show the minimal code to run inference, with no peripherals connected to provide data. Instead, we provide a static buffer of data obtained from a studio sample. Follow the steps described here to extract sample features from studio, and use these to populate the features array in source/main.cpp
This repository contains a docker image with the required dependencies for building with gcc:
docker build -t alif-firmware .
Build the the firmware with following command:
docker run --rm -it -v "${PWD}":/app alif-firmware /bin/bash -c "sh build_appkit.sh"
- Ensure you have a compatible version of ARM GCC installed and added to your path
- Extract the zip file downloaded from edge impulse into the
source
directory of this repository - Run
build_appkit.sh
- Ensure your board is configured for programming over the SEUART interface by following the Edge Impulse Ensemble E7 setup guide
- Copy
./build/bin/app.bin
into the Alif Security Toolkit directory./app-release/build/images
- Copy the
ei-app-gcc.json
file into the Alif Security Toolkit directory./app-release/build/config
- Execute the following commands to program your board:
cd app-release
./app-gen-toc -f ./build/config/ei-app-gcc.json
./app-write-mram.py -d
When prompted to select the serial interface to program over. Select the corresponding the FTDI COM interface.
Once programmed, the firmware will run inference and print the results over the UART2 serial port.
- Baud 115200
- "8,N,1" (the typical settings for everything else, 8 bit, no parity, 1 stop bit)
- 1.8 Vcc
Timing calculations are performed in ei_classifier_porting.cpp and make use of an interrupt attached to SysTick.
- An RTOS may take over this interrupt handler, in which case you should reimplement ei_read_timer_us and _ms.
- The default calculation is based on the default clock rates of the Alif dev kit (400 MHz for HP core, 160 MHz for HE core). If you change this, redefine EI_CORE_CLOCK_HZ.
Alif M55 processors have a private fast DTCM, and also access to a larger, but slower, chip global SRAM.
- For armclang the linker file attempts to place as much as possible in DTCM, and overflows into SRAM if needed.
- For gcc, the linker is unable to auto place based on size. When your entire program can't fit into DTCM, sometimes customizing placement of objects can improve performance. See ensemble.sct for example placement commands (currently commented out)