Add more info about flash memory to process.env/process.memory

This commit is contained in:
Gordon Williams 2020-02-12 14:46:55 +00:00
parent 7c52cbf949
commit 5d2a373673
4 changed files with 10 additions and 2 deletions

View File

@ -93,6 +93,7 @@
Remove broken Graphics.drawImage centerx/y (fix #1742)
Add Storage.writeJSON to avoid any confusion of writing arrays/numbers/etc
Bangle.js: Keep widget area free when using showPrompt/Alert/etc (fix #1756)
Add more info about flash memory to process.env/process.memory
2v04 : Allow \1..\9 escape codes in RegExp
ESP8266: reading storage is not working for boot from user2 (fix #1507)

View File

@ -132,7 +132,7 @@ devices = {
'pin_miso' : 'D20', # D1
'pin_wp' : 'D31', # D2
'pin_rst' : 'D17', # D3
'size' : 2097152
'size' : 4096*1024 # 4MB
}
};

View File

@ -454,6 +454,7 @@ if "PRESSURE" in board.devices:
if "SPIFLASH" in board.devices:
codeOut("#define SPIFLASH_BASE 0x40000000UL")
codeOut("#define SPIFLASH_PAGESIZE 4096")
codeOut("#define SPIFLASH_LENGTH "+str(board.devices["SPIFLASH"]["size"]))
codeOutDevicePins("SPIFLASH", "SPIFLASH")
for device in ["USB","SD","LCD","JTAG","ESP8266","IR"]:

View File

@ -109,6 +109,10 @@ JsVar *jswrap_process_env() {
#endif
jsvObjectSetChildAndUnLock(obj, "BOARD", jsvNewFromString(PC_BOARD_ID));
jsvObjectSetChildAndUnLock(obj, "FLASH", jsvNewFromInteger(FLASH_TOTAL));
#ifdef SPIFLASH_LENGTH
jsvObjectSetChildAndUnLock(obj, "SPIFLASH", jsvNewFromInteger(SPIFLASH_LENGTH));
#endif
jsvObjectSetChildAndUnLock(obj, "STORAGE", jsvNewFromInteger(FLASH_SAVED_CODE_LENGTH));
jsvObjectSetChildAndUnLock(obj, "RAM", jsvNewFromInteger(RAM_TOTAL));
jsvObjectSetChildAndUnLock(obj, "SERIAL", jswrap_interface_getSerial());
jsvObjectSetChildAndUnLock(obj, "CONSOLE", jsvNewFromString(jshGetDeviceString(jsiGetConsoleDevice())));
@ -136,13 +140,14 @@ Run a Garbage Collection pass, and return an object containing information on me
* `history` : Memory used for command history - that is freed if memory is low. Note that this is INCLUDED in the figure for 'free'
* `gc` : Memory freed during the GC pass
* `gctime` : Time taken for GC pass (in milliseconds)
* `blocksize` : Size of a block (variable) in bytes
* `stackEndAddress` : (on ARM) the address (that can be used with peek/poke/etc) of the END of the stack. The stack grows down, so unless you do a lot of recursion the bytes above this can be used.
* `flash_start` : (on ARM) the address of the start of flash memory (usually `0x8000000`)
* `flash_binary_end` : (on ARM) the address in flash memory of the end of Espruino's firmware.
* `flash_code_start` : (on ARM) the address in flash memory of pages that store any code that you save with `save()`.
* `flash_length` : (on ARM) the amount of flash memory this firmware was built for (in bytes). **Note:** Some STM32 chips actually have more memory than is advertised.
Memory units are specified in 'blocks', which are around 16 bytes each (depending on your device). See http://www.espruino.com/Performance for more information.
Memory units are specified in 'blocks', which are around 16 bytes each (depending on your device). The actual size is available in `blocksize`. See http://www.espruino.com/Performance for more information.
**Note:** To find free areas of flash memory, see `require('Flash').getFree()`
*/
@ -166,6 +171,7 @@ JsVar *jswrap_process_memory() {
jsvObjectSetChildAndUnLock(obj, "history", jsvNewFromInteger((JsVarInt)history));
jsvObjectSetChildAndUnLock(obj, "gc", jsvNewFromInteger((JsVarInt)gc));
jsvObjectSetChildAndUnLock(obj, "gctime", jsvNewFromFloat(jshGetMillisecondsFromTime(time2-time1)));
jsvObjectSetChildAndUnLock(obj, "blocksize", jsvNewFromInteger(sizeof(JsVar)));
#ifdef ARM
extern uint32_t LINKER_END_VAR; // end of ram used (variables) - should be 'void', but 'int' avoids warnings