TensorFlow Lite Micro makes use of Renode to for software emulation.
Here, we document how Renode is used as part of the TFLM project. For more general use of Renode, please refer to the Renode documentation.
Renode can be installed and used in a variety of ways, as documented here. For the purpose of Tensorflow Lite Micro, we make use of a portable version for Linux.
Download portable version of Renode for Linux:
tensorflow/lite/micro/testing/download_renode.sh tensorflow/lite/micro/tools/make/downloads/renode
Install the Renode test dependencies
pip3 install -r tensorflow/lite/micro/tools/make/downloads/renode/tests/requirements.txt
At this point in time you will be ready to run TFLM tests with Renode.
All the tests for a specific platform (e.g. bluepill) can be run with:
make -f tensorflow/lite/micro/tools/make/Makefile TARGET=bluepill test
Describe how we wait for a particular string on the UART. Some pointers into the robot files as well as any relevant documentation from Renode.
A test failure is the absence of a specific string on the UART so the test will wait for a specific timeout period (configured in the .robot) file before failing.
What this means in practice is that a failing test will take longer to finish than a test that passes.
If needed, an optimization on this would be to have a specific failure message as well so that both success and failure can be detected quickly.
Renode can also be used to run and debug binaries interactively. For example, to debug kernel_addr_test
on Bluepill platform, run Renode:
tensorflow/lite/micro/tools/make/downloads/renode/renode
and issue following commands:
mach create machine LoadPlatformDescription @platforms/cpus/stm32f103.repl # Create additional semihosting interface peripheral machine LoadPlatformDescriptionFromString "uartSemihosting: UART.SemihostingUart @ cpu" # Open separate window for semihosting UART output showAnalyzer sysbus.cpu.uartSemihosting # Load ELF file sysbus LoadELF @tensorflow/lite/micro/tools/make/gen/bluepill_cortex-m3/bin/kernel_add_test # Start simulation start
You can also connect GDB to the simulation. To do that, start the GDB server in Renode before issuing the start
command:
machine StartGdbServer 3333
Than you can connect from GDB with:
target remote localhost:3333
For further reference please see the Renode documentation.