You are reading a single comment by @fanoush and its replies. Click here to read the full conversation.
  • the code is loaded into RAM

    I hoped all the compiled code wasn't in RAM. Is this because it's in a string or does the chip not support XiP to run directly from flash?

  • I hoped all the compiled code wasn't in RAM. Is this because it's in a string or does the chip not support XiP to run directly from flash?

    It is meant for small time critical things, otherwise you are supposed to code mainly in JavaScript :-)
    It is linked so that data segment with writable variables is in same area together with code (for simplicity of loading). Also yes, Bangle2 SPI flash is not setup for XIP (hardware can do it). There is support for two flash storage areas, one being internal nrf52 flash which is executable, but it is currently not enabled (?), I have this enabled in some older builds for other devices and it works, if you would write the flat string there and don't use any global variable then it would probably work. Also another answer is that if you need lot of C code added you make your own build of Espruino with your own module compiled in.

    EDIT: you can try require("Flash").getFree() if it gives you something sensible on Bangle2, then you could write the code to free area of internal flash directly to test how/if it works

    EDIT2:
    require("Flash").getFree()
    =[
    { addr: 675840, length: 249856 }
    ]

    250KB is quite a lot, with some JS code that would manage loading code into that, it could be usable.

About

Avatar for fanoush @fanoush started