embassy-rs/embassy · error
The write size for the concatenated flashes must be the same
Error message
The write size for the concatenated flashes must be the same
What it means
The const fn `get_write_size` panics when the two flashes combined by `ConcatFlash::new` declare different WRITE_SIZE constants. A concatenated flash exposes a single write granularity, so mismatched write sizes are rejected. As a compile-time (const-eval) panic, it typically surfaces when instantiating the ConcatFlash type.
Solutions
- Choose two flashes whose WRITE_SIZE constants match
- Wrap the odd flash in an adapter normalizing WRITE_SIZE to the shared value
- Buffer writes so the effective write size is identical (e.g. page-buffer wrapper)
- Review driver release notes for changed WRITE_SIZE constants after an update
Example fix
// before type Boot = ConcatFlash<InternalFlash, SpiNor>; // WRITE_SIZE 256 vs 1 // after type Boot = ConcatFlash<InternalFlash, NorWrapper<256, SpiNor>>;
Defensive patterns
Strategy: validation
Validate before calling
const fn write_sizes_match<A: NorFlash, B: NorFlash>() -> bool { A::WRITE_SIZE == B::WRITE_SIZE }
const _: () = assert!(write_sizes_match::<MyFlashA, MyFlashB>(), "WRITE_SIZE mismatch for ConcatFlash"); Prevention
- Confirm WRITE_SIZE equality before ConcatFlash::new
- Use a page-buffer wrapper to present a uniform write granularity
- Pin and review driver versions so WRITE_SIZE constants don't change silently
- Encode flash constants as board-level const items reused everywhere
When it happens
Trigger: `ConcatFlash::new(a, b)` where `First::WRITE_SIZE != Second::WRITE_SIZE`, evaluated by the NorFlash/AsyncNorFlash WRITE_SIZE computation.
Common situations: Mixing internal MCU flash (WRITE_SIZE 8/256) with SPI NOR flash (WRITE_SIZE 1 or 256); switching one flash to a chip with different page-write granularity; firmware version change that altered a driver's WRITE_SIZE.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- The read size for the concatenated flashes must be the same
- The erase sizes for the concatenated flashes must have have…
- Partition offset must be a multiple of read, write and…
- Partition size must be a multiple of read, write and erase…
- Partition offset must be a multiple of read, write and…
AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10).
Data as JSON: /api/errors/47144fd6e64d7e4d.
Report an issue: GitHub.
Appendix: source
Thrown at embassy-embedded-hal/src/flash/concat_flash.rs:27
pub struct ConcatFlash<First, Second>(First, Second);
impl<First, Second> ConcatFlash<First, Second> {
/// Create a new flash that concatenates two consecutive flashes.
pub fn new(first: First, second: Second) -> Self {
Self(first, second)
}
}
const fn get_read_size(first_read_size: usize, second_read_size: usize) -> usize {
if first_read_size != second_read_size {
panic!("The read size for the concatenated flashes must be the same");
}
first_read_size
}
const fn get_write_size(first_write_size: usize, second_write_size: usize) -> usize {
if first_write_size != second_write_size {
panic!("The write size for the concatenated flashes must be the same");
}
first_write_size
}
const fn get_max_erase_size(first_erase_size: usize, second_erase_size: usize) -> usize {
let max_erase_size = if first_erase_size > second_erase_size {
first_erase_size
} else {
second_erase_size
};
if max_erase_size % first_erase_size != 0 || max_erase_size % second_erase_size != 0 {
panic!("The erase sizes for the concatenated flashes must have have a gcd equal to the max erase size");
}
max_erase_size
}
impl<First, Second, E> ErrorType for ConcatFlash<First, Second>
whereView on GitHub (pinned to 463a07b963)