• Hi,

    I just did a new build, with a more universal API for accessing flash memory, which will work on both the Original board and the Pico. It's here and will be in 1v80 when it's released.

    Rough outline:

    >var f = require("Flash");
    >var freeFlash = process.memory().flash_code_start;
    >f.getPage(freeFlash)
    ={ "addr": 134234112, "length": 16384 }
    >f.read(12, freeFlash)
    =new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255])
    >f.write("Hello World!", 134234112)
    =undefined
    >f.read(12, freeFlash)
    =new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])
    >f.erasePage(freeFlash)
    =undefined
    >f.read(12, freeFlash)
    =new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255])
    

    It'll all go in the reference when the full release is made.

    Be careful, because you can easily blow away your bootloader with it if you're not careful!

    And the surprise is...

    >var freeFlash = process.memory().flash_start + 511*1024;
    =134740992
    >f.read(12, freeFlash)
    =new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255])
    >f.write("Hello World!", freeFlash)
    =undefined
    >f.read(12, freeFlash)
    =new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33])
    

    So there's a whole extra page of flash memory, 128kB long at address 0x8060000 that we shouldn't have. Much like on the original boards, the chip is a STM32F401CE even though it's marked as a STM32F401CD.

    While there's no guarantee that newer boards will be like this, I reckon all the current ones are!

    ... also this firmware has some new changes that use simple RLE compression when saving program code to flash. It means I've been able to raise the amount of variables from 3000 up to 5100. While you won't be able to save a program that uses all of them, realistically you need a few free variables to run your program, and those will compress down.

About

Avatar for Gordon @Gordon started