Enable Corstone 300 to run on CI backend (#2321)
@tensorflow/micro
Update makefile and download scripts to allow Corstone 300 to build and run on the CI backend.
Output extra stats at the end of the simulator run.
bug=fixes #2324
diff --git a/tensorflow/lite/micro/testing/test_with_arm_corstone_300.sh b/tensorflow/lite/micro/testing/test_with_arm_corstone_300.sh
index 9b39ee4..27635ba 100755
--- a/tensorflow/lite/micro/testing/test_with_arm_corstone_300.sh
+++ b/tensorflow/lite/micro/testing/test_with_arm_corstone_300.sh
@@ -1,5 +1,5 @@
#!/bin/bash -e
-# Copyright 2021 The TensorFlow Authors. All Rights Reserved.
+# Copyright 2023 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.
@@ -36,7 +36,8 @@
FVP+="-C mps3_board.telnetterminal0.start_telnet=0 "
FVP+='-C mps3_board.uart0.out_file="-" '
FVP+='-C mps3_board.uart0.unbuffered_output=1 '
-FVP+='-C mps3_board.uart0.shutdown_on_eot=1'
+FVP+='-C mps3_board.uart0.shutdown_on_eot=1 '
+FVP+='--stat'
${FVP} ${BINARY_TO_TEST} | tee ${MICRO_LOG_FILENAME}
if [[ ${2} != "non_test_binary" ]]
diff --git a/tensorflow/lite/micro/tools/make/corstone_300_download.sh b/tensorflow/lite/micro/tools/make/corstone_300_download.sh
index aa0a762..19e4a4f 100755
--- a/tensorflow/lite/micro/tools/make/corstone_300_download.sh
+++ b/tensorflow/lite/micro/tools/make/corstone_300_download.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2022 The TensorFlow Authors. All Rights Reserved.
+# Copyright 2023 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.
@@ -17,6 +17,7 @@
# Called with following arguments:
# 1 - Path to the downloads folder which is typically
# tensorflow/lite/micro/tools/make/downloads
+# 2 - (optional) TENSORFLOW_ROOT: path to root of the TFLM tree (relative to directory from where the script is called).
#
# This script is called from the Makefile and uses the following convention to
# enable determination of sucess/failure:
@@ -31,11 +32,8 @@
set -e
-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-ROOT_DIR=${SCRIPT_DIR}/../../../../..
-cd "${ROOT_DIR}"
-
-source tensorflow/lite/micro/tools/make/bash_helpers.sh
+TENSORFLOW_ROOT=${2}
+source ${TENSORFLOW_ROOT}tensorflow/lite/micro/tools/make/bash_helpers.sh
DOWNLOADS_DIR=${1}
if [ ! -d ${DOWNLOADS_DIR} ]; then
diff --git a/tensorflow/lite/micro/tools/make/ethos_u_core_platform_download.sh b/tensorflow/lite/micro/tools/make/ethos_u_core_platform_download.sh
index eb99a49..a449e77 100755
--- a/tensorflow/lite/micro/tools/make/ethos_u_core_platform_download.sh
+++ b/tensorflow/lite/micro/tools/make/ethos_u_core_platform_download.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 2022 The TensorFlow Authors. All Rights Reserved.
+# Copyright 2023 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.
@@ -31,11 +31,8 @@
set -e
-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-ROOT_DIR=${SCRIPT_DIR}/../../../../..
-cd "${ROOT_DIR}"
-
-source tensorflow/lite/micro/tools/make/bash_helpers.sh
+TENSORFLOW_ROOT=${2}
+source ${TENSORFLOW_ROOT}tensorflow/lite/micro/tools/make/bash_helpers.sh
DOWNLOADS_DIR=${1}
if [ ! -d ${DOWNLOADS_DIR} ]; then
@@ -55,23 +52,21 @@
fi
git clone https://git.mlplatform.org/ml/ethos-u/ethos-u-core-platform.git ${DOWNLOADED_ETHOS_U_CORE_PLATFORM_PATH} >&2
- cd ${DOWNLOADED_ETHOS_U_CORE_PLATFORM_PATH}
+ pushd ${DOWNLOADED_ETHOS_U_CORE_PLATFORM_PATH} > /dev/null
git checkout e25a89dec1cf990f3168dbd6c565e3b0d51cb151 >&2
rm -rf .git
create_git_repo ./
-
apply_patch_to_folder ./ ../../ethos_u_core_platform.patch "TFLM patch"
-
- cd "${ROOT_DIR}"
+ popd > /dev/null
LINKER_PATH=${DOWNLOADED_ETHOS_U_CORE_PLATFORM_PATH}/targets/corstone-300
# Run C preprocessor on linker file to get rid of ifdefs and make sure compiler is downloaded first.
COMPILER=${DOWNLOADS_DIR}/gcc_embedded/bin/arm-none-eabi-gcc
if [ ! -f ${COMPILER} ]; then
- RETURN_VALUE=`./tensorflow/lite/micro/tools/make/arm_gcc_download.sh ${DOWNLOADS_DIR}`
+ RETURN_VALUE=`${TENSORFLOW_ROOT}tensorflow/lite/micro/tools/make/arm_gcc_download.sh ${DOWNLOADS_DIR} ${TENSORFLOW_ROOT}`
if [ "SUCCESS" != "${RETURN_VALUE}" ]; then
- echo "The script ./tensorflow/lite/micro/tools/make/arm_gcc_download.sh failed."
+ echo "The script ${TENSORFLOW_ROOT}tensorflow/lite/micro/tools/make/arm_gcc_download.sh failed."
exit 1
fi
fi
diff --git a/tensorflow/lite/micro/tools/make/targets/cortex_m_corstone_300_makefile.inc b/tensorflow/lite/micro/tools/make/targets/cortex_m_corstone_300_makefile.inc
index 0ffe5a3..85d5fc0 100644
--- a/tensorflow/lite/micro/tools/make/targets/cortex_m_corstone_300_makefile.inc
+++ b/tensorflow/lite/micro/tools/make/targets/cortex_m_corstone_300_makefile.inc
@@ -16,23 +16,23 @@
# ARM Cortex M makefile targeted for a FVP based on Arm Corstone-300 software.
# For more info see: tensorflow/lite/micro/cortex_m_corstone_300/README.md
-export PATH := $(MAKEFILE_DIR)/downloads/corstone300/models/Linux64_GCC-6.4:$(PATH)
-DOWNLOAD_RESULT := $(shell $(MAKEFILE_DIR)/corstone_300_download.sh ${MAKEFILE_DIR}/downloads)
+export PATH := $(DOWNLOADS_DIR)/corstone300/models/Linux64_GCC-6.4:$(PATH)
+DOWNLOAD_RESULT := $(shell $(MAKEFILE_DIR)/corstone_300_download.sh $(DOWNLOADS_DIR) $(TENSORFLOW_ROOT))
ifneq ($(DOWNLOAD_RESULT), SUCCESS)
$(error Something went wrong with the Arm Corstone-300 software download: $(DOWNLOAD_RESULT))
endif
-ETHOS_U_CORE_PLATFORM := ${PWD}/$(MAKEFILE_DIR)/downloads/ethos_u_core_platform/targets/corstone-300
-DOWNLOAD_RESULT := $(shell $(MAKEFILE_DIR)/ethos_u_core_platform_download.sh ${MAKEFILE_DIR}/downloads)
+ETHOS_U_CORE_PLATFORM := $(DOWNLOADS_DIR)/ethos_u_core_platform/targets/corstone-300
+DOWNLOAD_RESULT := $(shell $(MAKEFILE_DIR)/ethos_u_core_platform_download.sh $(DOWNLOADS_DIR) $(TENSORFLOW_ROOT))
ifneq ($(DOWNLOAD_RESULT), SUCCESS)
$(error Something went wrong with the Ethos-U Core Platform software download: $(DOWNLOAD_RESULT))
endif
# This target has dependencies to CMSIS-Device so just in case running without OPTIMIZED_KERNEL_DIR=cmsis_nn.
-CMSIS_DEFAULT_DOWNLOAD_PATH := $(MAKEFILE_DIR)/downloads/cmsis
+CMSIS_DEFAULT_DOWNLOAD_PATH := $(DOWNLOADS_DIR)/cmsis
CMSIS_PATH := $(CMSIS_DEFAULT_DOWNLOAD_PATH)
ifeq ($(CMSIS_PATH), $(CMSIS_DEFAULT_DOWNLOAD_PATH))
- DOWNLOAD_RESULT := $(shell $(MAKEFILE_DIR)/ext_libs/cmsis_download.sh ${MAKEFILE_DIR}/downloads)
+ DOWNLOAD_RESULT := $(shell $(MAKEFILE_DIR)/ext_libs/cmsis_download.sh $(DOWNLOADS_DIR) $(TENSORFLOW_ROOT))
ifneq ($(DOWNLOAD_RESULT), SUCCESS)
$(error Something went wrong with the CMSIS download: $(DOWNLOAD_RESULT))
endif
@@ -104,7 +104,7 @@
ARMC6_LDFLAGS += -Wl,--strict,--summary_stderr,--info,summarysizes,--map
ARMC6_LDFLAGS += -Wl,--load_addr_map_info,--xref,--callgraph,--symbols
ARMC6_LDFLAGS += -Wl,--info,sizes,--info,totals,--info,unused,--info,veneers
- ARMC6_LDFLAGS += -Wl,--list=${TENSORFLOW_ROOT}gen/$(TARGET).map
+ ARMC6_LDFLAGS += -Wl,--list=gen/$(TARGET).map
ARMC6_LDFLAGS += -Wl,--entry=Reset_Handler --verbose
ARMC6_LDFLAGS += -Wl,--scatter=$(ETHOS_U_CORE_PLATFORM)/platform.scatter
@@ -131,10 +131,10 @@
MICROLITE_LIBS := $(filter-out -lm,$(MICROLITE_LIBS))
else ifeq ($(TOOLCHAIN), gcc)
- TARGET_DEFAULT_TOOLCHAIN_ROOT := $(MAKEFILE_DIR)/downloads/gcc_embedded/bin/
+ TARGET_DEFAULT_TOOLCHAIN_ROOT := $(DOWNLOADS_DIR)/gcc_embedded/bin/
TARGET_TOOLCHAIN_ROOT := $(TARGET_DEFAULT_TOOLCHAIN_ROOT)
ifeq ($(TARGET_TOOLCHAIN_ROOT), $(TARGET_DEFAULT_TOOLCHAIN_ROOT))
- DOWNLOAD_RESULT := $(shell $(MAKEFILE_DIR)/arm_gcc_download.sh ${MAKEFILE_DIR}/downloads)
+ DOWNLOAD_RESULT := $(shell $(MAKEFILE_DIR)/arm_gcc_download.sh $(DOWNLOADS_DIR) $(TENSORFLOW_ROOT))
ifneq ($(DOWNLOAD_RESULT), SUCCESS)
$(error Something went wrong with the GCC download: $(DOWNLOAD_RESULT))
endif
@@ -148,7 +148,7 @@
LDFLAGS += \
--specs=nosys.specs \
-T $(ETHOS_U_CORE_PLATFORM)/platform_parsed.ld \
- -Wl,-Map=${TENSORFLOW_ROOT}gen/$(TARGET).map,--cref \
+ -Wl,-Map=gen/$(TARGET).map,--cref \
-Wl,--gc-sections \
--entry Reset_Handler
@@ -186,7 +186,7 @@
ETHOSU_ARCH=u55
endif
-CMSIS_DEFAULT_DOWNLOAD_PATH := $(MAKEFILE_DIR)/downloads/cmsis
+CMSIS_DEFAULT_DOWNLOAD_PATH := $(DOWNLOADS_DIR)/cmsis
CMSIS_PATH := $(CMSIS_DEFAULT_DOWNLOAD_PATH)
THIRD_PARTY_CC_SRCS += \
$(CMSIS_PATH)/Device/ARM/$(ARM_CPU)/Source/system_$(ARM_CPU).c \
@@ -197,8 +197,8 @@
# TODO(#274): Examine why some tests fail here.
EXCLUDED_TESTS := \
- tensorflow/lite/micro/memory_arena_threshold_test.cc \
- tensorflow/lite/micro/recording_micro_allocator_test.cc
+ $(TENSORFLOW_ROOT)tensorflow/lite/micro/memory_arena_threshold_test.cc \
+ $(TENSORFLOW_ROOT)tensorflow/lite/micro/recording_micro_allocator_test.cc
MICROLITE_TEST_SRCS := $(filter-out $(EXCLUDED_TESTS), $(MICROLITE_TEST_SRCS))
-TEST_SCRIPT := tensorflow/lite/micro/testing/test_with_arm_corstone_300.sh
+TEST_SCRIPT := $(TENSORFLOW_ROOT)tensorflow/lite/micro/testing/test_with_arm_corstone_300.sh