diff --git a/firmware/config/stm32f4ems/efifeatures.h b/firmware/config/stm32f4ems/efifeatures.h index e75086c4ed..e480137090 100644 --- a/firmware/config/stm32f4ems/efifeatures.h +++ b/firmware/config/stm32f4ems/efifeatures.h @@ -267,9 +267,15 @@ #ifdef EFI_IS_F42x #define EFI_USE_COMPRESSED_INI_MSD #define ENABLE_PERF_TRACE TRUE + + #define LUA_USER_HEAP 20000 + #define LUA_SYSTEM_HEAP 20000 #else // small memory F40x can't fit perf trace #define ENABLE_PERF_TRACE FALSE + + #define LUA_USER_HEAP 12000 + #define LUA_SYSTEM_HEAP 12000 #endif #ifndef EFI_LUA diff --git a/firmware/config/stm32f7ems/efifeatures.h b/firmware/config/stm32f7ems/efifeatures.h index 7c6de5bc3c..d3047d628f 100644 --- a/firmware/config/stm32f7ems/efifeatures.h +++ b/firmware/config/stm32f7ems/efifeatures.h @@ -57,3 +57,8 @@ // F7 may have dual bank, so flash on its own (low priority) thread so as to not block any other operations #define EFI_FLASH_WRITE_THREAD TRUE + +#undef LUA_USER_HEAP +#define LUA_USER_HEAP 100000 +#undef LUA_SYSTEM_HEAP +#define LUA_SYSTEM_HEAP 100000 diff --git a/firmware/config/stm32h7ems/efifeatures.h b/firmware/config/stm32h7ems/efifeatures.h index 4bd948b4d3..1e78c2e09c 100644 --- a/firmware/config/stm32h7ems/efifeatures.h +++ b/firmware/config/stm32h7ems/efifeatures.h @@ -47,3 +47,8 @@ #undef HAL_VSS_USE_PAL #define HAL_VSS_USE_PAL TRUE + +#undef LUA_USER_HEAP +#define LUA_USER_HEAP 100000 +#undef LUA_SYSTEM_HEAP +#define LUA_SYSTEM_HEAP 100000 diff --git a/firmware/controllers/lua/lua.cpp b/firmware/controllers/lua/lua.cpp index bd2cb0fad3..ac2c7d14c0 100644 --- a/firmware/controllers/lua/lua.cpp +++ b/firmware/controllers/lua/lua.cpp @@ -13,11 +13,11 @@ #if EFI_PROD_CODE || EFI_SIMULATOR #ifndef LUA_USER_HEAP -#define LUA_USER_HEAP 12000 +#define LUA_USER_HEAP 1 #endif // LUA_USER_HEAP #ifndef LUA_SYSTEM_HEAP -#define LUA_SYSTEM_HEAP 15000 +#define LUA_SYSTEM_HEAP 1 #endif // LUA_SYSTEM_HEAP static char luaUserHeap[LUA_USER_HEAP]; @@ -211,6 +211,7 @@ static LuaHandle systemLua; const char* getSystemLuaScript(); void initSystemLua() { +#if LUA_SYSTEM_HEAP > 1 efiAssertVoid(OBD_PCM_Processor_Fault, !systemLua, "system lua already init"); Timer startTimer; @@ -231,6 +232,7 @@ void initSystemLua() { #if !EFI_UNIT_TEST efiPrintf("System Lua loaded in %.2f ms using %d bytes", startTime * 1'000, heaps[1].used()); #endif +#endif } #if !EFI_UNIT_TEST @@ -359,9 +361,12 @@ void LuaThread::ThreadTask() { } } +#if LUA_USER_HEAP > 1 static LuaThread luaThread; +#endif void startLua() { +#if LUA_USER_HEAP > 1 luaThread.Start(); addConsoleActionS("lua", [](const char* str){ @@ -387,6 +392,7 @@ void startLua() { efiPrintf("Lua memory heap %d: %d / %d bytes = %.1f%%", i, memoryUsed, heapSize, pct); } }); +#endif } #else // not EFI_UNIT_TEST