-
I was trying to build Espruino 2v08 for ESP32 with reduced libraries. I managed to remove all libraries from ESP32 in the
BOARD.py
file, but "NET" was the only one I could not remove. (the build failed after removing it)Here is my
info.build
fromboards/ESP32.py
:{ 'optimizeflags' : '-Og', 'libraries' : [ ], 'makefile' : [ 'DEFINES+=-DESP_PLATFORM -DESP32=1', 'DEFINES+=-DESP_STACK_SIZE=25000', 'DEFINES+=-DJSVAR_MALLOC', # Allocate space for variables at jsvInit time 'DEFINES+=-DUSE_FONT_6X8', 'ESP32_FLASH_MAX=1572864', 'USE_NETWORK_JS=0', ] }
Here is the error message from build:
targets/esp32/jshardware.c:48:34: fatal error: jswrap_esp32_network.h: No such file or directory compilation terminated. Makefile:777: recipe for target 'targets/esp32/jshardware.o' failed make: *** [targets/esp32/jshardware.o] Error 1 make: *** Waiting for unfinished jobs.... make: *** wait: No child processes. Stop.
I tried to remove the
#include <jswrap_esp32_network.h>
fromjshardware.c
but there are still other dependencies broken. Am I doing anything wrong?Any help will be appreciated.
-
Try to answer question 2:
Just realized2300
is actually the number of JsVars allocated for Espruino. The number is automatically calculated in targets/esp32/main.c based on the available heap - 40000 bytes (I guess it's for the Bluetooth stack?).
So the approaches to increase the number of JsVars (e.g. RAM for Espruino) could be:- remove unused libraries from build to save more heap space (remove that 40000 if Bluetooth stack is removed)
- decrease the ESP_STACK_SIZE to allocate less DRAM heap for Espruino task's stack
- remove unused libraries from build to save more heap space (remove that 40000 if Bluetooth stack is removed)
-
Try to answer question 1:
Since Espruino creates its task with xTAskCreatePinnedToCore() in task_init(), the available RAM size for Espruino depends on the available DRAM heap which is dynamically allocated from the data RAM (composed of DRAM and I/DRAM in several non-contiguous regions).The available heap for a FreeRTOS task is all of the data RAM which is not statically allocated. https://github.com/espressif/esp-idf/issues/2042#issuecomment-396101249
Since ESP32 has 328 KiB of data RAM, the theoretical maximum DRAM heap for Espruino is 328 KiB. But the stack size needs to be allocated from the heap. Other tasks also take up the data RAM.
In the end, the total available heap (data RAM) for Espruino may be less than 190 KiB if the Bluetooth stack is used. -
Answer to question 3:
Seems ESP_STACK_SIZE is used byxTAskCreatePinnedToCore()
in task_init() as an input argument. The function creates a FreeRTOS task to run Espruino, andESP_STACK_SIZE
defines the stack size for the task. -
-
Some questions regarding the RAM size and board definition file for Espruino on ESP32.
What is the theoretical maximum number of the available RAM for Espruino on ESP32? Since ESP32's RAM is not contiguous, is Espruino taking up only one of the chunks? Is that configurable somewhere?
How can I increase the current
2300
blocks of total available RAM?>process.memory() ={ free: 2259, usage: 41, total: 2300, history: 13, gc: 0, gctime: 2.346, blocksize: 16 }
(I tried with reducing
ESP_STACK_SIZE
from theboards/*.py
file and it worked.
I tried removingBLUETOOTH
but build failed with errors)What does
ESP_STACK_SIZE
mean inboards/ESP32.py
? Is that reserved for function calls in JS code? Is the stack here using the same RAM chunk as the runtime RAM?
-
Hi there, I have some questions regarding some partitions defined in partitions_espruino.csv.
I thought
storage
partition was used for the file system, but turns out the default address forE.flashFatFS()
is0x30000
instead of0x360000
. (Maybe because it's outdated?)
I also thoughtstorage
was the target of the upload destinationStorage
in the Web IDE, but turns out the target partitions forStorage
,Flash
, andFlash (always)
in the Web IDE are alljs_code
partition.Is there any difference between the
flash
andstorage
partitions?Any help will be appreciated :)
-
The VL Discovery has only 128k flash, and there is some space reserved for saving code, so the board can run code standalone.
Do you know where the space for saving code is reserved? Because I haven't found
'saved_code'
defined in the board definition file STM32VLDISCOVERY.py. -
-
I was browsing the 2v07 firmwares downloaded from https://www.espruino.com/Download, and found out that Espruino firmware on STM32 VL Discovery is only about
116.3 KB
while for other boards at least around220 KB
(even without hardware modules like WiFi, Bluetooth, etc.).
Is that because of the size of fundamental libraries used for supporting STM32 VL Discovery is much smaller?Best regards
-
On the Espruino ESP32 page , it says the
factory
partition is for the initial Espruino firmware.And on the FAQ page it says
Espruino uses between 100kb and 200kb of Flash,
But the
esptool.py
says it actually takes around 1.33 MB instead of 200 KB when I flash the firmware to ESP32.Wrote 1397712 bytes (903419 compressed) at 0x00010000 in 12.3 seconds (effective 907.6 kbit/s)...
My question is:
Does thefactory
partition also include ESP32 firmwares and other underlying drivers utilized by Espruino? If that's true, is it possible to get the exact flash space used by Espruino engine itself? -
-
-
-
Another example of fibonacci:
print(`Initial: ${JSON.stringify(process.memory())}`); function fibonacci(num) { print(`num ${num}: ${JSON.stringify(process.memory())}`); if (num <= 1) return 1; return fibonacci(num - 1) + fibonacci(num - 2); } print(`Before: ${JSON.stringify(process.memory())}`); fibonacci(5); print(`After: ${JSON.stringify(process.memory())}`);
Result:
Initial: {"free":2379,"usage":121,"total":2500,"history":0} Before: {"free":2373,"usage":127,"total":2500,"history":0} num 5: {"free":2366,"usage":134,"total":2500,"history":0} num 4: {"free":2360,"usage":140,"total":2500,"history":0} num 3: {"free":2354,"usage":146,"total":2500,"history":0} num 2: {"free":2348,"usage":152,"total":2500,"history":0} num 1: {"free":2342,"usage":158,"total":2500,"history":0} num 0: {"free":2341,"usage":159,"total":2500,"history":0} num 1: {"free":2347,"usage":153,"total":2500,"history":0} num 2: {"free":2353,"usage":147,"total":2500,"history":0} num 1: {"free":2347,"usage":153,"total":2500,"history":0} num 0: {"free":2346,"usage":154,"total":2500,"history":0} num 3: {"free":2359,"usage":141,"total":2500,"history":0} num 2: {"free":2353,"usage":147,"total":2500,"history":0} num 1: {"free":2347,"usage":153,"total":2500,"history":0} num 0: {"free":2346,"usage":154,"total":2500,"history":0} num 1: {"free":2352,"usage":148,"total":2500,"history":0} After: {"free":2373,"usage":127,"total":2500,"history":0}
It's fun to see how the RAM usage grows, but I don't find how I can get the peak RAM usage of the program without putting
process.memory()
on every step... -
Thanks a lot for your help! :)
I played withprocess.memory()
for a while on some toy code, but still no sure whatusage
andhistory
mean.
For example:const ramBefore = process.memory(); const helloWorld = `${JSON.stringify(process.memory())} Hello, world!`; const ramAfter = process.memory(); print(`RAM Before: ${JSON.stringify(ramBefore)}`); print(`RAM Middle: ${helloWorld}`); print(`RAM After: ${JSON.stringify(ramAfter)}`);
Result:
RAM Before: {"free":2383,"usage":117,"total":2500,"history":6,"gc":0,"gctime":3.47900390625,"blocksize":16,"stackEndAddress":536929592,"flash_start":0,"flash_binary_end":443732,"flash_code_start":446464,"flash_length":524288} RAM Middle: {"free":2336,"usage":164,"total":2500,"history":11,"gc":0,"gctime":3.57055664062,"blocksize":16,"stackEndAddress":536929592,"flash_start":0,"flash_binary_end":443732,"flash_code_start":446464,"flash_length":524288} Hello, world! RAM After: {"free":2330,"usage":170,"total":2500,"history":19,"gc":0,"gctime":3.57055664062,"blocksize":16,"stackEndAddress":536929592,"flash_start":0,"flash_binary_end":443732,"flash_code_start":446464,"flash_length":524288}
If I understand the document correctly, then
usage
is the number of currently used blocks of RAM, andhistory
is the number blocks used by all the the commands (JS statements) until inclusive the current statement, right? -
Hello there,
Does anyone know how I can get the heap or RAM usage of a program on Pixl?
I'm trying to find out how much RAM or heap can be saved from applying the Performance Notes. Also trying to see how much RAM is used by the Espruino engine itself and by my program.
Any help will be appreciated.
Understood. Thank you :)