Writing to Espruino Flash without IDE

Posted on
  • I need to write code to Puck.Js and Bangle.Js flash memory with an Android app I'm writing.
    How does the IDE send data to the device? I get that it's minimising the code but after that I have no idea.

  • The IDE just connects using the 'Nordic UART' bluetooth characteristics that Espruino provides, and sends character data over the REPL (which is basically what you see on the left-hand side of the IDE).

    So if you want to write a program to flash, you need to generate the JavaScript to write that in, which might look like:

    require("Storage").write(".bootcde","pri­nt('hello world')");
    

    You need to put a newline after it (to cause it to be executed) and it helps to put char code 16 right before, and that tells Espruino not to 'echo' the line back to you, which can slow things down.

    Actually creating the code to do that can be a bit of a pain, so we have a tool (basically the Espruino IDE as a command-line app): https://www.npmjs.com/package/espruino

    Rather than connecting, it can spit out a file which is the commands which you should send in order to upload the code. See Not Connecting in https://www.npmjs.com/package/espruino

    The command can look a bit like:

    espruino --board PUCKJS --minify mycode.js -o output.js
    

    Some more info on doing the connection itself is at https://www.espruino.com/Interfacing#blu­etooth-le

  • Thank you, I'll look into that!

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

Writing to Espruino Flash without IDE

Posted by Avatar for user154225 @user154225

Actions