Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions libraries/InternalFileSytem/src/flash/flash_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ bool flash_cache_flush (flash_cache_t* fc)
// included, and its data does not survive a reboot anyway.
if ( ok || ++fc->flush_failures >= FLASH_CACHE_MAX_FLUSH_FAILURES )
{
// Writes already reported as done are lost with it
if ( !ok && fc->pages_dropped ) (*fc->pages_dropped)++;
fc->cache_addr = FLASH_CACHE_INVALID_ADDR;
fc->flush_failures = 0;
}
Expand Down
1 change: 1 addition & 0 deletions libraries/InternalFileSytem/src/flash/flash_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ typedef struct
uint32_t cache_addr;
uint8_t* cache_buf;
uint8_t flush_failures; // consecutive failed flushes of the cached page
uint32_t* pages_dropped; // counts pages given up after FLASH_CACHE_MAX_FLUSH_FAILURES, may be NULL
} flash_cache_t;

#ifdef __cplusplus
Expand Down
3 changes: 2 additions & 1 deletion libraries/InternalFileSytem/src/flash/flash_nrf5x.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ static flash_cache_t _cache =
.verify = fal_verify,

.cache_addr = FLASH_CACHE_INVALID_ADDR,
.cache_buf = _cache_buffer
.cache_buf = _cache_buffer,
.pages_dropped = &flash_nrf5x_stats.pages_dropped
};

//--------------------------------------------------------------------+
Expand Down
1 change: 1 addition & 0 deletions libraries/InternalFileSytem/src/flash/flash_nrf5x.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ typedef struct
uint32_t max_ticks; // longest completed operation
uint32_t last_result; // NRF_SUCCESS or the last error code
uint32_t written_off; // completions given up as lost once the SoftDevice accepted a later operation
uint32_t pages_dropped; // cached pages given up after repeated flush failures, losing their writes
} flash_nrf5x_stats_t;

extern flash_nrf5x_stats_t flash_nrf5x_stats;
Expand Down
Loading