Running a TF-Lite Model on RENODE (Litex Vexx RISC-V SoC)

Mahnoor Ismail
3 min readAug 28, 2023

In today’s embedded world, having a reliable emulation platform can drastically reduce development time and facilitate system-level testing. Renode is one such platform, and today, we’ll delve into running a TensorFlow Lite application on the LiteX Vexx RISC-V SoC under the Renode emulation environment.

Prerequisites

  1. Linux environment (for our steps).
  2. Knowledge about Zephyr, an open-source Real-Time Operating System (RTOS).

STEP 1: Setting Up Renode

Head to the Renode Github Repository.

STEP 2: Downloading Necessary Files

From the releases section, download the following files:

  1. renode-1.12.0–1-x86_64.pkg.tar.xz8.13 MB
  2. renode-1.12.0–1.f23.x86_64.rpm12.5 MB
  3. renode-1.12.0.linux-portable.tar.gz46.1 MB
  4. renode_1.12.0.dmg14.3 MB
  5. renode_1.12.0.msi15.7 MB
  6. renode_1.12.0.zip15.2 MB
  7. renode_1.12.0_amd64.deb12.6 MB
  8. Source code (zip)
  9. Source code (tar.gz)

STEP 3: Unpacking The Files

mkdir renode_portable
tar xf renode-*.linux-portable.tar.gz -C renode_portable --strip-components=1

STEP 4: Adding to System Path

To conveniently call Renode from any terminal:

cd renode_portable
export PATH="`pwd`:$PATH"

STEP 5: Launching Renode

Open a terminal and simply type:

renode

This will launch the Renode monitor (CLI) where the emulation environment can be controlled.

STEP 6: Loading a Script

Scripts are crucial in Renode. To load one, use:

include @/path/to/script.resc

For instance:

include @/home/mahnoor/renode/renode_portable/scripts/single-node/litex.resc

STEP 7: Installing Zephyr

Zephyr can be installed following the guidelines provided here.

STEP 8: Building the Zephyr Shell Demo Application

cd ~/zephyrproject/zephyr
source zephyr-env.sh
west build -p auto -b litex_vexriscv samples/subsys/shell/shell_module/

STEP 9: Relaunching Renode

Again, type:

renode

STEP 10: Running the Zephyr Binary on Renode

In the Renode monitor, run:

(monitor) $zephyr=@/path/to/zephyrproject/zephyr/build/zephyr/zephyr.elf
(monitor) start @scripts/single-node/litex_vexriscv_zephyr.resc

E: if you will get an error from the above command; goto: https://www.mono-project.com/download/stable/

It looks like mono can’t find the libdl.so file. Perhaps it’s the .2 postfix in the filename.

Then Run this command

sudo ln -s /usr/lib/x86_64-linux-gnu/libdl.so.2 /usr/lib/dl

E: if you get an error :

(monitor) $zephyr?=@/path/to/zephyrproject/zephyr/build/zephyr/zephyr.elf                (zephyr binary)
(monitor) start @scripts/single-node/litex_vexriscv_zephyr.resc (soc/board )

STEP 11: Running an Application on Renode

The power of Renode extends beyond the basic Zephyr shell. You can also run specialized applications, like TensorFlow Lite, on the emulated LiteX Vexx RISC-V SoC. Let’s dive into the steps:

  1. Setting Up The Application: Navigate to the ‘hello world’ folder within Zephyr’s sample applications.
  2. Building the Binary: Open your command prompt or terminal and execute:
west build -b {board_name}
  1. As an example, if you’re using the litex_vexriscv board:
west build -b litex_vexriscv
  1. This will generate the application’s binary. Note that litex_vexriscv is just one of the many boards supported by Zephyr. You can replace it with any board name supported by Zephyr.
  2. Loading the Binary in Renode: Launch Renode, and in the monitor, input:
(monitor) $zephyr?=@/path/to/zephyrproject/zephyr/samples/modules/tflite-micro/build/zephyr/zephyr.elf
  1. Make sure to replace the path with the exact location of your Zephyr binary.
  2. Starting the Emulation: Now, to initiate the emulation, enter:
(monitor) start @scripts/single-node/litex_vexriscv_zephyr.resc
  1. Observing the Output: Once the command is executed, Renode will bring up the UART window, showcasing the application’s output.

Congratulations!

Your TensorFlow Lite Application is now humming smoothly on the LiteX Vexx RISC-V SoC in Renode’s emulated environment.

For those deeply interested in embedded systems, the approach outlined in this blog offers a promising way to run and test applications in a risk-free environment before transferring them to real hardware. Happy coding!

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Mahnoor Ismail
Mahnoor Ismail

Written by Mahnoor Ismail

Research Assistant at Micro Electronics Research Lab (MERL-UIT)

No responses yet

Write a response