Merge pull request #25635 from hshankar61:master

PiperOrigin-RevId: 234876855
This commit is contained in:
TensorFlower Gardener
2019-02-20 15:11:41 -08:00
10 changed files with 281 additions and 43 deletions

View File

@@ -10,15 +10,21 @@ detection model, takes up a total of 22KB.
## Table of Contents
- [Getting Started](#getting-started)
* [Getting Started with Portable Reference Code](#getting-started-with-portable-reference-code)
* [Building Portable Reference Code using Make](#building-portable-reference-code-using-make)
* [Building for the "Blue Pill" STM32F103 using Make](#building-for-the-blue-pill-stm32f103-using-make)
* [Building for "Hifive1" SiFive FE310 development board using Make](#building-for-hifive1-sifive-fe310-development-board-using-make)
* [Building for Ambiq Micro Apollo3Blue EVB using Make](#building-for-ambiq-micro-apollo3blue-evb-using-make)
* [Additional Apollo3 Instructions](#additional-apollo3-instructions)
* [Building for the Eta Compute ECM3531 EVB using Make](#Building-for-the-Eta-Compute-ECM3531-EVB-using-Make)
- [Goals](#goals)
- [Generating Project Files](#generating-project-#files)
- [How to Port TensorFlow Lite Micro to a New Platform](#how-to-port-tensorflow-lite-micro-to-a-new-platform)
* [Requirements](#requirements)
* [Getting Started](getting-started)
* [Troubleshooting](#troubleshooting)
@@ -39,12 +45,13 @@ easy as possible to add support for others.
If you're a product developer, we have build instructions or pre-generated
project files that you can download for the following platforms:
| Device | Mbed | Keil | Make/GCC
-------- | ---- | ---- | --------
[STM32F746G Discovery Board](https://www.st.com/en/evaluation-tools/32f746gdiscovery.html) | [Download](https://drive.google.com/open?id=1OtgVkytQBrEYIpJPsE8F6GUKHPBS3Xeb) | - | [Download](https://drive.google.com/open?id=1u46mTtAMZ7Y1aD-He1u3R8AE4ZyEpnOl) | -
["Blue Pill" STM32F103-compatible development board](https://github.com/google/stm32_bare_lib) | - | - | [Instructions](#building-for-the-blue-pill-stm32f103-using-make)
[Ambiq Micro Apollo3Blue EVB using Make](https://ambiqmicro.com/apollo-ultra-low-power-mcus/) | - | - | [Instructions](#building-for-ambiq-micro-apollo3blue-evb-using-make)
[Generic Keil uVision Projects](http://www2.keil.com/mdk5/uvision/) | - | [Download](https://drive.google.com/open?id=1Lw9rsdquNKObozClLPoE5CTJLuhfh5mV) | -
Device | Mbed | Keil | Make/GCC
---------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | --------
[STM32F746G Discovery Board](https://www.st.com/en/evaluation-tools/32f746gdiscovery.html) | [Download](https://drive.google.com/open?id=1OtgVkytQBrEYIpJPsE8F6GUKHPBS3Xeb) | - | [Download](https://drive.google.com/open?id=1u46mTtAMZ7Y1aD-He1u3R8AE4ZyEpnOl)
["Blue Pill" STM32F103-compatible development board](https://github.com/google/stm32_bare_lib) | - | - | [Instructions](#building-for-the-blue-pill-stm32f103-using-make)
[Ambiq Micro Apollo3Blue EVB using Make](https://ambiqmicro.com/apollo-ultra-low-power-mcus/) | - | - | [Instructions](#building-for-ambiq-micro-apollo3blue-evb-using-make)
[Generic Keil uVision Projects](http://www2.keil.com/mdk5/uvision/) | - | [Download](https://drive.google.com/open?id=1Lw9rsdquNKObozClLPoE5CTJLuhfh5mV) | -
[Eta Compute ECM3531 EVB](https://etacompute.com/) | - | - | [Instructions](#Building-for-the-Eta-Compute-ECM3531-EVB-using-Make)
If your device is not yet supported, it may not be too hard to add support. You
can learn about that process
@@ -317,6 +324,53 @@ To flash a part with JFlash Lite, do the following:
4. Data file = `tensorflow/lite/experimental/micro/tools/make/gen/apollo3evb_cortex-m4/bin/pushbutton_cmsis_speech_test.bin`
5. Prog Addr = 0x0000C000
## Building for the Eta Compute ECM3531 EVB using Make
1. Follow the instructions at
[Tensorflow Micro Speech](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/experimental/micro/examples/micro_speech#getting-started)
to down load the Tensorflow source code and the support libraries \(but do
not run the make command shown there.\)
2. Download the Eta Compute SDK, version 0.0.17. Contact info@etacompute.com
3. You will need the the Arm compiler arm-none-eabi-gcc, version 7.3.1
20180622, release ARM/embedded-7-branch revision 261907, 7-2018-q2-update.
This compiler is downloaded when you run the
tensorflow/lite/experimental/micro/tools/make/download_dependencies.sh
script.
4. Edit the file
tensorflow/lite/experimental/micro/tools/make/targets/ecm3531_makefile.inc
so that the variables ETA_SDK and GCC_ARM point to the correct directories.
5. Compile the code with the command \
    make -f
tensorflow/lite/experimental/micro/tools/make/Makefile TARGET=ecm3531
TAGS="CMSIS" test \
This will produce a set of executables in the
tensorflow/lite/experimental/micro/tools/make/gen/ecm3531_cortex-m3/bin
directory.
6. To load an executable into SRAM \
    Start ocd \
    cd
tensorflow/lite/experimental/micro/tools/make/targets/ecm3531 \
    ./load_program name_of_executable, for e.g.,
./load_program audio_provider_test \
    Start PuTTY \(Connection type = Serial, Speed =
11520, Data bits = 8, Stop bits = 1, Parity = None\) \
The following output should appear: \
Testing TestAudioProvider \
Testing TestTimer \
2/2 tests passed \
\~\~\~ALL TESTS PASSED\~\~\~ \
Execution time \(msec\) = 7
7. To load into flash \
    Edit the variable ETA_LDS_FILE in
tensorflow/lite/experimental/micro/tools/  make/targets/ecm3531_makefile.inc
to point to the ecm3531_flash.lds file \
    Recompile \( make -f
tensorflow/lite/experimental/micro/tools/make/Makefile TARGET=ecm3531
TAGS="CMSIS" test\) \
    cd
tensorflow/lite/experimental/micro/tools/make/targets/ecm3531 \
    ./flash_program executable_name to load into flash.
## Goals
The design goals are for the framework to be:

View File

@@ -0,0 +1,16 @@
#!/bin/bash -e
# 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.
# ==============================================================================

View File

@@ -0,0 +1,9 @@
Compiling instructions here
https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/experimental/micro
CONTACT INFORMATION:
Contact info@etacompute.com for more information on obtaining the Eta Compute
SDK and evalution board.
www.etacompute.com

View File

@@ -1,32 +0,0 @@
Running The Micro Speech Example On Eta Compute's ECM3531EVB
This code will enable you to compile and execute the Tensorflow Lite Micro Speech Example on Eta Computes's low power ECM3531 chip.
GETTING STARTED:
1. Download the Tensorflow code from Github and follow instructions there to download other dependencies.
2. Download the Eta Compute SDK, version 0.0.17.
3. Install the Arm compiler arm-none-eabi-gcc, version = arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 7-2018-q2-update) 7.3.1 20180622 (release) [ARM/embedded-7-branch revision 261907]
4. Edit the file tensorflow/lite/experimental/micro/tools/make/targets/ecm3531_makefile.inc so that the variable ETA_SDK points to the location where the Eta Compute SDK is installed, and the variable GCC_ARM points to the Arm compiler.
5. Compile the code with the command "make -f tensorflow/lite/experimental/micro/tools/make/Makefile TARGET=ecm3531 test". This will create the executable tensorflow/lite/experimental/micro/tools/make/gen/ecm3531_cortex-m3/bin/micro_speech_test.
6. Connect the board to the host computer, start PuTTY (Connection type = Serial, Speed = 11520, Data bits = 8, Stop bits = 1, Parity = None), and load the executable with ocd. A sample script for loading the image is provided in tensorflow/lite/experimental/micro/tools/make/targets/ecm3531/load_program.
The following will be printed on the Uart:
Testing TestInvoke
Ran successfully
/ tests passed
~~~ALL TESTS PASSED~~~
CONTACT INFORMATION:
Contact info@etacompute.com for more information on obtaining the Eta Compute SDK and evalution board.

View File

@@ -55,7 +55,7 @@ SECTIONS
{
_datax = .;
KEEP(*(.mainStack))
. += 12288;
. += 16384;
_edatax = .;
_stack_top = .;
. += 4;

View File

@@ -0,0 +1,85 @@
/* Copyright 2015 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.
==============================================================================*/
/*
* linker script for use with ECM3531 chip.
* .text and .ro map to FLASH all else to SRAM.
*
*/
/*
* Indicate to the linker the entry point.
*/
ENTRY(ResetISR)
/*
* FLASH is at 0x01000000 of length 0x00080000 512KB
* SRAM is at 0x10000000 of length 0x00020000 128KB
*/
MEMORY
{
FLASH (RX) : ORIGIN = 0x01000000, LENGTH = 0x00080000
SRAM (RWX) : ORIGIN = 0x10000000, LENGTH = 0x00020000
}
SECTIONS
{
.text :
{
_text = .;
KEEP(*(.vectors))
. = ALIGN(0x4);
*(.text*)
. = ALIGN(0x4);
*(.rodata*)
. = ALIGN(0x4);
_etext = .;
} > FLASH= 0
.dummy :
{
. = ALIGN(0x4);
_eftext = .;
} > FLASH
/* put the stack at the bottom of SRAM*/
.datax (NOLOAD) :
{
_datax = .;
KEEP(*(.mainStack))
. = ALIGN(0x4);
. += 16384;
_edatax = .;
_stack_top = .;
} > SRAM
.data :
{
_data = .;
*(.data*)
KEEP(*(.mainHeap))
_edata = .;
} > SRAM AT > FLASH
.bss (NOLOAD) :
{
_bss = .;
*(.bss*)
*(COMMON)
_ebss = .;
} > SRAM
}

View File

@@ -0,0 +1,47 @@
#!/usr/bin/python3
#Usage: cd to the directory tensorflow/lite/experimental/micro/tools/make/targets/ecm3531 and type ./flash_erase to erase the flash.
#
#
# Copyright 2015 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.
#==============================================================================
import os
import telnetlib
def send_ocd_cmd(line):
ocd_sock.write(bytes(line,encoding = 'utf-8'))
print(ocd_sock.read_until(b'> ').decode('utf-8'), end='')
def get_ocd_response():
print(ocd_sock.read_until(b'> ').decode('utf-8'), end='')
#get hooked up to openocd daemon
ocd_sock = telnetlib.Telnet(host='localhost', port=4444)
get_ocd_response() # clean it out
#ocd comand
ocd_commands = ["halt\n",
"flash erase_sector 0 0 127\n",
"mww 0x1001fff8 0\n",
"mdw 0x01000000 16\n",
"reset\n"]
# OK now do what we came here for!!!
for x in ocd_commands:
print(x)
send_ocd_cmd(x)

View File

@@ -0,0 +1,53 @@
#!/usr/bin/python3
#Usage: cd to the directory tensorflow/lite/experimental/micro/tools/make/targets/ecm3531 and type ./flash_program executable_name to load an executable from the directory tensorflow/lite/experimental/micro/tools/make/gen/ecm3531_cortex-m3/bin/ into flash
#
#
# Copyright 2015 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.
#==============================================================================
import sys, getopt
import os
import telnetlib
def send_ocd_cmd(line):
ocd_sock.write(bytes(line,encoding = 'utf-8'))
print(ocd_sock.read_until(b'> ').decode('utf-8'), end='')
def get_ocd_response():
print(ocd_sock.read_until(b'> ').decode('utf-8'), end='')
#get hooked up to openocd daemon
ocd_sock = telnetlib.Telnet(host='localhost', port=4444)
get_ocd_response() # clean it out
# git path to project elf file
cur_dir = os.getcwd()
#elf_file = cur_dir + '/../../gen/ecm3531_cortex-m3/bin/' + 'micro_speech'
elf_file = cur_dir + '/../../gen/ecm3531_cortex-m3/bin/' + sys.argv[1]
print("elf_file = ",elf_file)
# use these to download and run the elf fle
ocd_commands = ["halt\n",
"flash erase_sector 0 0 127\n",
"flash write_image {}\n".format(elf_file),
"mww 0x1001fff8 0\n",
"reset\n"]
# OK now do what we came here for!!!
for x in ocd_commands:
print(x)
send_ocd_cmd(x)

View File

@@ -1,5 +1,5 @@
#!/usr/bin/python3
#Usage: cd to the directory tensorflow/lite/experimental/micro/tools/make/targets/ecm3531 and type ./load_prgram to load the executable tensorflow/lite/experimental/micro/tools/make/gen/ecm3531_cortex-m3/bin/micro_speech_test into SRAM
#Usage: cd to the directory tensorflow/lite/experimental/micro/tools/make/targets/ecm3531 and type ./load_prgram executable_name to load an executable from the directory tensorflow/lite/experimental/micro/tools/make/gen/ecm3531_cortex-m3/bin/
#
#
# Copyright 2015 The TensorFlow Authors. All Rights Reserved.
@@ -18,6 +18,7 @@
#==============================================================================
import sys, getopt
import os
import telnetlib
@@ -34,7 +35,8 @@ get_ocd_response() # clean it out
# git path to project elf file
cur_dir = os.getcwd()
elf_file = cur_dir + '/../../gen/ecm3531_cortex-m3/bin/' + 'micro_speech_test'
#elf_file = cur_dir + '/../../gen/ecm3531_cortex-m3/bin/' + 'preprocessor_test'
elf_file = cur_dir + '/../../gen/ecm3531_cortex-m3/bin/' + sys.argv[1]
print("elf_file = ",elf_file)

View File

@@ -5,6 +5,10 @@ ifeq ($(TARGET), ecm3531)
ETA_SDK := /home/hari/TensaiSDK-v0.0.17/soc/
GCC_ARM := /home/hari/Downloads/gcc-arm-none-eabi-7-2018-q2-update/
#Pick the appropriate lds file depending whether you are running frof SRAM of flash
ETA_LDS_FILE := ecm3531.lds
# ETA_LDS_FILE := ecm3531_flash.lds
ifeq ($(wildcard $(ETA_SDK)),)
$(error Path to ETA SDK is not set (ETA_SDK))
endif
@@ -59,7 +63,7 @@ ifeq ($(TARGET), ecm3531)
-Wl,--start-group -lm -lc -lgcc -Wl,--end-group \
-fno-exceptions \
-nostdlib --specs=nano.specs -t -lstdc++ -lc -lnosys -lm \
-Wl,-T,$(MAKEFILE_DIR)/targets/ecm3531/ecm3531.lds \
-Wl,-T,$(MAKEFILE_DIR)/targets/ecm3531/$(ETA_LDS_FILE) \
-Wl,-Map=$(MAKEFILE_DIR)/targets/ecm3531/ecm3531.map,--cref
BUILD_TYPE := micro
MICROLITE_LIBS := \
@@ -92,7 +96,7 @@ ifeq ($(TARGET), ecm3531)
# directory for generated projects. This is similar to the behavior needed
# for headers.
MICROLITE_CC_HDRS += \
$(MAKEFILE_DIR)/targets/ecm3531/ecm3531.lds
$(MAKEFILE_DIR)/targets/ecm3531/$(ETA_LDS_FILE)
TEST_SCRIPT := tensorflow/lite/experimental/micro/testing/test_ecm3531_binary.sh
# These are tests that don't currently work on the blue pill.