Skip to content

Commit

Permalink
Disable boot couter
Browse files Browse the repository at this point in the history
  • Loading branch information
ojousima committed Jan 31, 2024
1 parent aa82519 commit 44a20b6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
4 changes: 3 additions & 1 deletion src/app_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
29 changes: 21 additions & 8 deletions test/test_app_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
{
Expand Down Expand Up @@ -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)));
Expand All @@ -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)));
Expand All @@ -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)));
Expand Down Expand Up @@ -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)));
Expand All @@ -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)));
Expand All @@ -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)));
Expand Down

0 comments on commit 44a20b6

Please sign in to comment.