You are reading a single comment by @fanoush and its replies. Click here to read the full conversation.
  • Just retested experiments with native strings and it works as expected now.

    var s;
    var s2;
    var s3="native string";
    var s4;
    function test(){
    s=atob("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA­AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
      s2="Hello";
      s4="This is a longer string";
    }
    test()
    

    after uploading this file to storage and running it s,s3,s4 are native strings pointing to internal flash. s2 is not as it is too short.

    However Inline C code upload does not work, the atob call there is not parsed properly, even this line does not work

    bin=atob("gAAH7pAK3+0barju53r47gB6sO5nWo­kAp+4mWgAgB+4QGrjux3rx7gBK5+4mep/tEnqw7m­dq8O5Hemfup2pn7gdaNu6lSrTuZErx7hD6D9UfKA­3cd+6nerDuRkqn7odKATB27uV6sO5EenfuhXrk53­BHAL8AAIA8AAAAAAAjELUcRgAiEEYZRv/3uv8BMk­AqBET30QEzQCvz0SBGEL0AAA==");
    

    I get

    Uncaught SyntaxError: Got [ERASED] expected EOF
     at line 7 col 21 in test.js
    @*D ?[247]"@+\xF3\xD1 F\x10\xBD\0\0;" [ERASED]
                                      ^
    

    I tried to reload https://www.espruino.com/ide/ but it does not help.

    Another thing is that even if it worked the native string in flash produced by atob is not aligned so even if the code had no global variables it is still not executable as is. E.toFlatString() helps with that and moves code to RAM like it was before.

    Too bad there is probably no easy way to align the native string in flash as quite a lot of inline C code don't use global variables so could in theory run directly from internal flash (when it is nrf52 internal flash, not SPI flash).

About

Avatar for fanoush @fanoush started