So the CubeBlack uses an F4 processor so it doesn’t have enough memory unless some features are turned off. We’ve been planning to add a wiki page with suggestions on what features are most effective at reducing memory but here are some ideas:
EK3_IMU_MASK = 1 (this disables the 2nd IMU)
TERRAIN_ENABLE = 0 (disables the terrain database which will stop missions from using AltFrame=Terrain using the inbuilt terrain database, rangefinders will still work)
LOG_FILE_BUFSIZE = 8 (this reduces the memory used for logging which could lead to mission log messages but shouldn’t have any impact beyond this)
If you double click on an item in the Action tab and select “freemem” from the huge black window you can see how much memory is free on the board. For example I have 25,000 free on this random autopilot. You’d always want to leave at least 5000 but you could increase the SCR_HEAP_SIZE parameter by whatever extra you’ve got. I’d guess that 70,000 is enough for most scripts.
Well, I’m out of ideas I’m afraid. Maybe check that there are no other scripts in the scripts directory… Maybe disable any other features that you don’t immediately need (rangefinders, optical flow, anything else)…
The CubeBlack just doesn’t have the memory required to run scripting very well I think.
There is no other script installed on the cube.similarly no other functions enabled like range finder,optical flow etc…
You can refer 1st section of this thread to see only quicktune lua script only installed.
In the screen shots above it looks like SCR_HEAP_SIZE is 202400 which is more than the available memory of 145800. I think if you reduced SCR_HEAP_SIZE to 130,000 the error would go away.
The complexity comes though because at startup many different features try to take memory. There may be other features that also couldn’t get memory so it’s possible the above change to SCR_HEAP_SIZE won’t resolve the problem.
I am including a change in 4.2.2 that allows for the CAN memory pool to be reduced, which will help if you use CAN.
Scripting is hard though on F4 based boards, and it can be very tricky to get memory usage low enough to allow complex lua scripts to work.
We have discussed moving quicktune to being in C++ to avoid that issue, but that is unlikely to happen soon, sorry.
I thought I would add my experience trying to get the VTOL quick tune script running on a F7 board in the Pixhawk 4 mini. I think it would have plenty of memory to run it but I am getting the out of memory error when I try to start the script. I do have the EKF3 2nd IMU disabled and the log bit mask set to min of 8. I disabled all the serial that I don’t use and tried moving the heap size up and down to see if it would start. for some reason when I change the heap size the free memory does not change at all from 182000 free mem. The first message I do get before “scripting out of memory” is the “unable to allocate memory”. really not sure what else to try… Maybe the mini will never support scripting.
Free memory won’t change until it’s actually allocated. Apparently you either haven’t set the heap size large enough, or the board simply can’t load a script as large as the tuning one (which, as I recall, is a bit resource intense).
The Matek H7-based boards are very affordable in a compact form factor and will support most reasonable scripting needs. For a board with more convenient connectors, check out the QioTek Zealot H743.