{"record":{"id":"5099d998b292cdd1","repo":"embassy-rs/embassy","slug":"otp-not-present","errorCode":null,"errorMessage":"OTP not present","messagePattern":"OTP not present","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embassy-stm32/build.rs","lineNumber":547,"sourceCode":"        let mut otp_base = None;\n        for region in flash_memory_regions.iter() {\n            if region.name == \"BANK_1\" || region.name == \"BANK_1_REGION_1\" {\n                bank_1_base = Some(region.address);\n            } else if region.name == \"BANK_2\" || region.name == \"BANK_2_REGION_1\" {\n                bank_2_base = Some(region.address);\n            } else if region.name == \"OTP\" {\n                otp_base = Some(region.address);\n            }\n        }\n        let bank_1 = bank_1_base\n            .map(|a| quote!(#a))\n            .unwrap_or_else(|| quote!(panic!(\"Bank 1 not present\")));\n        let bank_2 = bank_2_base\n            .map(|a| quote!(#a))\n            .unwrap_or_else(|| quote!(panic!(\"Bank 2 not present\")));\n        let otp = otp_base\n            .map(|a| quote!(#a))\n            .unwrap_or_else(|| quote!(panic!(\"OTP not present\")));\n\n        let (swap_check, bank1, bank2) = if check_fb_mode {\n            (\n                quote! { let is_swapped = crate::pac::SYSCFG.memrmp().read().fb_mode(); },\n                quote! { if is_swapped { #bank_2 } else { #bank_1 } },\n                quote! { if is_swapped { #bank_1 } else { #bank_2 } },\n            )\n        } else {\n            (quote! {}, quote! { #bank_1 }, quote! { #bank_2 })\n        };\n\n        flash_regions.extend(quote! {\n            impl crate::flash::FlashBank {\n                /// Absolute base address.\n                pub fn base(&self) -> u32 {\n                    #swap_check\n                    match self {\n                        crate::flash::FlashBank::Bank1 => #bank1,","sourceCodeStart":529,"sourceCodeEnd":565,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-stm32/build.rs#L529-L565","documentation":"Generated into the flash driver: when no OTP region is present in the chip's memory map, `otp` compiles to `panic!(\"OTP not present\")`. It fires at runtime when user code reads the OTP (one-time-programmable) flash area on a chip where embassy-stm32 has no OTP base address.","triggerScenarios":"Calling `flash.in_otp()` / OTP region reads on a chip whose memory-map data has no region named \"OTP\", so `otp_base` stays None in build.rs.","commonSituations":"Porting code that reads factory OTP (e.g. MAC addresses) from one STM32 family to a chip that lacks a modeled OTP region; missing metadata for newly supported chips.","solutions":["Gate OTP usage behind a chip check — only read OTP on parts known to expose it.","Verify the target chip actually has an OTP region and that embassy-stm32's metadata includes it; update the chip data if it's missing.","Replace OTP reads with another storage (e.g. a flash sector) on chips without OTP."],"exampleFix":"// before\nlet mut otp = flash.in_otp().unwrap();\notp.read(0, &mut buf);\n// after\n#[cfg(feature = \"chip-with-otp\")]\n{\n    let mut otp = flash.in_otp().unwrap();\n    otp.read(0, &mut buf);\n}","handlingStrategy":"validation","validationCode":"// feature-gate OTP use\n#[cfg(feature = \"has-otp\")]\nfn read_otp(flash: &mut Flash) { let mut otp = flash.in_otp().unwrap(); otp.read(0, &mut buf); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only call in_otp()/OTP reads on chips documented to have OTP.","Verify OTP region presence in embassy-stm32 chip data when porting.","Provide a fallback source (flash sector) for values usually read from OTP."],"tags":["flash","otp","stm32","runtime-panic"],"backgroundTag":"resource-not-found","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"}