Can I add a js into firmware as a init.js?

Posted on
  • Can I add a js into firmware as a init.js?

    I mean that when I build a firmware, I can add a js file into the firmware, and when the Espruino starts,
    the js file can be auto loaded( I call it init.js :-) )

  • This is what save();

    On the right hand side of the ide, upload you code. Test it is working as intended.

    Then on the left hand side of the ide, type save()

    This code you had uploaded is then saved into flash memory. On restart, the code will be loaded and run.

  • Thanks!
    yes.
    But, when flash a new firmware, I have to upload/save the js file again.
    Can some js file be added AS A PART of the firmware , and can be flashed(not upload or save) to the ESPs, and be executed when the ESPs boot/reboot.
    When we change the js file, we make a new firmware that contains the js file, and then we flash or OTA the ESPs.

  • We can reference to the architecture of Mongoose OS's firmware and the conception of init.js.

  • Which board are you using?

    The code save area does not get overwritten when you flash the firmware, so the previous saved code would still be intact.

    Sorry, I'm not familiar with the Mongoose OS's init.js

  • It sounds like he's using ESP8266?

    You can use E.setBootCode to write raw JS into flash - if you are so inclined you could add something to your build process to write your code into flash automatically, but you'd have to look at jswrap_flash.c for the exact format needed.

    An easier way would be to add some C code yourself that calls jspEvaluate("your_code")

  • Thanks.

    I use ESP32 and ESP8266.

    That is a good idea about jswrap_flash.c, jspEvaluate("your_code").

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Can I add a js into firmware as a init.js?

Posted by Avatar for Aifer @Aifer

Actions