{"record":{"id":"47e50cf33afc4a7a","repo":"embassy-rs/embassy","slug":"bad-dma-channel-kind","errorCode":null,"errorMessage":"bad dma channel kind {}","messagePattern":"bad dma channel kind (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-stm32/build.rs","lineNumber":2711,"sourceCode":"        if ch.supports_2d.unwrap_or(false) {\n            g.extend(quote!(dma_channel_2d_impl!(#name);));\n        }\n\n        let dma = format_ident!(\"{}\", ch.dma);\n        let ch_num = ch.channel as usize;\n        let bi = dma_peri.registers.as_ref().unwrap();\n\n        if ch.supports_2d.unwrap_or(false) && bi.kind == \"gpdma\" {\n            has_gpdma_2d = true;\n        }\n\n        let dma_info = match bi.kind {\n            \"dma\" => quote!(crate::dma::DmaInfo::Dma(crate::pac::#dma)),\n            \"bdma\" => quote!(crate::dma::DmaInfo::Bdma(crate::pac::#dma)),\n            \"gpdma\" => quote!(crate::dma::DmaInfo::Gpdma(crate::pac::#dma)),\n            \"mdma\" => quote!(crate::dma::DmaInfo::Mdma(crate::pac::#dma)),\n            \"lpdma\" => quote!(crate::dma::DmaInfo::Lpdma(crate::pac::#dma)),\n            _ => panic!(\"bad dma channel kind {}\", bi.kind),\n        };\n\n        let dmamux = if has_dmamux {\n            match &ch.dmamux {\n                Some(dmamux) => {\n                    let dmamux = format_ident!(\"{}\", dmamux);\n                    let num = ch.dmamux_channel.unwrap() as usize;\n                    quote! {\n                        dmamux: Some(crate::dma::DmamuxInfo {\n                            mux: crate::pac::#dmamux,\n                            num: #num,\n                        }),\n                    }\n                }\n                None => quote!(dmamux: None),\n            }\n        } else {\n            quote!()","sourceCodeStart":2693,"sourceCodeEnd":2729,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/build.rs#L2693-L2729","documentation":"build.rs generates `DmaInfo` tokens per DMA channel based on the channel block's `kind` (dma, bdma, gpdma, mdma, lpdma). An unknown kind means the chip metadata tagged a DMA channel with a type embassy-stm32's generator doesn't handle, so the script panics naming the kind. It is a build-time consistency check between chip metadata and supported DMA engines.","triggerScenarios":"Building DMA support for a chip whose metadata has a channel with `bi.kind` outside the five known values — typically from new/unsupported DMA engine types in freshly added chip data.","commonSituations":"Adding a new STM32 family with a DMA variant not yet handled by the generator; typos or renames in chip metadata kind strings.","solutions":["Update embassy-stm32 to a version that supports the DMA kind present in your chip's metadata.","Fix the chip metadata so the channel kind is one of dma/bdma/gpdma/mdma/lpdma.","Add a match arm in build.rs for the new kind, mapping it to a corresponding DmaInfo variant."],"exampleFix":"// before\nlet dma_info = match bi.kind {\n    \"dma\" => ..., \n    _ => panic!(\"bad dma channel kind {}\", bi.kind),\n};\n// after (support new kind)\n\"newdma\" => quote!(crate::dma::DmaInfo::Dma(crate::pac::#dma)),\n_ => panic!(\"bad dma channel kind {}\", bi.kind),","handlingStrategy":"validation","validationCode":"// metadata sanity check\nconst VALID: [&str; 5] = [\"dma\", \"bdma\", \"gpdma\", \"mdma\", \"lpdma\"];\nassert!(VALID.contains(&bi.kind), \"bad dma channel kind {}\", bi.kind);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only use DMA on chips whose channel kinds are supported by your embassy-stm32 version.","Keep chip metadata kind strings aligned with build.rs's known set.","When adding new DMA engine types, extend both metadata and build.rs match arms together."],"tags":["dma","build-script","metadata","stm32"],"backgroundTag":"invalid-enum-value","analyzedSha":"463a07b963419a1bfe61d5d597c44acb810afb8b","analyzedAt":"2026-09-10T13:38:26.660Z","contentChangedAt":"2026-09-10T13:38:26.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}