diff --git a/samples/task_profiler/README.txt b/samples/task_profiler/README.txt index 3dd10d1fa25..5078fd21c53 100644 --- a/samples/task_profiler/README.txt +++ b/samples/task_profiler/README.txt @@ -66,7 +66,7 @@ How to enable profiler in your application Conventions: $ZEPHYR_BASE = Zephyr base folder $APP_BASE = Application base folder -$PROFILER_BASE = Profiler base folder +$PROFILER_BASE = Profiler base folder i.e. $ZEPHYR_BASE/samples/task_profiler/profiler prof.log = profiler output file generated from Zephyr target (binary) 1) Enable KERNEL_EVENT_LOGGER @@ -164,7 +164,7 @@ prof_flush in the main loop, where processing will be the least impacted) prof_flush function must be called from main task before going in idle mode <--snippet -extern void prof_flush() +#include "profiler.h" ... @@ -177,6 +177,13 @@ void main(void) // Going to idle e.g. calling nano_cpu_idle() --> +Note that profiler src folder must be added to the Makefile: +$APP_BASE/src/Makefile: + +<--snippet +ccflags-y += -I${ZEPHYR_BASE}/samples/task_profiler/profiler/src +--> + 2.2) Add path to $PROFILER_BASE folder in application Makefile -------------------------------------------------------------- @@ -186,6 +193,10 @@ For example in $APP_BASE/src/Makefile: obj-y += $PROFILER_BASE/ --> +Note: +- the final "/" after $PROFILER_BASE is important +- the path must be relative to application src folder + 2.3) Increase console UART baud rate (depending on your board) ------------------------------------ @@ -267,6 +278,13 @@ const struct shell_cmd apps_cmd[] = { } --> +Note that profiler src folder must be added to the Makefile: +$APP_BASE/src/Makefile: + +<--snippet +ccflags-y += -I${ZEPHYR_BASE}/samples/task_profiler/profiler/src +--> + Additionally, the profiler must not register its console so PROFILER_NO_SHELL_REGISTER must be set to 1 while building: export PROFILER_NO_SHELL_REGISTER=1 diff --git a/samples/task_profiler/profiler/src/profiler.c b/samples/task_profiler/profiler/src/profiler.c index 0b753d9a935..d2f71720ae8 100644 --- a/samples/task_profiler/profiler/src/profiler.c +++ b/samples/task_profiler/profiler/src/profiler.c @@ -163,7 +163,7 @@ int shell_cmd_prof(int argc, char *argv[]) return 0; } -struct shell_cmd commands[] = { +struct shell_cmd prof_commands[] = { PROF_CMD, { NULL, NULL} }; @@ -223,7 +223,7 @@ void prof_init(void) #ifdef PROFILER_SHELL #ifndef PROFILER_NO_SHELL_REGISTER - shell_init("shell> ", commands); + shell_init("shell> ", prof_commands); #endif #endif diff --git a/samples/task_profiler/profiler/src/profiler.h b/samples/task_profiler/profiler/src/profiler.h index e7d6097a0b8..1b3645c9a44 100644 --- a/samples/task_profiler/profiler/src/profiler.h +++ b/samples/task_profiler/profiler/src/profiler.h @@ -19,8 +19,14 @@ #ifndef PROFILER_H #define PROFILER_H +extern void prof_flush(void); + +#if defined(CONFIG_CONSOLE_HANDLER_SHELL) && defined(CONFIG_KERNEL_EVENT_LOGGER_DYNAMIC) extern int shell_cmd_prof(int argc, char *argv[]); #define PROF_CMD { "prof", shell_cmd_prof, " [cfg1] [cfg2]" } +#else +#define PROF_CMD { "prof", NULL } +#endif #endif /* PROFILER_H */ diff --git a/samples/task_profiler/sample_nanokernel_app/src/Makefile b/samples/task_profiler/sample_nanokernel_app/src/Makefile index 1444554c052..c2b899a209a 100644 --- a/samples/task_profiler/sample_nanokernel_app/src/Makefile +++ b/samples/task_profiler/sample_nanokernel_app/src/Makefile @@ -1,3 +1,4 @@ ccflags-y += ${PROJECTINCLUDE} +ccflags-y += -I${ZEPHYR_BASE}/samples/task_profiler/profiler/src obj-y = hello.o ../../profiler/ diff --git a/samples/task_profiler/sample_nanokernel_app/src/hello.c b/samples/task_profiler/sample_nanokernel_app/src/hello.c index 7dfd463b421..e73ea1185db 100644 --- a/samples/task_profiler/sample_nanokernel_app/src/hello.c +++ b/samples/task_profiler/sample_nanokernel_app/src/hello.c @@ -26,6 +26,8 @@ #define PRINT printk #endif +#include "profiler.h" + #ifdef CONFIG_NANOKERNEL /* @@ -47,8 +49,6 @@ char __stack fiberStack[STACKSIZE]; struct nano_sem nanoSemTask; struct nano_sem nanoSemFiber; -extern void prof_flush(void); - void fiberEntry(void) { while (1) {