Skip to content

Commit e8ca5c3

Browse files
BujSetlucylq
authored andcommitted
PAL File for Arm Zephyr Executor Runner (#12348)
### Summary Platform file for building Zephyr applications that use Executorch as a module. This is a simplified version of the file used in a Zephyr development branch [here](https://github.com/BujSet/zephyr/blob/executorch-module-integration/samples/modules/executorch/arm/hello_world/src/arm_zephyr_pal.hpp). In the future, it may be prudent to have a PAL file for arm bare metal (I imagine this would require a simple splicing of he PAL functions from the `arm_executor_runner.cpp` file). Leaving that task for a separate PR. ### Test plan Tested against the `arm_executor_runner.cpp` that is used in the [Arm-EthosU tutorial](https://docs.pytorch.org/executorch/main/tutorial-arm-ethos-u.html). Was able to successfully build the Arm Executor Runner, and run the simple add model.
1 parent 776c789 commit e8ca5c3

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include <zephyr/kernel.h>
2+
#include <zephyr/sys/printk.h>
3+
4+
void et_pal_init(void) {}
5+
6+
ET_NORETURN void et_pal_abort(void) {
7+
_exit(-1);
8+
}
9+
10+
et_timestamp_t et_pal_current_ticks(void) {
11+
return k_uptime_ticks();
12+
}
13+
14+
et_tick_ratio_t et_pal_ticks_to_ns_multiplier(void) {
15+
// Since we don't know the CPU freq for your target and just cycles in the
16+
// FVP for et_pal_current_ticks() we return a conversion ratio of 1
17+
return {1, 1};
18+
}
19+
20+
/**
21+
* Emit a log message via platform output (serial port, console, etc).
22+
*/
23+
void et_pal_emit_log_message(
24+
ET_UNUSED et_timestamp_t timestamp,
25+
et_pal_log_level_t level,
26+
const char* filename,
27+
ET_UNUSED const char* function,
28+
size_t line,
29+
const char* message,
30+
ET_UNUSED size_t length) {
31+
fprintf(
32+
stderr,
33+
"%c [executorch:%s:%zu %s()] %s\n",
34+
level,
35+
filename,
36+
line,
37+
function,
38+
message);
39+
}
40+
41+
void* et_pal_allocate(size_t size) {
42+
return k_malloc(size);
43+
}
44+
45+
void et_pal_free(ET_UNUSED void* ptr) {
46+
k_free(ptr);
47+
}

0 commit comments

Comments
 (0)