Deployment Workflow

rocket_launch

Train → Compress → Convert → Flash Pipeline

1. Data Collection & Preprocessing

Gather sensor data that mirrors production conditions: same hardware, same mounting, same environmental variation. For audio, record on the target microphone. For motion, record on the target IMU. Balance classes and augment sparingly.

Key Features
  • Record on target hardware when possible
  • Edge Impulse Data Forwarder for live capture
  • Minimum 500 samples per class
  • Include noise and edge-case samples
  • Store raw data before any preprocessing
Similar Technologies
Simulated data (risk: domain gap)Transfer from similar datasetsSynthetic augmentation
2. Model Architecture Selection

Choose an architecture sized to the target MCU's RAM and Flash budget. Starting from MobileNet, DS-CNN, or MCUNet is faster than compressing a large model. Use the MCU's RAM budget to back-calculate maximum layer size.

Key Features
  • DS-CNN: depthwise-separable for audio
  • MobileNetV1 for image (heavy for MCU)
  • MCUNet / ProxylessNAS for MCU-native
  • Back-calculate RAM from activation sizes
  • Prefer flat architectures (fewer residuals)
Similar Technologies
Compressed ResNetEfficientNet-LiteCustom NAS search
3. Training & Quantization

Train with INT8 quantization in mind from the start. Use QAT if PTQ accuracy is insufficient. Fix the random seed and log all hyperparameters. Validate on a held-out set that includes out-of-domain samples.

Key Features
  • QAT via TF Model Optimization Toolkit
  • PTQ: representative_dataset of 100–1000 samples
  • Log: accuracy, loss, confusion matrix
  • Test with real INT8 inference via TFLite
  • Track model size (KB) alongside accuracy
Similar Technologies
Binary quantizationMixed-precision QATGPTQ-style PTQ
4. Conversion to TFLite / C Array

Export the quantized Keras model to a .tflite flatbuffer, then embed it in firmware as a C byte array. The model is stored in Flash and loaded into a static memory arena at runtime — no filesystem required.

Key Features
  • TFLiteConverter.from_keras_model()
  • optimizations = [DEFAULT] for INT8
  • xxd -i model.tflite > model_data.h
  • model_data.h included in firmware source
  • Validate flatbuffer with TFLite Python runtime
Similar Technologies
Edge Impulse SDK (automates all)microTVM compile outputLittleFS model file on external Flash
5. Firmware Integration

Include the model C header and TFLite Micro runtime in the firmware project. Allocate a static tensor arena (aligned byte array) for activations. Use the MicroInterpreter API to run inference.

Key Features
  • Static tensor_arena[N] — no heap needed
  • MicroInterpreter with MicroMutableOpResolver
  • RegisterOp for only required ops (saves Flash)
  • GetInputTensor() → fill → Invoke()
  • GetOutputTensor() → read results
Similar Technologies
EloquentTinyML wrapperEdge Impulse SDKmicroTVM generated code
6. On-Device Validation & Profiling

Measure actual RAM consumption, Flash usage, and inference latency on the physical device. These differ from simulator estimates. TFLite Micro's benchmark_model and PlatformIO profiling give cycle-accurate measurements.

Key Features
  • benchmark_model via serial output
  • RAM: Arena size + interpreter overhead
  • Flash: .tflite C array size + runtime
  • Latency: DWT cycle counter or timer
  • Edge Impulse profiler for quick estimate
Similar Technologies
Simulator (Renode, QEMU)Static analysis toolsST X-CUBE-AI profiling
checklist

Deployment Checklist

StepTaskTool / CommandPass Criteria
1Collect representative datasetEdge Impulse Data Forwarder, custom scripts≥500 samples/class, balanced
2Train baseline model (FP32)Keras / PyTorchAccuracy meets threshold on validation set
3Apply QAT or PTQTF Model Optimization ToolkitAccuracy drop <2% vs FP32 baseline
4Convert to .tflitetf.lite.TFLiteConverter.tflite file created, flatbuffer valid
5Profile on target MCUTFLite Micro benchmark_model, Edge Impulse profilerRAM/Flash within budget, latency < requirement
6Generate C header arrayxxd -i model.tflite > model_data.hmodel_data.h contains valid byte array
7Integrate into firmwareTFLite Micro C++ APIInference runs without memory errors
8Run on-device testsPlatformIO Unity test, custom test suiteAccuracy on held-out set meets threshold
9Flash to production deviceopenocd, bossac, esptool.pyDevice boots and runs inference correctly
10Plan OTA update pathMCUboot, ESP-IDF OTA, nRF FOTAModel update deployable without device recall
code

Conversion Patterns

TFLite INT8 PTQ Conversion

Standard path from Keras FP32 model to INT8 TFLite. Requires a representative dataset to calibrate quantization scale factors for activations.

Key Features
  • converter = TFLiteConverter.from_keras_model(model)
  • converter.optimizations = [DEFAULT]
  • converter.representative_dataset = gen_fn
  • converter.target_spec.supported_ops = [INT8]
  • tflite_model = converter.convert()
Similar Technologies
QAT conversionONNX → microTVM pathEdge Impulse auto-convert
TFLite Micro C++ Inference

Minimal firmware integration: resolve required ops, allocate a static tensor arena, run interpreter, copy input, invoke, read output.

Key Features
  • #include "tensorflow/lite/micro/micro_interpreter.h"
  • MicroMutableOpResolver<N> resolver
  • resolver.AddConv2D(); resolver.AddDepthwiseConv2D();
  • alignas(16) uint8_t tensor_arena[ARENA_SIZE]
  • interpreter.Invoke(); // run inference
Similar Technologies
EloquentTinyML APIEdge Impulse run_classifier()microTVM tvmgen_*()
system_update

OTA Updates & Model Lifecycle

MCUboot (Secure OTA)

Open-source bootloader for MCUs supporting A/B image slots, cryptographic signature verification, and rollback on failed updates. Used with Zephyr RTOS and supported on STM32, nRF52, ESP32.

Key Features
  • A/B image slots in Flash
  • SHA-256 + ECDSA image signing
  • Rollback on bad image
  • Works with Zephyr, nRF Connect SDK
  • Can update model C array as part of firmware
Similar Technologies
ESP-IDF OTA (native ESP32)nRF FOTACustom bootloader
Model Versioning Strategy

Embed model version and metadata in firmware. Track model ID, training dataset version, and quantization config. Log inference statistics to detect when a model update is needed (concept drift).

Key Features
  • Store model_version in Flash config block
  • Hash model data for integrity check
  • Report version + confidence via BLE/MQTT
  • Monitor accuracy proxy metrics (confidence histogram)
  • Trigger OTA when drift detected server-side
Similar Technologies
Fixed model (no OTA)Cloud inference fallbackFederated learning refresh