Почему EEPROM "кривится"?

Как по мне - это аппаратное. Может есть третья ардуина/компьютер/кабель?

1 лайк

Сместил с 14-го на 78-й адрес всё свое хранимое. Взял mega2560 pro mini, т.е. обе Nano исключаются. USB-TTL в USB порт, т.е. кабель от Nano тоже исключается. Чудеса продолжаются. Завтра, Бог даст, у жены ноут абонирую.

Код чтения да, в самом начале. На usb-порту компьютера питание присутствует постоянно - 4.9, но есть. Конечно оно может плавать.

С паузой попробовал. При delay(2000) эффект положительный. Но мало проверял, может и взбрыкнёт.

Ради интереса “подкинул” посмотреть.
И с делеем и без всё вроде норм.
Это без паузы

Спойлер

Go… short
eeReadROM:
14 Marker 0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A

Go… short
eeReadROM:
14 Marker 0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A

Go… short
eeReadROM:
14 Marker 0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A

Go… short
eeReadROM:
14 Marker 0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A

Go… short
eeReadROM:
14 Marker 0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A

Go… short
eeReadROM:
14 Marker 0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A

Go… short
eeReadROM:
14 Marker 0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A

Go… short
eeReadROM:
14 Marker 0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A

Go… short
eeReadROM:
14 Marker 0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A

Go… short
eeReadROM:
14 Marker 0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A

