+#if CONFIG_EEPROM_VERIFY
+/**
+ * Check that the contents of an EEPROM range
+ * match with a provided data buffer.
+ *
+ * \return true on success.
+ */
+static bool eeprom_verify(e2addr_t addr, const void *buf, size_t count)
+{
+ uint8_t verify_buf[16];
+ bool result = true;
+
+ while (count && result)
+ {
+ /* Split read in smaller pieces */
+ size_t size = MIN(count, sizeof verify_buf);
+
+ /* Read back buffer */
+ if (eeprom_read(addr, verify_buf, size))
+ {
+ if (memcmp(buf, verify_buf, size) != 0)
+ {
+ TRACEMSG("Data mismatch!");
+ result = false;
+ }
+ }
+ else
+ {
+ TRACEMSG("Read error!");
+ result = false;
+ }
+
+ /* Update count and addr for next operation */
+ count -= size;
+ addr += size;
+ buf = ((const char *)buf) + size;
+ }
+
+ return result;
+}
+#endif /* CONFIG_EEPROM_VERIFY */
+
+
+bool eeprom_write(e2addr_t addr, const void *buf, size_t count)
+{
+#if CONFIG_EEPROM_VERIFY
+ int retries = 5;
+
+ while (retries--)
+ if (eeprom_writeRaw(addr, buf, count)
+ && eeprom_verify(addr, buf, count))
+ return true;
+
+ return false;
+
+#else /* !CONFIG_EEPROM_VERIFY */
+ return eeprom_writeRaw(addr, buf, count);
+#endif /* !CONFIG_EEPROM_VERIFY */
+}
+
+
+/**