Skip to content

Commit

Permalink
handle flash storage being full
Browse files Browse the repository at this point in the history
  • Loading branch information
gferraro committed Dec 9, 2024
1 parent 0696b58 commit 00cca46
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/core0_audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ pub fn offload(
false,
) && flash_storage.has_files_to_offload()
{
info!("Failed to offload events and storage");
return Err(());
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/onboard_flash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,19 @@ impl OnboardFlash {
}
}
}
// flash full
if self.last_used_block_index.is_none() && self.first_used_block_index.is_some() {
self.last_used_block_index = Some(NUM_RECORDING_BLOCKS - 1);
self.file_start_block_index = self.prev_page.file_start_block_index();

self.current_block_index = NUM_RECORDING_BLOCKS;
self.current_page_index = 0;
println!(
"Setting next starting block index {}",
self.current_block_index
);
}

self.bad_blocks = bad_blocks;
}

Expand Down Expand Up @@ -931,6 +944,9 @@ impl OnboardFlash {
pub fn start_file(&mut self, start_page: isize) -> isize {
// CPTV always start writing a new file at page 1, reserving page 0 for when we come back
// and write the header once we've finished writing the file.
if self.current_block_index >= NUM_RECORDING_BLOCKS {
panic!("Flash is full cannnot start new file");
}
self.previous_file_start_block_index = self.file_start_block_index;
self.current_page_index = start_page;
warn!(
Expand Down

0 comments on commit 00cca46

Please sign in to comment.