diff --git a/Kconfig b/Kconfig index 4018c04cd5..2a631b3cab 100644 --- a/Kconfig +++ b/Kconfig @@ -2056,6 +2056,17 @@ menu "LVGL configuration" help Set the step size of the mouse movement in pixels. + config LV_USE_NUTTX_TRACE_FILE + bool "Use NuttX trace file" + depends on LV_USE_NUTTX + depends on LV_USE_PROFILER_BUILTIN + default n + + config LV_NUTTX_TRACE_FILE_PATH + depends on LV_USE_NUTTX_TRACE_FILE + string "NuttX trace file path" + default "/data/lvgl-trace.log" + config LV_USE_LINUX_DRM bool "Use Linux DRM device" default n diff --git a/lv_conf_template.h b/lv_conf_template.h index 8c3ac8886f..e3744cc770 100644 --- a/lv_conf_template.h +++ b/lv_conf_template.h @@ -1271,6 +1271,13 @@ /** Mouse movement step (pixels) */ #define LV_USE_NUTTX_MOUSE_MOVE_STEP 1 + + /*NuttX trace file and its path*/ + #define LV_USE_NUTTX_TRACE_FILE 0 + #if LV_USE_NUTTX_TRACE_FILE + #define LV_NUTTX_TRACE_FILE_PATH "/data/lvgl-trace.log" + #endif + #endif /** Driver for /dev/dri/card */ diff --git a/src/drivers/nuttx/lv_nuttx_entry.c b/src/drivers/nuttx/lv_nuttx_entry.c index 03fd167b81..47c3b18ae2 100644 --- a/src/drivers/nuttx/lv_nuttx_entry.c +++ b/src/drivers/nuttx/lv_nuttx_entry.c @@ -111,6 +111,10 @@ void lv_nuttx_dsc_init(lv_nuttx_dsc_t * dsc) #if LV_USE_NUTTX_MOUSE dsc->mouse_path = "/dev/mouse0"; #endif + +#if LV_USE_NUTTX_TRACE_FILE + dsc->trace_path = LV_NUTTX_TRACE_FILE_PATH; +#endif } void lv_nuttx_init(const lv_nuttx_dsc_t * dsc, lv_nuttx_result_t * result) @@ -131,6 +135,9 @@ void lv_nuttx_init(const lv_nuttx_dsc_t * dsc, lv_nuttx_result_t * result) #if LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN lv_nuttx_profiler_init(); +#if LV_USE_NUTTX_TRACE_FILE + lv_nuttx_profiler_set_file(dsc->trace_path); +#endif #endif if(result) { @@ -254,6 +261,9 @@ void lv_nuttx_deinit(lv_nuttx_result_t * result) lv_nuttx_cache_deinit(); lv_nuttx_image_cache_deinit(); +#if LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN + lv_nuttx_profiler_deinit(); +#endif lv_free(nuttx_ctx_p); nuttx_ctx_p = NULL; } diff --git a/src/drivers/nuttx/lv_nuttx_entry.h b/src/drivers/nuttx/lv_nuttx_entry.h index a23bb99082..6100b96c2c 100644 --- a/src/drivers/nuttx/lv_nuttx_entry.h +++ b/src/drivers/nuttx/lv_nuttx_entry.h @@ -36,6 +36,7 @@ typedef struct { const char * input_path; const char * utouch_path; const char * mouse_path; + const char * trace_path; } lv_nuttx_dsc_t; typedef struct { @@ -47,6 +48,7 @@ typedef struct { typedef struct _lv_nuttx_ctx_t { void * image_cache; + int trace_fd; } lv_nuttx_ctx_t; /********************** diff --git a/src/drivers/nuttx/lv_nuttx_profiler.c b/src/drivers/nuttx/lv_nuttx_profiler.c index 63c1a5374d..e48fb1d0dd 100644 --- a/src/drivers/nuttx/lv_nuttx_profiler.c +++ b/src/drivers/nuttx/lv_nuttx_profiler.c @@ -13,12 +13,15 @@ #if LV_USE_NUTTX && LV_USE_PROFILER && LV_USE_PROFILER_BUILTIN #include +#include #include /********************* * DEFINES *********************/ +#define trace_fd (LV_GLOBAL_DEFAULT()->nuttx_ctx->trace_fd) + #define TICK_TO_NSEC(tick) ((tick) * 1000 / cpu_freq) /********************** @@ -55,6 +58,10 @@ void lv_nuttx_profiler_init(void) } LV_LOG_USER("CPU frequency: %" LV_PRIu32 " MHz", cpu_freq); +#if LV_USE_NUTTX_TRACE_FILE + trace_fd = -1; +#endif + lv_profiler_builtin_config_t config; lv_profiler_builtin_config_init(&config); config.tick_per_sec = 1000000000; /* 1 sec = 1000000000 nsec */ @@ -63,6 +70,31 @@ void lv_nuttx_profiler_init(void) lv_profiler_builtin_init(&config); } +void lv_nuttx_profiler_set_file(const char * file) +{ +#if LV_USE_NUTTX_TRACE_FILE + if(trace_fd >= 0) { + close(trace_fd); + } + + trace_fd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if(trace_fd < 0) { + LV_LOG_ERROR("Failed to open trace file %s, error: %d", file, errno); + } +#endif +} + +void lv_nuttx_profiler_deinit(void) +{ + lv_profiler_builtin_uninit(); +#if LV_USE_NUTTX_TRACE_FILE + if(trace_fd >= 0) { + close(trace_fd); + } + trace_fd = -1; +#endif +} + /********************** * STATIC FUNCTIONS **********************/ @@ -90,6 +122,12 @@ static uint64_t tick_get_cb(void) static void flush_cb(const char * buf) { +#if LV_USE_NUTTX_TRACE_FILE + if(trace_fd >= 0) { + write(trace_fd, buf, strlen(buf)); + return; + } +#endif printf("%s", buf); } diff --git a/src/drivers/nuttx/lv_nuttx_profiler.h b/src/drivers/nuttx/lv_nuttx_profiler.h index 8b8cf65210..01f97589eb 100644 --- a/src/drivers/nuttx/lv_nuttx_profiler.h +++ b/src/drivers/nuttx/lv_nuttx_profiler.h @@ -27,6 +27,8 @@ extern "C" { **********************/ void lv_nuttx_profiler_init(void); +void lv_nuttx_profiler_set_file(const char * file); +void lv_nuttx_profiler_deinit(void); /********************** * MACROS diff --git a/src/lv_conf_internal.h b/src/lv_conf_internal.h index c350ff1811..9a3f343c9b 100644 --- a/src/lv_conf_internal.h +++ b/src/lv_conf_internal.h @@ -4116,6 +4116,25 @@ #define LV_USE_NUTTX_MOUSE_MOVE_STEP 1 #endif #endif + + /*NuttX trace file and its path*/ + #ifndef LV_USE_NUTTX_TRACE_FILE + #ifdef CONFIG_LV_USE_NUTTX_TRACE_FILE + #define LV_USE_NUTTX_TRACE_FILE CONFIG_LV_USE_NUTTX_TRACE_FILE + #else + #define LV_USE_NUTTX_TRACE_FILE 0 + #endif + #endif + #if LV_USE_NUTTX_TRACE_FILE + #ifndef LV_NUTTX_TRACE_FILE_PATH + #ifdef CONFIG_LV_NUTTX_TRACE_FILE_PATH + #define LV_NUTTX_TRACE_FILE_PATH CONFIG_LV_NUTTX_TRACE_FILE_PATH + #else + #define LV_NUTTX_TRACE_FILE_PATH "/data/lvgl-trace.log" + #endif + #endif + #endif + #endif /** Driver for /dev/dri/card */