Modifying the SyNAP Framework
This tutorial will guide you through the steps to modify the SyNAP framework to build custom C++ applications similar to synap_cli, synap_cli_ic, etc.
To learn more about the SyNAP framework, you can visit the latest release branch at SyNAP framework repo. You can learn more about the usage of these C++ applications at SyNAP Documentation. These applications allow you to run networks on your Synaptics Astra™ Machina™'s NPU.
Let's get started with the step-by-step process of how you can build these apps.
Step 1. Start a build environment container:
You will use your host development machine as Ubuntu. In order to ensure a correctly configured and clean environment, the build must be performed within a Docker container.
To start the container use the following docker command:
docker run --rm -it -v $(pwd):$(pwd) ghcr.io/synaptics-astra/crops:1.0.0 --workdir=$(pwd)
This command will spawn a pokyuser@xyz:/path/to/workspace/ shell inside the container.
On Ubuntu 20 and 18 LTS, the seccomp protection feature of Docker has to be disabled when creating the build container by adding the parameter --security-opt "seccomp=unconfined" after the --rm parameter. So use this instead:
docker run --rm --security-opt "seccomp=unconfined" -it -v $(pwd):$(pwd) ghcr.io/synaptics-astra/crops:1.0.0 --workdir=$(pwd)
If your environment requires a proxy to connect to the internet, please follow these instructions for configuring the Docker daemon and configuring the Docker client to use a proxy server.
Step 2. Clone the sources from GitHub
The Synaptics Yocto SDK release can be downloaded by cloning the latest version of this Astra SDK git repo. This command will clone all the required layers as submodules from the Astra SDK git repository.
git clone -b v1.3.0 --recurse-submodules https://github.com/synaptics-astra/sdk
Make sure you clone the latest version of the SDK, for example, the above command is cloning the v1.3.0 branch.
To set up the build tree, use:
cd sdk
source meta-synaptics/setup/setup-environment
You will be prompted to select your processor which you want to build/run the sample app.
Select the MACHINE you want to build:
- sl1620
- sl1640
- sl1680
Above command creates a new build folder named build-sl16xx (Depending on your choice of processor) and makes this as current working directory.
Step 3. Build SyNAP framework
Now, you need to extract the source of the SyNAP framework. You can use the following command to check out the source files:
devtool modify synasdk-synap-framework
This will extract the sources here: sdk/build-sl16xx/workspace/sources/synasdk-synap-framework/synap/framework
This framework folder contains the app folder which has the source code of all the different C++ applications like synap_cli, synap_cli_od, etc.
If you want to modify or create your own C++ application, you can do that here according to your needs, whether it is preprocessing or postprocessing.
This is the directory structure of the SyNAP framework. According to your requirement, make changes in apps or dependent libs.
You can find these applications under the app folder. These applications are dependent on some libraries such as synap_img, synap_preprocess, synap_postprocess, etc., which can be found in the lib folder.
framework
├── app
│ ├── ...
│ ├── synap_cli
│ ├── synap_cli_ic
│ ├── synap_cli_od
│ └── ...
├── ...
└── lib
├── ...
├── synap_app
├── synap_img
├── synap_postprocess
├── synap_preprocess
└── ...
Step 4. Build your own C++ app
Once you have customized the C++ application, you can use devtool build command to build you application.
devtool build synasdk-synap-framework
Step 5. Deploying Your App on Machina
This command builds binaries of your C++ application and pushes your app to Machina Board. It also updates the SyNAP framework on your Machina Board.
Make sure to have the address of the board user@hostname:/ for the below command:
devtool deploy-target synasdk-synap-framework root@10.3.10.158:/ -s
Congratulations! You were able to build C++ application with SyNAP and push it onto your Machina Board.
Once connected to the board, you can find all your C++ applications here: /usr/bin/