FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Compile script by klutvott123 · Pull Request #311 · betaflight/betaflight-tx-lua-scripts · GitHub

Compile script - #311

Merged
mikeller merged 1 commit into
betaflight:masterfrom
klutvott123:compile-script
Feb 14, 2020
Merged

mikeller merged 1 commit into
betaflight:masterfrom
klutvott123:compile-script

Conversation

Copy link
Copy Markdown
Member

Adds a script that compiles all Betaflight lua files the first time bf.lua is executed.
build.sh has been repurposed to create a file containing a table with the files to be compiled. The .lua files are tested for errors using luac -p. No .luac files are created.

As discussed in #281 the main memory issue we have now is running out of memory when compiling the betaflight lua scripts on the TX. OpenTX uses a modified version of LUA 5.2.2 with lua tiny RAM applied. This means that precompiled scripts will not work unless they are created with a version of lua that has had the same mod applied.

I believe the problem with on device compilation is that we're trying to load too many files in one lua cycle(bf.lua). The solution is to use a compile script that loads and compiles one file each lua cycle.

compile.lua will only run the first time bf.luais executed. It loads and compiles all files listed in scripts.lua one by one and exits when done. The next time bf.lua is executed everything will be as normal. compile.lua will not run again unless scripts_compiled.lua is modified or overwritten(new bf lua version).

"Free mem" in OpenTX shows over 40KB after running this(used to be close to 0 or out of memory).

Adds a script that compiles all Betaflight lua files the first time bf.lua is executed.
build.sh has been repurposed to create a file containing a table with the files to be compiled. The .lua files are tested for errors using luac -p. No .luac files are created.
mikeller added this to the 1.5 milestone Feb 12, 2020
collectgarbage()
return 0
end
local file = io.open("COMPILE/scripts_compiled.lua", 'w')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I had been looking for a way to persist state in lua - this seems to be a good way to do so.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

👍 . The first iteration of this had compile.lua delete it's contents when finished. Quickly abandoned that idea lol.

mikeller merged commit 968d5be into betaflight:master Feb 14, 2020
klutvott123 deleted the compile-script branch March 19, 2020 16:30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL