Browse Source

update:luavm的heap free的时候需要先判断一下是不是在ram空间
add:支持小内存模式
update:luavm退出时也要停掉lvgl的tick

alienwalker 4 years ago
parent
commit
dc30840815

+ 4 - 0
application/include/luat_conf_bsp.h

@@ -162,6 +162,10 @@ extern unsigned int gLVFlashTime;
 #define LV_USE_PERF_MONITOR     1
 #define __LVGL_SLEEP_ENABLE__
 
+#ifdef __LUATOS_SMALL_RAM__
+#define LUAT_USE_MEMORY_OPTIMIZATION_CODE_MMAP
+#endif
+
 #ifndef __DEBUG__
 #undef LV_USE_PERF_MONITOR
 #endif

+ 7 - 1
application/src/luat_base_air105.c

@@ -201,7 +201,7 @@ static const luaL_Reg loadedlibs[] = {
   {NULL, NULL}
 };
 
-
+void luat_lvgl_tick_sleep(uint8_t OnOff);
 // 按不同的rtconfig加载不同的库函数
 void luat_openlibs(lua_State *L) {
     // 初始化队列服务
@@ -232,6 +232,7 @@ void luat_os_standy(int timeout) {
 }
 
 void luat_ota_reboot(int timeout_ms) {
+	luat_lvgl_tick_sleep(1);
   if (timeout_ms > 0)
     luat_timer_mdelay(timeout_ms);
   SystemReset();
@@ -262,6 +263,11 @@ void luat_lvgl_tick_sleep(uint8_t OnOff)
 	{
 		Timer_Stop(lv_timer);
 	}
+}
+#else
+void luat_lvgl_tick_sleep(uint8_t OnOff)
+{
+
 }
 #endif
 

+ 9 - 4
application/src/luat_malloc_air105.c

@@ -33,7 +33,7 @@
 
 #include "FreeRTOS.h"
 #include "task.h"
-
+#include "app_interface.h"
 
 //------------------------------------------------
 //  管理系统内存
@@ -86,7 +86,6 @@ void* luat_heap_alloc(void *ud, void *ptr, size_t osize, size_t nsize) {
 //            return ptr;
 //        }
 //    }
-
     if (nsize)
     {
     	void* ptmp = pvPortMalloc(nsize);
@@ -100,7 +99,10 @@ void* luat_heap_alloc(void *ud, void *ptr, size_t osize, size_t nsize) {
     		{
     			memcpy(ptmp, ptr, osize);
     		}
-    		vPortFree(ptr);
+    		if (((uint32_t)ptr & __SRAM_BASE_ADDR__) == __SRAM_BASE_ADDR__)
+    		{
+    			vPortFree(ptr);
+    		}
     		return ptmp;
     	}
     	else if (osize >= nsize)
@@ -108,7 +110,10 @@ void* luat_heap_alloc(void *ud, void *ptr, size_t osize, size_t nsize) {
     		return ptr;
     	}
     }
-    vPortFree(ptr);
+	if (((uint32_t)ptr & __SRAM_BASE_ADDR__) == __SRAM_BASE_ADDR__)
+	{
+		vPortFree(ptr);
+	}
     return NULL;
 }
 

+ 1 - 0
application/src/luat_shell_air105.c

@@ -58,6 +58,7 @@ static void luat_shell(void *sdata)
 		Task_GetEvent(prvhShell, CORE_EVENT_ID_ANY, &Event, NULL, 0);
 		len = 1;
 		while (len > 0 && len < 512) {
+			memset(buff, 0, 512);
             len = Uart_RxBufferRead(0, buff, 512);
             if (len > 0 && len < 512){
                 buff[len] = 0x00; // 确保结尾