Skip to content

Commit

Permalink
Only limit App partitions to 16MB, allow others to be bigger.
Browse files Browse the repository at this point in the history
The bootloader will crash when starting from an app partition which exceeds
16MB, but larger sizes are fine for data partitions.

Fixes esp-rs#34
  • Loading branch information
AVee committed May 3, 2024
1 parent 3774056 commit 0b9643c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ impl PartitionTable {
pub fn validate(&self) -> Result<(), Error> {
use self::partition::{APP_PARTITION_ALIGNMENT, DATA_PARTITION_ALIGNMENT};

const MAX_PART_SIZE: u32 = 0x100_0000; // 16MB
const MAX_APP_PART_SIZE: u32 = 0x100_0000; // 16MB
const OTADATA_SIZE: u32 = 0x2000; // 8kB

// There must be at least one partition with type 'app'
Expand Down Expand Up @@ -317,9 +317,9 @@ impl PartitionTable {
return Err(Error::UnalignedPartition);
}

// Partitions cannot exceed 16MB; see:
// App partitions cannot exceed 16MB; see:
// https://github.com/espressif/esp-idf/blob/c212305/components/bootloader_support/src/esp_image_format.c#L158-L161
if partition.size() > MAX_PART_SIZE {
if partition.ty() == Type::App && partition.size() > MAX_APP_PART_SIZE {
return Err(Error::PartitionTooLarge(partition.name()));
}
}
Expand Down

0 comments on commit 0b9643c

Please sign in to comment.