Try it out: Ethos-U on NXP FRDM i.MX 93 Development Board
Run a TensorFlow Lite model on the Arm Ethos-U65 NPU of the NXP FRDM-IMX93 board, using upstream Linux and Mesa.
This guide turns the Open Inference Stack base requirements into concrete steps for the NXP FRDM i.MX93 Development Board which includes an Arm Ethos-U65 NPU.
After completing this guide, you will have a complete Linux distro installation
using mainline kernel and Mesa with the open ethosu NPU drivers fully
operational.
It’s a quick way to see the whole stack working end to end, meant for evaluation and demos, and as a reference for your own implementation.
Required Software Versions #
| Component | Minimum version | Notes |
|---|---|---|
| Linux | 6.19 | CONFIG_DRM_ACCEL_ARM_ETHOSU must be enabled |
| Mesa | 26.0 | built with -Dgallium-drivers=ethosu |
Yocto Reference Image #
We will build a custom image of Yocto’s reference distribution (Poky) for this board with the open stack included, as well as TensorFlow Lite and some sample models/tools.
1. Build the image #
To build the image, follow the Yocto Project Quick Build instructions with the following selections and modifications:
- Build from
masterbranch (some required components have not yet made it into the released versions) - Add the
meta-freescalelayer and configure appropriately:- Enable the
machine/imx93-11x11-lpddr4x-frdmfragment to select the FRDM-IMX93 platform as the target for this build. - Enable the
bsp/fslcfragment to select the mainline kernel instead of the vendor kernel. - Enable
eula/accept-fsl-eulato indicate acceptance of the NXP EULA, which is required to build the bootloader.
- Enable the
- Enable the
meta-tensorflowlayer and its dependencies (meta-oe,meta-python) - Enable installation of Teflon and TensorFlow Lite in the final image
The end result is that while meta-freescale is used to place the
vendor-specific early boot setup in the image, the fslc fragment causes system
boot to proceed with mainline u-boot and mainline Linux. meta-freescale also
configures Mesa to be built with teflon and ethosu included. And that’s all
that is needed to get the Open Inference Stack up and running!
Adapting the Quick Build guide to those changes, the resultant commands are e.g.:
python3 -m venv --clear ./bitbake-setup-venv
. ./bitbake-setup-venv/bin/activate
pip install bitbake-setup
bitbake-setup init --non-interactive poky-master poky-with-sstate distro/poky machine/qemuarm64
cd bitbake-builds/poky-master
. build/init-build-env
# bitbake-layers takes care of dependencies automatically
bitbake-layers layerindex-fetch -b master -f ../layers meta-freescale meta-tensorflow
bitbake-config-build enable-fragment machine/imx93-11x11-lpddr4x-frdm \
freescale-layer/bsp/fslc freescale-layer/eula/accept-fsl-eula \
core/yocto/root-login-with-empty-password
echo 'CORE_IMAGE_EXTRA_INSTALL += "libteflon tensorflow-lite"' >> conf/local.conf
bitbake core-image-sato
2. Flash the eMMC #
Install NXP’s uuu flashing tool.
Set the SW1 boot switch to serial download mode (1000)
Connect the USB-C download port and power.
Save the following as
flash-frdm.uuuin the deploy directory:uuu_version 1.5.0 SDPS: boot -f flash.bin FB: ucmd setenv fastboot_dev mmc FB: ucmd setenv mmcdev 0 FB: ucmd mmc dev 0 0 FB: flash -raw2sparse -bmap core-image-sato-imx93-11x11-lpddr4x-frdm.rootfs.wic.bmap all core-image-sato-imx93-11x11-lpddr4x-frdm.rootfs.wic.gz/* FB: doneThen run it:
cd bitbake-builds/poky-master/build/tmp/deploy/images/imx93-11x11-lpddr4x-frdm uuu flash-frdm.uuuSet SW1 back to eMMC boot (0100) and power-cycle the board.
3. Run a model on the NPU #
The image includes a quantized MobileNet model with test data.
Connect to the debug UART console on the other USB-C port (115200 8N1; it appears as
/dev/ttyACM0on a Linux host).Log in as
rootwith no password.Run the benchmark on the CPU and then on the NPU through Teflon:
M=/usr/share/label_image # CPU, 2 threads: about 30 ms per inference benchmark_model --graph=$M/mobilenet_v1_1.0_224_quant.tflite --num_threads=2 # NPU through Teflon: about 4.7 ms per inference benchmark_model --graph=$M/mobilenet_v1_1.0_224_quant.tflite \ --external_delegate_path=/usr/lib/libteflon.soClassify an image. The top result should be “military uniform”, with or without the delegate:
label_image -m $M/mobilenet_v1_1.0_224_quant.tflite -i $M/grace_hopper.bmp \ -l $M/labels_mobilenet_quant_v1_224.txt \ --external_delegate_path=/usr/lib/libteflon.so