edgetx icon indicating copy to clipboard operation
edgetx copied to clipboard

chores: update to LUA 5.3

Open raphaelcoeffic opened this issue 2 years ago • 14 comments

Preview of what is coming for 3.0...

Current issues:

  • [x] On T15 the radio goes into EM on shutdown

raphaelcoeffic avatar Oct 14 '23 12:10 raphaelcoeffic

Will it increase memory demand? Something is ringing in my head that 5.3 has 32bit numbers so it takes more mem.

JimB40 avatar Oct 15 '23 18:10 JimB40

Will it increase memory demand? Something is ringing in my head that 5.3 has 32bit numbers so it takes more mem.

The current LUA version we are using only supports 64Bit floating point. So I expect the memory usage to be reduced.

raphaelcoeffic avatar Oct 22 '23 21:10 raphaelcoeffic

Hi, what is the status of this?

LupusTheCanine avatar Jun 16 '24 00:06 LupusTheCanine

This will come with EdgeTX 3.0. we want to have one release where we combine multiple incompatible changes, to make life easier for the lua Devs.

gagarinlg avatar Jun 16 '24 07:06 gagarinlg

@raphaelcoeffic when you rebase pls ping me so I can make some tests.

JimB40 avatar Aug 20 '24 19:08 JimB40

Rebased to current main; but having issues with crashes to EM and stack overflow in widgets.

philmoz avatar Aug 21 '24 04:08 philmoz

I've rebases this to current main and it seems to be working ok on the radios I've tested (B&W and Color).

@raphaelcoeffic - I made one small change to ldump.c and lundump.c so that the .luac files generated by the simulator will work on the radio (tested on MacOS). This involves forcing the size_t size value in the header to 32 bits (commit 22219748).

With this change the .luac files generated in the simulator and on the radio are identical.

philmoz avatar Oct 01 '24 10:10 philmoz

Compiled .luac files are smaller with 5.3. E.G. ELRS Lua script:

  • 5.2 = 17758 bytes
  • 5.3 = 15590 bytes

philmoz avatar Oct 01 '24 23:10 philmoz

How to fix it? What was changed? Bitmap.* global table became bitmap.*? Changing Bitmap.open to bitmap.open in lua code doesn't work Screenshot 2024-10-06 at 13 58 30

JimB40 avatar Oct 06 '24 12:10 JimB40

How to fix it? What was changed? Bitmap.* global table became bitmap.*? Changing Bitmap.open to bitmap.open in lua code doesn't work Screenshot 2024-10-06 at 13 58 30

Odd. Changing it worked for me on the scripts I tested.

philmoz avatar Oct 06 '24 12:10 philmoz

Found it. It is io.open('file', 'r') that shuts down Simulator (Companion) abrubtly.

Here is test scipt "test_53ioopen.lua"

local fh

return {
  run = function(e)
    return 0
  end,

  init = function()    
    fh = io.open('/SCRIPTS/TOOLS/test_53ioopen.lua')
  end
}

But you can also put in LUA local fh = io.open('whatever') to get same result

JimB40 avatar Oct 07 '24 07:10 JimB40

io.* library works now.

I've made some inital tests comparing 2.10 LUA 5.2 and 2.11 LUA 5.3 using TX16S simulator.

  1. compiled *.luac files with LUA 5.3 are indeed smaller in size than those compiled with LUA 5.2 Difference is 10-25% depending on file.

  2. Run-time memory requrement increased about 8-9% :(

Toolbox compiled with 5.2 screenshot_tx16s_24-10-07_13-45-15

Toolbox compiled with 5.3 screenshot_tx16s_24-10-07_13-43-09

Need to do same test with B&W target but that's not good sign as bigger apps like BF Config script already works woth memory limit.

JimB40 avatar Oct 07 '24 11:10 JimB40

Even more increase for run-time memory with BW target, ca 11%

Toolbox compiled with 5.2 screenshot_x7access_24-10-07_14-43-08

Toolbox compiled with 5.3 screenshot_x7_24-10-07_14-40-55

JimB40 avatar Oct 07 '24 12:10 JimB40

I'm seeing reduced memory usage for running scripts. E.G. ELRS v3 script on T20V2:

  • 5.2 = 44967 bytes
  • 5.3 = 41796 bytes

I can't do any detailed analysis of the memory usage on your toolbox scripts as I can't see the source code anywhere.

philmoz avatar Oct 07 '24 20:10 philmoz

@philmoz we decided we will go with LUA 5.3 in EdgeTX 2.11

There is one change in API that affects text LUA text files: Bitmap.* functions are now bitmap.* To make trasistion easer would be good to have both bitmap.* and Bitmap.* (as alias) working in 2.11

JimB40 avatar Dec 15 '24 11:12 JimB40

'Bitmap' table restored for 2.11.

philmoz avatar Dec 15 '24 23:12 philmoz

LGTM on TX12, T20v2 and TX16S

pfeerick avatar Dec 24 '24 02:12 pfeerick

Hey! Lovely to see this change happening!

Is there a reason why EdgeTX is going to Lua 5.3 instead of 5.4? It seems to be quite a bit faster. Not sure there is any backwards-incompatible changes in that release compared to 5.3 either.

vifino avatar Dec 25 '24 09:12 vifino

The main reason was the availability of code for some specific changes that allow for read-only tables coming from the NodeMCU project. This is essential for us to reduce RAM usage of builtin libs and relocate them completely to FLASH memory.

raphaelcoeffic avatar Dec 29 '24 04:12 raphaelcoeffic