Skip to content

Commit

Permalink
backport tensorflow#33972.
Browse files Browse the repository at this point in the history
  • Loading branch information
NobuoTsukamoto committed Jan 3, 2020
1 parent 9647d13 commit 8017159
Show file tree
Hide file tree
Showing 7 changed files with 121 additions and 17 deletions.
16 changes: 16 additions & 0 deletions tensorflow/lite/micro/arduino/abi.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/

void* __dso_handle;
Original file line number Diff line number Diff line change
@@ -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) \
tensorflow/lite/micro/arduino/abi.cc

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
26 changes: 26 additions & 0 deletions tensorflow/lite/micro/examples/magic_wand/riscv32_mcu/Makefile.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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) \
tensorflow/lite/micro/arduino/abi.cc
magic_wand_SRCS += $(MICRO_FE310_LIBWRAP_SRCS) $(MICRO_FE310_BSP_ENV_SRCS) \
tensorflow/lite/micro/arduino/abi.cc

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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) \
tensorflow/lite/micro/arduino/abi.cc
MICRO_SPEECH_SRCS += $(MICRO_FE310_LIBWRAP_SRCS) $(MICRO_FE310_BSP_ENV_SRCS) \
tensorflow/lite/micro/arduino/abi.cc

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
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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) \
tensorflow/lite/micro/arduino/abi.cc
person_detection_SRCS += $(MICRO_FE310_LIBWRAP_SRCS) $(MICRO_FE310_BSP_ENV_SRCS) \
tensorflow/lite/micro/arduino/abi.cc

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
2 changes: 1 addition & 1 deletion tensorflow/lite/micro/tools/make/helper_functions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,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 $$@)
Expand Down
17 changes: 1 addition & 16 deletions tensorflow/lite/micro/tools/make/targets/mcu_riscv_makefile.inc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Settings for RISCV 32-bit MCU toolchain.
ifeq ($(TARGET), riscv32_mcu)
export PATH := $(MAKEFILE_DIR)/downloads/riscv_toolchain/bin/:$(PATH)
# export PATH := $(MAKEFILE_DIR)/downloads/riscv_toolchain/bin/:$(PATH)
TARGET_ARCH := riscv32_mcu
TARGET_TOOLCHAIN_PREFIX := riscv64-unknown-elf-

Expand Down Expand Up @@ -49,22 +49,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 \
Expand Down

0 comments on commit 8017159

Please sign in to comment.