Flash with JS Code

Posted on
  • New to Espruino... I've searched extensively and apologize if this has been answered already.

    I'm using ESP8266 (NodeMCU). After flashing the firmware (v2.01_4MB) there is no access point established by default. Of course I can connect via serial and upload JS that way.

    However, I'm testing Espruino to be used with a device that I am unable to connect via serial however I am able to flash firmware using an OTA method (of course, once Espruino is flashed, that OTA method is no longer available). So I'd like to be able to flash the firmware PLUS an initial upload of JS code (similar to E.setBootCode() functionality). Can this be done?

    espruino cli tools allow me to minify JS to HEX code. And the non-combined download directory for 2.01 shows an esp_init_data_default.bin which makes me think this is possible. But I can't seem to connect the dots to turn the hex file into something that can be flashed.

    Can someone point me in the right direction?

  • Moved to ESP8266 forums - this is 100% ESP8266 related.

    The hex file does contain the data but potentially the address might be wrong because of the flash map... @MaBe?

    However the easy solution is just to take an ESP8266, flash it with Espruino plus the firmware you want, run it up in bootloader, and read out the contents of flash.

  • Thank you! Not sure how I missed the whole "Other Boards" category on first posting.

    Pulling the firmware from an already flashed ESP8266 could work. It just seems like this is something others would have already done already and that there was likely a better way. But I guess not.

    I'm a bit shocked, honestly, that no one else has wanted to Flash once for firmware and JS code, vs Flashing, then sending the JS code separately. Especially in the case of anyone who is using multiple devices with the same intent and attached sensors, etc.

    Hopefully @MaBe has another solution?

  • As a second best option, since the Espruino WiFi and, for instance, the Espruino Puck.js have very different capabilities, I assume that, by default, they start up differently on first boot. I also assume this means there are some compile options that change what goes in to the firmware. If I could simply get the flashed ESP8266 to do something like this on boot:

    require('Wifi').startAP('EspruinoAP', { password: '0123456789', authMode: 'wpa2' })

    And, assuming that would also start the Telnet listener, that would be good enough.

  • Hi @dlashua,

    Check this page, it is nice overview of what you get with Espruino on ESP8266's.

    there is no access point established by default.

    Have a look at this section and use wifi.save(); to store the connection information.
    The startup sequence will look for that stored information and tries to restore the wifi setup as stored (connect to AP, setup AP, or both).

    flash firmware using an OTA method

    Yes you can, it is implemented, check wiflash for details.
    There is just one issue to fix, see #1507.

    Can someone point me in the right direction?

    What about get everything in place on the device and than use esptool.py to create your own v2.01_4MB file for further flash activities. Run esptool.py read_flash --help for details.

  • Just to add...

    sending the JS code separately

    This has been done a few times, but usually people don't use OTA and upload the new code using JS itself - which makes this whole process way easier.

    Offline-wise there is the hex file output as you noted, but obviously most of the work that I do tends to be around the boards that make me money. If someone has used the hex file output on ESP8266 (which seems likely) then I don't believe they have shared how they did it.

  • OOOH! The code of wiflash is interesting indeed, but, alas doesn't help me.

    Once I flash Espruino to this device, it will not create an access point until I connect to it via serial and enable Wifi, and since I can't connect to it via serial, it will, at that point, essentially be a brick.

    read_flash, as @Gordon suggested as well, could possibly work. At the very least I could create a firmware that would at least enable AP and flash that. Then I could use the JS console from there to do anything else I needed. It's not ideal. But.. it's better than nothing.

  • obviously most of the work that I do tends to be around the boards that make me money

    I'd love to be able to use one of your boards for this project. Hell, I'd even be happy if I could use a regular old NodeMCU or something for this project. But, it's all centered around the "reuse" of existing, but not very accessible, hardware.

  • Once I flash Espruino to this device, it will not create an access point until I connect to it via serial and enable Wifi, and since I can't connect to it via serial, it will, at that point, essentially be a brick.

    If I take a new device and flash the 4MB bin file the esp8266 starts with the default access point.

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

Flash with JS Code

Posted by Avatar for dlashua @dlashua

Actions