From fc2b3be21400f5d87316b39682add8a683666910 Mon Sep 17 00:00:00 2001 From: Otso Jousimaa Date: Wed, 31 Jan 2024 23:51:31 +0200 Subject: [PATCH] Disable boot counter (#357) --- src/app_log.c | 4 +++- test/test_app_log.c | 29 +++++++++++++++++++++-------- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/src/app_log.c b/src/app_log.c index b26984be..56ae6cb1 100644 --- a/src/app_log.c +++ b/src/app_log.c @@ -180,7 +180,9 @@ rd_status_t app_log_init (void) err_code |= purge_logs(); } - err_code |= app_log_increment_boot_count(); + // Boot count used to be incremented here, + // but as boot counter is not used line is omitted + // err_code |= app_log_increment_boot_count(); return err_code; } diff --git a/test/test_app_log.c b/test/test_app_log.c index 450abe98..5b2ac752 100644 --- a/test/test_app_log.c +++ b/test/test_app_log.c @@ -235,6 +235,24 @@ static void log_purge_Expect (void) rt_flash_gc_run_ExpectAndReturn (RD_SUCCESS); } +static void log_purge_noflash_Expect (void) +{ + for (uint8_t r_idx = 0; r_idx < APP_FLASH_LOG_DATA_RECORDS_NUM; r_idx++) + { + rd_status_t rvalue = RD_ERROR_INVALID_STATE; + rt_flash_free_ExpectAndReturn (APP_FLASH_LOG_FILE, + (APP_FLASH_LOG_DATA_RECORD_PREFIX << 8U) + r_idx, + rvalue); + rt_flash_busy_ExpectAndReturn (true); + ri_yield_ExpectAndReturn (RD_SUCCESS); + rt_flash_busy_ExpectAndReturn (false); + } + + rt_flash_gc_run_ExpectAndReturn (RD_ERROR_INVALID_STATE); +} + +/* + These functions are not needed as the app bootcounter is unused. Leaving them here for future reference. static void app_log_read_boot_count_Expect (void) { rt_flash_load_ExpectAndReturn (APP_FLASH_LOG_FILE, APP_FLASH_LOG_BOOT_COUNTER_RECORD, @@ -261,6 +279,7 @@ static void app_log_read_boot_count_noflash_Expect (void) &m_boot_count, sizeof (uint32_t), RD_ERROR_INVALID_STATE); rt_flash_load_IgnoreArg_message(); } +*/ static void sample_process_expect (const rd_sensor_data_t * const sample) { @@ -432,7 +451,6 @@ void test_app_log_init_nostored (void) rt_flash_store_IgnoreArg_message(); #endif log_purge_Expect(); - app_log_read_boot_count_Expect(); err_code |= app_log_init(); TEST_ASSERT (RD_SUCCESS == err_code); TEST_ASSERT (!memcmp (&defaults, &m_log_config, sizeof (m_log_config))); @@ -459,7 +477,6 @@ void test_app_log_init_stored (void) rt_flash_load_IgnoreArg_message(); rt_flash_load_ReturnMemThruPtr_message (&stored, sizeof (stored)); log_purge_Expect(); - app_log_read_boot_count_Expect(); err_code |= app_log_init(); TEST_ASSERT (RD_SUCCESS == err_code); TEST_ASSERT (!memcmp (&stored, &m_log_config, sizeof (m_log_config))); @@ -478,9 +495,8 @@ void test_app_log_init_noflash (void) RD_ERROR_INVALID_STATE); rt_flash_load_IgnoreArg_message(); # else - log_purge_Expect(); + log_purge_noflash_Expect(); # endif - app_log_read_boot_count_noflash_Expect(); err_code |= app_log_init(); TEST_ASSERT (RD_ERROR_INVALID_STATE == err_code); TEST_ASSERT (!memcmp (&defaults, &m_log_config, sizeof (m_log_config))); @@ -512,7 +528,6 @@ void test_app_log_init_nostored_nocounter (void) rt_flash_store_IgnoreArg_message(); #endif log_purge_Expect(); - app_log_read_boot_count_not_found_Expect(); err_code |= app_log_init(); TEST_ASSERT (RD_SUCCESS == err_code); TEST_ASSERT (!memcmp (&defaults, &m_log_config, sizeof (m_log_config))); @@ -539,7 +554,6 @@ void test_app_log_init_stored_nocounter (void) rt_flash_load_IgnoreArg_message(); rt_flash_load_ReturnMemThruPtr_message (&stored, sizeof (stored)); log_purge_Expect(); - app_log_read_boot_count_not_found_Expect(); err_code |= app_log_init(); TEST_ASSERT (RD_SUCCESS == err_code); TEST_ASSERT (!memcmp (&stored, &m_log_config, sizeof (m_log_config))); @@ -558,9 +572,8 @@ void test_app_log_init_noflash_nocounter (void) RD_ERROR_INVALID_STATE); rt_flash_load_IgnoreArg_message(); # else - log_purge_Expect(); + log_purge_noflash_Expect(); # endif - app_log_read_boot_count_noflash_Expect(); err_code |= app_log_init(); TEST_ASSERT (RD_ERROR_INVALID_STATE == err_code); TEST_ASSERT (!memcmp (&defaults, &m_log_config, sizeof (m_log_config)));