code: function setStorageBufferFile(buffer, addr, filename, data) {
    if (!typeof data=="string") throw "Expecting string";
    if (addr&3) throw "Unaligned";
    var fileSize = data.length;
    var nextAddr = addr+16+((fileSize+3)&~3);
    if (nextAddr>buffer.length) throw "File too big for buffer";
    // https://github.com/espruino/Espruino/blob/master/src/jsflash.h#L30
    // 'size'
    buffer.set([fileSize&255, (fileSize>>8)&255,
                (fileSize>>16)&255, (fileSize>>24)&255], addr);
    // 'replacement' - none, since this is the only file
    buffer.set([0xFF,0xFF,0xFF,0xFF], addr+4);
    // 'filename', 8 bytes
    if (filename.length>8) throw "Filename "+JSON.stringify(filename)+" too big";
    buffer.set([0,0,0,0,0,0,0,0], addr+8);
    for (var i=0;i<filename.length;i++)
      buffer[addr+8+i] = filename.charCodeAt(i);
    // Write the data in
    for (var i=0;i<fileSize;i++)
      buffer[addr+16+i] = data.charCodeAt(i);
    // return next addr
    return nextAddr;
  }
docs: /* Write a file into a Uint8Array in the form that Espruino expects. Return the
  address of the next file.
  NOTE: On platforms with only a 64 bit write (STM32L4) this won't work