Merge #689
689: Avoid writing bootloader flash if not needed r=lulf a=lulf bors r+ Co-authored-by: Ulf Lilleengen <lulf@redhat.com>
This commit is contained in:
commit
a9e63167e1
1 changed files with 36 additions and 24 deletions
|
@ -318,21 +318,27 @@ impl FirmwareUpdater {
|
||||||
#[repr(align(4))]
|
#[repr(align(4))]
|
||||||
struct Aligned([u8; 4]);
|
struct Aligned([u8; 4]);
|
||||||
|
|
||||||
flash
|
let mut magic = Aligned([0; 4]);
|
||||||
.write(self.state.from as u32, &Aligned([0; 4]).0)
|
flash.read(self.state.from as u32, &mut magic.0).await?;
|
||||||
.await?;
|
let magic = u32::from_le_bytes(magic.0);
|
||||||
flash
|
|
||||||
.erase(self.state.from as u32, self.state.to as u32)
|
if magic != SWAP_MAGIC {
|
||||||
.await?;
|
flash
|
||||||
trace!(
|
.write(self.state.from as u32, &Aligned([0; 4]).0)
|
||||||
"Setting swap magic at {} to 0x{:x}, LE: 0x{:x}",
|
.await?;
|
||||||
self.state.from,
|
flash
|
||||||
&SWAP_MAGIC,
|
.erase(self.state.from as u32, self.state.to as u32)
|
||||||
&SWAP_MAGIC.to_le_bytes()
|
.await?;
|
||||||
);
|
trace!(
|
||||||
flash
|
"Setting swap magic at {} to 0x{:x}, LE: 0x{:x}",
|
||||||
.write(self.state.from as u32, &SWAP_MAGIC.to_le_bytes())
|
self.state.from,
|
||||||
.await?;
|
&SWAP_MAGIC,
|
||||||
|
&SWAP_MAGIC.to_le_bytes()
|
||||||
|
);
|
||||||
|
flash
|
||||||
|
.write(self.state.from as u32, &SWAP_MAGIC.to_le_bytes())
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -341,15 +347,21 @@ impl FirmwareUpdater {
|
||||||
#[repr(align(4))]
|
#[repr(align(4))]
|
||||||
struct Aligned([u8; 4]);
|
struct Aligned([u8; 4]);
|
||||||
|
|
||||||
flash
|
let mut magic = Aligned([0; 4]);
|
||||||
.write(self.state.from as u32, &Aligned([0; 4]).0)
|
flash.read(self.state.from as u32, &mut magic.0).await?;
|
||||||
.await?;
|
let magic = u32::from_le_bytes(magic.0);
|
||||||
flash
|
|
||||||
.erase(self.state.from as u32, self.state.to as u32)
|
if magic != BOOT_MAGIC {
|
||||||
.await?;
|
flash
|
||||||
flash
|
.write(self.state.from as u32, &Aligned([0; 4]).0)
|
||||||
.write(self.state.from as u32, &BOOT_MAGIC.to_le_bytes())
|
.await?;
|
||||||
.await?;
|
flash
|
||||||
|
.erase(self.state.from as u32, self.state.to as u32)
|
||||||
|
.await?;
|
||||||
|
flash
|
||||||
|
.write(self.state.from as u32, &BOOT_MAGIC.to_le_bytes())
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue