Page 1 of 1

resetConfig: Flashing Default Script: FAILED

Posted: Sat Sep 02, 2017 7:49 pm
by eacmen
This is more of a bug report than a question expecting an answer.

After several iterations of modifying lua scripts I will eventually get the following error:

lua: Failed to allocate memory for script buffer.

When this error pops up the RCP gets very unstable and has to be hard-reset. Usually I would expect this error would happen with a lua script that is too long. However, even with lua scripts that I *know* have worked before and also tried examples from the wiki.

So, naturally, I went to do a resetConfig over the TTY (which usually fixes any bad state with RCP). And I get the following error when doing resetConfig:

Code: Select all

0 peter@ld64 ~$ sudo miniterm.py /dev/ttyACM0 115200
--- Miniterm on /dev/ttyACM0  115200,8,N,1 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---



=============================================
Welcome to RaceCapture/Pro MK3 version 2.12.0
=============================================

Available Commands:

resetConfig   : Resets All configuration Data to factory default Usage: resetConfig
testSD        &#58; Test Write to SD card. Usage&#58; testSD <lineWrites> <periodicFlush> <quietMode>
startTerminal &#58; Starts a debugging terminal session on the specified port. Usage&#58; startTerminal <port> <baud> &#91;echo 1|0&#93;
setLogLevel   &#58; Sets the log level Usage&#58; setLogLevel <level>
logGpsData    &#58; Enables logging of raw GPS data from the GPS Mouse Usage&#58; logGpsData <1|0>
viewLog       &#58; Prints out logging messages to the terminal as they happen Usage&#58; viewLog
setSerialLog  &#58; Enables/disables logging of  serial device for debug purposes Usage&#58; setSerialLog <port> <0|1>
flashConfig   &#58; Flashes the NVRAM with the current configuration of the LoggerConfig Usage&#58; flashConfig
showTasks     &#58; Show status of running tasks Usage&#58; showTasks
version       &#58; Gets the version numbers Usage&#58; version
showStats     &#58; Info on system statistics. Usage&#58; showStats
sysReset      &#58; Reset the system Usage&#58; sysReset &#91;bootloader 0|1&#93;
lua           &#58; Enter the lua script interpreter. Usage&#58; lua
reloadScript  &#58; Reloads the current script. Usage&#58; reloadScript
RaceCapture/Pro MK3 > resetConfig

Flashing Default Logger Config&#58; PASS
Flashing Default Script&#58; FAILED       <<<<< UH OH?!?
Flashing Default Tracks&#58; PASS
I try this several times with the same result. And the lua script persists.

Now when I go in through the RCP App interface and delete the script, then do a resetConfig it works.

I guess my ultimate question is now that the interface supports CAN Mapping, is there any reason to be using the E46 Lua script on the wiki? Is the built-in CAN mapping feature going to be more stable than the lua script method?

[/code]

Posted: Tue Sep 05, 2017 4:54 pm
by brentp
Hi,

The built-in CAN mapping is designed to be the primary CAN mapping tool for RaceCapture/Pro /Apex - and the Lua scripting is still there to cover the unusual mapping scenarios that the direct CAN mapping cannot handle. A combination of both can be used.

Both approaches are described here: https://wiki.autosportlabs.com/CAN_Bus_Integration

The Lua scripting runtime is designed in such a way to prevent compromising system stability when it runs out of memory. Do you have an example of a script that reproduces this problem? We'd like to characterize the issue if possible.

Thanks!

Posted: Sat Aug 04, 2018 4:04 am
by wcorredor
Brent
I found the original post by eacmen.
This is exactly the same problem I have.
Once you hit the limit it becomes unstable and difficult to recover, even with small scripts you get the "lua: Failed to allocate memory for script buffer."

Posted: Sat Aug 04, 2018 4:37 am
by brentp
Right. This is a side effect of increasing the memory limit by 20% in the 2.13.0 firmware. This problem does not happen in the 2.12.x firmware.

We will work to make it easier to recover from this in an upcoming firmware. In the meantime, take extra care to not hit the memory limit.

Thanks,

Posted: Sat Aug 04, 2018 9:46 pm
by wcorredor
OK. I will be counting bytes next time.

In the meantime, can you tell me how to reset that memory?

I can't load even shorter scripts that worked before.

Posted: Sun Aug 05, 2018 6:21 pm
by brentp
Try temporarily downgrading to 2.12.0 firmware to see if you can reset the configuration.

Posted: Sun Aug 05, 2018 7:01 pm
by wcorredor
This is what I did and it worked:

saved configuration not to loose analog sensors.
Downgraded to 2.12.0
flashed an empty script
resetConfig (via Putty)

upgraded to 2.13.5
The scripts worked again.

Not sure which of the steps really erased the configuration, but it is working again.

Posted: Mon Aug 06, 2018 9:04 pm
by brentp
Thanks for the update. We'll work to get flashing of the default script working reliably with 2.13.6 or 2.14.0.

Posted: Sun Oct 21, 2018 7:14 pm
by wcorredor
Was this issue addressed in the new beta version?
Should I try the longer script or not yet?
I don't want to block it again, it is realy hard to recuperate.

Posted: Sun Oct 21, 2018 7:17 pm
by brentp
No, the beta version strictly has the long-promised feature of enabling pit-to car alerts. We'll address this in the production non-beta release.

Thanks!