Skip to content
Open
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
1 change: 1 addition & 0 deletions esp-bootloader-esp-idf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ strum = { version = "0.27", default-features = false, features = ["derive"] }

crc = { version = "3.3.0", optional = true }
md-5 = { version = "0.10.6", default-features = false, optional = true }
zerocopy = { version = "0.8.33", features = ["derive"] }

[build-dependencies]
jiff = { version = "0.2.13", default-features = false, features = ["std"] }
Expand Down
38 changes: 14 additions & 24 deletions esp-bootloader-esp-idf/src/ota.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ where

#[cfg(test)]
mod tests {
use zerocopy::FromBytes;

use super::*;
use crate::partitions::PartitionEntry;

Expand Down Expand Up @@ -421,16 +423,14 @@ mod tests {
fn test_initial_state_and_next_slot() {
let mut binary = PARTITION_RAW;

let mock_entry = PartitionEntry {
binary: &mut binary,
};
let mock_entry = PartitionEntry::ref_from_bytes(&binary).unwrap();

let mut mock_flash = MockFlash {
data: [0xff; 0x2000],
};

let mock_region = FlashRegion {
raw: mock_entry,
raw: mock_entry.clone(),
flash: &mut mock_flash,
};

Expand Down Expand Up @@ -468,9 +468,7 @@ mod tests {
fn test_slot0_valid_next_slot() {
let mut binary = PARTITION_RAW;

let mock_entry = PartitionEntry {
binary: &mut binary,
};
let mock_entry = PartitionEntry::ref_from_bytes(&binary).unwrap();

let mut mock_flash = MockFlash {
data: [0xff; 0x2000],
Expand All @@ -480,7 +478,7 @@ mod tests {
mock_flash.data[0x1000..][..0x20].copy_from_slice(SLOT_INITIAL);

let mock_region = FlashRegion {
raw: mock_entry,
raw: mock_entry.clone(),
flash: &mut mock_flash,
};

Expand Down Expand Up @@ -508,9 +506,7 @@ mod tests {
fn test_slot1_new_next_slot() {
let mut binary = PARTITION_RAW;

let mock_entry = PartitionEntry {
binary: &mut binary,
};
let mock_entry = PartitionEntry::ref_from_bytes(&binary).unwrap();

let mut mock_flash = MockFlash {
data: [0xff; 0x2000],
Expand All @@ -520,7 +516,7 @@ mod tests {
mock_flash.data[0x1000..][..0x20].copy_from_slice(SLOT_COUNT_2_NEW);

let mock_region = FlashRegion {
raw: mock_entry,
raw: mock_entry.clone(),
flash: &mut mock_flash,
};

Expand Down Expand Up @@ -549,16 +545,14 @@ mod tests {
fn test_multi_updates() {
let mut binary = PARTITION_RAW;

let mock_entry = PartitionEntry {
binary: &mut binary,
};
let mock_entry = PartitionEntry::ref_from_bytes(&binary).unwrap();

let mut mock_flash = MockFlash {
data: [0xff; 0x2000],
};

let mock_region = FlashRegion {
raw: mock_entry,
raw: mock_entry.clone(),
flash: &mut mock_flash,
};

Expand Down Expand Up @@ -615,16 +609,14 @@ mod tests {
fn test_multi_updates_4_apps() {
let mut binary = PARTITION_RAW;

let mock_entry = PartitionEntry {
binary: &mut binary,
};
let mock_entry = PartitionEntry::ref_from_bytes(&binary).unwrap();

let mut mock_flash = MockFlash {
data: [0xff; 0x2000],
};

let mock_region = FlashRegion {
raw: mock_entry,
raw: mock_entry.clone(),
flash: &mut mock_flash,
};

Expand Down Expand Up @@ -700,16 +692,14 @@ mod tests {
fn test_multi_updates_skip_parts() {
let mut binary = PARTITION_RAW;

let mock_entry = PartitionEntry {
binary: &mut binary,
};
let mock_entry = PartitionEntry::ref_from_bytes(&binary).unwrap();

let mut mock_flash = MockFlash {
data: [0xff; 0x2000],
};

let mock_region = FlashRegion {
raw: mock_entry,
raw: mock_entry.clone(),
flash: &mut mock_flash,
};

Expand Down
3 changes: 2 additions & 1 deletion esp-bootloader-esp-idf/src/ota_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ where
crate::partitions::DataPartitionSubType::Ota,
))?;
if let Some(ota_part) = ota_part {
let ota_part = ota_part.as_embedded_storage(self.flash);
let ota_part = ota_part.clone().as_embedded_storage(self.flash);
let ota = crate::ota::Ota::new(ota_part, self.ota_count)?;
Ok(ota)
} else {
Expand Down Expand Up @@ -152,6 +152,7 @@ where
.pt
.find_partition(crate::partitions::PartitionType::App(next_slot))?
.ok_or(Error::Invalid)?
.clone()
.as_embedded_storage(self.flash);

Ok((flash_region, next_slot))
Expand Down
Loading
Loading