lite:micro:riscv32_mcu:Fix build failure of undefined references.
Fix the ld error: undefined references to `__wrap_puts` for build commands like `make -f tensorflow/lite/micro/tools/make/Makefile TARGET=riscv32_mcu hello_world_bin` The related issue is tensorflow#32041 Refactoring, suggested by Nick Kreeger(nick.kreeger@gmail.com): The targets/mcu_riscv_makefile.inc should only include the bare-bones parts for building for this platform. So move platform specific items from targets/mcu_riscv_makefile.inc to the actual example folder. Create a riscv32_mcu folder in each example directory. In those directories, create a new Makefile.inc that adds these rules moved out. The bug's original reasons: The Makefile variables XXX_TEST_SRCS/XXX_SRCS in targets/mcu_riscv_makefile.inc are overridden by the the examples's respective makefile.inc (eg. hello_world/Makefile.inc), which leads to the architecture special __wrap__funs are not included correctly.
This commit is contained in:
parent
18bde9a6b2
commit
84b639d858
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
@ -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
|
@ -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 $$@)
|
||||
|
@ -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
|
||||
endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user