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
New files for Tensorflow Lite Micro Speech Example targetting the Eta… #24222
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
fc19d28
New files for Tensorflow Lite Micro Speech Example targetting the Eta…
9192d06
fixed grammer
374ad6b
conform to Google coding standards
6042bbb
conform to Google coding standards
7fbd071
added copyright statement
ac0d13b
added copyright statement and comment for usage
6f5e6dc
added brief comment about this file
3eb35ec
Delete test_ecm3531_binary.sh
petewarden File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
tensorflow/lite/experimental/micro/tools/make/targets/ecm3531/README.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
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. |
95 changes: 95 additions & 0 deletions
95
tensorflow/lite/experimental/micro/tools/make/targets/ecm3531/_main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* 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. | ||
==============================================================================*/ | ||
|
||
/* This is file contains the entry point to the application and is called after | ||
startup. | ||
The GPIOs, Uart and timer are intialized and Tensorflow is invoked with the | ||
call to main(). | ||
Tensorflow will print out if the tests have passed or failed and the | ||
execution time is also | ||
printed. */ | ||
|
||
#include <inttypes.h> | ||
#include <stdint.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include "eta_bsp.h" | ||
#include "eta_chip.h" | ||
#include "eta_csp.h" | ||
#include "eta_csp_buck.h" | ||
#include "eta_csp_gpio.h" | ||
#include "eta_csp_io.h" | ||
#include "eta_csp_pwr.h" | ||
#include "eta_csp_rtc.h" | ||
#include "eta_csp_socctrl.h" | ||
#include "eta_csp_sys_clock.h" | ||
#include "eta_csp_timer.h" | ||
#include "eta_csp_uart.h" | ||
|
||
tUart g_sUart0 = {eUartNum0, eUartBaud115200}; | ||
tUart g_sUart1 = {eUartNum1, eUartBaud115200}; | ||
|
||
int init_main(int); | ||
void EtaPrintExecutionTime(uint64_t); | ||
|
||
//***************************************************************************** | ||
// | ||
// The entry point for the application. | ||
// | ||
//***************************************************************************** | ||
extern int main(int argc, char** argv); | ||
|
||
void DebugLog(const char* s) { EtaCspIoPrintf("%s", s); } | ||
void DebugLogInt32(int32_t i) { EtaCspIoPrintf("%d", i); } | ||
void DebugLogUInt32(uint32_t i) { EtaCspIoPrintf("%d", i); } | ||
void DebugLogHex(uint32_t i) { EtaCspIoPrintf("0x%8x", i); } | ||
void DebugLogFloat(float i) { EtaCspIoPrintf("%f", i); } | ||
|
||
int _main(void) { | ||
uint64_t time_ms; | ||
|
||
EtaCspInit(); // initialize csp registers | ||
EtaCspGpioInit(); // initialize gpios | ||
EtaCspUartInit(&g_sUart1, eUartNum0, eUartBaud115200, | ||
eUartFlowControlHardware); // initialize Uart | ||
EtaCspBuckInit(ETA_BSP_VDD_IO_SETTING, eBuckAo600Mv, eBuckM3Frequency60Mhz, | ||
eBuckMemVoltage900Mv); // set M3 freq | ||
EtaCspTimerInitMs(); // start timer | ||
main(0, NULL); // Call to Tensorflow; this will print if test was successful. | ||
time_ms = EtaCspTimerCountGetMs(); // read time | ||
EtaPrintExecutionTime(time_ms); // print execution time | ||
} | ||
|
||
void EtaPrintExecutionTime(uint64_t time_ms) { | ||
uint8_t c; | ||
int k1; | ||
char time_string[] = "00000"; | ||
|
||
EtaCspIoPrintf("Execution time (msec) = "); | ||
if (time_ms < 100000) // Convert time to a string | ||
{ | ||
for (k1 = 0; k1 < 5; k1++) { | ||
c = time_ms % 10; | ||
time_ms = time_ms / 10; | ||
time_string[k1] = (char)(0x30 + c); | ||
} | ||
for (k1 = 4; k1 > 0; k1--) { // print out 1 char at a time | ||
EtaCspUartPutc(&g_sUart1, time_string[k1]); | ||
} | ||
} else { | ||
EtaCspIoPrintf("Execution time exceeds 100 sec\n"); | ||
} | ||
EtaCspIoPrintf("\n\n"); | ||
} |
85 changes: 85 additions & 0 deletions
85
tensorflow/lite/experimental/micro/tools/make/targets/ecm3531/ecm3531.lds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
* All sections must map to 128KBytes of SRAM beginning at 0x10000000 | ||
* | ||
*/ | ||
|
||
/* | ||
* Indicate to the linker the entry point. | ||
*/ | ||
ENTRY(ResetISR) | ||
|
||
/* | ||
* SRAM is at 0x10000000 of length 0x00020000 | ||
*/ | ||
MEMORY | ||
{ | ||
SRAM (RWX) : ORIGIN = 0x10000000, LENGTH = 0x00020000 | ||
} | ||
|
||
SECTIONS | ||
{ | ||
.text : | ||
{ | ||
_text = .; | ||
KEEP(*(.vectors)) | ||
. = ALIGN(0x4); | ||
*(.text*) | ||
. = ALIGN(0x4); | ||
*(.rodata*) | ||
. = ALIGN(0x4); | ||
_etext = .; | ||
} > SRAM= 0 | ||
.dummy : | ||
{ | ||
. = ALIGN(0x4); | ||
_eftext = .; | ||
} > SRAM | ||
.datax : | ||
{ | ||
_datax = .; | ||
KEEP(*(.mainStack)) | ||
. += 12288; | ||
_edatax = .; | ||
_stack_top = .; | ||
. += 4; | ||
} > SRAM | ||
.data : | ||
AT (ADDR(.text) + SIZEOF(.text) ) | ||
{ | ||
_data = .; | ||
*(.data*) | ||
KEEP(*(.mainHeap)) | ||
_edata = .; | ||
} > SRAM | ||
|
||
.bss : | ||
{ | ||
_bss = .; | ||
*(.bss*) | ||
*(COMMON) | ||
_ebss = .; | ||
} > SRAM | ||
.ARM.exidx : | ||
{ | ||
*(.ARM.exidx*) | ||
} | ||
|
||
} | ||
|
53 changes: 53 additions & 0 deletions
53
tensorflow/lite/experimental/micro/tools/make/targets/ecm3531/load_program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/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 | ||
# | ||
# | ||
# 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. | ||
#============================================================================== | ||
|
||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a quick comment about usage, even if it's just pointing back to the main doc file? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
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_test' | ||
print("elf_file = ",elf_file) | ||
|
||
|
||
# use these to download and run the elf fle | ||
ocd_commands = ["halt\n", | ||
"load_image {}\n".format(elf_file), | ||
"mww 0x1001FFF8 0xDEADBEEF\n", | ||
"mww 0x1001FFFC 0xC369A517\n", | ||
"reset\n"] | ||
|
||
# OK now do what we came here for!!! | ||
for x in ocd_commands: | ||
print(x) | ||
send_ocd_cmd(x) | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a copyright notice here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done