-
-
-
-
-
@tve, did you have the time to test changes around E.memoryArea for this build ?
-
Let me try to give a better explanation. Its more or less a proof of concept.
The idea behind is to use it like a "firmware-extension".
First of all, I made some changes to Espruino firmware:- new code for handling strings in flash http://forum.espruino.com/comments/12709163/
- added functions for a kind of housekeeping in a flash page.
- Start of page is 4 bytes for each string, first 2 bytes are relative start, next 2 bytes are length
- http://jumspruino.jumware.com/sources/flashMemory/jswrap_FlashExtension.h
- http://jumspruino.jumware.com/sources/flashMemory/jswrap_FlashExtension.c
Next created a nodejs application to build a page for flash.
My idea is to make this available some day.
Today my learning curve is still steeply rising, got my public virtual server some days ago ....
Could give access right now on a personal base only :-(
Writing this to flash is done with nodemcu firmware programmer.
Data is written to 0x71000 and/or 0x72000, since this is the first empty page I found.
Source for 1st test with function and object. Only removed module-relevant commands - SHA1 function http://jumspruino.jumware.com/sources/http/SHA1.js
- http-server object http://jumspruino.jumware.com/sources/http/EspSrv.js
- test itself http://jumspruino.jumware.com/sources/flashMemory/Test1.js
Source for 2nd test - SHA1 sourcecode http://jumspruino.jumware.com/sources/flashMemory/SHA1.js
- test itself http://jumspruino.jumware.com/sources/flashMemory/Test2.js
- new code for handling strings in flash http://forum.espruino.com/comments/12709163/
-
One more test.
This time the SHA1 was copied to flash without function body.
All variables have been set to undefined at the end of source.
2 more global variables are defined, one for input data, one for the result.- sent to board with minification free:1330
- checked memory some seconds later free:1347
- called test function free:1286, duration 500ms
- checked memory some seconds later free:1292
- called test function several times, no change in free memory
- sent to board with minification free:1330
-
I did some testing with new function to use strings in flash.
Testcase is a SHA1-function and an server-object in WebIDE.
For testing a simple function calls SHA1 and creates an object.- sent to the board with minification free:985
- checked memory some seconds later free:1168
- called testing function free:1101, duration 553ms
- checked memory some seconds later free:1133
Next testcase has SHA1-function and server-object in Flash.
Both, function and object are executed with eval from Flash.- sent to the board with minification free:1156
- checked memory some seconds later free:1174
- called testing function free:1113, duration 500ms
- checked memory some seconds later free:1144
Result from this test(IMHO) is:
- sending from WebIDE takes some memory which is free later.
- at the end memory consumption does not change much.
- source from Flash executes 10% faster, no idea why
- reading sources from flash can be helpful for state oriented apps, where functions/objects are not needed all the time. Not used functions could then be dropped and others could be reloaded. LUA on ESP8266 supports something like this.
- I would like to have this function, especially for ESP8266 where memory is a problem
- sent to the board with minification free:985
-
Based on a lot of copy/paste, trial and error, E.memoryArea works for strings.
function jsvStringIteratorGetChar in jsviterator.h is extend to handle native stringstatic ALWAYS_INLINE char jsvStringIteratorGetChar(JsvStringIterator *it) { if (!it->ptr) return 0; if (jsvIsNativeString(it->var)){ int addr = (int)it->ptr + (int)it->charIdx; uint32_t bytes = *(uint32_t*)(addr & ~3); return ((uint8_t*)&bytes)[(int)addr & 3]; } else return it->ptr[it->charIdx]; }
In next step function jslNextCh in jslex.c is extended too and first test calling a simple function works fine.
static ALWAYS_INLINE char jslNextCh(JsLex *lex) { if(jsvIsNativeString(lex->it.var)){ int addr = (int)lex->it.ptr + (int)lex->it.charIdx; uint32_t bytes = *(uint32_t*)(addr & ~3); return ((uint8_t*)&bytes)[(int)addr & 3]; } else return (char)(lex->it.ptr ? lex->it.ptr[lex->it.charIdx] : 0); }
Pretty sure there is a nicer way doing this, and we will see this in next version.
Anyway, it opened a new door of knowledge for me. -
-
peek32 works fine on flash
there only needs to be an address translation (0x71000 to 0x40271000)
peek16 and peek8 don't work and create an errorSorry my knowledge is too poor to make the changes by myself :-(
Learned a lot, but I'm still far away from changes like this.
See this, thats my level right now, somewhere around copy/paste from already existing sources. -
-
-
There have been some changes in ESP8266-port, to make it more general. This works for me:
wifi.getIP(function(data){console.log("IPInfo",data.ip);});
wifi.getStatus(function(data){console.log("ConnStatus",data);});
Actual docu is available on @tve : http://s3.voneicken.com/espruino/functions.html#t_Wifi
Since Gordon takes some days off, this will make its way to actual docu next year.
There is some more info in "Espruino on ESP8266"-board in this forum, including link to actual version. Seems to me your version is an older one (?)From my best knowledge, reset looks like a misaligned text(error message for unknown command in a class) in flash. In my actual version this does'nt come up anymore.
-
-
-
@tve, I would like to compile on my own VM.
There was something about using a different SDK, but I cannot find it anymore.
Are these commands still correct ?git clone hhttps://github.com/tve/Espruino.git curl -Ls http://s3.voneicken.com/xtensa-lx106-elf.tgx | tar Jxf - curl -Ls http://s3.voneicken.com/esp_iot_sdk_v1.5.0.tgx | tar Jxf - cd Espruino
-
Some days ago, I started to compile my own firmware with an extension to handle LEDMatrix(WS2812). Main focus was to add simple animation. This is an video, showing actual status (see animation at 3:40). video
In the video you will also see short description of available commands, and some Javascript functions that have been used for testing. -
-
To set a byte value in an Arraybuffer jsvArrayBufferIteratorSetByteValue(&it,value) is very helpful.
Is there an similar function to read a byte value using iterator ?
What I would like to do is something like this:jsvArrayBufferIteratorSetByteValue(&itDestination,jsvArrayBufferIteratorGetByteValue(&itSource))
-
@Gordon, could this be an option ?
ifdef USE_MYLIB WRAPPERSOURCES += $(wildcard myLibs/jswrap*.c) endif
-
-
@gordon, the copy example would copy mylib to folders, downloaded using git. Isn't there still a need to add mylib to make file ?
How would this help to share mylib ? Isn't it still on my computer only?
Creating a github for my mylibs could be done. So everybody could download, are you talking about that ? Is there a place where you would recommend to open a dictionary for tools like this ?Is Virtualbox a placeholder for any virtual tool ? There have been a lot of problems installing VirtualBox for me, and at the end I gave up. For example, it didn't let me install 64bit version. VMware is working fine for me, even the 64bit version, and installation ran fine the first time.
In my understanding up to some minutes ago, please correct me if I'm wrong
- crypto needs a lot of memory (ram and/or flash ?), and therefore it only fits to the pico. Since ESP8266 has more restrictions for memory, I didn't expect it to work.
- crypto has a lot of SHAnn-functions in and can only be used as it is. To switch off some functions could be helpful.
Right now, my computer is far away, therefore I cannot check immediately.
Recommendation to use #ifdef in crypto would be a change on a standard library supported by you. Therefore I wouldn't like do any changes there. Especially for a port, still under development, which may be supported or not (there was a discussion about that). Last not least, my knowledge is too poor to feel good for changes like this.
On the other hand, I fully agree to avoid reinvention of existing libs. Its always a bad decision, since both options could have their own pros and cons. - crypto needs a lot of memory (ram and/or flash ?), and therefore it only fits to the pico. Since ESP8266 has more restrictions for memory, I didn't expect it to work.
-
@alexanderbrevig, good point. I had in mind there was something like that, but couldn't find.
In my case I will use this for a very simple tool, to combine wifi and ws2812, I'm compiling for ESP8266.
Installation of toolchain on vmware was a kind of complex. Therefore my question:
could you please try to do ESP8266_BOARD=1 make ?
If this is running, at least some of my concerns are gone.
You could copy everything to an ubuntu-vm from @tve server:
git clone https://github.com/tve/Espruino.git
curl -Ls http://s3.voneicken.com/xtensa-lx106-elf.tgx | tar Jxf -
curl -Ls http://s3.voneicken.com/esp_iot_sdk_v1.5.0.tgx | tar Jxf -
next assign variables:
ESP8266SDK_ROOT needs to be set to esp_iot_sdk....
and xtensa-lx106.... is appended to path
last not least cd to Espruino folder and:
ESP8266_BOARD=1 make