-
Notifications
You must be signed in to change notification settings - Fork 136
Skip reflashing similar blocks #588
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
Comments
Will be quite a bit of work so probably we should check how much we can benefit from it beforehand. We could create images via save-image and check the diff |
I did a quick check with an esp-hal example (embassy_i2s_sound.rs on ESP32-C3) and changed a few things between release builds:
Then I checked the output of The only sectors which are same are the gaps between code and data (since data needs to be 64k aligned). The fill-byte is I wonder if we could somehow optimize for this in another way? Could we just avoid flashing whatever is in that gap completely? (i.e. no need to even check the md5) |
I tried changing the padding byte to 0xff and made the flasher-stub skip the writing in that case. No measurable difference for me. So probably not worth it |
I was afraid the entropy of the generated image file would be too high for this kind of improvement to be possible :( EDIT: I tried compiling with different profiles. With |
For diffing in sector-sized chunks I just wrote a few lines in Rust since I wasn't able to find some utility (but didn't tried hard to find one) fn main() {
let args: Vec<String> = std::env::args().collect();
let f1 = std::fs::read(&args[1]).unwrap();
let f2 = std::fs::read(&args[2]).unwrap();
let mut chunk = 0;
let mut same = 0;
let mut diff = 0;
for page in f1.chunks(4096) {
let dl = usize::min(4096, f2.len() - chunk*4096);
if page == &f2[chunk*4096..][..dl] {
same += 1;
} else {
diff += 1;
}
chunk += 1;
}
println!("Chunks={chunk}, Same={same}, Different={diff}");
} Then I feed it two images generated with espflash's |
Imo this is probably not worth pursuing for the v3 release, removing from the milestone. |
I think probably we will not go down this path at this time. We can always revisit this in the future if there is a need/desire for it. |
If it is possible to read the hash of a particular flash region, it should also be possible I believe to implement selective reflashing: for each flash block, read the hash, compare, and only reflash if differs.
Also, cc #259 as this issue is basically the meat of flash content verification.
Originally posted by @bugadani in #479 (comment)
The text was updated successfully, but these errors were encountered: