Losing BOOT var

After saving variable inside function all my saved functions and variables are lost.
Boot variable is empty.

= "..\\src_lua\\flash_read.lua:27: attempt to call a nil value"

The only way to use Lua again is to clear memory(AT+WOPEN=4) and to load Lua again.
Why it happened and how to fix it?

Best Regards
Doron Zamir

It happend again and this is what i get from shell after start lua.

+WIND: 13
[LUAW][MEM] reserving 101 KB for Lua mempools
[LUAW][MEM] Reserving 2600 bytes out of 104160 for 8-blocks pool
[LUAW][MEM] Reserving 5160 bytes out of 101560 for 16-blocks pool
[LUAW][MEM] Reserving 19320 bytes out of 96400 for 20-blocks pool
[LUAW][MEM] Reserving 23160 bytes out of 77080 for 24-blocks pool
[LUAW][MEM] Reserving 9000 bytes out of 53920 for 28-blocks pool
[LUAW][MEM] Reserving 20560 bytes out of 44920 for 32-blocks pool
[LUAW][MEM] Reserving 24360 bytes out of 24360 for 76-blocks pool
[LUAW][MEM] memory pools ready
[LUAW] load library base...uses 3246 bytes
[LUAW] load library table...uses 756 bytes
[LUAW] load library string...uses 1030 bytes
[LUAW] load library package...uses 1753 bytes
[LUAW] load library debug...uses 1396 bytes
[LUAW] load library strict...uses 2074 bytes
[LUAW] load library scheduling...uses 11945 bytes
[LUAW] load library timer...uses 569 bytes
[LUAW] load library options...uses 1376 bytes
[LUAW] load library channels...uses 13415 bytes
[LUAW] load library bearers...uses 5249 bytes
[LUAW] load library tcp...uses 4253 bytes
[LUAW] load library flash_read...uses 2486 bytes
[LUAW] load library flash_write...uses 6110 bytes
[LUAW] load library rawflash...uses 1273 bytes
[LUAW] load library shell...uses 13385 bytes
[LUAW] load library misc...uses 979 bytes
[LUAW] load library bootload...[LUAW][ERROR] *** ..\src_lua\flash_read.lua:26: Can't allocate buffer to retrieve from flash ***
uses 19774 bytes
[LUAW] load library ad...uses 2320 bytes
[LUAW] load library at...uses 9803 bytes
[LUAW] load library mem...uses 64 bytes
[LUAW] load library print...uses 3296 bytes
[LUAW] load library sms...uses 20 bytes
[LUAW] load library initcom...uses 44 bytes
[LUAW] load library pollereader...uses 20 bytes
[LUAW] RUN [thread 0x180edad0]
[LUAW] Starting telnet server
[WIP] new TCPSERVER 0x180ef3b0
[UART1]: startsrv: -> CONNECTING

One of the nice things of open source is, you can trace problems further in source code.

This error is raised in luaw_flash.c around line 46:

buffer = adl_memGet( size);
  if( ! buffer) luaL_error( L, "Can't allocate buffer to retrieve from flash");
  r = adl_flhRead( handle, i, size, buffer);

So adl can not supply you with enough memory to read from flash?

Maybe are you writting to much data to BOOT cell or are using it in inappropriate way, check your code. On the other side you can read that cell with adl, I think the used handle is ‘wiplua.boot’. Or maybe use TMT in RTE mode and read out contents to your PC.

BOOT works fine for me.

ljweko Thx for replay.
How can i know how mach memory i use or how mach still left for use?
It happend during loading software in the terminal.

First, I hope you are using G type (1MB+) of product, smaller ones are only good for some Mickey Mouse sort of programs and that may be source of your problem.

LuaW has mem() function, it gives you data about how much memory you use now and its peak use. There is also memdisp() function, which outpus to debug device, I think to be used to optimize pool memory.

this is my status:
$ =mem()
= {
USED_MEM_NOW = 123530,
USED_MEM_MAX = 144380,
HEAP_MEM_NOW = 87168,
POOL_MEM_MAX = 59640,
POOL_MEM_NOW = 51860,
HEAP_MEM_MAX = 113344,
LOST_MEM_NOW = 12765,
LOST_MEM_MAX = 13412 }
it look like that I using 95% of memory.
I have Wavecom fastrack supreme module.
with Ram size of 1024K
and Flash size of 4096K
Can i expend the size of the memory used by lua?
how can i delete from lua flash function and ver that saved.

Thanks :stuck_out_tongue:
that really makes me feel Great :smiley:
Writing Mickey Mouse programs :stuck_out_tongue:

No, you are using only a fraction of available memory.

As said, problem lies in size of your BOOT object, check it out. Also, there are some restrictions on use of flash objects, do check them in LuaW refman. There is also a description what can you do with them.