diff --git a/src/W800 SDK v1.00.08/Makefile b/src/W800 SDK v1.00.08/Makefile index f098bdd..16dc8b2 100644 --- a/src/W800 SDK v1.00.08/Makefile +++ b/src/W800 SDK v1.00.08/Makefile @@ -5,7 +5,8 @@ ifndef PDIR # { GEN_IMAGES= $(TARGET).elf GEN_BINS = $(TARGET).bin SUBDIRS = \ - $(TOP_DIR)/app + $(TOP_DIR)/app \ + $(TOP_DIR)/lvgl endif # } PDIR ifndef PDIR # { @@ -29,7 +30,8 @@ endif endif COMPONENTS_$(TARGET) = \ - $(TOP_DIR)/app/libuser$(LIB_EXT) + $(TOP_DIR)/app/libuser$(LIB_EXT) \ + $(TOP_DIR)/lvgl/liblvgl$(LIB_EXT) ifeq ($(USE_LIB), 0) COMPONENTS_$(TARGET) += \ diff --git a/src/W800 SDK v1.00.08/include/platform/wm_mem.h b/src/W800 SDK v1.00.08/include/platform/wm_mem.h index bf029f8..655b1d4 100644 --- a/src/W800 SDK v1.00.08/include/platform/wm_mem.h +++ b/src/W800 SDK v1.00.08/include/platform/wm_mem.h @@ -84,6 +84,7 @@ void * mem_alloc_debug(u32 size); void mem_free_debug(void *p); void * mem_realloc_debug(void *mem_address, u32 size); void *mem_calloc_debug(u32 length, u32 size); +u32 tls_mem_get_avail_heapsize(void); /** * @defgroup System_APIs System APIs diff --git a/src/W800 SDK v1.00.08/platform/common/mem/wm_mem.c b/src/W800 SDK v1.00.08/platform/common/mem/wm_mem.c index a866bed..9c09bb2 100644 --- a/src/W800 SDK v1.00.08/platform/common/mem/wm_mem.c +++ b/src/W800 SDK v1.00.08/platform/common/mem/wm_mem.c @@ -773,7 +773,7 @@ u32 tls_mem_get_avail_heapsize(void) // tls_os_release_critical(cpu_sr); tls_os_sem_release(mem_sem); - return availablemem&0xFFFFF000; + return availablemem/*&0xFFFFF000*/; #else u8 *p = NULL; u32 startpos = 0; diff --git a/src/W800 SDK v1.00.08/platform/sys/wm_main.c b/src/W800 SDK v1.00.08/platform/sys/wm_main.c index 6634bf8..d148914 100644 --- a/src/W800 SDK v1.00.08/platform/sys/wm_main.c +++ b/src/W800 SDK v1.00.08/platform/sys/wm_main.c @@ -216,7 +216,7 @@ int main(void) u32 value = 0; /*standby reason setting in here,because pmu irq will clear it.*/ - if ((tls_reg_read32(HR_PMU_INTERRUPT_SRC)>>7)&0x1) + if( (tls_reg_read32(HR_PMU_INTERRUPT_SRC) >> 8) & 0x1) { tls_sys_set_reboot_reason(REBOOT_REASON_STANDBY); } diff --git a/src/W800 SDK v1.00.08/src/os/rtos/include/task.h b/src/W800 SDK v1.00.08/src/os/rtos/include/task.h index f05b6fc..de84968 100644 --- a/src/W800 SDK v1.00.08/src/os/rtos/include/task.h +++ b/src/W800 SDK v1.00.08/src/os/rtos/include/task.h @@ -1799,11 +1799,14 @@ UBaseType_t uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, * will be written, in ASCII form. This buffer is assumed to be large * enough to contain the generated report. Approximately 40 bytes per * task should be sufficient. + * @param uxWriteBufferSize The size of the pre-allocated string buffer in bytes, the NULL terminating character is included in the size. + * + * @return The number of bytes or characters written to the buffer * * \defgroup vTaskList vTaskList * \ingroup TaskUtils */ -void vTaskList( char * pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ +UBaseType_t vTaskList( char * pcWriteBuffer, UBaseType_t uxWriteBufferSize) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ /** * task. h diff --git a/src/W800 SDK v1.00.08/src/os/rtos/source/tasks.c b/src/W800 SDK v1.00.08/src/os/rtos/source/tasks.c index 1029cc6..e2bae4b 100644 --- a/src/W800 SDK v1.00.08/src/os/rtos/source/tasks.c +++ b/src/W800 SDK v1.00.08/src/os/rtos/source/tasks.c @@ -4516,11 +4516,25 @@ static void prvResetNextTaskUnblockTime( void ) #if ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) - void vTaskList( char * pcWriteBuffer ) + UBaseType_t vTaskList( char * pcWriteBuffer, UBaseType_t uxWriteBufferSize) { + /* + * If there is no space allocated for the buffer, we do not print anything. + */ + if(!uxWriteBufferSize || !pcWriteBuffer) + { + return 0; + } + + TaskStatus_t * pxTaskStatusArray; UBaseType_t uxArraySize, x; char cStatus; + /* We save here the start address of our buffer, it'll be used to compute the written size at the end. */ + char *startOfWriteBuffer = pcWriteBuffer; + /* We reserve the last byte for the string terminating character : \0*/ + uxWriteBufferSize--; + unsigned short usStackRemaining = 0, usCurStack = 0; /* @@ -4549,8 +4563,20 @@ static void prvResetNextTaskUnblockTime( void ) /* Make sure the write buffer does not contain a string. */ - //*pcWriteBuffer = ( char ) 0x00; - pcWriteBuffer += strlen(strcpy(pcWriteBuffer,"task\t\ttask num\ttask prio\ttask status\tstack total\tstack remain\tstack least remain\tmin stack space\r\n")); + + strncpy(pcWriteBuffer,"task\t\ttask num\ttask prio\ttask status\tstack total\tstack remain\tstack least remain\tmin stack space\r\n", uxWriteBufferSize); + pcWriteBuffer[uxWriteBufferSize] = '\0'; + UBaseType_t writtenSize = strlen(pcWriteBuffer); + /* We move the string pointer n bytes to be ready to write the next data. */ + pcWriteBuffer += writtenSize; + /* We update the remaining size. */ + uxWriteBufferSize -= writtenSize; + + /* We check if we still have space for the name of the first task.*/ + if(uxWriteBufferSize < configMAX_TASK_NAME_LEN) + { + return writtenSize; + } /* Take a snapshot of the number of tasks in case it changes while this * function is executing. */ @@ -4615,12 +4641,18 @@ static void prvResetNextTaskUnblockTime( void ) } #endif + /* We save the start of the buffer to be able to compute the written task name length. */ + char *startOfbuffer = pcWriteBuffer; /* Write the task name to the string, padding with spaces so it * can be printed in tabular form more easily. */ pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName ); + /* We compute the task name written length. */ + writtenSize = pcWriteBuffer - startOfbuffer; + /* We update our buffer size by removing what we just wrote. */ + uxWriteBufferSize -= writtenSize; /* Write the rest of the string. */ - sprintf( pcWriteBuffer, "\t\t%lu\t\t%u\t\t%c\t\t%u\t\t%u\t\t%u\t\t%u\t\r\n", + writtenSize = snprintf(pcWriteBuffer, uxWriteBufferSize, "\t\t%lu\t\t%u\t\t%c\t\t%u\t\t%u\t\t%u\t\t%u\t\r\n", pxTaskStatusArray[ x ].xTaskNumber, ( unsigned int ) (configMAX_PRIORITIES - pxTaskStatusArray[ x ].uxCurrentPriority), cStatus, @@ -4629,7 +4661,19 @@ static void prvResetNextTaskUnblockTime( void ) ( unsigned int )usStackRemaining, pxTaskStatusArray[ x ].usStackHighWaterMark ); /*lint !e586 sprintf() allowed as this is compiled with many compilers and this is a utility function only - not part of the core kernel implementation. */ - pcWriteBuffer += strlen( pcWriteBuffer ); /*lint !e9016 Pointer arithmetic ok on char pointers especially as in this case where it best denotes the intent of the code. */ + /* If what we tried to write is bigger than the space which was left in the buffer, then we set the remaining space to 0. */ + uxWriteBufferSize -= writtenSize > uxWriteBufferSize ? uxWriteBufferSize : writtenSize; + + /* We check if we have space for the next task name. */ + if(uxWriteBufferSize >= configMAX_TASK_NAME_LEN) + { + pcWriteBuffer += writtenSize; /*lint !e9016 Pointer arithmetic ok on char pointers especially as in this case where it best denotes the intent of the code. */ + } + /* This means no space left so we exit the loop. */ + else + { + break; + } } /* Free the array again. NOTE! If configSUPPORT_DYNAMIC_ALLOCATION @@ -4639,7 +4683,14 @@ static void prvResetNextTaskUnblockTime( void ) else { mtCOVERAGE_TEST_MARKER(); + return 0; } + + /* We don't forget to add the string NULL terminating character. */ + *pcWriteBuffer = '\0'; + + /* We return the number of bytes written during the whole operation. */ + return pcWriteBuffer - startOfWriteBuffer; } #endif /* ( ( configUSE_TRACE_FACILITY == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS > 0 ) && ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) ) */ diff --git a/src/W800 SDK v1.00.08/src/os/rtos/wm_osal_rtos.c b/src/W800 SDK v1.00.08/src/os/rtos/wm_osal_rtos.c index fc5e545..000ab79 100644 --- a/src/W800 SDK v1.00.08/src/os/rtos/wm_osal_rtos.c +++ b/src/W800 SDK v1.00.08/src/os/rtos/wm_osal_rtos.c @@ -1437,7 +1437,7 @@ void tls_os_disp_task_stat_info(void) if(NULL == buf) return; #if configUSE_TRACE_FACILITY - vTaskList((char *)buf); + vTaskList((char *)buf, 1024); #endif printf("\n%s",buf); tls_mem_free(buf); diff --git a/src/W800 SDK v1.00.08/tools/w800/inc.mk b/src/W800 SDK v1.00.08/tools/w800/inc.mk index 2647f69..5906484 100644 --- a/src/W800 SDK v1.00.08/tools/w800/inc.mk +++ b/src/W800 SDK v1.00.08/tools/w800/inc.mk @@ -43,6 +43,14 @@ INCLUDES += -I $(TOP_DIR)/src/os/rtos/include INCLUDES += -I $(TOP_DIR)/src/app/factorycmd INCLUDES += -I $(TOP_DIR)/src/app/bleapp +INCLUDES += -I $(TOP_DIR)/app/app_include +INCLUDES += -I $(TOP_DIR)/app + +#lvgl include +INCLUDES += -I $(TOP_DIR)/lvgl/lvgl_v8.3 +INCLUDES += -I $(TOP_DIR)/lvgl/lvgl_port + + #nimble host INCLUDES += -I $(TOP_DIR)/src/bt/blehost/ext/tinycrypt/include INCLUDES += -I $(TOP_DIR)/src/bt/blehost/nimble/host/include diff --git a/src/W800 SDK v1.00.08/tools/w800/rules.mk b/src/W800 SDK v1.00.08/tools/w800/rules.mk index dec9c54..f8faa80 100644 --- a/src/W800 SDK v1.00.08/tools/w800/rules.mk +++ b/src/W800 SDK v1.00.08/tools/w800/rules.mk @@ -57,6 +57,7 @@ $$(IMAGEODIR)/$(1).elf: $$(OBJS) $$(DEP_OBJS_$(1)) $$(DEP_LIBS_$(1)) $$(DEPENDS_ @mkdir -p $$(IMAGEODIR) $(LINK) -Wl,--gc-sections -Wl,-zmax-page-size=1024 -Wl,--whole-archive $$(OBJS) $$(DEP_OBJS_$(1)) $$(DEP_LIBS_$(1)) $$(if $$(LINKFLAGS_$(1)),$$(LINKFLAGS_$(1))) -Wl,--no-whole-archive $(LINKFLAGS) $(MAP) -o $$@ $(SIZE) -A -t $(IMAGEODIR)/$(TARGET).elf + $(SIZE) -B $(IMAGEODIR)/$(TARGET).elf endef $(BINODIR)/%.bin: $(IMAGEODIR)/%.elf