Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions backends/arm/test/runner_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import json
import logging
import os
import re
import shutil
import subprocess
import tempfile
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()}"
)
Expand Down
21 changes: 18 additions & 3 deletions backends/arm/test/setup_testing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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} \
Expand All @@ -40,4 +53,6 @@ function build_semihosting_executorch_runner() {
find ${build_test_dir} -name "arm_executor_runner"
}

build_semihosting_executorch_runner
build_semihosting_executorch_runner corstone-300

build_semihosting_executorch_runner corstone-320
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
From 162ea6b51bd94fabf623cc6b63cf271497eaff8d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Per=20=C3=85strand?= <[email protected]>
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)

15 changes: 10 additions & 5 deletions examples/arm/executor_runner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
"../../.."
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
8 changes: 4 additions & 4 deletions examples/arm/executor_runner/arm_executor_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
* 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
*/

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;

Expand Down Expand Up @@ -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];

/**
Expand All @@ -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) {}
Expand Down
6 changes: 3 additions & 3 deletions examples/arm/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/
Expand Down Expand Up @@ -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
Expand Down
Loading