embassy-rs/embassy · error
YCbCr pixel format not supported for background buffer
Error message
YCbCr pixel format not supported for background buffer
What it means
When converting a PixelFormat for the DMA2D background layer (BGPFCCR), the YCbCr formats are only valid as foreground/chroma input, not for the background buffer. On dma2d_v2 hardware the driver panics rather than writing an invalid CM value.
Solutions
- Use an RGB/ARGB/L4/A8/A4/AL44/AL88 pixel format for the background layer.
- Convert YCbCr frames to RGB via the DMA2D foreground chroma path before blitting.
- Pass the YCbCr format only to the foreground layer where it is accepted.
Example fix
// before let mut bg = BgLayer::new(&mut dma2d, buf, layout, PixelFormat::YCbCr420); // after let mut bg = BgLayer::new(&mut dma2d, buf, layout, PixelFormat::Rgb565);
Defensive patterns
Strategy: validation
Validate before calling
fn assert_bg_format(f: PixelFormat) {
assert!(!matches!(f, PixelFormat::YCbCr420 | PixelFormat::YCbCr422),
"YCbCr not valid for DMA2D background buffer");
} Type guard
fn is_bg_pixel_format(f: PixelFormat) -> bool { !matches!(f, PixelFormat::YCbCr420 | PixelFormat::YCbCr422) } Prevention
- Reserve YCbCr formats for the foreground/chroma path only.
- Keep background framebuffers in RGB/ARGB/L4/A8 formats.
When it happens
Trigger: Creating/configuring a DMA2D background layer with PixelFormat::YCbCr420/YCbCr422 (any non-RGB/alpha variant rejected here) on a dma2d_v2 part.
Common situations: Video pipelines that decode YCbCr and set it as the background framebuffer; copying foreground-layer setup code to the background layer.
Related errors
- Selected output pixel format not supported
- Flexable pixels are not yet implemented
- Can only take the executor once
- Invalid FilterConfig (TooManyFilters)! A FilterConfig must…
- Invalid FilterConfig (EmptyFilterConfig)! A FilterConfig…
AI-assisted analysis of embassy-rs/embassy@463a07b963 (2026-09-10).
Data as JSON: /api/errors/62e7c9bb0e35ed21.
Report an issue: GitHub.
Appendix: source
Thrown at embassy-stm32/src/dma2d/mod.rs:213
}
}
impl Into<vals::BgpfccrCm> for PixelFormat {
fn into(self) -> vals::BgpfccrCm {
match self {
PixelFormat::Argb8888 => vals::BgpfccrCm::Argb8888,
PixelFormat::Rgb888 => vals::BgpfccrCm::Rgb888,
PixelFormat::Rgb565 => vals::BgpfccrCm::Rgb565,
PixelFormat::Argb1555 => vals::BgpfccrCm::Argb1555,
PixelFormat::Argb4444 => vals::BgpfccrCm::Argb4444,
PixelFormat::L8 => vals::BgpfccrCm::L8,
PixelFormat::AL44 => vals::BgpfccrCm::Al44,
PixelFormat::AL88 => vals::BgpfccrCm::Al88,
PixelFormat::L4 => vals::BgpfccrCm::L4,
PixelFormat::A8 => vals::BgpfccrCm::A8,
PixelFormat::A4 => vals::BgpfccrCm::A4,
#[cfg(dma2d_v2)]
_ => panic!("YCbCr pixel format not supported for background buffer"),
}
}
}
impl Into<vals::OpfccrCm> for PixelFormat {
fn into(self) -> vals::OpfccrCm {
match self {
PixelFormat::Argb8888 => vals::OpfccrCm::Argb8888,
PixelFormat::Rgb888 => vals::OpfccrCm::Rgb888,
PixelFormat::Rgb565 => vals::OpfccrCm::Rgb565,
PixelFormat::Argb1555 => vals::OpfccrCm::Argb1555,
PixelFormat::Argb4444 => vals::OpfccrCm::Argb4444,
_ => panic!("Selected output pixel format not supported"),
}
}
}
/// Input buffer alpha ModeView on GitHub (pinned to 463a07b963)