Skip to content

Instantly share code, notes, and snippets.

@orklann
Last active June 18, 2021 07:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orklann/be0a9309a0a743ef08d8accfa8eb79ba to your computer and use it in GitHub Desktop.
Save orklann/be0a9309a0a743ef08d8accfa8eb79ba to your computer and use it in GitHub Desktop.
Meowbit read and write Flash
from meowbit import screen
from meowbit import pyb
fl = pyb.Flash()
# Doc:
# 1. https://docs.micropython.org/en/latest/library/pyb.Flash.html#pyb-flash
# 2. https://docs.micropython.org/en/latest/reference/filesystem.html#stm32-pyboard
# 4000th blocks to read and write, as Meowbit has 2MB flash size,
# it has 1024 * 1024 * 2 / 512 = 4096 blocks
start = 4000
bufr = bytearray(512) # Every block size is 512
fl.readblocks(start, bufr)
s = "" + str(bufr[0])
screen.text(s)
buf = bytearray(512)
buf[0] = bufr[0] + 1
if buf[0] > 255:
buf[0] = 255
fl.writeblocks(start, buf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment