Question/Issue:
I am trying to integrate my Edge Impulse inference engine (C++ library + compiled model) directly into custom MicroPython firmware for the Raspberry Pi Pico. However, when I build the firmware with the inference library included, the final .uf2
file becomes too large (~1.9 MB) and the board does not boot after flashing — there is no serial output and the device does not enumerate over USB.
Context/Use case:
The goal is to provide an integrated firmware that includes both the MicroPython interpreter and the native inference engine as a module.
Steps Taken:
- Built the inference library (
ei_inference
) in C++ with the Pico SDK — standalone version works fine. - Verified the compiled model runs correctly on the Pico with a native C++ application.
- Tried to compile a custom MicroPython build using the official MicroPython port for RP2040, adding the
ei_inference
static library and model as a custom C module. - The firmware compiled successfully but produced a
.uf2
file ~1.9 MB in size. - After flashing, the board does not enumerate over USB, no serial output appears, and the device appears bricked until reflashed with standard MicroPython.
Expected Outcome:
The Pico should boot into MicroPython with the custom inference module available (import ei_inference
) so students can run inference calls directly from Python scripts.
Actual Outcome:
The device does not boot at all.
No serial device appears, and no REPL output.
The Pico must be reflashed with plain MicroPython to work again.
Reproducibility:
—Always
… Sometimes
…Rarely
Environment:
Platform: Raspberry Pi Pico (RP2040)
Build Environment Details:
- Pico SDK v1.5.1
- Custom MicroPython build using
mpy-cross
andmake
on macOS 13 - Edge Impulse C++ library and compiled model embedded as static library in MicroPython build
OS Version: macOS 13.5.2 (also tested on Ubuntu 22.04)
Custom Blocks / Impulse Configuration:
- 3-axis raw accelerometer data, small NN classifier, compiled with CMSIS-NN and TFLM micro kernels.
- No custom DSP blocks.
I want to confirm:
- Is this approach feasible for the Pico (2 MB flash limit)?
- Any tips for reducing size (e.g., exclude unused modules, shrink model, other linker flags)?