Flash Usage on Raspberry Pi Pico

1,760 views
Skip to first unread message

Steven Su

unread,
Apr 24, 2021, 10:54:15 PM4/24/21
to thonny
Hello,

I read the documentation for the Raspberry Pi Pico and it appears that in the C/C++ SDK, there is an option to load programs to RAM to avoid writing to flash during development. (See question "Can I make my code run from RAM?" on the Pi Pico FAQ)

In Thonny, I noticed that programs can be saved to the Pi Pico flash storage, or to the local computer. Does saving the program to the local computer achieve a similar effect as running code from RAM? (in other words, can I reduce writes to the flash storage on the Pico by saving to local drive but still run the program on the Pico?)

Thank you very much.

Steven Su

unread,
Apr 24, 2021, 11:02:40 PM4/24/21
to thonny
Edit: I did some investigation myself and it seems like saving the program to local file does save writes on flash by loading the entire program into memory. I used the gc library to check free memory and artificially increased the program size with print statements. Memory available decreased as I made the program larger so it seems like the behavior is what I wanted.

Aivar Annamaa

unread,
Apr 25, 2021, 2:02:18 AM4/25/21
to thonny
Hi!

When you run a script in Thonny, be it on local disk or on Pico, Thonny makes soft reboot in raw mode (ie without running main.py) and sends editor content to MicroPython REPL. I believe soft reboot does read something from flash, but submitting code to the REPL shouldn't.

If you want more confidence or more details, then I recommend asking at MicroPython forum.

Best regards,
Aivar
Reply all
Reply to author
Forward
0 new messages