You are reading a single comment by @tve and its replies. Click here to read the full conversation.
  • I'm a bit confused about "executing out of flash memory" using E.memoryArea. Here's what I tried on an esp8266.

    First write a simple function to flash memory and check that it's there:

    >fl.erasePage(487424)
    =undefined
    >fl.write("function hello(t) { t1 = t.toUpperCase(); console.log('hello', t1); }   ", 487424)
    =undefined
    >fl.read(72, 487424)
    =new Uint8Array([102, 117, 110, 99, 116,  ... 32, 125, 32, 32, 32])
    

    Now eval it (I know I didn't need "ma"):

    >ma = eval(E.memoryArea(0x40200000+487424, 72));
    =function (t) { ... }
    >ma=null;
    =null
    

    Now see what's in memory:

    >trace()
    #1[r2,l1] Object {
      ... lots of stuff skipped ...
      #58[r1,l2] Name String [2 blocks] "hello"    #79[r1,l1] Function { return
          #81[r1,l2] Name Param "t"         undefined
          #80[r1,l2] Name String [1 blocks] "\xFFcod"        #138[r1,l1] String [5 blocks] "t1 = t.toUp
        }
    }
    

    Doesn't this mean that the function "hello" uses just as much memory as if it had been normally loaded, or is #138 really all in flash and doesn't use any jsVars?

    Is there a different trick that's eluding me here to get the code in "hello" to stay in flash? Or am I just confused?

About

Avatar for tve @tve started