[SOLVED] PreArm: Scripting: Out of memory

[SOLVED] Hey everyone. I want to run the QuikTune Lua script on my Pixhawk 4. It is the only script in the APM/scripts folder, and it is only 20 KB. My SCR_HEAP_SIZE is 104KB so that is more than enough (besides, I set SCR_HEAP_SIZE to the maximum allowable under freemem = 191056 and that didn’t help either), so I think the issue is actually something else. In other words, all indications are that I do have the memory. Anyone seen this or know how to clear the PreArm check? Thanks!

Edit: Fun fact, if scripting is enabled at all then I get the PreArm: Scripting: Out of memory fail. I even took the Quiktune script off the SD card.

Here is a solution! (Well, part of it) Lua Scripts not working on Pixhawk 4 - #12 by Christopher_Milner

The full solution is quite cursed. There are two things at play: For the Pixhawk 4, you need less than is allocated by default in SCR_HEAP_SIZE but more than some other value. I literally trial and error’d my way to a SCR_HEAP_SIZE that wouldn’t throw a PreArm fail. For me that number was 83968. Which is like, random. Cursed. Anyway hope this helps somebody.

1 Like