Browse Source

Fix size of erased sectors in progress bar

double-buffering
Dominik Boehi 2 years ago
committed by Yatekii
parent
commit
2131fad182
  1. 2
      RESOURCES.md
  2. 5
      cargo-flash/src/main.rs
  3. 7
      probe-rs/src/flash/builder.rs
  4. 4
      probe-rs/src/flash/flasher.rs
  5. 9
      probe-rs/src/flash/progress.rs

2
RESOURCES.md

@ -10,6 +10,8 @@
[JEDEC CODES](https://www.jedec.org/system/files/docs/JEP106AY.pdf)
[CMSIS Packs](https://developer.arm.com/tools-and-software/embedded/cmsis/cmsis-packs)
## Releated OSS projects
[PyOCD](https://github.com/mbedmicro/pyOCD) Open source Python library for

5
cargo-flash/src/main.rs

@ -265,11 +265,10 @@ fn main_try() -> Result<(), failure::Error> {
match event {
Initialized {
total_pages,
total_sectors,
sector_size,
total_sector_size,
page_size,
} => {
erase_progress.set_length(total_sectors as u64 * sector_size as u64);
erase_progress.set_length(total_sector_size as u64);
program_progress.set_length(total_pages as u64 * page_size as u64);
}
StartedFlashing => {

7
probe-rs/src/flash/builder.rs

@ -193,7 +193,10 @@ impl<'a> FlashBuilder<'a> {
let num_pages = sectors.iter().map(|s| s.pages.len()).sum();
let sizes = sectors.first().map(|s| (s.size, s.page_size));
let (sector_size, page_size) = sizes.unwrap_or((0, 0));
progress.initialized(sectors.len(), num_pages, sector_size, page_size);
let sector_size:u32 = sectors.iter().map(|s| s.size ).sum();
progress.initialized(num_pages, sector_size as usize, page_size);
// Check if there is even sectors to flash.
if sectors.is_empty() || sectors[0].pages.is_empty() {
@ -434,7 +437,7 @@ impl<'a> FlashBuilder<'a> {
for sector in sectors {
if !sector.pages.is_empty() {
active.erase_sector(sector.address)?;
progress.sector_erased(sector.page_size, t.elapsed().as_millis());
progress.sector_erased(sector.size, t.elapsed().as_millis());
t = std::time::Instant::now();
}
}

4
probe-rs/src/flash/flasher.rs

@ -478,7 +478,7 @@ impl<'a> ActiveFlasher<'a, Erase> {
}
pub fn erase_sector(&mut self, address: u32) -> Result<(), FlasherError> {
log::info!("Erasing sector at address 0x{:08x}.", address);
log::info!("Erasing sector at address 0x{:08x}", address);
let t1 = std::time::Instant::now();
let flasher = self;
let algo = flasher.flash_algorithm;
@ -511,7 +511,7 @@ impl<'a> ActiveFlasher<'a, Program> {
let flasher = self;
let algo = flasher.flash_algorithm;
log::info!("Flashing one page of size: {}", bytes.len());
log::info!("Flashing page at address {:#08x} with size: {}", address, bytes.len());
// Transfer the bytes to RAM.
flasher.probe.write_block8(algo.begin_data, bytes)?;

9
probe-rs/src/flash/progress.rs

@ -15,15 +15,13 @@ impl FlashProgress {
pub fn initialized(
&self,
total_sectors: usize,
total_pages: usize,
sector_size: u32,
total_sector_size: usize,
page_size: u32,
) {
self.emit(ProgressEvent::Initialized {
total_sectors,
total_pages,
sector_size,
total_sector_size,
page_size,
});
}
@ -56,8 +54,7 @@ impl FlashProgress {
pub enum ProgressEvent {
Initialized {
total_pages: usize,
total_sectors: usize,
sector_size: u32,
total_sector_size: usize,
page_size: u32,
},
StartedFlashing,

Loading…
Cancel
Save