samples/task_profiler: modifications to ease integration

- Few clarifications in README
- addition of prof_flush() in profiler.h
- renamed shell "commands" variable (too generic)

Change-Id: I1bcf1867c15774a84ba24c19546e5ddafb2233a2
Signed-off-by: Fabrice Olivero <fabrice.olivero@intel.com>
This commit is contained in:
Fabrice Olivero 2016-05-26 10:13:47 +02:00 committed by Anas Nashif
commit 275a853c16
5 changed files with 31 additions and 6 deletions

View file

@ -66,7 +66,7 @@ How to enable profiler in your application
Conventions: Conventions:
$ZEPHYR_BASE = Zephyr base folder $ZEPHYR_BASE = Zephyr base folder
$APP_BASE = Application 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) prof.log = profiler output file generated from Zephyr target (binary)
1) Enable KERNEL_EVENT_LOGGER 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 prof_flush function must be called from main task before going in idle mode
<--snippet <--snippet
extern void prof_flush() #include "profiler.h"
... ...
@ -177,6 +177,13 @@ void main(void)
// Going to idle e.g. calling nano_cpu_idle() // 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 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/ 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) 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 Additionally, the profiler must not register its console so
PROFILER_NO_SHELL_REGISTER must be set to 1 while building: PROFILER_NO_SHELL_REGISTER must be set to 1 while building:
export PROFILER_NO_SHELL_REGISTER=1 export PROFILER_NO_SHELL_REGISTER=1

View file

@ -163,7 +163,7 @@ int shell_cmd_prof(int argc, char *argv[])
return 0; return 0;
} }
struct shell_cmd commands[] = { struct shell_cmd prof_commands[] = {
PROF_CMD, PROF_CMD,
{ NULL, NULL} { NULL, NULL}
}; };
@ -223,7 +223,7 @@ void prof_init(void)
#ifdef PROFILER_SHELL #ifdef PROFILER_SHELL
#ifndef PROFILER_NO_SHELL_REGISTER #ifndef PROFILER_NO_SHELL_REGISTER
shell_init("shell> ", commands); shell_init("shell> ", prof_commands);
#endif #endif
#endif #endif

View file

@ -19,8 +19,14 @@
#ifndef PROFILER_H #ifndef PROFILER_H
#define 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[]); extern int shell_cmd_prof(int argc, char *argv[]);
#define PROF_CMD { "prof", shell_cmd_prof, "<start|stop|cfg> [cfg1] [cfg2]" } #define PROF_CMD { "prof", shell_cmd_prof, "<start|stop|cfg> [cfg1] [cfg2]" }
#else
#define PROF_CMD { "prof", NULL }
#endif
#endif /* PROFILER_H */ #endif /* PROFILER_H */

View file

@ -1,3 +1,4 @@
ccflags-y += ${PROJECTINCLUDE} ccflags-y += ${PROJECTINCLUDE}
ccflags-y += -I${ZEPHYR_BASE}/samples/task_profiler/profiler/src
obj-y = hello.o ../../profiler/ obj-y = hello.o ../../profiler/

View file

@ -26,6 +26,8 @@
#define PRINT printk #define PRINT printk
#endif #endif
#include "profiler.h"
#ifdef CONFIG_NANOKERNEL #ifdef CONFIG_NANOKERNEL
/* /*
@ -47,8 +49,6 @@ char __stack fiberStack[STACKSIZE];
struct nano_sem nanoSemTask; struct nano_sem nanoSemTask;
struct nano_sem nanoSemFiber; struct nano_sem nanoSemFiber;
extern void prof_flush(void);
void fiberEntry(void) void fiberEntry(void)
{ {
while (1) { while (1) {