本帖最后由 xiaoch669 于 2024-2-17 21:03 编辑
lvgl库aithinker_Ai-M6X_SDK\examples\lvgl\demos文件夹下有benchmark例程,我用1.3寸LCD跑了一晚上,程序一直莫名奇妙卡死,而且都是在不同的地方卡顿,我把帧率从50fps降到18fps,也修改了LV_MEM_SIZE,LV_LAYER_SIMPLE_BUF_SIZE,LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE 等参数,也没有一次完整跑完,还是在不同的地方卡死。感觉调整参数没有规律可循,特地来问问大佬。
下面是过程中的某张图片。
部分配置信息lv_conf.h
- MEMORY SETTINGS
- *=========================*/
- /*1: use custom malloc/free, 0: use the built-in `lv_mem_alloc()` and `lv_mem_free()`*/
- #define LV_MEM_CUSTOM 0
- #if LV_MEM_CUSTOM == 0
- /*Size of the memory available for `lv_mem_alloc()` in bytes (>= 2kB)*/
- #define LV_MEM_SIZE (230U * 1024U) /*[bytes]*/
- /*Set an address for the memory pool instead of allocating it as a normal array. Can be in external SRAM too.*/
- #define LV_MEM_ADR 0 /*0: unused*/
- /*Instead of an address give a memory allocator that will be called to get a memory pool for LVGL. E.g. my_malloc*/
- #if LV_MEM_ADR == 0
- #undef LV_MEM_POOL_INCLUDE
- #undef LV_MEM_POOL_ALLOC
- #endif
- #else /*LV_MEM_CUSTOM*/
- #define LV_MEM_CUSTOM_INCLUDE <stdlib.h> /*Header for the dynamic memory function*/
- #define LV_MEM_CUSTOM_ALLOC malloc
- #define LV_MEM_CUSTOM_FREE free
- #define LV_MEM_CUSTOM_REALLOC realloc
- #endif /*LV_MEM_CUSTOM*/
- /*Number of the intermediate memory buffer used during rendering and other internal processing mechanisms.
- *You will see an error log message if there wasn't enough buffers. */
- #define LV_MEM_BUF_MAX_NUM 16
- /*Use the standard `memcpy` and `memset` instead of LVGL's own functions. (Might or might not be faster).*/
- #define LV_MEMCPY_MEMSET_STD 0
- /*====================
- HAL SETTINGS
- *====================*/
- /*Default display refresh period. LVG will redraw changed areas with this period time*/
- #define LV_DISP_DEF_REFR_PERIOD 55 /*[ms]*/
- /*Input device read period in milliseconds*/
- #define LV_INDEV_DEF_READ_PERIOD 20 /*[ms]*/
- /*Use a custom tick source that tells the elapsed time in milliseconds.
- *It removes the need to manually update the tick with `lv_tick_inc()`)*/
- #define LV_TICK_CUSTOM 1
- #if LV_TICK_CUSTOM
- #define LV_TICK_CUSTOM_INCLUDE "bflb_mtimer.h" /*Header for the system time function*/
- #define LV_TICK_CUSTOM_SYS_TIME_EXPR ((uint32_t)bflb_mtimer_get_time_ms()) /*Expression evaluating to current system time in ms*/
- #endif /*LV_TICK_CUSTOM*/
- /*Default Dot Per Inch. Used to initialize default sizes such as widgets sized, style paddings.
- *(Not so important, you can adjust it to modify default sizes and spaces)*/
- #define LV_DPI_DEF 130 /*[px/inch]*/
- /*=======================
- * FEATURE CONFIGURATION
- *=======================*/
- /*-------------
- * Drawing
- *-----------*/
- /*Enable complex draw engine.
- *Required to draw shadow, gradient, rounded corners, circles, arc, skew lines, image transformations or any masks*/
- #define LV_DRAW_COMPLEX 1
- #if LV_DRAW_COMPLEX != 0
- /*Allow buffering some shadow calculation.
- *LV_SHADOW_CACHE_SIZE is the max. shadow size to buffer, where shadow size is `shadow_width + radius`
- *Caching has LV_SHADOW_CACHE_SIZE^2 RAM cost*/
- #define LV_SHADOW_CACHE_SIZE 0
- /* Set number of maximally cached circle data.
- * The circumference of 1/4 circle are saved for anti-aliasing
- * radius * 4 bytes are used per circle (the most often used radiuses are saved)
- * 0: to disable caching */
- #define LV_CIRCLE_CACHE_SIZE 4
- #endif /*LV_DRAW_COMPLEX*/
- /**
- * "Simple layers" are used when a widget has `style_opa < 255` to buffer the widget into a layer
- * and blend it as an image with the given opacity.
- * Note that `bg_opa`, `text_opa` etc don't require buffering into layer)
- * The widget can be buffered in smaller chunks to avoid using large buffers.
- *
- * - LV_LAYER_SIMPLE_BUF_SIZE: [bytes] the optimal target buffer size. LVGL will try to allocate it
- * - LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE: [bytes] used if `LV_LAYER_SIMPLE_BUF_SIZE` couldn't be allocated.
- *
- * Both buffer sizes are in bytes.
- * "Transformed layers" (where transform_angle/zoom properties are used) use larger buffers
- * and can't be drawn in chunks. So these settings affects only widgets with opacity.
- */
- #define LV_LAYER_SIMPLE_BUF_SIZE (64 * 1024)
- #define LV_LAYER_SIMPLE_FALLBACK_BUF_SIZE (12* 1024)
复制代码
文件如下
原因:见C站 [LVGL]移植记录:v8.3 运行demo跑飞进入HardFault_Handler 学习记录_1_lvgl hardfault_handler-CSDN博客
解决方法:
堆栈溢出,增大Stack Size
具体操作:
M61进行开发底层使用了操作系统,使用了freertos,并不是裸机编程,而freertos有自己的一套内存管理,使用者只需要对FreeRTOSConfig.h文件根据自身需求修改堆栈大小即可。
修改为:
- #define configMINIMAL_STACK_SIZE ((unsigned short)256)
- #define configTOTAL_HEAP_SIZE ((size_t)128 * 1024)
复制代码 结果:
说明M61的性能还是很强大滴
|