Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only show one 'Loading' and one 'Verifying' progress bar when loading #130

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
31 changes: 16 additions & 15 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4256,11 +4256,13 @@ bool load_guts(picoboot::connection con, iostream_memory_access &file_access) {
}
}
}
for (auto mem_range : ranges) {
enum memory_type type = get_memory_type(mem_range.from, model);
// new scope for progress bar
{
progress_bar bar("Loading into " + memory_names[type] + ": ");
size_t total_bytes = 0;
for (auto r : ranges) { total_bytes += r.to - r.from; }
{
Comment on lines +4260 to +4261
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably worth keeping the // new scope for progress bar comment, oherwise it might look like the { on the second line is associated with the for on the previous line 😉
Or alternatively, as there's now not multiple progress bars, perhaps this additional scope is no longer necessary? 🤔

progress_bar bar("Loading: ");
size_t loaded_bytes = 0;
for (auto mem_range : ranges) {
enum memory_type type = get_memory_type(mem_range.from, model);
uint32_t batch_size = FLASH_SECTOR_ERASE_SIZE;
bool ok = true;
vector<uint8_t> file_buf;
Expand Down Expand Up @@ -4296,16 +4298,17 @@ bool load_guts(picoboot::connection con, iostream_memory_access &file_access) {
raw_access.write_vector(base, file_buf);
base += this_batch;
}
bar.progress(base - mem_range.from, mem_range.to - mem_range.from);
bar.progress(base - mem_range.from + loaded_bytes, total_bytes);
}
loaded_bytes += mem_range.to - mem_range.from;
}
}
for (auto mem_range : ranges) {
enum memory_type type = get_memory_type(mem_range.from, model);
if (settings.load.verify) {
if (settings.load.verify) {
progress_bar bar("Verifying: ");
size_t verified_bytes = 0;
for (auto mem_range : ranges) {
bool ok = true;
{
lurch marked this conversation as resolved.
Show resolved Hide resolved
progress_bar bar("Verifying " + memory_names[type] + ": ");
uint32_t batch_size = FLASH_SECTOR_ERASE_SIZE;
vector<uint8_t> file_buf;
vector<uint8_t> device_buf;
Expand All @@ -4327,16 +4330,14 @@ bool load_guts(picoboot::connection con, iostream_memory_access &file_access) {
}
if (ok) {
pos = base + this_batch;
bar.progress(pos - mem_range.from + verified_bytes, total_bytes);
}
bar.progress(pos - mem_range.from, mem_range.to - mem_range.from);
}
}
if (ok) {
std::cout << " OK\n";
} else {
std::cout << " FAILED\n";
if (!ok) {
fail(ERROR_VERIFICATION_FAILED, "The device contents did not match the file");
}
verified_bytes += mem_range.to - mem_range.from;
}
}
if (settings.load.execute) {
Expand Down