embassy-rs/embassy · error
Partition size must be a multiple of read, write and erase…
Error message
Partition size must be a multiple of read, write and erase size
What it means
This is a compile-time const-evaluation panic in BlockingPartition::new: the partition bounds are rejected before any flash access can occur. It fires because the requested offset or size is not aligned to the underlying NorFlash's READ_SIZE, WRITE_SIZE or ERASE_SIZE, or (in the sibling check) the size itself is not a multiple of those alignment units. Flash hardware can only read, program and erase on these granularities, so a misaligned partition would cause undefined behavior or data corruption.
Solutions
- Align the partition offset to a multiple of the flash's ERASE_SIZE (which is always a multiple of READ_SIZE and WRITE_SIZE)
- Choose a partition size that is an exact multiple of the erase size so every sector fits wholly within the partition
- Compute offset and size from the chip's geometry constants (e.g. 4096-byte sectors) instead of hardcoding arbitrary values
- If a non-aligned region is genuinely needed, add a software layer that pads/rounds accesses to alignment boundaries rather than slicing the flash directly
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at embassy-embedded-hal/src/flash/partition/blocking.rs:40 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10).
Data as JSON: /api/errors/2710ba4a3eebc9e8.
Report an issue: GitHub.
Appendix: source
Thrown at embassy-embedded-hal/src/flash/partition/blocking.rs:40
impl<'a, M: RawMutex, T: NorFlash> Clone for BlockingPartition<'a, M, T> {
fn clone(&self) -> Self {
Self {
flash: self.flash,
offset: self.offset,
size: self.size,
}
}
}
impl<'a, M: RawMutex, T: NorFlash> BlockingPartition<'a, M, T> {
/// Create a new partition
pub const fn new(flash: &'a Mutex<M, RefCell<T>>, offset: u32, size: u32) -> Self {
if offset % T::READ_SIZE as u32 != 0 || offset % T::WRITE_SIZE as u32 != 0 || offset % T::ERASE_SIZE as u32 != 0
{
panic!("Partition offset must be a multiple of read, write and erase size");
}
if size % T::READ_SIZE as u32 != 0 || size % T::WRITE_SIZE as u32 != 0 || size % T::ERASE_SIZE as u32 != 0 {
panic!("Partition size must be a multiple of read, write and erase size");
}
Self { flash, offset, size }
}
/// Get the partition offset within the flash
pub const fn offset(&self) -> u32 {
self.offset
}
/// Get the partition size
pub const fn size(&self) -> u32 {
self.size
}
}
impl<M: RawMutex, T: NorFlash> ErrorType for BlockingPartition<'_, M, T> {
type Error = Error<T::Error>;
}View on GitHub (pinned to 463a07b963)