diff --git a/backends/arm/test/runner_utils.py b/backends/arm/test/runner_utils.py index 4fbf1f2f813..2935a2e13ef 100644 --- a/backends/arm/test/runner_utils.py +++ b/backends/arm/test/runner_utils.py @@ -6,6 +6,7 @@ import json import logging import os +import re import shutil import subprocess import tempfile @@ -229,7 +230,9 @@ def run_corstone300( os.path.join(self.intermediate_path, f"{name}.bin"), ) elf_path = os.path.join( - "cmake-out", "arm_semihosting_executor_runner", "arm_executor_runner" + "cmake-out", + "arm_semihosting_executor_runner_corstone-300", + "arm_executor_runner", ) assert os.path.exists( elf_path @@ -266,7 +269,12 @@ def run_corstone300( ] result = _run_cmd(command_args, check=False) result_stdout = result.stdout.decode() - if "Hard fault" in result_stdout or len(result.stderr) > 0: + + error_regex = r"(^[EF][: ].*$)|(^.*Hard fault.*$)|(^.*Assertion.*$)" + + # Check for errors in the output + # regex to check for error or fault messages in stdout from FVP + if re.compile(error_regex, re.MULTILINE).search(result_stdout): raise RuntimeError( f"Corstone simulation failed, log: \n {result_stdout}\n{result.stderr.decode()}" ) diff --git a/backends/arm/test/setup_testing.sh b/backends/arm/test/setup_testing.sh index 683eee7a007..5625ae212f2 100755 --- a/backends/arm/test/setup_testing.sh +++ b/backends/arm/test/setup_testing.sh @@ -13,17 +13,30 @@ ethos_u_root_dir=${et_root_dir}/examples/arm/ethos-u-scratch/ethos-u toolchain_cmake=${et_root_dir}/examples/arm/ethos-u-setup/arm-none-eabi-gcc.cmake et_build_dir=${et_root_dir}/cmake-out -build_test_dir=${et_build_dir}/arm_semihosting_executor_runner +build_root_test_dir=${et_build_dir}/arm_semihosting_executor_runner fvp_model=FVP_Corstone_SSE-300_Ethos-U55 # Build Arm Baremetal executor_runner in semihosting mode. # Put in backends/arm/test/res to be used by unit tests. function build_semihosting_executorch_runner() { + target_board=$1 + build_test_dir=${build_root_test_dir}_${target_board} + echo "[${FUNCNAME[0]}] Configuring ${target_board}" + if [[ ${target_board} == "corstone-300" ]]; then + local target_cpu=cortex-m55 + elif [[ ${target_board} == "corstone-320" ]]; then + local target_cpu=cortex-m85 + else + echo "[${FUNCNAME[0]}] ERROR: Invalid target_board specified!" + exit 1 + fi cd ${et_root_dir}/examples/arm/executor_runner pwd mkdir -p ${build_test_dir} cmake -DCMAKE_TOOLCHAIN_FILE=${toolchain_cmake} \ - -DTARGET_CPU=cortex-m55 \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DTARGET_CPU=${target_cpu} \ + -DTARGET_BOARD=${target_board} \ -DSEMIHOSTING=ON \ -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${build_test_dir} \ -B ${build_test_dir} \ @@ -40,4 +53,6 @@ function build_semihosting_executorch_runner() { find ${build_test_dir} -name "arm_executor_runner" } -build_semihosting_executorch_runner \ No newline at end of file +build_semihosting_executorch_runner corstone-300 + +build_semihosting_executorch_runner corstone-320 diff --git a/examples/arm/ethos-u-setup/core_platform/patches/0001-Add-.data-fixup-from-Corestone-300.patch b/examples/arm/ethos-u-setup/core_platform/patches/0001-Add-.data-fixup-from-Corestone-300.patch new file mode 100644 index 00000000000..f2df3350d04 --- /dev/null +++ b/examples/arm/ethos-u-setup/core_platform/patches/0001-Add-.data-fixup-from-Corestone-300.patch @@ -0,0 +1,24 @@ +From 162ea6b51bd94fabf623cc6b63cf271497eaff8d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Per=20=C3=85strand?= +Date: Fri, 13 Sep 2024 11:47:03 +0200 +Subject: [PATCH] Add .data fixup from Corestone-300 + +--- + targets/corstone-320/platform.ld | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/targets/corstone-320/platform.ld b/targets/corstone-320/platform.ld +index 2010d14..fb4e7b7 100644 +--- a/targets/corstone-320/platform.ld ++++ b/targets/corstone-320/platform.ld +@@ -77,6 +77,7 @@ PHDRS + rom_boot PT_LOAD; + rom_exec PT_LOAD; + rom_dram PT_LOAD; ++ data PT_LOAD; /* HACK: New prog header for .data (and friends) going in DTCM */ + null PT_NULL; + } + +-- +2.39.3 (Apple Git-146) + diff --git a/examples/arm/executor_runner/CMakeLists.txt b/examples/arm/executor_runner/CMakeLists.txt index 9eeb4475b05..93fd8cca602 100644 --- a/examples/arm/executor_runner/CMakeLists.txt +++ b/examples/arm/executor_runner/CMakeLists.txt @@ -16,6 +16,8 @@ if(NOT DEFINED ET_PTE_FILE_PATH AND NOT ${SEMIHOSTING}) ) endif() +set(TARGET_BOARD "corstone-300" CACHE STRING "Target board") + # Example ExecuTorch demo for bare metal Cortex-M based systems set(ET_DIR_PATH "../../.." @@ -55,10 +57,13 @@ endif() # libraries. We link against ethosu_target_init which includes all of these # dependencies. -# For Corstone-300 FVP builds we put models into the larger DRAM area -set(MEMORY_MODEL "dram") -set(MEMORY_ARENA "dram") -add_subdirectory(${ETHOS_SDK_PATH}/core_platform/targets/corstone-300 target) +if(TARGET_BOARD STREQUAL "corstone-300") + add_subdirectory(${ETHOS_SDK_PATH}/core_platform/targets/corstone-300 target) +elseif(TARGET_BOARD STREQUAL "corstone-320") + add_subdirectory(${ETHOS_SDK_PATH}/core_platform/targets/corstone-320 target) +else() + message(FATAL_ERROR "Unsupported TARGET_BOARD: ${TARGET_BOARD}") +endif() # Dependencies from the ExecuTorch build add_library(executorch STATIC IMPORTED) @@ -171,7 +176,7 @@ endif() if(SEMIHOSTING) # Remove this when MLBEDSW-8910 is closed. set_source_files_properties( - ${ETHOS_SDK_PATH}/core_platform/targets/corstone-300/retarget.c + ${ETHOS_SDK_PATH}/core_platform/targets/${TARGET_BOARD}/retarget.c PROPERTIES HEADER_FILE_ONLY TRUE ) endif() diff --git a/examples/arm/executor_runner/arm_executor_runner.cpp b/examples/arm/executor_runner/arm_executor_runner.cpp index 65f5ffeaab3..0280c729ca2 100644 --- a/examples/arm/executor_runner/arm_executor_runner.cpp +++ b/examples/arm/executor_runner/arm_executor_runner.cpp @@ -31,7 +31,7 @@ * In our unit test flow, we have the capability to provide an enitre model to * the Corstone-3xx FVP using semi hosting. Hence, the input file allocation * pool needs to be large enough to take an entire model and input. On the FVP, - * network_model_sec is linked to the DDR, which is large (256MB on + * input_data_sec is linked to the DDR, which is large (256MB on * Corstone-300). * If you use semihosting on your HW this can be lowered to fit your * files/memory @@ -39,7 +39,7 @@ const size_t input_file_allocation_pool_size = 60 * 1024 * 1024; unsigned char __attribute__(( - section("network_model_sec"), + section("input_data_sec"), aligned(16))) input_file_allocation_pool[input_file_allocation_pool_size]; char* model_pte = nullptr; @@ -90,7 +90,7 @@ using executorch::runtime::TensorInfo; const size_t method_allocation_pool_size = ET_ARM_BAREMETAL_METHOD_ALLOCATOR_POOL_SIZE; unsigned char __attribute__(( - section("network_model_sec"), + section("input_data_sec"), aligned(16))) method_allocation_pool[method_allocation_pool_size]; /** @@ -105,7 +105,7 @@ unsigned char __attribute__(( const size_t temp_allocation_pool_size = ET_ARM_BAREMETAL_TEMP_ALLOCATOR_POOL_SIZE; unsigned char __attribute__(( - section("network_model_sec"), + section("input_data_sec"), aligned(16))) temp_allocation_pool[temp_allocation_pool_size]; void et_pal_init(void) {} diff --git a/examples/arm/setup.sh b/examples/arm/setup.sh index 3d99143d27b..73d552cb268 100755 --- a/examples/arm/setup.sh +++ b/examples/arm/setup.sh @@ -76,7 +76,7 @@ fi # ethos-u ethos_u_repo_url="https://review.mlplatform.org/ml/ethos-u/ethos-u" -ethos_u_base_rev="24.05" +ethos_u_base_rev="24.08" ######## ### Mandatory user args @@ -163,7 +163,7 @@ function patch_repo() { name="$(basename $repo_dir)" echo -e "[${FUNCNAME[0]}] Preparing ${name}..." cd $repo_dir - + git fetch git reset --hard ${base_rev} patch_dir=${script_dir}/ethos-u-setup/${name}/patches/ @@ -261,7 +261,7 @@ setup_ethos_u # Patch the ethos-u dev environment to include executorch application repo_dir="${root_dir}/ethos-u/core_platform" -base_rev=204210b1074071532627da9dc69950d058a809f4 +base_rev=b728c774158248ba2cad8e78a515809e1eb9b77f patch_repo # Setup the tosa_reference_model