{"id":19130412,"url":"https://github.com/mathworks/build-steps-for-cmsisnn-library","last_synced_at":"2025-09-08T16:32:14.591Z","repository":{"id":92435956,"uuid":"508404590","full_name":"mathworks/build-steps-for-cmsisnn-library","owner":"mathworks","description":"Build and install steps for the ARM CMSIS-NN library for use with code generated from deep learning networks in MATLAB and Simulink.","archived":false,"fork":false,"pushed_at":"2024-12-02T14:53:04.000Z","size":15,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-09T03:26:13.136Z","etag":null,"topics":["cmsis-nn","cortex-m","matlab","simulink"],"latest_commit_sha":null,"homepage":"","language":"Makefile","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathworks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-06-28T18:01:44.000Z","updated_at":"2025-04-04T04:23:57.000Z","dependencies_parsed_at":"2024-12-08T16:49:52.955Z","dependency_job_id":null,"html_url":"https://github.com/mathworks/build-steps-for-cmsisnn-library","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mathworks/build-steps-for-cmsisnn-library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fbuild-steps-for-cmsisnn-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fbuild-steps-for-cmsisnn-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fbuild-steps-for-cmsisnn-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fbuild-steps-for-cmsisnn-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathworks","download_url":"https://codeload.github.com/mathworks/build-steps-for-cmsisnn-library/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathworks%2Fbuild-steps-for-cmsisnn-library/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274213635,"owners_count":25242519,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cmsis-nn","cortex-m","matlab","simulink"],"created_at":"2024-11-09T06:10:40.430Z","updated_at":"2025-09-08T16:32:14.309Z","avatar_url":"https://github.com/mathworks.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Build Steps for CMSIS-NN Library\nTo generate and run C code for deep neural networks on Cortex\u0026reg;-M hardware, you must have the CMSIS-NN (Cortex Microcontroller Software Interface Standard - Neural Networks) library. The following describes the build steps for CMSIS-NN on Windows\u0026reg; and Linux\u0026reg; platforms that use a cross-compiler toolchain.\n\n## Requirements \n\n### Makefile\nTo build the CMSIS-NN static library, you must first create a Makefile. Create a copy of the `Makefile.mk` file in this repository and save it to your computer. **To avoid errors during code generation, you must supply the appropriate CFLAGS variable for your target hardware.** The Makefile shared here includes several CFLAGS variables pre-validated for popular Cortex-M development boards supported by MATLAB\u0026reg;.\n\nFor example, for an STM32F746G-Discovery board, define `CFLAGS` in the Makefile as:\n\n```\nCFLAGS = -fPIC -c -mcpu=cortex-m7 -Ofast -DNDEBUG -mfloat-abi=hard -mfpu=fpv5-sp-d16\n```\nIf you do not see your hardware target listed, you must create a custom CFLAGS variable with the necessary `-mcpu`, `-mfloat-abi`, and `-mfpu` flags.\n\n### Toolchain\nWe recommend using the same toolchain for building your MATLAB-based application and the CMSIS-NN library. We have validated the CMSIS-NN library build processes below using the following toolchains:\n* Linux platforms: GNU ARM\u0026reg; Embedded Toolchain version 8.3.0\n* Windows platforms: GNU ARM\u0026reg; Embedded Toolchain version 10.3.1\n\n\n## Linux Install Steps\n1. Install the open-source, AArch32 bare-metal target (arm-eabi) GNU Arm Embedded Toolchain (v8.3.0) provided by ARM ([https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads/8-3-2019-03](https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2019q3/RC1.1/gcc-arm-none-eabi-8-2019-q3-update-linux.tar.bz2?rev=c34d758abe0c476ea2deaf8c6e16a8a2\u0026revision=c34d758a-be0c-476e-a2de-af8c6e16a8a2?product=Downloads,64-bit,,Linux,8-2019-q3-update)).\n2. Download the source code for CMSIS version 5.7.0 (available at https://github.com/ARM-software/CMSIS_5/archive/refs/tags/5.7.0.zip).\n3. Unzip the CMSIS source code to a folder and follow these steps to build and generate the static library:\n     * Open a Linux terminal.\n     * Change directory to the CMSIS-NN source folder by running the below command. Here, ```\u003cCMSIS Root folder\u003e``` refers to the extracted CMSIS folder.\n     ```\n     cd \u003cCMSIS Root folder\u003e/CMSIS/NN\n     ```\n     * Copy your `Makefile.mk` file to the current directory (```\u003cCMSIS Root folder\u003e/CMSIS/NN```). Ensure the `CFLAGS` variable is correctly defined for your hardware target in the Makefile.\n     * At the terminal, run the makefile by using the `make` command:\n     ```\n     make -f Makefile.mk\n     ```\n     * Running the makefile creates the static library `libcmsisnn.a` in the ```\u003cCMSIS Root folder\u003e/CMSIS/NN/lib``` folder.\n4. Configure the MATLAB environment to generate code that uses the CMSIS-NN library:\n     * At `/usr/local/`, create a folder named `cmsisnn`.\n     * Copy the header files located at ```\u003cCMSIS Root folder\u003e/CMSIS/DSP/Include``` and ```\u003cCMSIS Root folder\u003e/CMSIS/NN/Include``` to the location `/usr/local/cmsisnn/include`.\n     * Copy the generated static library located at ```\u003cCMSIS Root folder\u003e/CMSIS/NN/lib``` to the location `/usr/local/cmsisnn/lib`.\n     * Open a Linux terminal and use the below command to create a `CMSISNN_PATH` environment variable:\n     ```\n     export CMSISNN_PATH=/usr/local/cmsisnn\n     ```\n    \n## Windows Install Steps\n1. Install the open-source GNU Arm Embedded Toolchain provided by ARM (available at https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-win32.exe).\n     * Add ```C:\\Program Files (x86)\\GNU Arm Embedded Toolchain\\10 2021.10\\bin``` to the ```PATH``` system variable in the Windows evironment variable editor.\n2. Download and install the `make` tool. We have tested this step with Cygwin (available at https://www.cygwin.com/install.html). Within the Cygwin installer, during package selection, find the `make` package under \"Devel\". Open the dropdown list and replace the default selection \"Skip\" with the version number of `make` to install. Finish the installation process.\n     * Add ```C:\\cygwin64\\bin``` to the ```PATH``` system variable in the Windows evironment variable editor.\n3. Download the source code for CMSIS version 5.7.0 (available at https://github.com/ARM-software/CMSIS_5/archive/refs/tags/5.7.0.zip).\n4. Unzip the source code to a folder, and follow these steps to build and generate the static library: \n     * Open a Windows command prompt.\n     * Change directory to the CMSIS-NN source folder by running the below command. Here, ```\u003cCMSIS Root folder\u003e``` refers to the location where the CMSIS folder was extacted.\n     ```\n     cd \u003cCMSIS Root folder\u003e\\CMSIS\\NN \n     ```\n     * Copy your `Makefile.mk` file to the current directory (```\u003cCMSIS Root folder\u003e\\CMSIS\\NN```). Ensure the `CFLAGS` variable is correctly defined for your hardware target in the Makefile.\n     * At the command prompt, run the Makefile with the `make` command:\n     ```\n     make -f Makefile.mk\n     ```\n     * Running the Makefile creates the static library `libcmsisnn.a` in the ```\u003cCMSIS Root folder\u003e\\CMSIS\\NN\\lib``` folder.\n5. Configure the MATLAB environment to generate code that uses the CMSIS-NN library:\n     * Create a folder named `cmsisnn` in an arbitrary location. Ensure the file path does not include any space. For example, we validated the following steps with the file path `C:\\cmsisnn`. \n     * Create two subfolders within `cmsisnn` called `include` and `lib`.\n     * Copy the header files located at ```\u003cCMSIS Root folder\u003e\\CMSIS\\DSP\\Include``` and ```\u003cCMSIS Root folder\u003e\\CMSIS\\NN\\Include``` to the location `..\\cmsisnn\\include` in the new folder you created in the previous step.\n     * Copy the generated static library located at ```\u003cCMSIS Root folder\u003e\\CMSIS\\NN\\lib``` to the location `..\\cmsisnn\\lib`.\n     * Create a Windows system environment variable named `CMSISNN_PATH` with the value ```\u003cfilepath\u003e\\cmsisnn```:\n          * For Windows 10, right-click the start menu and select System.\n          * Click System Info.\n          * Click Advanced System Settings.\n          * In the Advanced tab, click Environment Variables.\n          * Click New.\n          * You will be presented with a prompt to enter a new environment variable. In the Variable name field, enter `CMSISNN_PATH`. In the Variable value field, enter the file path to the `cmsisnn` folder you created. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks%2Fbuild-steps-for-cmsisnn-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathworks%2Fbuild-steps-for-cmsisnn-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathworks%2Fbuild-steps-for-cmsisnn-library/lists"}