Extra Ram/Flash

Posted on
  • Can I add extra ram or external flash? Can I use external flash as ram?

  • There's 4MB of external flash on Bangle.js already, and while it can't be used 'as RAM' you can effectively memory-map it so that JS code in the interpreter can read from it as if it was in RAM.

    If you wanted to unsolder the flash chip and solder a bigger one on then you could do that and recompile the firmware to take advantage of it though.

  • How would I memory map it?

  • SPI flash is maped to adresses above 0x60000000 so e.g. require("Flash").read/write work with that. But what Gordon meant is that pieces of javascript that you are executing from flash are not loaded to ram as a whole so e.g. if you have javascript function with 128kb long code it is executed directly from SPI flash even including strings - so something like var s ="....60kb string of data ..." points directly to SPI flash without need of loading whole string to ram when evaluating it.
    Also Storage.write and Storage.read would work like that - giving you pointers backed directly by SPI flash.

  • I want to use flash memory as ram, how would I do that? In simple terms, please

  • Oh, well, in simple terms you can't because flash is not ram :-)

    Maybe you can explain what you mean by 'use as ram'? Or provide example of your 'use as ram' code?

  • I want to "memory-map it so that JS code in the interpreter can read from it as if it was in RAM.", like gordon said was possible.

  • It already does. Any javascript code executed from flash works like that (as I previosly tried to explain more in detail). You don't need to do anything special. You just need to be aware of it and use it for your advantage as much as possible. As an example - you can have variable initialized with very long string stored in flash just by writing code var s="verylongstring" when this code is stored in flash, but once you try to join it with just one additional character s=s+"x" it all moves to ram and you may run out of it.

  • @LeebWeeb

    What's discussed so far is static stuff that happens once on upload...

    Espruino can though also use unused space in the flash for non-volatile storage, populated with write and then read back with read. Works perfect when way more read than writes... but I would not exactly call this as RAM, even though rewriteable at runtime.

    Rewrite has its issues. Inherent to the technology used, a rewrite can only happen after an erase, and the number of erase and rewrite cycles are limited. Espruino components to write to and read from "Storage" - as it is called - makes it very acceptable and super easy to use: it takes care of the erase as well as applies wear leveling to get maximum life time out of flash uses as r/w Storage.

    Checkout out require("Storage").xyz()` - the Storage 'class' at https://www.espruino.com/Reference#Stora­ge ( and as well https://www.espruino.com/Reference#Stora­geFile )...

    I hope this helps you to conceive the app you have in mind to fit...

  • Thanks. I have a watch face that uses a lot of RAM, and can lag out the watch. I am trying to work on this to fix it, and wanted to use flash memory as RAM for that purpose. Otherwise, I have to optimize the code from the ground up

  • Can I display a bitmap on top of another bitmap?

  • Sat 2021.03.20

    'Can I display a bitmap on top of another bitmap?'

    Is the intent to merge the two bitmaps into one that is rendered, or render one bitmap, then alternate between the second and the first?

  • i heard that loading bitmaps takes less ram then drawing new images to the screen. so, I want it to draw a clock face. For whatever minute, second or hour it is, it puts that image onto the screen as well. So merge multiple

  • This starts at post #19 and is likely what you are after

    full-screen background image

    also take a peek at post #29 (there) with link to full source

    Still searching for a thread that I believe @allObjects solved this many months ago

  • As @Robin says, what you're after is g.drawImages - it allows you to draw multiple images at once, so you can for instance overlay a clock face on another image, and any or all of those images can be in Flash.

  • yes! Thanks!

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

Extra Ram/Flash

Posted by Avatar for LeebWeeb @LeebWeeb