-
Notifications
You must be signed in to change notification settings - Fork 74k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35854 from mansnils:renode
PiperOrigin-RevId: 295777715 Change-Id: I5561aee7f8367d45cf55a717213da38a94867d3d
- Loading branch information
Showing
13 changed files
with
417 additions
and
3 deletions.
There are no files selected for viewing
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,25 @@ | ||
/* 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. | ||
==============================================================================*/ | ||
|
||
#include "tensorflow/lite/micro/debug_log.h" | ||
|
||
extern "C" void DebugLog(const char* s) { | ||
asm("mov r0, #0x04\n" // SYS_WRITE0 | ||
"mov r1, %[str]\n" | ||
"bkpt #0xAB\n" | ||
: | ||
: [ str ] "r"(s) | ||
: "r0", "r1"); | ||
} |
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
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,21 @@ | ||
# 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. | ||
# ============================================================================== | ||
|
||
# This docker configuration file lets you emulate a stm32f4 board | ||
# on an x86 desktop or laptop, which can be useful for debugging and | ||
# automated testing. | ||
FROM antmicro/renode:latest | ||
|
||
LABEL maintainer="Pete Warden <petewarden@google.com>" |
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
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,33 @@ | ||
# 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. | ||
# ============================================================================== | ||
|
||
using sysbus | ||
|
||
mach create | ||
machine LoadPlatformDescription @platforms/cpus/stm32f4.repl | ||
|
||
# These lines are needed to show the results of DebugLog calls in the output. | ||
machine LoadPlatformDescriptionFromString "uartSemihosting: UART.SemihostingUart @ cpu" | ||
showAnalyzer cpu.uartSemihosting Antmicro.Renode.Analyzers.LoggingUartAnalyzer | ||
|
||
logFile @/tmp/renode_stm32f4_log.txt | ||
|
||
macro reset | ||
""" | ||
sysbus LoadELF $bin | ||
""" | ||
|
||
runMacro $reset | ||
|
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,23 @@ | ||
*** Settings *** | ||
Suite Setup Setup | ||
Suite Teardown Teardown | ||
Test Setup Reset Emulation | ||
Resource /opt/renode/tests/renode-keywords.robot | ||
|
||
*** Variables *** | ||
${UART} sysbus.cpu.uartSemihosting | ||
|
||
*** Test Cases *** | ||
Should Run Stm32f4 Test | ||
[Documentation] Runs a Stm32f4 test and waits for a specific string on the semihosting UART | ||
[Tags] stm32f4 uart tensorflow arm | ||
${BIN} = Get Environment Variable BIN | ||
${SCRIPT} = Get Environment Variable SCRIPT | ||
${EXPECTED} = Get Environment Variable EXPECTED | ||
Execute Command $bin = @${BIN} | ||
Execute Script ${SCRIPT} | ||
|
||
Create Terminal Tester ${UART} timeout=30 | ||
Start Emulation | ||
|
||
Wait For Line On Uart ${EXPECTED} |
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,60 @@ | ||
#!/bin/bash -e | ||
# 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. | ||
# ============================================================================== | ||
# | ||
# Tests a 'stm32f4' STM32F4 ELF by parsing the log output of Renode emulation. | ||
# | ||
# First argument is the ELF location. | ||
# Second argument is a regular expression that's required to be in the output logs | ||
# for the test to pass. | ||
# | ||
# This script must be run from the top-level folder of the tensorflow github | ||
# repository as it mounts `pwd` to the renode docker image (via docker run -v) | ||
# and paths in the docker run command assume the entire tensorflow repo is mounted. | ||
|
||
declare -r ROOT_DIR=`pwd` | ||
declare -r TEST_TMPDIR=/tmp/test_stm32f4_binary/ | ||
declare -r MICRO_LOG_PATH=${TEST_TMPDIR} | ||
declare -r MICRO_LOG_FILENAME=${MICRO_LOG_PATH}/logs.txt | ||
mkdir -p ${MICRO_LOG_PATH} | ||
|
||
docker build -t renode_stm32f4 \ | ||
-f ${ROOT_DIR}/tensorflow/lite/micro/testing/Dockerfile.stm32f4 \ | ||
${ROOT_DIR}/tensorflow/lite/micro/testing/ | ||
|
||
exit_code=0 | ||
# running in `if` to avoid setting +e | ||
if ! docker run \ | ||
--log-driver=none -a stdout -a stderr \ | ||
-v ${ROOT_DIR}:/workspace \ | ||
-v /tmp:/tmp \ | ||
-e BIN=/workspace/$1 \ | ||
-e SCRIPT=/workspace/tensorflow/lite/micro/testing/stm32f4.resc \ | ||
-e EXPECTED="$2" \ | ||
-it renode_stm32f4 \ | ||
/bin/bash -c "/opt/renode/tests/test.sh /workspace/tensorflow/lite/micro/testing/stm32f4.robot 2>&1 >${MICRO_LOG_FILENAME}" | ||
then | ||
exit_code=1 | ||
fi | ||
|
||
echo "LOGS:" | ||
cat ${MICRO_LOG_FILENAME} | ||
if [ $exit_code -eq 0 ] | ||
then | ||
echo "$1: PASS" | ||
else | ||
echo "$1: FAIL - '$2' not found in logs." | ||
fi | ||
exit $exit_code |
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
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,40 @@ | ||
#!/usr/bin/env bash | ||
# 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. | ||
# ============================================================================== | ||
# | ||
# Tests the microcontroller code for stm32f4 | ||
|
||
set -e | ||
|
||
TARGET=stm32f4 | ||
TAGS=cmsis-nn | ||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
ROOT_DIR=${SCRIPT_DIR}/../../../../.. | ||
cd ${ROOT_DIR} | ||
pwd | ||
|
||
source tensorflow/lite/micro/tools/ci_build/helper_functions.sh | ||
|
||
readable_run make -f tensorflow/lite/micro/tools/make/Makefile clean | ||
|
||
# TODO(b/143715361): downloading first to allow for parallel builds. | ||
readable_run make -f tensorflow/lite/micro/tools/make/Makefile TAGS=${TAGS} TARGET=${TARGET} third_party_downloads | ||
|
||
# Build test binaries first | ||
readable_run make -j8 -f tensorflow/lite/micro/tools/make/Makefile TAGS=${TAGS} TARGET=${TARGET} build | ||
|
||
# Parallell builds doesn't work very well with this | ||
readable_run make -f tensorflow/lite/micro/tools/make/Makefile TAGS=${TAGS} TARGET=${TARGET} test | ||
|
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
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
102 changes: 102 additions & 0 deletions
102
tensorflow/lite/micro/tools/make/targets/stm32f4/stm32f4.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,102 @@ | ||
/* Copyright 2020 Google Inc. All Rights Reserved. | ||
|
||
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. | ||
==============================================================================*/ | ||
|
||
/* Copied and modified from: tensorflow/lite/micro/tools/make/targets/bluepill/bluepill.lds | ||
|
||
*/ | ||
|
||
/* | ||
* 0x00000000 - 0x07ffffff - aliased to flash or sys memory depending on BOOT jumpers. | ||
* 0x08000000 - 0x0801ffff - Flash. | ||
* 0x1ffff000 - 0x1ffff7ff - Boot firmware in system memory. | ||
* 0x1ffff800 - 0x1fffffff - Option bytes. | ||
* 0x20000000 - 0x20004fff - SRAM. | ||
* 0x40000000 - 0x40023400 - Peripherals | ||
*/ | ||
|
||
/* Define main entry point */ | ||
ENTRY(_main) | ||
|
||
/* 32K of RAM and 256K of FLASH */ | ||
MEMORY { | ||
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 32K | ||
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 256K | ||
} | ||
|
||
/* Compute where the stack ends rather than hard coding it */ | ||
_ld_stack_end_addr = ORIGIN(RAM) + LENGTH(RAM); | ||
_ld_min_stack_size = 0x200; | ||
|
||
SECTIONS { | ||
|
||
/* interrupt vector goes to top of flash */ | ||
|
||
.interrupt_vector : { | ||
. = ALIGN(4); | ||
KEEP(*(.interrupt_vector)) | ||
. = ALIGN(4); | ||
} >FLASH | ||
|
||
/* read only .text and .rodata go to flash */ | ||
|
||
.text : { | ||
. = ALIGN(4); | ||
KEEP(*(.text.interrupt_handler)) | ||
*(.text*) | ||
} >FLASH | ||
|
||
.rodata : { | ||
. = ALIGN(4); | ||
*(.rodata*) | ||
. = ALIGN(4); | ||
} >FLASH | ||
|
||
/* read mwrite data needs to be stored in flash but copied to ram */ | ||
.data : { | ||
. = ALIGN(4); | ||
_ld_data_load_dest_start = .; /* export where to load from */ | ||
*(.data*) | ||
. = ALIGN(4); | ||
_ld_data_load_dest_stop = .; /* export where to load from */ | ||
} >RAM AT> FLASH | ||
_ld_data_load_source = LOADADDR(.data); | ||
|
||
/* unitialized data section needs zero initialization */ | ||
.bss : | ||
{ | ||
. = ALIGN(4); | ||
_ld_bss_data_start = .; | ||
*(.bss*) | ||
. = ALIGN(4); | ||
_ld_bss_data_stop = .; | ||
} >RAM | ||
|
||
._user_heap_stack : | ||
{ | ||
. = ALIGN(8); | ||
. += _ld_min_stack_size; | ||
PROVIDE(end = .); | ||
. = ALIGN(8); | ||
} >RAM | ||
|
||
/DISCARD/ : | ||
{ | ||
libc.a (*) | ||
libm.a (*) | ||
libgcc.a (*) | ||
} | ||
|
||
} /* SECTIONS */ |
Oops, something went wrong.