Немного изменить пришлось, не знаю, может чего не понял
#2
стр. 9 if (eeReadDefMarker() != DEF_MARKER) {

P.S. Забыл сказать, может в этом дело - код немного подправил, Serial.printf не работал, прикрутил другой вариант

Спойлер

/*****************/
/*   eeProm_.h   */
/*****************/

#pragma once

//#include <Arduino.h>
#include <EEPROM.h>
#include "printf.h"

struct eeprom_t {
  uint8_t key[8];
  char note[8];
};

const uint8_t eeDefMarkerAddress = 14;                                        // defMarker == 0x1812
constexpr uint8_t eeFirstAddress = eeDefMarkerAddress + sizeof(uint16_t);     //
const uint8_t eeCountKeys = 4;                                                //
constexpr uint8_t eeSizeKey = sizeof(eeprom_t);                               //
constexpr uint8_t eeMaxAddress = (eeFirstAddress + eeSizeKey * eeCountKeys);  //
eeprom_t data_rom[eeCountKeys];
const uint16_t DEF_MARKER = 0x1812U;

const uint8_t keys_main[4][8] = {
  { 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x1A },
  { 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x2A },
  { 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x3A },
  { 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x4A }
};

const char* keys_name[eeCountKeys] = { "key_01_", "key_02_", "key_03_", "key_04_" };

//*********************//
void serial_eeprom_key(const uint8_t* key, bool lineFeed = true);
void serial_eeprom_item(uint8_t addr, const eeprom_t& ee_data_rom);
void serial_eeprom_item_hex(uint8_t addr, const eeprom_t& ee_data_rom);
void eeSerialAddr();
uint16_t eeReadDefMarker();
bool eeWriteDefMarker();
uint8_t eeCalcAddress(uint8_t idx);
void eeClearROM();
void eeReadROM();
void eeWriteROM();

//*********************//
//                     //
//*********************//
void serial_eeprom_key(const uint8_t* key, bool lineFeed) {
  for (uint8_t i = 0; i < 8; i++) {
    if (key[i] < 16) Serial.print(F("0"));
    Serial.print(key[i], HEX);
    if (i < 7) Serial.print(F(":"));
  }
  if (lineFeed) Serial.println();
}

//*********************//
void serial_eeprom_item(uint8_t addr, const eeprom_t& ee_data_rom) {
  Serial.print(addr);
  Serial.print(F(" "));
  for (uint8_t i = 0; i < 8; i++) printf("%c", ee_data_rom.note[i]);
  Serial.print(F(" "));
  serial_eeprom_key(ee_data_rom.key);
}

//*********************//
void serial_eeprom_item_hex(uint8_t addr, const eeprom_t& ee_data_rom) {
  printf("%2d ", addr);
  serial_eeprom_key((uint8_t*)ee_data_rom.note, false);
  Serial.print(F(" "));
  serial_eeprom_key(ee_data_rom.key);
}

//*********************//
uint16_t eeReadDefMarker() {
  uint16_t _1812;
  EEPROM.get(eeDefMarkerAddress, _1812);
  return _1812;
}

//*********************//
bool eeWriteDefMarker() {
  printf("write Marker:\n%2d 0x%04X\n", eeDefMarkerAddress, DEF_MARKER);
  EEPROM.put(eeDefMarkerAddress, DEF_MARKER);
  return eeReadDefMarker() == DEF_MARKER;
}

//*********************//
uint8_t eeCalcAddress(uint8_t idx) {
  return eeFirstAddress + (eeSizeKey * idx);
}

//*********************//
void eeClearROM() {
  const uint32_t zero = 0xFFFFFFFF;
  uint8_t idx = 0;
  Serial.println("eeClearROM:");
  for (uint8_t i = 0; i < eeMaxAddress; i += sizeof(zero)) {
    EEPROM.put(i, zero);
    if (idx++ == 0) printf("%2d", i);
    Serial.print(" 0x");
    Serial.print(zero, HEX);
    if (idx == 4) {
      idx = 0;
      Serial.println();
    }
  }
}

//*********************//
void eeReadROM() {
  uint8_t addr, i;
  Serial.println(F("eeReadROM:"));
  printf("%2d Marker  0x%04X\n", eeDefMarkerAddress, eeReadDefMarker());

  for (i = 0; i < eeCountKeys; i++) {  //  чтение в data_rom
    addr = eeCalcAddress(i);
    EEPROM.get(addr, data_rom[i]);
    serial_eeprom_item(addr, data_rom[i]);
  }

  eeprom_t _ee;
  for (i = 0; i < eeMaxAddress; i += eeSizeKey) {  //  чтение в _ee и вывод для перестраховки
    EEPROM.get(i, _ee);
    serial_eeprom_item_hex(i, _ee);
  }
}

//*********************//
void eeWriteROM() {
  uint8_t addr;
  eeprom_t ee;
  Serial.println(F("eeWriteROM:"));
  memset(ee.key, 0, 8);
  memset(ee.note, '\0', 8);
  for (uint8_t i = 0; i < eeCountKeys; i++) {
    addr = eeCalcAddress(i);
    memcpy(ee.key, keys_main[i], 8);
    memcpy(ee.note, keys_name[i], 7);
    EEPROM.put(addr, ee);
    serial_eeprom_item(addr, ee);
  }
}

//*********************//

printf.h

Спойлер
/*

  Using printf on the Arduino.
  by Michael McElligott
  
  Usage:
  Set a buffer size with _PRINTF_BUFFER_LENGTH_, default is 64 bytes, or about a single line
  Set output stream with _Stream_Obj_. eg; SerialUSB
  
  printf(format string, argument(s) list).
  printfn(): As above but appends a new line on each print; aka serial.println()
  
  eg; printf("%.2f, 0x%X", 1234.5678f, 32768);
  
  For a detailed list on printf specifiers:
  http://www.cplusplus.com/reference/cstdio/printf/
  and
  http://man7.org/linux/man-pages/man3/printf.3.html


    
  Tested with the Arduino Due 1.6.6
  Jan 2016  

*/





#ifndef _printf_h_
#define _printf_h_

#define _PRINTF_BUFFER_LENGTH_    64
#define _Stream_Obj_        Serial




#if 1
static char _pf_buffer_[_PRINTF_BUFFER_LENGTH_];
#else
extern char _pf_buffer_[_PRINTF_BUFFER_LENGTH_];
#endif


#define printf(a,...)                           \
  do{                                   \
  snprintf(_pf_buffer_, sizeof(_pf_buffer_), a, ##__VA_ARGS__);     \
  _Stream_Obj_.print(_pf_buffer_);                    \
  }while(0)

#define printfn(a,...)                            \
  do{                                   \
  snprintf(_pf_buffer_, sizeof(_pf_buffer_), a"\r\n", ##__VA_ARGS__);   \
  _Stream_Obj_.print(_pf_buffer_);                    \
  }while(0)



#endif

По следам Дим-мычъ. Создал каталог __Dim. В нем с __Dim.ino с кодом из выложенного мной выше Short.ino. Скопировал в этот каталог выложенный Дим-мычъ printf.h и выложенный мной eeProm.h. Свой используемый eeProm.h уже несколько модернизировал, так что… Для наглядности ещё поправил 6-ю строку: Serial.println(“\nGo… short Dim”);
Что ещё:
a) В 7-ю строку __Dim.ino добавил безусловный вызов eeClearROM().
b) Условие в 9-й строке изменил на if (eeReadDefMarker() == DEF_MARKER) {…}
Выявился некий алгоритм, это отправная точка. Далее компиляция и загрузка:

Спойлер

---- Открыт последовательный порт COM3 ----
Go… short Dim
eeClearROM:
0 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
16 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
32 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
48 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
64 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
eeReadROM:
14 Marker 0xFFFF
16 ÿÿÿÿÿÿÿÿ FF:FF:FF:FF:FF:FF:FF:FF
32 ÿÿÿÿÿÿÿÿ FF:FF:FF:FF:FF:FF:FF:FF
48 ÿÿÿÿÿÿÿÿ FF:FF:FF:FF:FF:FF:FF:FF
64 ÿÿÿÿÿÿÿÿ FF:FF:FF:FF:FF:FF:FF:FF
0 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
16 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
32 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
48 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
64 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
---- Закрыт последовательный порт COM3 ----

Всё верно. Затёрта часть eeprom. Условие в 9-й строке не выполняется, поэтому “очистки” и записи данных по условию нет. Только чтение.
В 7-й заремил вызов eeClearROM().
Компиляция и загрузка:

Спойлер

---- Открыт последовательный порт COM3 ----

Go… short Dim
eeReadROM:
14 Marker 0xFFFF
16 ÿÿÿÿÿÿÿÿ FF:FF:FF:FF:FF:FF:FF:FF
32 ÿÿÿÿÿÿÿÿ FF:FF:FF:FF:FF:FF:FF:FF
48 ÿÿÿÿÿÿÿÿ FF:FF:FF:FF:FF:FF:FF:FF
64 ÿÿÿÿÿÿÿÿ FF:FF:FF:FF:FF:FF:FF:FF
0 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
16 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
32 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
48 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
64 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
---- Закрыт последовательный порт COM3 ----

Всё верно. Условие в 9-й строке не выполняется, поэтому “очистки” и записи данных по условию нет. Только чтение.
Условие в 9-й строке изменил на if (eeReadDefMarker() != DEF_MARKER) {…}
Компиляция и загрузка:

Спойлер

---- Открыт последовательный порт COM3 ----

Go… short Dim
eeReadROM:
14 Marker 0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A
---- Закрыт последовательный порт COM3 ----

Вот так, без записи в eeprom из неоткуда прочитались данные.
Условие в 9-й строке изменил на if (eeReadDefMarker() == DEF_MARKER) {…}
Компиляция и загрузка:

Спойлер

---- Открыт последовательный порт COM3 ----

Go… short Dim
Erase…
eeClearROM:
0 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
16 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
32 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
48 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
64 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
write Marker:
14 0x1812
eeWriteROM:
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
eeReadROM:
14 Marker 0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A
---- Закрыт последовательный порт COM3 ----

И стирание, и запись, и по условию…
Именно такая последовательность. И что делать? Оптимизация какая что ли?
P.S.
видео результата на яндекс-диске
Прямая ссылка:

https://disk.yandex.ru/i/LZTnN2CaKH4eYA
Спойлер

//==============

  1. Только eeReadROM(), остальное закомментировал:

eeReadROM:
14 Marker 0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A

//================

  1. Полный скетч(#24), маркер в #define исправил на 0х1813
    В EEPROM ес-но не писал

    if (eeReadDefMarker() != DEF_MARKER) {
    Serial.println(F(“Erase…”));
    eeClearROM(); // “Erase…” не выполняется!)))

Go… short
eeReadROM:
14 Marker 0x1813
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
0 FF:FF:FF:FF:FF:FF:13:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A

Загадка на загадке. Интересно бы разобраться, жаль сейчас буду уже занят, разве совсем поздно время будет

Выложите последний вариант всех исходников, плиз

__Dim.ino
#include "eeProm_.h"

//*********************//
void setup() {
  Serial.begin(115200);
  Serial.println("\nGo... short Dim");
  eeClearROM();
  Serial.print("* * * if -> ");
  if (eeReadDefMarker() == DEF_MARKER) {
    Serial.println(F("Erase..."));
    eeClearROM();
    if (eeWriteDefMarker()) eeWriteROM();
    else {
      Serial.println(F("Error write <DefMarker>..."));
      while (1) {};
    }
  }
  eeReadROM();
}

//*********************//
void loop() {}

//*********************//
eeProm_.h
/*****************/
/*   eeProm_.h   */
/*****************/

#pragma once

#include <EEPROM.h>
#include "printf.h"

struct eeprom_t {
  uint8_t key[8];
  char note[8];
};

const uint8_t eeDefMarkerAddress = 14;                                        // defMarker == 0x1812
constexpr uint8_t eeFirstAddress = eeDefMarkerAddress + sizeof(uint16_t);     //
const uint8_t eeCountKeys = 4;                                                //
constexpr uint8_t eeSizeKey = sizeof(eeprom_t);                               //
constexpr uint8_t eeMaxAddress = (eeFirstAddress + eeSizeKey * eeCountKeys);  //
eeprom_t data_rom[eeCountKeys];
const uint16_t DEF_MARKER = 0x1812U;

const uint8_t keys_main[4][8] = {
  { 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x1A },
  { 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x2A },
  { 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00, 0x3A },
  { 0x04, 0x04, 0x04, 0x04, 0x04, 0x00, 0x00, 0x4A }
};

const char* keys_name[eeCountKeys] = { "key_01_", "key_02_", "key_03_", "key_04_" };

//*********************//
void serial_eeprom_key(const uint8_t* key, bool lineFeed = true);
void serial_eeprom_item(uint8_t addr, const eeprom_t& ee_data_rom);
void serial_eeprom_item_hex(uint8_t addr, const eeprom_t& ee_data_rom);
void eeSerialAddr();
uint16_t eeReadDefMarker();
bool eeWriteDefMarker();
uint8_t eeCalcAddress(uint8_t idx);
void eeClearROM();
void eeReadROM();
void eeWriteROM();

//*********************//
//                     //
//*********************//
void serial_eeprom_key(const uint8_t* key, bool lineFeed) {
  for (uint8_t i = 0; i < 8; i++) {
    if (key[i] < 16) Serial.print(F("0"));
    Serial.print(key[i], HEX);
    if (i < 7) Serial.print(F(":"));
  }
  if (lineFeed) Serial.println();
}

//*********************//
void serial_eeprom_item(uint8_t addr, const eeprom_t& ee_data_rom) {
  Serial.print(addr);
  Serial.print(F(" "));
  for (uint8_t i = 0; i < 8; i++) printf("%c", ee_data_rom.note[i]);
  Serial.print(F(" "));
  serial_eeprom_key(ee_data_rom.key);
}

//*********************//
void serial_eeprom_item_hex(uint8_t addr, const eeprom_t& ee_data_rom) {
  printf("%2d ", addr);
  serial_eeprom_key((uint8_t*)ee_data_rom.note, false);
  Serial.print(F(" "));
  serial_eeprom_key(ee_data_rom.key);
}

//*********************//
uint16_t eeReadDefMarker() {
  uint16_t _1812;
  EEPROM.get(eeDefMarkerAddress, _1812);
  printf("readDefMarker 0x%04X\n", _1812);
  return _1812;
}

//*********************//
bool eeWriteDefMarker() {
  printf("write Marker:\n%2d 0x%04X\n", eeDefMarkerAddress, DEF_MARKER);
  EEPROM.put(eeDefMarkerAddress, DEF_MARKER);
  return eeReadDefMarker() == DEF_MARKER;
}

//*********************//
uint8_t eeCalcAddress(uint8_t idx) {
  return eeFirstAddress + (eeSizeKey * idx);
}

//*********************//
void eeClearROM() {
  const uint32_t zero = 0xFFFFFFFF;
  uint8_t idx = 0;
  Serial.println("eeClearROM:");
  for (uint8_t i = 0; i < eeMaxAddress; i += sizeof(zero)) {
    EEPROM.put(i, zero);
    if (idx++ == 0) printf("%2d", i);
    Serial.print(" 0x");
    Serial.print(zero, HEX);
    if (idx == 4) {
      idx = 0;
      Serial.println();
    }
  }
}

//*********************//
void eeReadROM() {
  uint8_t addr, i;
  Serial.println(F("eeReadROM:"));
  printf("%2d Marker  0x%04X\n", eeDefMarkerAddress, eeReadDefMarker());

  for (i = 0; i < eeCountKeys; i++) {  //  чтение в data_rom
    addr = eeCalcAddress(i);
    EEPROM.get(addr, data_rom[i]);
    serial_eeprom_item(addr, data_rom[i]);
  }

  eeprom_t _ee;
  for (i = 0; i < eeMaxAddress; i += eeSizeKey) {  //  чтение в _ee и вывод для перестраховки
    EEPROM.get(i, _ee);
    serial_eeprom_item_hex(i, _ee);
  }
}

//*********************//
void eeWriteROM() {
  uint8_t addr;
  eeprom_t ee;
  Serial.println(F("eeWriteROM:"));
  memset(ee.key, 0, 8);
  memset(ee.note, '\0', 8);
  for (uint8_t i = 0; i < eeCountKeys; i++) {
    addr = eeCalcAddress(i);
    memcpy(ee.key, keys_main[i], 8);
    memcpy(ee.note, keys_name[i], 7);
    EEPROM.put(addr, ee);
    serial_eeprom_item(addr, ee);
  }
}

//*********************//
printf.h
/*

  Using printf on the Arduino.
  by Michael McElligott
  
  Usage:
  Set a buffer size with _PRINTF_BUFFER_LENGTH_, default is 64 bytes, or about a single line
  Set output stream with _Stream_Obj_. eg; SerialUSB
  
  printf(format string, argument(s) list).
  printfn(): As above but appends a new line on each print; aka serial.println()
  
  eg; printf("%.2f, 0x%X", 1234.5678f, 32768);
  
  For a detailed list on printf specifiers:
  http://www.cplusplus.com/reference/cstdio/printf/
  and
  http://man7.org/linux/man-pages/man3/printf.3.html


    
  Tested with the Arduino Due 1.6.6
  Jan 2016  

*/





#ifndef _printf_h_
#define _printf_h_

#define _PRINTF_BUFFER_LENGTH_ 64
#define _Stream_Obj_ Serial




#if 1
static char _pf_buffer_[_PRINTF_BUFFER_LENGTH_];
#else
extern char _pf_buffer_[_PRINTF_BUFFER_LENGTH_];
#endif


#define printf(a, ...) \
  do { \
    snprintf(_pf_buffer_, sizeof(_pf_buffer_), a, ##__VA_ARGS__); \
    _Stream_Obj_.print(_pf_buffer_); \
  } while (0)

#define printfn(a, ...) \
  do { \
    snprintf(_pf_buffer_, sizeof(_pf_buffer_), a "\r\n", ##__VA_ARGS__); \
    _Stream_Obj_.print(_pf_buffer_); \
  } while (0)



#endif

Спасибо
Можно в двух словах - в чем суть проблемы на данный момент?

При какой последовательности проявляется у меня:
1.строка #7 eeClearROM();
2.строка #9 if (eeReadDefMarker() == DEF_MARKER) {…}
3.компиляция и загрузка:

Спойлер
Go... short Dim
eeClearROM:
 0 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
16 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
32 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
48 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
64 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
if -> readDefMarker 0xFFFF
eeReadROM:
readDefMarker 0xFFFF
14 Marker  0xFFFF
16 �������� FF:FF:FF:FF:FF:FF:FF:FF
32 �������� FF:FF:FF:FF:FF:FF:FF:FF
48 �������� FF:FF:FF:FF:FF:FF:FF:FF
64 �������� FF:FF:FF:FF:FF:FF:FF:FF
 0 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
16 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
32 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
48 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
64 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF

1.строка #7 //eeClearROM();
2.строка #9 if (eeReadDefMarker() != DEF_MARKER) {…}
3.компиляция и загрузка:

Спойлер
Go... short Dim
if -> readDefMarker 0x1812
eeReadROM:
readDefMarker 0x1812
14 Marker  0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
 0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A

P.S.
Логи из IDE 2.3.2

При выполнении данного алгоритма, без записи в eeprom в нём появляется “правильное” содержимое.

if -> readDefMarker 0x1812

P.S.
Сегодня поставил Arduino IDE 2.3.2 на ноут жены. Результат идентичен.

На ИДЕ 1.х пробовали? Проблема подтверждается?

да. 1.8.19

Спойлер
Go... short Dim
eeClearROM:
 0 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
16 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
32 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
48 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
64 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
* * * if -> readDefMarker 0xFFFF
eeReadROM:
readDefMarker 0xFFFF
14 Marker  0xFFFF
16 ⸮⸮⸮⸮⸮⸮⸮⸮ FF:FF:FF:FF:FF:FF:FF:FF
32 ⸮⸮⸮⸮⸮⸮⸮⸮ FF:FF:FF:FF:FF:FF:FF:FF
48 ⸮⸮⸮⸮⸮⸮⸮⸮ FF:FF:FF:FF:FF:FF:FF:FF
64 ⸮⸮⸮⸮⸮⸮⸮⸮ FF:FF:FF:FF:FF:FF:FF:FF
 0 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
16 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
32 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
48 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
64 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
Спойлер
Go... short Dim
* * * if -> readDefMarker 0x1812
eeReadROM:
readDefMarker 0x1812
14 Marker  0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_⸮⸮⸮⸮ 03:03:03:03:03:00:00:3A
64 ⸮⸮⸮⸮⸮⸮⸮⸮ FF:FF:FF:FF:FF:FF:FF:FF
 0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:FF:FF:FF:FF 03:03:03:03:03:00:00:3A
64 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF

Представленный вывод не соответсвует коду, например в строке 8 должны быть звездочки перед “if - >”,

Serial.print("* * * if -> ");

а в вашей распечатке их нет:

это заставляет сомневатся во всем другом, что вы говорите…

Сайт от них (звёздочек) косит, при выкладке убрал.

что еще убрали?

Не пробовали выкладывать распечатку с тегами кода? - тогда все выложится именно так, как в тексте

Изначально выложил только под спойлер. Изображение скривило. Убрал звэздочки. Стало лучше. Потом переделал под код, а звёзды не вернул.

Тест 1
1.строка #7 eeClearROM();
2.строка #9 if (eeReadDefMarker() == DEF_MARKER) {…}
3.компиляция и загрузка:

Результат:

Go... short Dim

eeClearROM:

 0 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFF
Go... short Dim
eeClearROM:
 0 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
16 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
32 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
48 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
64 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
* * * if -> readDefMarker 0xFFFF
eeReadROM:
readDefMarker 0xFFFF
14 Marker  0xFFFF
16 ⸮⸮⸮⸮⸮⸮⸮⸮ FF:FF:FF:FF:FF:FF:FF:FF
32 ⸮⸮⸮⸮⸮⸮⸮⸮ FF:FF:FF:FF:FF:FF:FF:FF
48 ⸮⸮⸮⸮⸮⸮⸮⸮ FF:FF:FF:FF:FF:FF:FF:FF
64 ⸮⸮⸮⸮⸮⸮⸮⸮ FF:FF:FF:FF:FF:FF:FF:FF
 0 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
16 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
32 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
48 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF
64 FF:FF:FF:FF:FF:FF:FF:FF FF:FF:FF:FF:FF:FF:FF:FF

1.строка #7 //eeClearROM();
2.строка #9 if (eeReadDefMarker() != DEF_MARKER) {…}
3.компиляция и загрузка:
Результат

Go... short Dim
* * * if -> readDefMarker 0xFFFF
Erase...
eeClearROM:
 0 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
16 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
32 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
48 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
64 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF 0xFFFFFFFF
write Marker:
14 0x1812
readDefMarker 0x1812
eeWriteROM:
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
eeReadROM:
readDefMarker 0x1812
14 Marker  0x1812
16 key_01_ 01:01:01:01:01:00:00:1A
32 key_02_ 02:02:02:02:02:00:00:2A
48 key_03_ 03:03:03:03:03:00:00:3A
64 key_04_ 04:04:04:04:04:00:00:4A
 0 FF:FF:FF:FF:FF:FF:12:18 FF:FF:FF:FF:FF:FF:FF:FF
16 6B:65:79:5F:30:31:5F:00 01:01:01:01:01:00:00:1A
32 6B:65:79:5F:30:32:5F:00 02:02:02:02:02:00:00:2A
48 6B:65:79:5F:30:33:5F:00 03:03:03:03:03:00:00:3A
64 6B:65:79:5F:30:34:5F:00 04:04:04:04:04:00:00:4A

Поскольку маркер не равен заданному, условие строки 9 выполняется и ЕЕПРОМ записывается правильным контентом.

Не вижу никакой мистики, все строго по коду

Какая ОС - Linux или Windows?

Линукс, но дело не в этом.
Готов вам после 8 вечера продемонстрировать ровно такой же результат и на винде.