Skip to content

Hw Mayfly config EEPROM

neilh edited this page Jul 13, 2021 · 8 revisions

The Mayfly mega1284 has internal EEPROM onboard that can be configured to hold board specific data.
I've divided this into two sections

  1. Mayfly board specific configuration - [BOOT] serial number, hardware revision
  2. Mayfly Application specific configuration. All other Application configuration

To program a specific Mayfly board EEPROM it uses a simple ms_cfg.ini for board specific configuration.

uSD ms_cfg.ini has section
[BOOT]
; For configuring a Mayfly board with unique info ]
BOARD_NAME=mayfly
BOARD_SN=MAYFLY180347
BOARD_REV=0.5bR04
EEPROM_WRITE=DEFAULT_APP_EEPROM ; Initialize the non-boot data then write,
EEPROM_WRITE=YES ;Last operation in [BOOT] section

Internally, on boot, the application's configuration is read from EEPROM, and then it reads the uSD ms_cfg.ini.
The code for managing this is in
github.com/neilh10/ModularSensors/blob/release1/src/iniHandler.h .
See github.com/neilh10/ModularSensors/blob/release1/examples/tu_xx01/src/tu_xx01.cpp for how it is called.

On configuring the .csv file, the board information is written out
Board: mayfly rev:'0.5bR04' sn:'MAYFLY180347'

github.com/neilh10/ModularSensors/blob/release1/src/LoggerBaseExtCpp.h : void Logger::printFileHeaderExtra(Stream* stream)
stream->print(F("Board: "));

The App section is more complex, but follow the same principles. These are [COMMON] [NETWORK] [PROVIDER_MMW] [USER]
See examples in
github.com/neilh10/ModularSensors/tree/release1/examples/tu_xx01/src/ini_opts .

https://github.com/neilh10/ModularSensors/releases/tag/v0.28.5.release1_210711 new features
On boot a uSD file hierarchy is parsed 1)ms_cfg.ini0 2) ms_cfg.ini1 and 3) then ms_cfg.ini If exist ms_cfg.ini0 it is parsed and then renamed to ms_cfg.ini0run If exist ms_cfg.ini1 it is parsed, rename to ms_cfg.ini1run and the system rebooted If exist ms_cfg.ini it is parsed and then the system is started.

Typically ms_cfg.ini0 provides board level EEPROM initialization. To initialize just the App section of the eeprom
[COMMON]
GEOGRAPHICAL_ID="Information - Initializing APP section"
[BOOT]
EEPROM_WRITE=DEFAULT_APP_EEPROM ; Initialize the non-boot data then write,

Typically ms_cfg.ini1 provides App level initilization, that can be written to EEPROM, renames ms_cfg.ini1 so won't execute again, and then reboots. This has the working sections [COMMON] [NETWORK] [PROVIDER_MMW] [USER]
followed by doing the actual write
[USER]
ACTION=WRITE ; Last line writing App configuration to EEPROM.