Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Riscv 32 mcu #36118

Merged
merged 3 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 2020 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,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

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

27 changes: 27 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,27 @@
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
7 changes: 4 additions & 3 deletions tensorflow/lite/micro/tools/make/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ CXX := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}${CXX_TOOL}
CC := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}${CC_TOOL}
AR := $(CC_PREFIX)${TARGET_TOOLCHAIN_PREFIX}${AR_TOOL}

# The default Makefile target(all) must appear before any target,
# which is compiled if there's no command-line arguments.
all: $(MICROLITE_LIB_PATH)

# Load the examples.
include $(wildcard tensorflow/lite/micro/examples/*/Makefile.inc)

Expand Down Expand Up @@ -268,9 +272,6 @@ $(OBJDIR)%.o: %.S $(THIRD_PARTY_TARGETS)
@mkdir -p $(dir $@)
$(CC) $(CCFLAGS) $(INCLUDES) -c $< -o $@

# The target that's compiled if there's no command-line arguments.
all: $(MICROLITE_LIB_PATH)

microlite: $(MICROLITE_LIB_PATH)

# Hack for generating schema file bypassing flatbuffer parsing
Expand Down
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 @@ -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 $$@)
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
Expand Up @@ -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 \
Expand All @@ -76,4 +61,4 @@ ifeq ($(TARGET), riscv32_mcu)
$(BINDIR)/%.bin: $(BINDIR)/%
@mkdir -p $(dir $@)
$(OBJCOPY) $< $@ -O binary
endif
endif