diff --git a/doc/eclipse_debugger_launch/ParaMETEO-STM32L476RG.launch b/doc/eclipse_debugger_launch/ParaMETEO-STM32L476RG.launch index 57fdb44..f041257 100644 --- a/doc/eclipse_debugger_launch/ParaMETEO-STM32L476RG.launch +++ b/doc/eclipse_debugger_launch/ParaMETEO-STM32L476RG.launch @@ -1,6 +1,6 @@ - + diff --git a/ldscripts/stm32l476/STM32L471RETx_FLASH.ld b/ldscripts/stm32l476/STM32L471RETx_FLASH.ld index e605bad..ee4ce0f 100644 --- a/ldscripts/stm32l476/STM32L471RETx_FLASH.ld +++ b/ldscripts/stm32l476/STM32L471RETx_FLASH.ld @@ -117,102 +117,6 @@ SECTIONS . = ALIGN(8); } >FLASH - __config_section_default_start = 0x0801E000; /* Page 120 and 121 */ - __config_section_first_start = 0x0801E800; /* Page 122 and 123 */ - __config_section_second_start = 0x0801F000; /* Page 124 and 125 */ - __config_section_third_start = 0x0801F800; /* Page 126 and 127 */ - - .config_section_default __config_section_default_start : - { - FILL(0xDD) - - . = ALIGN(8); - - start = .; - - KEEP(*(.config_section_default)); - - . = start + 0x10; - KEEP(*(.config_section_default.mode)); - - . = start + 0x20; - KEEP(*(.config_section_default.basic)); - - . = start + 0x100; - KEEP(*(.config_section_default.sources)); - - . = start + 0x120; - KEEP(*(.config_section_default.umb)); - - . = start + 0x140; - KEEP(*(.config_section_default.rtu)); - } >FLASH - - .config_section_first __config_section_first_start : - { - FILL(0xAA) - - . = ALIGN(8); - - start = .; - - KEEP(*(.config_section_first)); - - . = start + 0x10; - KEEP(*(.config_section_first.mode)); - - . = start + 0x20; - KEEP(*(.config_section_first.basic)); - - . = start + 0x100; - KEEP(*(.config_section_first.sources)); - - . = start + 0x120; - KEEP(*(.config_section_first.umb)); - - . = start + 0x140; - KEEP(*(.config_section_first.rtu)); - - . = 0x7FC; - KEEP(*(.config_section_first.crc)); - - } >FLASH - - .config_section_second __config_section_second_start : - { - FILL(0xBB) - - . = ALIGN(8); - - start = .; - - KEEP(*(.config_section_second)); - - . = start + 0x10; - KEEP(*(.config_section_second.mode)); - - . = start + 0x20; - KEEP(*(.config_section_second.basic)); - - . = start + 0x100; - KEEP(*(.config_section_second.sources)); - - . = start + 0x120; - KEEP(*(.config_section_second.umb)); - - . = start + 0x140; - KEEP(*(.config_section_second.rtu)); - - . = 0x7FC; - KEEP(*(.config_section_second.crc)); - - } >FLASH - - .config_section_third __config_section_third_start : - { - KEEP(*(.config_section_third)) - } >FLASH - .preinit_array : { . = ALIGN(8); diff --git a/src/config_data_default.c b/src/config_data_default.c index 0e5033f..4c0000e 100644 --- a/src/config_data_default.c +++ b/src/config_data_default.c @@ -42,7 +42,7 @@ /** * */ -volatile const config_data_mode_t __attribute__((section(".config_section_default.mode"))) config_data_mode_default = { +const config_data_mode_t __attribute__((section(".config_section_default.mode"))) config_data_mode_default = { #ifdef _DIGI .digi = 1, #else @@ -126,7 +126,7 @@ volatile const config_data_mode_t __attribute__((section(".config_section_defaul /** * */ -volatile const config_data_basic_t __attribute__((section(".config_section_default.basic"))) config_data_basic_default = { +const config_data_basic_t __attribute__((section(".config_section_default.basic"))) config_data_basic_default = { .callsign = _CALL, .ssid = _SSID, .latitude = _LAT, @@ -194,7 +194,7 @@ volatile const config_data_basic_t __attribute__((section(".config_section_defau * Data sources for different parameters * */ -volatile const config_data_wx_sources_t __attribute__((section(".config_section_default.sources"))) config_data_wx_sources_default = { +const config_data_wx_sources_t __attribute__((section(".config_section_default.sources"))) config_data_wx_sources_default = { #ifdef _TEMPERATURE_INTERNAL .temperature = WX_SOURCE_INTERNAL, #endif @@ -259,7 +259,7 @@ volatile const config_data_wx_sources_t __attribute__((section(".config_section_ /** * */ -volatile const config_data_umb_t __attribute__((section(".config_section_default.umb"))) config_data_umb_default = { +const config_data_umb_t __attribute__((section(".config_section_default.umb"))) config_data_umb_default = { #ifdef _UMB_SLAVE_ID .slave_id = _UMB_SLAVE_ID, #else @@ -291,7 +291,7 @@ volatile const config_data_umb_t __attribute__((section(".config_section_default /** * */ -volatile const config_data_rtu_t __attribute__((section(".config_section_default.rtu"))) config_data_rtu_default = { +const config_data_rtu_t __attribute__((section(".config_section_default.rtu"))) config_data_rtu_default = { .slave_speed = _RTU_SLAVE_SPEED, .slave_parity = _RTU_SLAVE_PARITY, diff --git a/src/configuration_handler.c b/src/configuration_handler.c index 3ab81f7..2a7d151 100644 --- a/src/configuration_handler.c +++ b/src/configuration_handler.c @@ -114,7 +114,7 @@ uint32_t configuration_handler_check_crc(void) { crc_current = CRC_CalcCRC((uint32_t)0x0); #endif -#ifdef STM32L471xxconfig_kiss_flash_state +#ifdef STM32L471xx // reset CRC engine LL_CRC_ResetCRCCalculationUnit(CRC); @@ -130,6 +130,7 @@ uint32_t configuration_handler_check_crc(void) { #endif //crc_expected = *__config_section_second_end; + crc_expected = *(config_section_second_start + CRC_32B_WORD_OFFSET); // check if calculated CRC value match value stored in flash memory if (crc_expected == crc_current) { @@ -244,6 +245,9 @@ uint32_t configuration_handler_restore_default_first(void) { } } } + else { + return -2; + } // set programming counter. If second region is also screwed the first one will be used as a source // if second is OK it will be used instead (if its programming counter has value three or more). @@ -400,6 +404,9 @@ uint32_t configuration_handler_restore_default_second(void) { } } } + else { + return -2; + } // set programming counter. If second region is also screwed the first one will be used as a source // if second is OK it will be used instead (if its programming counter has value three or more). diff --git a/src/main.c b/src/main.c index 15c87e5..3dab105 100644 --- a/src/main.c +++ b/src/main.c @@ -319,6 +319,8 @@ int main(int argc, char* argv[]){ // if not store the flag in the backup register to block // reinitializing once again in the consecutive restart configuration_set_bits_register(CONFIG_FIRST_FAIL_RESTORING); + + configuration_clear_bits_register(CONFIG_FIRST_CRC_OK); } diff --git a/src/pwr_save.c b/src/pwr_save.c index 6506aac..e9fe3ff 100644 --- a/src/pwr_save.c +++ b/src/pwr_save.c @@ -591,7 +591,9 @@ void pwr_save_pooling_handler(const config_data_mode_t * config, const config_da pwr_save_switch_mode_to_l7((timers->wx_transmit_period * 60) - 120); } else { - reinit_sensors= pwr_save_switch_mode_to_c1(); + // TODO: Workaround here for HW-RevB!!! + //reinit_sensors= pwr_save_switch_mode_to_c1(); + reinit_sensors = pwr_save_switch_mode_to_c0(); } } } @@ -670,7 +672,9 @@ void pwr_save_pooling_handler(const config_data_mode_t * config, const config_da } else { if (pwr_save_seconds_to_wx <= 30) { - pwr_save_switch_mode_to_c1(); + // TODO: Workaround here for HW-RevB!!! + //reinit_sensors= pwr_save_switch_mode_to_c1(); + pwr_save_switch_mode_to_c0(); // do not reinitialize everything as reinitialization had been done when switching to m4 mode reinit_sensors = 0;