Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.
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
55 changes: 0 additions & 55 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ esp32h2-hal = { version = "0.3.0", optional = true }
esp32s2-hal = { version = "0.12.0", optional = true }
esp32s3-hal = { version = "0.12.0", optional = true }
heapless = { version = "0.7.16", default-features = false }
md-5 = { version = "0.10.5", default-features = false }
static_cell = "1"


Expand All @@ -38,11 +37,11 @@ esp32c2 = ["esp32c2-hal"]
dprint = []

[profile.release]
strip = true
opt-level = "s" # temporary because of https://github.com/llvm/llvm-project/issues/57988
codegen-units = 1
lto = true
panic = "abort"
debug = true

[workspace]
members = ["xtask"]
14 changes: 7 additions & 7 deletions src/protocol.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use core::{cmp::min, mem::size_of, slice};

use md5::{Digest, Md5};
use slip::*;

use crate::{
commands::{CommandCode::*, Error::*, *},
hal::rom::md5::Context,
miniz_types::*,
targets::{EspCommon, FLASH_BLOCK_SIZE, FLASH_SECTOR_MASK},
};
Expand Down Expand Up @@ -114,17 +114,17 @@ impl<'a> Stub<'a> {

fn calculate_md5(&mut self, mut address: u32, mut size: u32) -> Result<[u8; 16], Error> {
let mut buffer: [u8; FLASH_SECTOR_SIZE as usize] = [0; FLASH_SECTOR_SIZE as usize];
let mut hasher = Md5::new();
let mut hasher = Context::new();

while size > 0 {
let to_read = min(size, FLASH_SECTOR_SIZE);
self.target.spi_flash_read(address, &mut buffer)?;
hasher.update(&buffer[0..to_read as usize]);
hasher.consume(&buffer[0..to_read as usize]);
size -= to_read;
address += to_read;
}

let result: [u8; 16] = hasher.finalize().into();
let result: [u8; 16] = hasher.compute().into();
Ok(result)
}

Expand Down Expand Up @@ -365,7 +365,7 @@ impl<'a> Stub<'a> {
let mut remaining = params.total_size;
let mut acked = 0;
let mut ack_buf: [u8; 4] = [0; 4];
let mut hasher = Md5::new();
let mut hasher = Context::new();
let mut sent = 0;
let max_inflight_bytes = params.max_inflight * params.packet_size;

Expand All @@ -375,7 +375,7 @@ impl<'a> Stub<'a> {
self.target
.spi_flash_read(address, &mut buffer[..len as usize])?;
write_packet(self.io, &buffer[..len as usize]);
hasher.update(&buffer[0..len as usize]);
hasher.consume(&buffer[0..len as usize]);
remaining -= len;
address += len;
sent += len;
Expand All @@ -384,7 +384,7 @@ impl<'a> Stub<'a> {
acked = u32_from_slice(resp, 0);
}

let md5: [u8; 16] = hasher.finalize().into();
let md5: [u8; 16] = hasher.compute().into();
write_packet(self.io, &md5);
Ok(())
}
Expand Down