Skip to content

Commit

Permalink
Issue restart rather than second lua_main() call on LFS reload.
Browse files Browse the repository at this point in the history
By the time we get informed that there's an LFS reload we've already
opened all the user libraries as well, so it's not safe to simply redo
that with a new lua_State. Currently that results in a hang, and a
manual reset is required to progress. Doing the automatic restart is
the correct approach here, even though this adds another reboot to the
LFS reload process.

Also fixed up a couple of minor issues when embedded-LFS is used.
  • Loading branch information
jmattsson committed Dec 6, 2024
1 parent 7c5bb15 commit a3212b2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion components/base_nodemcu/user_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ static void start_lua ()
{
NODE_DBG("Task task_lua started.\n");
if (lua_main()) // If it returns true then LFS restart is needed
lua_main();
esp_restart();
}

static void nodemcu_init(void)
Expand Down
5 changes: 2 additions & 3 deletions components/lua/lua-5.3/lnodemcu.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,9 @@ LUAI_FUNC int luaN_init (lua_State *L) {
lua_getglobal(L, #t); luaL_getmetafield( L, 1, #f ); lua_remove(L, -2);

LUALIB_API void luaL_lfsreload (lua_State *L) {
#if defined(CONFIG_NODEMCU_EMBEDDED_FLS_SIZE)
(void)L;
#if defined(CONFIG_NODEMCU_EMBEDDED_LFS_SIZE)
lua_pushstring(L, "Not allowed to write to LFS section");
return 1;
return;
#else
#ifdef LUA_USE_ESP
size_t l;
Expand Down

0 comments on commit a3212b2

Please sign in to comment.