Skip to content

Commit 33e32c1

Browse files
MabezDevjessebraham
authored andcommitted
limit default partition size
Some chips can have more than 16MB of flash, mine as 32MB. Historically espflash failed to detect this flash size but now can. Without this change the board will boot loop because the esp idf bootloader max size is only 16MB.
1 parent 984d95c commit 33e32c1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

espflash/src/targets/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ use crate::{
3131
image_format::{ImageFormat, ImageFormatKind},
3232
};
3333

34+
/// Max partition size is 16 MB
35+
const MAX_PARTITION_SIZE: u32 = 16 * 1000 * 1024;
36+
3437
mod esp32;
3538
mod esp32c2;
3639
mod esp32c3;
@@ -187,7 +190,10 @@ impl Esp32Params {
187190
Type::App,
188191
SubType::App(AppType::Factory),
189192
self.app_addr,
190-
flash_size.map_or(self.app_size, |size| size - self.app_addr),
193+
core::cmp::min(
194+
flash_size.map_or(self.app_size, |size| size - self.app_addr),
195+
MAX_PARTITION_SIZE,
196+
),
191197
false,
192198
),
193199
])

0 commit comments

Comments
 (0)