diff --git a/tensorflow/lite/micro/examples/hello_world/riscv32_mcu/Makefile.inc b/tensorflow/lite/micro/examples/hello_world/riscv32_mcu/Makefile.inc new file mode 100644 index 00000000000..61d683286dd --- /dev/null +++ b/tensorflow/lite/micro/examples/hello_world/riscv32_mcu/Makefile.inc @@ -0,0 +1,25 @@ +ifeq ($(TARGET), riscv32_mcu) + # Wrap functions + MICRO_FE310_LIBWRAP_SRCS := \ + $(wildcard $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/sys/*.c) \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/misc/write_hex.c \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/stdlib/malloc.c + + MICRO_FE310_BSP_ENV_SRCS := \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/start.S \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/entry.S \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/freedom-e300-hifive1/init.c + + HELLO_WORLD_TEST_SRCS += $(MICRO_FE310_LIBWRAP_SRCS) $(MICRO_FE310_BSP_ENV_SRCS) + HELLO_WORLD_SRCS += $(MICRO_FE310_LIBWRAP_SRCS) $(MICRO_FE310_BSP_ENV_SRCS) + + LIBWRAP_SYMS := malloc free \ + open lseek read write fstat stat close link unlink \ + execve fork getpid kill wait \ + isatty times sbrk _exit puts + + LDFLAGS += $(foreach s,$(LIBWRAP_SYMS),-Wl,--wrap=$(s)) + LDFLAGS += $(foreach s,$(LIBWRAP_SYMS),-Wl,--wrap=_$(s)) + LDFLAGS += -L. -Wl,--start-group -lc -Wl,--end-group +endif + diff --git a/tensorflow/lite/micro/examples/magic_wand/riscv32_mcu/Makefile.inc b/tensorflow/lite/micro/examples/magic_wand/riscv32_mcu/Makefile.inc new file mode 100644 index 00000000000..e8f8b15a279 --- /dev/null +++ b/tensorflow/lite/micro/examples/magic_wand/riscv32_mcu/Makefile.inc @@ -0,0 +1,25 @@ +ifeq ($(TARGET), riscv32_mcu) + # Wrap functions + MICRO_FE310_LIBWRAP_SRCS := \ + $(wildcard $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/sys/*.c) \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/misc/write_hex.c \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/stdlib/malloc.c + + MICRO_FE310_BSP_ENV_SRCS := \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/start.S \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/entry.S \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/freedom-e300-hifive1/init.c + + magic_wand_TEST_SRCS += $(MICRO_FE310_LIBWRAP_SRCS) $(MICRO_FE310_BSP_ENV_SRCS) + magic_wand_SRCS += $(MICRO_FE310_LIBWRAP_SRCS) $(MICRO_FE310_BSP_ENV_SRCS) + + LIBWRAP_SYMS := malloc free \ + open lseek read write fstat stat close link unlink \ + execve fork getpid kill wait \ + isatty times sbrk _exit puts + + LDFLAGS += $(foreach s,$(LIBWRAP_SYMS),-Wl,--wrap=$(s)) + LDFLAGS += $(foreach s,$(LIBWRAP_SYMS),-Wl,--wrap=_$(s)) + LDFLAGS += -L. -Wl,--start-group -lc -Wl,--end-group +endif + diff --git a/tensorflow/lite/micro/examples/micro_speech/riscv32_mcu/Makefile.inc b/tensorflow/lite/micro/examples/micro_speech/riscv32_mcu/Makefile.inc new file mode 100644 index 00000000000..3c9960d1510 --- /dev/null +++ b/tensorflow/lite/micro/examples/micro_speech/riscv32_mcu/Makefile.inc @@ -0,0 +1,24 @@ +ifeq ($(TARGET), riscv32_mcu) + # Wrap functions + MICRO_FE310_LIBWRAP_SRCS := \ + $(wildcard $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/sys/*.c) \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/misc/write_hex.c \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/stdlib/malloc.c + + MICRO_FE310_BSP_ENV_SRCS := \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/start.S \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/entry.S \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/freedom-e300-hifive1/init.c + + MICRO_SPEECH_TEST_SRCS += $(MICRO_FE310_LIBWRAP_SRCS) $(MICRO_FE310_BSP_ENV_SRCS) + MICRO_SPEECH_SRCS += $(MICRO_FE310_LIBWRAP_SRCS) $(MICRO_FE310_BSP_ENV_SRCS) + + LIBWRAP_SYMS := malloc free \ + open lseek read write fstat stat close link unlink \ + execve fork getpid kill wait \ + isatty times sbrk _exit puts + + LDFLAGS += $(foreach s,$(LIBWRAP_SYMS),-Wl,--wrap=$(s)) + LDFLAGS += $(foreach s,$(LIBWRAP_SYMS),-Wl,--wrap=_$(s)) + LDFLAGS += -L. -Wl,--start-group -lc -Wl,--end-group +endif diff --git a/tensorflow/lite/micro/examples/person_detection/riscv32_mcu/Makefile.inc b/tensorflow/lite/micro/examples/person_detection/riscv32_mcu/Makefile.inc new file mode 100644 index 00000000000..54c180c3baa --- /dev/null +++ b/tensorflow/lite/micro/examples/person_detection/riscv32_mcu/Makefile.inc @@ -0,0 +1,24 @@ +ifeq ($(TARGET), riscv32_mcu) + # Wrap functions + MICRO_FE310_LIBWRAP_SRCS := \ + $(wildcard $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/sys/*.c) \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/misc/write_hex.c \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/stdlib/malloc.c + + MICRO_FE310_BSP_ENV_SRCS := \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/start.S \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/entry.S \ + $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/freedom-e300-hifive1/init.c + + person_detection_TEST_HDRS += $(MICRO_FE310_LIBWRAP_SRCS) $(MICRO_FE310_BSP_ENV_SRCS) + person_detection_SRCS += $(MICRO_FE310_LIBWRAP_SRCS) $(MICRO_FE310_BSP_ENV_SRCS) + + LIBWRAP_SYMS := malloc free \ + open lseek read write fstat stat close link unlink \ + execve fork getpid kill wait \ + isatty times sbrk _exit puts + + LDFLAGS += $(foreach s,$(LIBWRAP_SYMS),-Wl,--wrap=$(s)) + LDFLAGS += $(foreach s,$(LIBWRAP_SYMS),-Wl,--wrap=_$(s)) + LDFLAGS += -L. -Wl,--start-group -lc -Wl,--end-group +endif diff --git a/tensorflow/lite/micro/tools/make/helper_functions.inc b/tensorflow/lite/micro/tools/make/helper_functions.inc index d07a119945f..cf8065c7cab 100644 --- a/tensorflow/lite/micro/tools/make/helper_functions.inc +++ b/tensorflow/lite/micro/tools/make/helper_functions.inc @@ -357,7 +357,7 @@ $(1)_LOCAL_SRCS := $$(call specialize,$$($(1)_LOCAL_SRCS)) ALL_SRCS += $$($(1)_LOCAL_SRCS) $(1)_LOCAL_HDRS := $(3) $(1)_LOCAL_OBJS := $$(addprefix $$(OBJDIR), \ -$$(patsubst %.cc,%.o,$$(patsubst %.c,%.o,$$($(1)_LOCAL_SRCS)))) +$$(patsubst %.S,%.o,$$(patsubst %.cc,%.o,$$(patsubst %.c,%.o,$$($(1)_LOCAL_SRCS))))) $(1)_BINARY := $$(BINDIR)$(1) $$($(1)_BINARY): $$($(1)_LOCAL_OBJS) $$(MICROLITE_LIB_PATH) @mkdir -p $$(dir $$@) diff --git a/tensorflow/lite/micro/tools/make/targets/mcu_riscv_makefile.inc b/tensorflow/lite/micro/tools/make/targets/mcu_riscv_makefile.inc index 1ec91cdca82..5d1a729dbaf 100644 --- a/tensorflow/lite/micro/tools/make/targets/mcu_riscv_makefile.inc +++ b/tensorflow/lite/micro/tools/make/targets/mcu_riscv_makefile.inc @@ -48,22 +48,7 @@ ifeq ($(TARGET), riscv32_mcu) MICROLITE_CC_SRCS += \ $(wildcard tensorflow/lite/micro/riscv32_mcu/*.cc) - MICRO_SPEECH_TEST_SRCS += \ - $(wildcard $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/sys/*.c) \ - $(wildcard $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/sys/*.cc) \ - $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/misc/write_hex.c \ - $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/libwrap/stdlib/malloc.c \ - $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/start.S \ - $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/entry.S \ - $(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/freedom-e300-hifive1/init.c - LIBWRAP_SYMS := malloc free \ - open lseek read write fstat stat close link unlink \ - execve fork getpid kill wait \ - isatty times sbrk _exit puts - LDFLAGS += $(foreach s,$(LIBWRAP_SYMS),-Wl,--wrap=$(s)) - LDFLAGS += $(foreach s,$(LIBWRAP_SYMS),-Wl,--wrap=_$(s)) - LDFLAGS += -L. -Wl,--start-group -lc -Wl,--end-group LDFLAGS += \ -T$(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/freedom-e300-hifive1/flash.lds \ -nostartfiles \ @@ -76,4 +61,4 @@ ifeq ($(TARGET), riscv32_mcu) $(BINDIR)/%.bin: $(BINDIR)/% @mkdir -p $(dir $@) $(OBJCOPY) $< $@ -O binary -endif \ No newline at end of file +endif