comaptibility numbers structure defined

master
Mateusz Lubecki 2023-07-04 20:38:35 +02:00
rodzic 3a6fd2ce87
commit 431d5a8d09
6 zmienionych plików z 85 dodań i 3 usunięć

Wyświetl plik

@ -459,4 +459,45 @@ typedef struct __attribute__((aligned (4))) config_data_gsm_t {
} config_data_gsm_t;
/**
* This structure holds compatibility numbers, which are used to check if
* configuration data stored in the NVM is compatible with running software.
* It is useful after firmware upgrade, which doesn't alter the configuration
* data. Each config block has a separate entry here (like basic, mode, RTU).
* During startup, if CRC verification is passed the software reads uint32_t
* word for each config block, and compare with internally hardcoded value
* If value in NVM is bigger than what application has, the app AND that
* with a bitmask (also hardcoded) to check if it can safely ignore that.
*
* If it cannot ignore, the configuration is too new and supposedly
* not compatible. The application should then either restore default values,
* or switch to different interpretation of that data - at least do something. 
*
* If the value from NVM is less than value from application (but not equal!!!)
* it is additionally ORed with another hardcoded bitmask. If a result of
* this OR is bigger than application
*
*
*/
typedef struct __attribute__((aligned (4))) config_data_compatibility_version_t {
uint64_t mode_block_compatiblity_number; // 8 bytes
uint64_t basic_block_compatiblity_number; // 8 bytes
uint64_t sources_block_compatiblity_number; // 8 bytes
uint64_t umb_block_compatiblity_number; // 8 bytes
uint64_t rtu_block_compatiblity_number; // 8 bytes
uint64_t gsm_block_compatiblity_number; // 8 bytes
uint64_t seventh_block_compatibility_number;
uint64_t eight_block_compatibility_number;
}config_data_compatibility_version_t;
#endif /* CONFIG_DATA_H_ */

Wyświetl plik

@ -266,6 +266,9 @@ SECTIONS
. = start + 0x160;
KEEP(*(.config_section_first.rtu));
. = start + 0x790;
KEEP(*(.config_section_first.compat));
. = 0x7F8;
KEEP(*(.config_section_first.crc));
@ -296,6 +299,9 @@ SECTIONS
. = start + 0x160;
KEEP(*(.config_section_second.rtu));
. = start + 0x790;
KEEP(*(.config_section_second.compat));
. = 0x7F8;
KEEP(*(.config_section_second.crc));

Wyświetl plik

@ -546,3 +546,13 @@ const config_data_gsm_t __attribute__((section(".config_section_default.gsm")))
#endif
const config_data_compatibility_version_t __attribute__((section(".config_section_default.compat"))) config_data_compatibility_default = {
.mode_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.basic_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.sources_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.umb_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.rtu_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.gsm_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.seventh_block_compatibility_number = 0xFFFFFFFFFFFFFFFFULL,
.eight_block_compatibility_number = 0xFFFFFFFFFFFFFFFFULL
};

Wyświetl plik

@ -525,4 +525,16 @@ const config_data_rtu_t __attribute__((section(".config_section_first.rtu"))) co
//};
//#endif
const config_data_compatibility_version_t __attribute__((section(".config_section_first.compat"))) config_data_compatibility_first = {
.mode_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.basic_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.sources_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.umb_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.rtu_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.gsm_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.seventh_block_compatibility_number = 0xFFFFFFFFFFFFFFFFULL,
.eight_block_compatibility_number = 0xFFFFFFFFFFFFFFFFULL
};
#endif

Wyświetl plik

@ -519,5 +519,17 @@ const config_data_rtu_t __attribute__((section(".config_section_second.rtu"))) c
#endif
const config_data_compatibility_version_t __attribute__((section(".config_section_second.compat"))) config_data_compatibility_second = {
.mode_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.basic_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.sources_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.umb_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.rtu_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.gsm_block_compatiblity_number = 0xFFFFFFFFFFFFFFFFULL,
.seventh_block_compatibility_number = 0xFFFFFFFFFFFFFFFFULL,
.eight_block_compatibility_number = 0xFFFFFFFFFFFFFFFFULL
};
#endif

Wyświetl plik

@ -42,11 +42,12 @@
#define CONFIG_MODE_PGM_CNTR 0x0
#define CONFIG_MODE_OFSET 0x20 // Current size: 0x14, free: 0x0C
#define CONFIG_BASIC_OFFSET 0x40 // Current size: 0xA6, free: 0x3A
#define CONFIG_BASIC_OFFSET 0x40 // Current size: 0xA8, free: 0x38
#define CONFIG_SOURCES_OFFSET 0x120 // Current size: 0x8, free: 0x18
#define CONFIG_UMB_OFFSET 0x140 // Current size: 0x10, free: 0x10
#define CONFIG_RTU_OFFSET 0x160 // Current size: 0x10, free: 0x90
#define CONFIG_GSM_OFFSET 0x200 // Current size: 0x114,
#define CONFIG_RTU_OFFSET 0x160 // Current size: 0x54, free: 0x4C
#define CONFIG_GSM_OFFSET 0x200 // Current size: 0x114,free:
#define CONFIG_COMPAT_OFFSET 0x790 // Current size: 0x40, free: 0x28
#define CONFIG__END__OFFSET 0x7E0
#include <string.h>