-
-
Notifications
You must be signed in to change notification settings - Fork 151
Update X9D+ 2015 to Letzter stabiler Build (#64) not enouge mamory #281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Just tried that build and got no error on my Q X7. @mikeller From looking at the console output of the jenkins builds it looks like the script is compiled using lua 5.3. Opentx uses 5.2.2. Could this cause Opentx to recompile the script when a jenkins build is used? |
Also there have been some changes since 1.4.1 was released which causes the script to use more memory. There are now two versions. One for the telemetry screen and one for the tools menu. |
Hello klutvott123, |
@klutvott123: It could - I am not a specialist in lua versioning. Can you compile the scripts yourself and test this hypothesis? (Or maybe copy the .luac files off one TX, and add them to another one?) |
@klutvott123 @mikeller loading the released scripts in the simulator gives the following:
Which is usually caused by 32/64 bit mismatch issues (although maybe lua version as well?) so it does look like it's being recompiled... (This was using a fresh download of the released 1.4.1) |
@klutvott123, @frozenskys: Trying to start the simulator from companion23 sinks the entire app into a memory hole - I've given up on getting this to work. Can you please try if the attached build fixes that version: |
@mikeller I'm still seeing the same "incompatible precompiled chunk" using that build... Let me dig further as looking on stackoverflow, lua is very picky about it's bitness, and endianness... |
@frozenskys: Would just not supplying the .luac files be a solution? |
@mikeller I agree as this is about where I have got to - It looks like we would need to cross compile to ARM because as far as I can work out lua scripts seem to be very picky about how and where they are compiled... I'm not sure that this would help the initial memory spike during OpenTx compiling the scripts - but if OpenTx is going to re-compile on first run anyway... |
Hi, |
@mikeller , @frozenskys I also did some investigating and have come to the same conclusion. I tried compiling the files in the sim and copying them over to my Q X7. It still recompiles the script. The luac files produced by the sim are identical to the files produced by the radio. Checked them in a hex editor. The memory spike is the same as when just copying over the files directly from Also did some reading in lua documentation. It says that precompiled chunks are not portable across architectures. I'm not sure if that is the case because I get the same files when compiling on my windows pc as I do on my raspberry pi. 😕 @ApophysX I think your radio just doesn't have enough free memory to run the latest build. |
@klutvott123 I've been looking around and there have also been reports on the iNav github of memory issues - I'm wondering if it can be caused by something like flex being included in the firmware or something else at the firmware level that could cause low memory? Did we add that much more memory use in the changes between 1.4.1 and 1.5.0 ? |
@frozenskys Maybe. But flex was available in 2.2.3 also? I see in the companion that flex is still optional. Or maybe you mean ACCESS support? Memory use has gone up a bit since 1.4.1. The pages use a few KB more than they used to. "Free mem" in opentx is also higher by maybe 6-7KB when using 1.4.1. Tools version uses a little less memory than telemetry version. Probably because there's no background function for one time scripts. I use
at the bottom of |
@klutvott123, After Remove the script from the telemetry screen and reboot my Tarenis and load SCRIPTS \ TOOLS \ bf.luac it starts now. |
@ApophysX Good. That should be enough to run the scripts, but it might not be enough for opentx to compile them. Can you tell us exactly what the error message says? Is it just "script syntax error not enough memory"? |
@frozenskys: Kind of sad - to me it looks like lua makes this harder than it needs be. Is there any downside in performance to having the .luac files in the current release (i.e. do we need to do a new release that removes the .luac files ASAP)? |
@mikeller no - no downside to shipping the .luac files as far as I can see, as they will just be re-compiled anyway - it's just currently pointless so we should stop doing it. More pressing is to work out why a few people are seeing memory errors, and seeing if we can shave a few Kb back off the refactored scripts. |
@frozenskys I think maybe |
@klutvott123 good call - I'll take a look at it when I get home tonight. But the data also looks higher for all the scripts after the refactoring - I wonder if that's because it's using two tables for the fields now, or if the removal of the |
@klutvott123, i deleted all * .luac files from the SD of my Taranis (64 elements). Then I started SCRIPTS \ TOOLS \ bf.lua because I get the message "Script syntax error TOOLS / bf.lua: 14 not enough memory" |
@frozenskys I would imagine using two tables has a bigger impact than removing the ``pre_xxx.lua```files but I'm not sure. @ApophysX That means it ran out of memory when compiling the script. Restart your radio and try running the script again. The files it has already compiled won't be compiled again so it will need less memory this time. Then you could try doing the same with the telemetry screen version of the script. |
@klutvott123, okay it works now, on the Tools menu (page 3 I was not aware, thanks for the info) and in the telemetry screen starts VTX Setup directly. |
@ApophysX Nice! Thanks for testing 👍 |
@mikeller , @frozenskys I have been looking into the precompile situation trying to find solutions. Here's the current master precompiled if anyone would like to test it. Included the scripts used to make it. |
@klutvott123: So this can work around problems that otherwise make it impossible to run the lua scripts on an actual TX?
|
@mikeller I agree. It's not very elegant. Right now it's mostly just to show that it's possible to have the script precompiled and not have opentx compile it again and run out of memory. I found that it's not impossible for it to run even if it ran out of memory when compiling. Just restart the TX and it doesn't recompile the files it compiled last time. Not very good from a users perspective but it works. I tried compiling on a raspberry pi which uses an ARM cpu using lua 5.2.2 but didn't have any luck with that. I'm starting to wonder if maybe all official lua versions are incompatible with opentx lua. The opentx version has been tampered with. It's possible to run the compile.lua I supplied directly on the radio. Might also be possible to do this automatically. I'll look into it |
Looking at the first 12 bytes of the header of a .luac file compiled on the sim looks like the following:
The one compiled on jenkins however has a different (size_t) value:
I wonder if something like a windows or linux port of eLua could be used to cross compile? |
@frozenskys: Could it be that this is something that was broken by OpenTX only recently? I remember that way back when we started we tested supplying the .luac files, and back then they were used by the TX without problems. |
@mikeller The only change I can see around this (i.e. in the OpenTx lua code) is from 3 years ago, when they moved from |
@mikeller I checked the headers of the 32bit files you provided and they were compiled with lua5.3 so I'm wondering if a 32Bit install of lua5.2 would do the trick? @klutvott123 what do you think? |
@frozenskys: That was a 32 bit install of lua 5.3... |
@mikeller yes but lua 5.3 - it generates completely different byte code than 5.2 😢 |
Well that's interesting... The header seems to match, but when trying to run on the sim I get the following error
Doing a binary compare between that and the one compiled by the sim shows an identical header but subtly different bytecode... 🤔 |
Digging further it looks like the LTR Patch from eLua was added to OpenTx sometime around 2014 http://www.eluaproject.net/doc/master/en_arch_ltr.html So i can't see how any normal lua bytecode could work... if the bitness is incorrect it would just recompile, and if the bitness is correct it won't load as it gets |
Good work! This further backs up my suspicion that opentx lua might be "incompatible" with regular lua. |
Interesting. I think going forward we either have to skip building / distributing .luac files that cannot be used, or find a way to run the OpenTX lua compliler from the command line, so this can be scripted. @raphaelcoeffic: Do you know if this is already possible, or have an idea of how feasible this is? |
@klutvott123 it's definitely incompatible: OpenTx Lua Types
Vanilla Lua 5.2.2 Types
In theory we could build an LTR patched version of luac that should produce compatible byte code... but then it would need to be kept in sync with the OpenTx version :( |
@frozenskys But then we would have to extract the patch from the opentx version? It's using a "modified" version of LTR. Sounds like a nightmare 😄 |
@klutvott123 I'm looking at that now - the OpenTx version is basically Lua 5.2.2 with the LTR patch added - however it's also pulling in some debug C++ headers that are OpenTx specific and aren't standard so the included default make file won't build the linux flavour without some magic... |
@frozenskys I just had a go at it myself. Applied the patch as it was done in opentx to a clean lua 5.2.2. Now I'm able to compile identical files to the ones compiled by opentx. |
@klutvott123: Have you been able to verify that they are accepted in OpenTX? I think we really need to strike up a conversation with the OpenTX team for this - it seems that on-device compilation is a major contributor to memory overruns, and giving script authors an easy way to automate off-device compilation would be a way around this, unlocking the potential for more complex scripts. |
@mikeller Yes, I have done multiple tests to verify that it works. No memory spike after loading the scripts compiled with this patched lua version. |
@klutvott123 I've been doing some more profiling, and it looks like after compilation 1.5.0 pages use around 2-3k more than the respective 1.4.1 pages when running in the sim. About 1k of this is caused by the new code for the menu, the rest I'm not sure about. |
@frozenskys I tried the vtx_defaults/vtx changes I mentioned earlier and it looks like we can maybe get around 2kb back by doing that. Should I make a PR for it and then you can have a look at it? |
@frozenskys Like this klutvott123@632ab6e |
@klutvott123 I had applied almost exactly the same change myself (only the variable name is different) but I don't see any change in memory (the following are after compilation using your memory used changes to ui.lua):
Also if there is an override "{model_name}.lua" it will still be loaded globally and therefore not applied. |
@frozenskys Did you check any of the other pages? It doesn't make much difference on the vtx page itself, but on the other pages there should be a reduction in memory use. |
@klutvott123 Ah OK - my misunderstanding - looks like that's working and good find :) ... We just need to fix model specific vtx_tables now, as they are still loaded globally (which will also need a change to the BF configurator code that dumps the lua tables) So worst case (compiled) memory use after your fix seems to be vtx page running as a telemetry script at 41.5Kb |
@frozenskys Now I see how it's intended to work. I just ignored
|
That would work - I'll need to update the BF exporter as it currently just writes out the bandTable, frequencyTable and frequenciesPerBand (but adding the other two static tables shouldn't be a problem) and also make it local like the defaults. |
@frozenskys All right, let's do it #284 |
Uh oh!
There was an error while loading. Please reload this page.
Hello,
after updat to Letzter stabiler Build (#64) my X9D+ (OpenTX 2.3.1) tells Script syntax error not enouge mamory.
i have use a clean SD Card to install the Lua.
The text was updated successfully, but these errors were encountered: