Skip to content

Commit

Permalink
AP_Logger: add flash speed test
Browse files Browse the repository at this point in the history
  • Loading branch information
andyp1per committed Dec 7, 2024
1 parent d0c9a76 commit ee1a4c2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion libraries/AP_Logger/AP_Logger_Block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ void AP_Logger_Block::write_log_page()

void AP_Logger_Block::flash_test()
{
const uint32_t pages_to_check = 128;
uint32_t pages_to_check = 128;
for (uint32_t i=1; i<=pages_to_check; i++) {
if ((i-1) % df_PagePerBlock == 0) {
printf("Block erase %u\n", get_block(i));
Expand Down Expand Up @@ -962,6 +962,19 @@ void AP_Logger_Block::flash_test()
i, bad_bytes, df_PageSize, buffer[first_bad_byte]);
}
}

// speed test
pages_to_check = 4096; // 1mB / 8mB
for (uint32_t i=1; i<=pages_to_check; i++) {
if ((i-1) % df_PagePerBlock == 0) {
SectorErase(get_block(i));
}
}
uint32_t now_ms = AP_HAL::millis();
for (uint32_t i=1; i<=pages_to_check; i++) {
BufferToPage(i);
}
printf("Flash speed test: %ukB/s\n", unsigned((pages_to_check * df_PageSize * 1000) / (1024 * (AP_HAL::millis() - now_ms))));
}

#endif // HAL_LOGGING_BLOCK_ENABLED

0 comments on commit ee1a4c2

Please sign in to comment.