Description
Bangle.js 2 stores most of the program code in external flash and executes from there, doing relatively small (16 byte) reads. Right now, we actually use software-based SPI for flash memory as usually we need the data immediately, and with the overhead of setting up the nRF52's SPI flash via their HAL it's just faster to bit-bash 16 bytes.
Using the QSPI peripheral and memory-mapping is an option, but it makes power saving very difficult because we want to put the flash to sleep to save power, but it means that when we wake up in an interrupt it may be that some memory referenced from a pointer there is in ext flash and so inaccessible because the flash is powered down.
I just added some instrumentation to jsvStringIteratorLoadFlashString
to see if any caching would help and I guess unsurprisingly most of the time we're reading contiguous areas of memory. In that case it's possible that if we could use the SPI hardware and then do an SPI read of the next 16b in the background, while we're executing the current 16b, we could get much better performance.
... or maybe this isn't worthwhile and we should really be looking at using internal flash for the storage of JS, which appears to work ok apart from some issue with compaction. issue on it here