Skip to content

Read, write and manage data in EEPROM, for Arduino AVR

License

Notifications You must be signed in to change notification settings

GitMoDu/EmbeddedStorage

Repository files navigation

EmbeddedStorage

Read, write and manage data in EEPROM, for Arduino AVR. Inspired by Arduino EEPROMWearLevel Library.

Features:

  • CRC validated data.
  • Templated StorageUnit (address and size).
  • Wear leveling options (thank you @PRosenb https://github.com/PRosenb/EEPROMWearLevel).
  • Optional run-time bounds check with EEPROM_BOUNDS_CHECK.
  • Support for ATTiny85.
  • Static compile-time var-arg allocator, for collection of units in one project.

Dependencies:

References

Special mention for Arduino EEPROMWearLevel Library flash twidling bits.

Library:

  • StorageUnit

    • Templated size and key.
    • Start address is passed on constructor.
    • CRC validated data.
    • CRC seed Key is optional and can be used for versioning. Defaults to Key = size.
    • 1 byte of EEPROM overhead.
  • WearLevelUnit

    • Same base features as StorageUnit.
    • Wear leveling options start at x2. For x1 use StorageUnit.
    • 1 byte of EEPROM overhead per level option, plus counter.
    • 1 to 8 bytes of counter EEPROM overhead.
    • Wear level units:
      • Tiny: from x2 to x9 levels of data. 1 byte of EEPROM overhead.
      • Short: from x10 to x17 levels of data. 2 bytes of EEPROM overhead.
      • Long: from x18 to x33 levels of data. 4 bytes of EEPROM overhead.
      • LongLong: from x34 to x65 levels of data. 8 bytes of EEPROM overhead.

Unit Testing Output

Embedded Storage Unit Test Start

Attribution (70 bytes)
	Inline Size Attribution
	Storage1 @ 0	(2 bytes)
	Storage2 @ 2	(16 bytes)
	Storage3 @ 18	(52 bytes)

	Constexpr Size Attribution
	Storage1 @ 0	(2 bytes)
	Storage2 @ 2	(16 bytes)
	Storage3 @ 18	(52 bytes)
	Validated.


Testing Storage Unit	0,2
	Validated.
Testing Wear Level Tiny2 Unit	2,16
	Erase 0b11111111
	Corrupt 0b00010000
	Initialized 0b00000000
	Reset 0b00000000
		0 0b11111111
		1 0b01111111
		2 0b00111111
		3 0b00011111
		4 0b00001111
	End 0b11111111
	Validated.
Testing Wear Level Short10 Unit	18,52
	Erase 0b1111111111111111
	Corrupt 0b1111111100010000
	Initialized 0b0000000000000000
	Reset 0b0000000000000000
		0 0b1111111111111111
		1 0b0111111111111111
		2 0b0011111111111111
		3 0b0001111111111111
		4 0b0000111111111111
		5 0b0000011111111111
		6 0b0000001111111111
		7 0b0000000111111111
		8 0b0000000011111111
		9 0b0000000001111111
	End 0b1111111111111111
	Validated.
Testing Wear Level Short17 Unit	0,36
	Erase 0b1111111111111111
	Corrupt 0b1111111100010000
	Initialized 0b0000000000000000
	Reset 0b0000000000000000
		0 0b1111111111111111
		1 0b0111111111111111
		2 0b0011111111111111
		3 0b0001111111111111
		4 0b0000111111111111
		5 0b0000011111111111
		6 0b0000001111111111
		7 0b0000000111111111
		8 0b0000000011111111
		9 0b0000000001111111
		10 0b0000000000111111
		11 0b0000000000011111
		12 0b0000000000001111
		13 0b0000000000000111
		14 0b0000000000000011
		15 0b0000000000000001
		16 0b0000000000000000
	End 0b1111111111111111
	Validated.
Testing Wear Level Long18 Unit	0,40
	Erase 0b11111111111111111111111111111111
	Corrupt 0b11111111111111111111111100010000
	Initialized 0b00000000000000000000000000000000
	Reset 0b00000000000000000000000000000000
		0 0b11111111111111111111111111111111
		1 0b01111111111111111111111111111111
		2 0b00111111111111111111111111111111
		3 0b00011111111111111111111111111111
		4 0b00001111111111111111111111111111
		5 0b00000111111111111111111111111111
		6 0b00000011111111111111111111111111
		7 0b00000001111111111111111111111111
		8 0b00000000111111111111111111111111
		9 0b00000000011111111111111111111111
		10 0b00000000001111111111111111111111
		11 0b00000000000111111111111111111111
		12 0b00000000000011111111111111111111
		13 0b00000000000001111111111111111111
		14 0b00000000000000111111111111111111
		15 0b00000000000000011111111111111111
		16 0b00000000000000001111111111111111
		17 0b00000000000000000111111111111111
	End 0b11111111111111111111111111111111
	Validated.
Testing Wear Level Long33 Unit	0,70
	Erase 0b11111111111111111111111111111111
	Corrupt 0b11111111111111111111111100010000
	Initialized 0b00000000000000000000000000000000
	Reset 0b00000000000000000000000000000000
		0 0b11111111111111111111111111111111
		1 0b01111111111111111111111111111111
		2 0b00111111111111111111111111111111
		3 0b00011111111111111111111111111111
		4 0b00001111111111111111111111111111
		5 0b00000111111111111111111111111111
		6 0b00000011111111111111111111111111
		7 0b00000001111111111111111111111111
		8 0b00000000111111111111111111111111
		9 0b00000000011111111111111111111111
		10 0b00000000001111111111111111111111
		11 0b00000000000111111111111111111111
		12 0b00000000000011111111111111111111
		13 0b00000000000001111111111111111111
		14 0b00000000000000111111111111111111
		15 0b00000000000000011111111111111111
		16 0b00000000000000001111111111111111
		17 0b00000000000000000111111111111111
		18 0b00000000000000000011111111111111
		19 0b00000000000000000001111111111111
		20 0b00000000000000000000111111111111
		21 0b00000000000000000000011111111111
		22 0b00000000000000000000001111111111
		23 0b00000000000000000000000111111111
		24 0b00000000000000000000000011111111
		25 0b00000000000000000000000001111111
		26 0b00000000000000000000000000111111
		27 0b00000000000000000000000000011111
		28 0b00000000000000000000000000001111
		29 0b00000000000000000000000000000111
		30 0b00000000000000000000000000000011
		31 0b00000000000000000000000000000001
		32 0b00000000000000000000000000000000
	End 0b11111111111111111111111111111111
	Validated.
Testing Wear Level LongLong34 Unit	0,76
	Erase 0b1111111111111111111111111111111111111111111111111111111111111111
	Corrupt 0b1111111111111111111111111111111111111111111111111111111100010000
	Initialized 0b0000000000000000000000000000000000000000000000000000000000000000
	Reset 0b0000000000000000000000000000000000000000000000000000000000000000
		0 0b1111111111111111111111111111111111111111111111111111111111111111
		1 0b0111111111111111111111111111111111111111111111111111111111111111
		2 0b0011111111111111111111111111111111111111111111111111111111111111
		3 0b0001111111111111111111111111111111111111111111111111111111111111
		4 0b0000111111111111111111111111111111111111111111111111111111111111
		5 0b0000011111111111111111111111111111111111111111111111111111111111
		6 0b0000001111111111111111111111111111111111111111111111111111111111
		7 0b0000000111111111111111111111111111111111111111111111111111111111
		8 0b0000000011111111111111111111111111111111111111111111111111111111
		9 0b0000000001111111111111111111111111111111111111111111111111111111
		10 0b0000000000111111111111111111111111111111111111111111111111111111
		11 0b0000000000011111111111111111111111111111111111111111111111111111
		12 0b0000000000001111111111111111111111111111111111111111111111111111
		13 0b0000000000000111111111111111111111111111111111111111111111111111
		14 0b0000000000000011111111111111111111111111111111111111111111111111
		15 0b0000000000000001111111111111111111111111111111111111111111111111
		16 0b0000000000000000111111111111111111111111111111111111111111111111
		17 0b0000000000000000011111111111111111111111111111111111111111111111
		18 0b0000000000000000001111111111111111111111111111111111111111111111
		19 0b0000000000000000000111111111111111111111111111111111111111111111
		20 0b0000000000000000000011111111111111111111111111111111111111111111
		21 0b0000000000000000000001111111111111111111111111111111111111111111
		22 0b0000000000000000000000111111111111111111111111111111111111111111
		23 0b0000000000000000000000011111111111111111111111111111111111111111
		24 0b0000000000000000000000001111111111111111111111111111111111111111
		25 0b0000000000000000000000000111111111111111111111111111111111111111
		26 0b0000000000000000000000000011111111111111111111111111111111111111
		27 0b0000000000000000000000000001111111111111111111111111111111111111
		28 0b0000000000000000000000000000111111111111111111111111111111111111
		29 0b0000000000000000000000000000011111111111111111111111111111111111
		30 0b0000000000000000000000000000001111111111111111111111111111111111
		31 0b0000000000000000000000000000000111111111111111111111111111111111
		32 0b0000000000000000000000000000000011111111111111111111111111111111
		33 0b0000000000000000000000000000000001111111111111111111111111111111
	End 0b1111111111111111111111111111111111111111111111111111111111111111
	Validated.
Testing Wear Level LongLong65 Unit	0,138
	Erase 0b1111111111111111111111111111111111111111111111111111111111111111
	Corrupt 0b1111111111111111111111111111111111111111111111111111111100010000
	Initialized 0b0000000000000000000000000000000000000000000000000000000000000000
	Reset 0b0000000000000000000000000000000000000000000000000000000000000000
		0 0b1111111111111111111111111111111111111111111111111111111111111111
		1 0b0111111111111111111111111111111111111111111111111111111111111111
		2 0b0011111111111111111111111111111111111111111111111111111111111111
		3 0b0001111111111111111111111111111111111111111111111111111111111111
		4 0b0000111111111111111111111111111111111111111111111111111111111111
		5 0b0000011111111111111111111111111111111111111111111111111111111111
		6 0b0000001111111111111111111111111111111111111111111111111111111111
		7 0b0000000111111111111111111111111111111111111111111111111111111111
		8 0b0000000011111111111111111111111111111111111111111111111111111111
		9 0b0000000001111111111111111111111111111111111111111111111111111111
		10 0b0000000000111111111111111111111111111111111111111111111111111111
		11 0b0000000000011111111111111111111111111111111111111111111111111111
		12 0b0000000000001111111111111111111111111111111111111111111111111111
		13 0b0000000000000111111111111111111111111111111111111111111111111111
		14 0b0000000000000011111111111111111111111111111111111111111111111111
		15 0b0000000000000001111111111111111111111111111111111111111111111111
		16 0b0000000000000000111111111111111111111111111111111111111111111111
		17 0b0000000000000000011111111111111111111111111111111111111111111111
		18 0b0000000000000000001111111111111111111111111111111111111111111111
		19 0b0000000000000000000111111111111111111111111111111111111111111111
		20 0b0000000000000000000011111111111111111111111111111111111111111111
		21 0b0000000000000000000001111111111111111111111111111111111111111111
		22 0b0000000000000000000000111111111111111111111111111111111111111111
		23 0b0000000000000000000000011111111111111111111111111111111111111111
		24 0b0000000000000000000000001111111111111111111111111111111111111111
		25 0b0000000000000000000000000111111111111111111111111111111111111111
		26 0b0000000000000000000000000011111111111111111111111111111111111111
		27 0b0000000000000000000000000001111111111111111111111111111111111111
		28 0b0000000000000000000000000000111111111111111111111111111111111111
		29 0b0000000000000000000000000000011111111111111111111111111111111111
		30 0b0000000000000000000000000000001111111111111111111111111111111111
		31 0b0000000000000000000000000000000111111111111111111111111111111111
		32 0b0000000000000000000000000000000011111111111111111111111111111111
		33 0b0000000000000000000000000000000001111111111111111111111111111111
		34 0b0000000000000000000000000000000000111111111111111111111111111111
		35 0b0000000000000000000000000000000000011111111111111111111111111111
		36 0b0000000000000000000000000000000000001111111111111111111111111111
		37 0b0000000000000000000000000000000000000111111111111111111111111111
		38 0b0000000000000000000000000000000000000011111111111111111111111111
		39 0b0000000000000000000000000000000000000001111111111111111111111111
		40 0b0000000000000000000000000000000000000000111111111111111111111111
		41 0b0000000000000000000000000000000000000000011111111111111111111111
		42 0b0000000000000000000000000000000000000000001111111111111111111111
		43 0b0000000000000000000000000000000000000000000111111111111111111111
		44 0b0000000000000000000000000000000000000000000011111111111111111111
		45 0b0000000000000000000000000000000000000000000001111111111111111111
		46 0b0000000000000000000000000000000000000000000000111111111111111111
		47 0b0000000000000000000000000000000000000000000000011111111111111111
		48 0b0000000000000000000000000000000000000000000000001111111111111111
		49 0b0000000000000000000000000000000000000000000000000111111111111111
		50 0b0000000000000000000000000000000000000000000000000011111111111111
		51 0b0000000000000000000000000000000000000000000000000001111111111111
		52 0b0000000000000000000000000000000000000000000000000000111111111111
		53 0b0000000000000000000000000000000000000000000000000000011111111111
		54 0b0000000000000000000000000000000000000000000000000000001111111111
		55 0b0000000000000000000000000000000000000000000000000000000111111111
		56 0b0000000000000000000000000000000000000000000000000000000011111111
		57 0b0000000000000000000000000000000000000000000000000000000001111111
		58 0b0000000000000000000000000000000000000000000000000000000000111111
		59 0b0000000000000000000000000000000000000000000000000000000000011111
		60 0b0000000000000000000000000000000000000000000000000000000000001111
		61 0b0000000000000000000000000000000000000000000000000000000000000111
		62 0b0000000000000000000000000000000000000000000000000000000000000011
		63 0b0000000000000000000000000000000000000000000000000000000000000001
		64 0b0000000000000000000000000000000000000000000000000000000000000000
	End 0b1111111111111111111111111111111111111111111111111111111111111111
	Validated.


All tests passed.



     :
 '.  _  .'
-=  (~)  =-
 .'  #  '.

About

Read, write and manage data in EEPROM, for Arduino AVR

Topics

Resources

License

Stars

Watchers

Forks