simplify set_magic
This commit is contained in:
parent
0e55bb2a20
commit
3dc26bbe39
1 changed files with 4 additions and 13 deletions
|
@ -587,22 +587,13 @@ impl FirmwareUpdater {
|
||||||
) -> Result<(), F::Error> {
|
) -> Result<(), F::Error> {
|
||||||
flash.read(self.state.from as u32, aligned).await?;
|
flash.read(self.state.from as u32, aligned).await?;
|
||||||
|
|
||||||
let mut is_set = true;
|
if aligned.iter().find(|&&b| b != magic).is_some() {
|
||||||
for b in 0..aligned.len() {
|
aligned.fill(0);
|
||||||
if aligned[b] != magic {
|
|
||||||
is_set = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !is_set {
|
|
||||||
for i in 0..aligned.len() {
|
|
||||||
aligned[i] = 0;
|
|
||||||
}
|
|
||||||
flash.write(self.state.from as u32, aligned).await?;
|
flash.write(self.state.from as u32, aligned).await?;
|
||||||
flash.erase(self.state.from as u32, self.state.to as u32).await?;
|
flash.erase(self.state.from as u32, self.state.to as u32).await?;
|
||||||
|
|
||||||
for i in 0..aligned.len() {
|
aligned.fill(magic);
|
||||||
aligned[i] = magic;
|
|
||||||
}
|
|
||||||
flash.write(self.state.from as u32, aligned).await?;
|
flash.write(self.state.from as u32, aligned).await?;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Reference in a new issue