tflite-micro (TensorFlow Lite for Microcontrollers)¶
- Homepage: https://github.com/tensorflow/tflite-micro
- Manpage: https://www.tensorflow.org/lite/microcontrollers
- Changelog: https://github.com/tensorflow/tflite-micro/commits/main
- Repository: https://github.com/tensorflow/tflite-micro
- Package: master/make/pkgs/tflite-micro/
- Steward: -
| Homepage | github.com/tensorflow/tflite-micro |
| Changelog | CHANGELOG.md |
| Repository | github.com/tensorflow/tflite-micro |
| Package | make/pkgs/tflite-micro/ |
| Maintainer | @Ircama |
Overview¶
TensorFlow Lite for Microcontrollers (TFLM) is Google's purpose-built runtime for machine learning
inference on resource-constrained devices — originally targeting bare-metal microcontrollers, and fully
capable of running on embedded Linux platforms like the FRITZ!Box.
The Freetz-EVO package cross-compiles TFLM into a static library (libtflm.a) for MIPS32, along
with 200+ C++ headers, making the full inference engine available to other packages at link time.
No Python runtime is needed on the device — the library is entirely self-contained.
Supported operations include the complete TFLM kernel set: convolutions (conv2d, depthwise conv,
transpose conv), pooling, LSTM, GRU, fully connected layers, softmax/sigmoid/tanh activations,
reshape, concatenation, dequantize, and more.
Installation¶
Enable the package in make menuconfig under:
An optional sub-option builds and installs a demo binary:
What Gets Installed¶
| Item | Location |
|---|---|
libtflm.a |
$TOOLCHAIN_STAGING/usr/lib/ |
| TFLM C++ headers (200+) | $TOOLCHAIN_STAGING/usr/include/tflite-micro/ |
tflm-hello-world (optional) |
/usr/bin/tflm-hello-world on the device |
The library and headers are installed to the staging area (not the target filesystem root) so they
are available to other packages at build time. Only the optional tflm-hello-world binary is deployed
to the device filesystem.
Linking Against libtflm.a¶
To use TFLM from another Freetz package, add the staging include and lib paths and declare a select
dependency:
MY_PACKAGE_CXXFLAGS := -I$(TARGET_TOOLCHAIN_STAGING_DIR)/usr/include/tflite-micro
MY_PACKAGE_CXXFLAGS += -std=c++17 -fno-rtti -fno-exceptions
MY_PACKAGE_LDFLAGS := -L$(TARGET_TOOLCHAIN_STAGING_DIR)/usr/lib -ltflm
Build Pipeline¶
The build involves three stages:
-
Host tool installation — numpy and Pillow are installed into freetz's own Python 3
(tools/path/python3) usingpython3 -m pip install. These are required by the TFLM
source-tree generator script. -
Source-tree generation — the official
create_tflm_tree.pyscript is run on the host
to produce a flat, single-directory source tree (tflm-tree/) containing all required.cc
and.hfiles, including third-party dependencies (kissfft, flatbuffers, ruy, gemmlowp). -
Cross-compilation — every
.ccfile in the flat tree is compiled to MIPS32 with
$(TARGET_CC)/$(TARGET_CXX), then archived intolibtflm.awith$(TARGET_AR).
Build Notes¶
-
Python 3 host tools: freetz has its own Python 3.14 at
tools/path/python3that shadows any
system Python during the build. numpy and Pillow are automatically installed into this interpreter
by the.mkrecipe (idempotent — subsequent builds skip re-installation if already present). -
array.hworkaround: the TFLM generator omits a transitive dependency (array.h) needed by
tensorflow/lite/micro/span.h; the recipe copies it from the TFLM source tree into the generated
flat tree automatically. -
Kiss FFT include path: the flat source tree places
kissfftunderthird_party/kissfft; the
cross-compilation step adds-I$(TFLITE_MICRO_TREE_DIR)/third_party/kissfftfor correct header
resolution. -
Compiler flags: all files are built with
-std=c++17 -fno-rtti -fno-exceptions -O2— the same
flags required by the upstream TFLM build system. Exceptions and RTTI are deliberately disabled to
keep code size small and avoid uClibc compatibility issues. -
Static linking only:
libtflm.ais a static archive; there is no shared library and no
lib*.sois installed to the device.
Relevant Files¶
| File | Purpose |
|---|---|
make/pkgs/tflite-micro/tflite-micro.mk |
Package makefile: download, tree generation, cross-compilation, staging install |
make/pkgs/tflite-micro/Config.in |
Kconfig options: main package + optional hello_world demo |
make/pkgs/tflite-micro/external.in |
External (squashfs) configuration for the hello_world binary |
make/pkgs/tflite-micro/external.files |
List of files to externalize |