Getting Started

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 #

ComponentMinimum versionNotes
Linux6.19CONFIG_DRM_ACCEL_ARM_ETHOSU must be enabled
Mesa26.0built 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 master branch (some required components have not yet made it into the released versions)
  • Add the meta-freescale layer and configure appropriately:
    • Enable the machine/imx93-11x11-lpddr4x-frdm fragment to select the FRDM-IMX93 platform as the target for this build.
    • Enable the bsp/fslc fragment to select the mainline kernel instead of the vendor kernel.
    • Enable eula/accept-fsl-eula to indicate acceptance of the NXP EULA, which is required to build the bootloader.
  • Enable the meta-tensorflow layer 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 #

  1. Install NXP’s uuu flashing tool.

  2. Set the SW1 boot switch to serial download mode (1000)

  3. Connect the USB-C download port and power.

  4. Save the following as flash-frdm.uuu in 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: done
    
  5. Then run it:

    cd bitbake-builds/poky-master/build/tmp/deploy/images/imx93-11x11-lpddr4x-frdm
    uuu flash-frdm.uuu
    
  6. Set 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.

  1. Connect to the debug UART console on the other USB-C port (115200 8N1; it appears as /dev/ttyACM0 on a Linux host).

  2. Log in as root with no password.

  3. 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.so
    
  4. Classify 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
    

Edit this page · View as Markdown