Skip to content

Commit c6a6caa

Browse files
authored
Arm backend: Auto generate cycle table if ETDump is used (#13943)
### Summary If you use **run.sh** with **--etdump** e.g. something like this: `examples/arm/run.sh --et_build_root=arm_test/test_run --target=ethos-u55-256 --model_name=mv2 --etdump` The script will dig out the ETDump file from the FVP logs and use it to produce a cycle table automatically. Please remember the the CorstoneFVP is not a cycle accurate simulator and the CPU cycle numbers can not be trusted, please run on real hardware or FPGA to get valid number. Running it on a FVP is mostly useful to check that the tools/flow work and not the actual CPU cycle numbers. ### Test plan This is tested by the test scripts cc @digantdesai @freddan80 @per @oscarandersson8218 Signed-off-by: Zingo Andersen <[email protected]>
1 parent cfd9b68 commit c6a6caa

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

backends/arm/scripts/run_fvp.sh

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ if [[ ${target} == *"ethos-u55"* ]]; then
9292
-C mps3_board.uart0.shutdown_on_eot=1 \
9393
-a "${elf_file}" \
9494
${data_file} \
95-
--timelimit ${timeout} 2>&1 | tee ${log_file} || true # seconds
95+
--timelimit ${timeout} 2>&1 | sed 's/\r$//' | tee ${log_file} || true # seconds
9696
echo "[${BASH_SOURCE[0]}] Simulation complete, $?"
9797
elif [[ ${target} == *"ethos-u85"* ]]; then
9898
${nobuf} ${fvp_model} \
@@ -104,13 +104,28 @@ elif [[ ${target} == *"ethos-u85"* ]]; then
104104
-C mps4_board.uart0.shutdown_on_eot=1 \
105105
-a "${elf_file}" \
106106
${data_file} \
107-
--timelimit ${timeout} 2>&1 | tee ${log_file} || true # seconds
107+
--timelimit ${timeout} 2>&1 | sed 's/\r$//' | tee ${log_file} || true # seconds
108108
echo "[${BASH_SOURCE[0]}] Simulation complete, $?"
109109
else
110110
echo "Running ${elf_file} for ${target} is not supported"
111111
exit 1
112112
fi
113113

114+
echo "Checking for a etdump in log"
115+
! grep "#\[RUN THIS\]" ${log_file} >/dev/null
116+
if [ $? != 0 ]; then
117+
echo "Found ETDump in log!"
118+
echo "#!/bin/sh" > etdump_script.sh
119+
sed -n '/^#\[RUN THIS\]$/,/^#\[END\]$/p' ${log_file} >> etdump_script.sh
120+
# You can run etdump_script.sh if you do
121+
# $ chmod a+x etdump_script.sh
122+
# $ ./etdump_script.sh
123+
# But lets not trust the script as a bad patch would run bad code on your machine
124+
grep ">etdump.bin" etdump_script.sh | cut -d\" -f2- | cut -d\" -f1 >etdump.base64
125+
base64 -d etdump.base64 >etdump.bin
126+
python3 -m devtools.inspector.inspector_cli --etdump_path etdump.bin --source_time_scale cycles --target_time_scale cycles
127+
fi
128+
114129
echo "Checking for problems in log:"
115130
! grep -E "^(F|E|\\[critical\\]|Hard fault.|Info: Simulation is stopping. Reason: CPU time has been exceeded.).*$" ${log_file}
116131
if [ $? != 0 ]; then

examples/arm/executor_runner/arm_executor_runner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ void write_etdump(RunnerContext& ctx) {
852852
encoded_buf[encoded_len] = 0x00; // Ensure null termination
853853
ET_LOG(Info, "Writing etdump.bin [base64]");
854854
printf(
855-
"#---\necho \"%s\" | base64 -d >etdump.bin\npython3 -m devtools.inspector.inspector_cli --etdump_path etdump.bin --source_time_scale cycles --target_time_scale cycles\n#---\n",
855+
"#[RUN THIS]\necho \"%s\" | base64 -d >etdump.bin\npython3 -m devtools.inspector.inspector_cli --etdump_path etdump.bin --source_time_scale cycles --target_time_scale cycles\n#[END]\n",
856856
encoded_buf);
857857
} else {
858858
ET_LOG(

0 commit comments

Comments
 (0)