AN 1011: TinyML Applications in Altera FPGAs Using LiteRT for Microcontrollers

ID 848984
Date 4/07/2025
Public
Document Table of Contents

3.2.2. Building LiteRT for Microcontroller Static Library

You must build LiteRT for Microcontroller libraries in Linux environments. If you are using Windows OS, you can invoke Windows* Subsystem for Linux* (WSL) within Nios V Command Shell.
Run the following commands:
$ sudo apt update
$ sudo apt install make git python3 unzip python3-pip
$ pip3 install numpy Image
$ git clone --depth 1 https://github.com/tensorflow/tflite-micro.git
$ cd tflite-micro
$ python3 tensorflow/lite/micro/tools/project_generation/create_tflm_tree.py\
 -e hello_world tflite_app
Note: Change Directory command (cd) to tflite-micro is mandatory. The execution of create_tflm_tree.py Python script fails when it is executed from different directory.
Figure 14. Content of the tflite_app Folder
Altera recommends you complete the following tasks:
  • Review the Hello World TinyML example in the examples folder. It is a prediction model on the sine function. For more information, refer to LiteRT – Hello World Example and LiteRT - Get started with microcontrollers.
  • Modify the micro_time.cc to be compatible with the Nios® V processor. You can find the source code micro_time.cc in tensorflow\lite\micro folder. For more information, refer to LiteRT - Porting to a new platform.
Figure 15. Modification on micro_time.cc