diff --git a/apps/boot/ChangeLog b/apps/boot/ChangeLog index e3f492d3b..a43ecf86e 100644 --- a/apps/boot/ChangeLog +++ b/apps/boot/ChangeLog @@ -51,3 +51,4 @@ 0.45: Fix 0.44 regression (auto-add semi-colon between each boot code chunk) 0.46: Fix no clock found error on Bangle.js 2 0.47: Add polyfill for setUI with an object as an argument (fix regression for 2v12 devices after Layout module changed) +0.48: Workaround for BTHRM issues on Bangle.js 1 (write .boot files in chunks) diff --git a/apps/boot/bootupdate.js b/apps/boot/bootupdate.js index 119cd2c2c..4cb3c52e4 100644 --- a/apps/boot/bootupdate.js +++ b/apps/boot/bootupdate.js @@ -197,8 +197,18 @@ bootFiles.forEach(bootFile=>{ require('Storage').write('.boot0',"//"+bootFile+"\n",fileOffset); fileOffset+=2+bootFile.length+1; var bf = require('Storage').read(bootFile); - require('Storage').write('.boot0',bf,fileOffset); - fileOffset+=bf.length; + // we can't just write 'bf' in one go because at least in 2v13 and earlier + // Espruino wants to read the whole file into RAM first, and on Bangle.js 1 + // it can be too big (especially BTHRM). + var bflen = bf.length; + var bfoffset = 0; + while (bflen) { + var bfchunk = Math.min(bflen, 2048); + require('Storage').write('.boot0',bf.substr(bfoffset, bfchunk),fileOffset); + fileOffset+=bfchunk; + bfoffset+=bfchunk; + bflen-=bfchunk; + } require('Storage').write('.boot0',";\n",fileOffset); fileOffset+=2; }); diff --git a/apps/boot/metadata.json b/apps/boot/metadata.json index d1bf2edde..62adc4db1 100644 --- a/apps/boot/metadata.json +++ b/apps/boot/metadata.json @@ -1,7 +1,7 @@ { "id": "boot", "name": "Bootloader", - "version": "0.47", + "version": "0.48", "description": "This is needed by Bangle.js to automatically load the clock, menu, widgets and settings", "icon": "bootloader.png", "type": "bootloader",