From 6a272d83b1e50695f0aea0860ee811daf6cf4e10 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Wed, 19 Jun 2019 15:09:07 +0200 Subject: [PATCH] Add compile time check for EEPROM stored varibles size. --- Firmware/eeprom.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index 4d37b93a..f8f944c6 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -167,11 +167,15 @@ #define EEPROM_NOZZLE_DIAMETER (EEPROM_CHECK_MODE-1) // uint8 #define EEPROM_NOZZLE_DIAMETER_uM (EEPROM_NOZZLE_DIAMETER-2) // uint16 +//This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items. +#define EEPROM_LAST_ITEM EEPROM_NOZZLE_DIAMETER_uM + // !!!!! // !!!!! this is end of EEPROM section ... all updates MUST BE inserted before this mark !!!!! // !!!!! + // Currently running firmware, each digit stored as uint16_t. // The flavor differentiates a dev, alpha, beta, release candidate or a release version. #define EEPROM_FIRMWARE_VERSION_END (FW_PRUSA3D_MAGIC_LEN+8) @@ -184,7 +188,9 @@ #ifdef __cplusplus #include "ConfigurationStore.h" +static_assert(EEPROM_FIRMWARE_VERSION_END < 20, "Firmware version EEPROM address conflicts with EEPROM_M500_base"); static M500_conf * const EEPROM_M500_base = reinterpret_cast(20); //offset for storing settings using M500 +static_assert(((sizeof(M500_conf) + 20) < EEPROM_LAST_ITEM), "M500_conf address space conflicts with previous items."); #endif enum