Issue persisting EEPROM on M404 and deviceOS@6.3.0

I am trying to write and read from EEPROM on a new M404 with deviceOS@6.3.0. Some code:


// Address to read and write to/from
static const int EEPROM_ADDR = 512;

// struct to save
struct FirmwareSettingsNew {
  uint8_t hasBeenConfigured;    // 1 byte
  uint8_t version;              // 1 byte

  Environment env;              // 1 byte
  SensorModel sensorModel;      // 1 byte
  WeatherStationModel wxModel;  // 1 byte 

  uint8_t board_version_major;  // 1 byte
  uint8_t board_version_minor;  // 1 byte
  uint8_t board_version_patch;  // 1 byte

  char serialNumber[20];        // 20 bytes
}; 

I do something like this:

EEPROM.get(EEPROM_ADDR, settings);

if (settings.hasBeenConfigured != 1) {
  // Initialize for the first time
  FirmwareSettingsNew newObj = {
      s_hasBeenConfigured,
      s_version,
      s_env,
      s_sensorModel,
      s_wxModel,
      p_board_version_major,
      p_board_version_minor,
      p_board_version_patch,
      "",
    };

  EEPROM.put(EEPROM_ADDR, newObj);
}

What's strange is that if I run the code and loop over it, it appears the EEPROM has been written correctly and will read correctly the second (and future) time around. However, if I reset the device, it defaults to values of settings.hasBeenConfigured=246 and settings.version=228.

The code is currently doing pretty much nothing else. What could be causing this? I've tried to see if it was a power issue, and it doesn't appear to be. I don't have my logic analyzer with me otherwise I would throw that on. Any hints on where to look or tests to run? I can post a full sketch if needed as well to run further tests.

That unexpected. EEPROM on Gen 3 and Gen 4 devices is just a file on the flash file system. In fact, you're typically better to just storing your settings in a file instead of using EEPROM. But, in any case:

If the EEPROM file was getting reinitialized, it should revert to 0xff bytes. Are you sure there isn't something else writing to that offset in EEPROM, possibly overflowing from something before offset 512?

It was indeed being overwritten. It looks like I still had the deviceKeyHelperEEPROM setup with defaults which appears to begin writing around 250 and runs through 540.