Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/tensorflow/lite/micro/epiphany_mcu/debug_log.cc b/tensorflow/lite/micro/epiphany_mcu/debug_log.cc
new file mode 100644
index 00000000..284501c6
--- /dev/null
+++ b/tensorflow/lite/micro/epiphany_mcu/debug_log.cc
@@ -0,0 +1,23 @@
+/* Copyright 2018 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.
+==============================================================================*/
+// TODO(b/121324430): Add test for DebugLog functions
+// TODO(b/121275099): Remove dependency on debug_log once the platform supports
+// printf
+
+#include <stdio.h>
+#include <string.h>
+
+//volatile char *debug = (void *)0x7000;
+
+extern "C" void DebugLog(const char* s) {
+ //*debug = 999;
+}
diff --git a/tensorflow/lite/micro/examples/hello_world/README.md b/tensorflow/lite/micro/examples/hello_world/README.md
index 0966a1fd..d84c313f 100644
--- a/tensorflow/lite/micro/examples/hello_world/README.md
+++ b/tensorflow/lite/micro/examples/hello_world/README.md
@@ -575,3 +575,7 @@ So far you have used an existing trained model to run inference on
microcontrollers. If you wish to train your own model, follow the instructions
given in the [train/](train/) directory.
+# Building on Epiphany
+```
+make -f tensorflow/lite/micro/tools/make/Makefile TARGET=epiphany_mcu hello_world_bin
+```
diff --git a/tensorflow/lite/micro/examples/hello_world/main.cc b/tensorflow/lite/micro/examples/hello_world/main.cc
index bdf7942a..54213eec 100644
--- a/tensorflow/lite/micro/examples/hello_world/main.cc
+++ b/tensorflow/lite/micro/examples/hello_world/main.cc
@@ -19,9 +19,14 @@ limitations under the License.
// point. Other devices (for example FreeRTOS or ESP32) that have different
// requirements for entry code (like an app_main function) should specialize
// this main.cc file in a target-specific subfolder.
+
+
+volatile unsigned long long *sample = (void *)0x7200;
+
int main(int argc, char* argv[]) {
+ (*sample) = 1;
+
setup();
- while (true) {
- loop();
- }
+
+ (*sample) = 2;
}
diff --git a/tensorflow/lite/micro/tools/make/targets/mcu_epiphany_makefile.inc b/tensorflow/lite/micro/tools/make/targets/mcu_epiphany_makefile.inc
new file mode 100644
index 00000000..b5601f6f
--- /dev/null
+++ b/tensorflow/lite/micro/tools/make/targets/mcu_epiphany_makefile.inc
@@ -0,0 +1,71 @@
+# Settings for RISCV 32-bit MCU toolchain.
+ifeq ($(TARGET), epiphany_mcu)
+ TARGET_ARCH := epiphany_mcu
+ TARGET_TOOLCHAIN_PREFIX := epiphany-elf-
+
+ # $(eval $(call add_third_party_download,$(RISCV_TOOLCHAIN_URL),$(RISCV_TOOLCHAIN_MD5),riscv_toolchain,))
+ # $(eval $(call add_third_party_download,$(SIFIVE_FE310_LIB_URL),$(SIFIVE_FE310_LIB_MD5),sifive_fe310_lib,))
+
+ PLATFORM_FLAGS = \
+ # -march=rv32imac \
+ # -mabi=ilp32 \
+ # -mcmodel=medany \
+ # -mexplicit-relocs \
+ -fno-builtin-printf \
+ -fno-exceptions \
+ -DTF_LITE_MCU_DEBUG_LOG \
+ -DTF_LITE_USE_GLOBAL_CMATH_FUNCTIONS \
+ -fno-unwind-tables \
+ -ffunction-sections \
+ -fdata-sections \
+ -funsigned-char \
+ -Wvla \
+ #-Wall \
+ #-Wextra \
+ -Wsign-compare \
+ -Wdouble-promotion \
+ -Wshadow \
+ -Wunused-variable \
+ -Wmissing-field-initializers \
+ -Wno-unused-parameter \
+ -Wno-write-strings \
+ -Wunused-function \
+ -fno-delete-null-pointer-checks \
+ -fno-threadsafe-statics \
+ -fomit-frame-pointer \
+ -fno-use-cxa-atexit \
+ -Wno-error \
+ -Os
+
+ CXXFLAGS += $(PLATFORM_FLAGS) \
+ -fpermissive \
+ -fno-rtti \
+ --std=gnu++11 \
+ -Wno-error
+
+ CCFLAGS += $(PLATFORM_FLAGS)
+
+ BUILD_TYPE := micro
+
+ # INCLUDES += \
+ # -I$(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/include \
+ # -I$(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/drivers/ \
+ # -I$(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env \
+ # -I$(MAKEFILE_DIR)/downloads/sifive_fe310_lib/bsp/env/freedom-e300-hifive1
+
+ MICROLITE_CC_SRCS += \
+ $(wildcard tensorflow/lite/micro/epiphany_mcu/*.cc)
+
+ LDFLAGS += \
+ -T/opt/adapteva/esdk/bsps/current/legacy.ldf \
+ -lm \
+ -s \
+ -g0
+
+# These are microcontroller-specific rules for converting the ELF output
+# of the linker into a binary image that can be loaded directly.
+ OBJCOPY := $(TARGET_TOOLCHAIN_PREFIX)objcopy
+ $(BINDIR)/%.bin: $(BINDIR)/%
+ @mkdir -p $(dir $@)
+ $(OBJCOPY) $< $@ --remove-section=.comment
+endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.