Skip to content

Commit 81131e4

Browse files
committed
Set the flash segment's address to the offset of the factory app partition
1 parent 783d32c commit 81131e4

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

espflash/src/image_format/esp32bootloader.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,16 @@ impl<'a> Esp32BootloaderFormat<'a> {
121121
let hash = hasher.finalize();
122122
data.write_all(&hash)?;
123123

124+
// The default partition table contains the "factory" partition, and if a user
125+
// provides a partition table via command-line then the validation step confirms
126+
// this is present, so it's safe to unwrap.
127+
let factory_partition = partition_table.find("factory").unwrap();
128+
124129
let flash_segment = RomSegment {
125-
addr: params.app_addr,
130+
addr: factory_partition.offset(),
126131
data: Cow::Owned(data),
127132
};
133+
128134
Ok(Self {
129135
params,
130136
bootloader,

espflash/src/partition_table.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ impl Partition {
367367
Ok(())
368368
}
369369

370+
pub fn offset(&self) -> u32 {
371+
self.offset
372+
}
373+
370374
fn overlaps(&self, other: &Partition) -> bool {
371375
max(self.offset, other.offset) < min(self.offset + self.size, other.offset + other.size)
372376
}

0 commit comments

Comments
 (0)