tflite-micro: Couldn't open elf file generated by hello world example

Hey, so I was attempting to build the hello world example for RISC-V target and then use Spike to run the subsequent binary file. These are the commands I used to do this:

  1. git clone https://github.com/tensorflow/tflite-micro.git
  2. cd tflite-micro
  3. make -f tensorflow/lite/micro/tools/make/Makefile third_party_downloads
  4. Change the target from riscv32_mcu to mcu_riscv in /tensorflow/lite/micro/tools/make/mcu_riscv_makefile.inc and in /tensorflow/lite/micro/examples/hello_world/riscv32_mcu/Makefile.inc
  5. Moved the flags -fnothreadsafe-statics and -fno-use-cxa-atexit from PLATFORM FLAGS to CXX FLAGS in /tensorflow/lite/micro/tools/make/targets/mcu_riscv_makefile.inc
  6. Changed -c11 to -gnu11 under CCFLAGS in /tensorflow/lite/micro/tools/make/Makefile
  7. Changed the functions fmin and fmax to min and max respectively in /tensorflow/lite/kernels/internal/min.h and /tensorflow/lite/kernels/internal/max.h.
  8. Run the command make -f tensorflow/lite/micro/tools/make/Makefile TARGET=mcu_riscv TARGET_ARCH=riscv32_mcu hello_world_bin
  9. Run the binary using Spike: spike --isa=rv32imafdc pk tensorflow/lite/micro/tools/make/gen/mcu_riscv_riscv32_mcu_default/bin/hello_world

I’ve checked that the binary generated is indeed ELF 32-bit RISC-V executable, but still on running the final command, it shows bbl loader couldn't open ELF program: tensorflow/lite/micro/tools/make/gen/mcu_riscv_riscv32_mcu_default/bin/hello_world!

Can anyone let me know what I’m doing wrong in this case??

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (1 by maintainers)

Most upvoted comments

  1. clone repository
  2. use this as micro/tools/make/targets/mcu_riscv_makefile.inc: https://pastebin.com/BgqEq5i7 (noticed i removed the downloads too, you should have a riscv compiler in your path)
  3. make -f tensorflow/lite/micro/tools/make/Makefile TARGET=mcu_riscv TARGET_ARCH=riscv32_mcu hello_world_bin

if it doesn’t work it might be a compiler problem, maybe install on path the one that tflite micro downloads

Thanks, your makefile flags helped me to compile for my CV32E40P.

  1. clone repository
  2. use this as micro/tools/make/targets/mcu_riscv_makefile.inc: https://pastebin.com/BgqEq5i7 (noticed i removed the downloads too, you should have a riscv compiler in your path)
  3. make -f tensorflow/lite/micro/tools/make/Makefile TARGET=mcu_riscv TARGET_ARCH=riscv32_mcu hello_world_bin

if it doesn’t work it might be a compiler problem, maybe install on path the one that tflite micro downloads