Writing a persistent byte or two

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
cefn
Posts: 230
Joined: Tue Aug 09, 2016 10:58 am

Writing a persistent byte or two

Post by cefn » Thu May 18, 2017 9:06 pm

Hi all,

Another newbie question about memory layout. I'm now trying to understand where I can get two bytes which can be written at runtime, and read at (the next) runtime, in order to be able to 'fork' a single firmware image which has frozen bytecode and no filesystem.

In particular we are using ESP8266 modules to host text adventures run across multiple boxes in different locations, with each story and each box needing slightly different behaviours. Ideally these would all run the same image, but be able to be 'specialised' through a simple interaction which causes the 'identification' bytes to be written. On boot, these identification bytes would cause the modules to run with different configurations.

When we need to repurpose a box, we can then easily do it. Currently, boxes all have to be flashed with slightly different hard-coded values in the frozen modules, which is a pain to maintain.

I'm expecting to use the esp functions flash_read(byte_offset, length_or_buffer) and flash_write(byte_offset, bytes), as documented at https://docs.micropython.org/en/latest/ ... y/esp.html to avoid having to bring up a whole filesystem just for two bytes.

However, the puzzle remains in what area should I try to write a couple of bytes like this (e.g. above or below what other segment whose address range I can identify, so the byte_offset numbers for the esp functions can be correctly chosen).

Thanks for your ideas!

Post Reply