{"record":{"id":"1e43f46a90d38190","repo":"embassy-rs/embassy","slug":"alloc-endpoint-in-failed","errorCode":null,"errorMessage":"alloc_endpoint_in failed","messagePattern":"alloc_endpoint_in failed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"embassy-usb/src/builder.rs","lineNumber":540,"sourceCode":"        self.builder\n            .config_descriptor\n            .endpoint(endpoint, synchronization_type, usage_type, extra_fields);\n    }\n\n    /// Allocate an IN endpoint, without writing its descriptor.\n    ///\n    /// Used for granular control over the order of endpoint and descriptor creation.\n    pub fn alloc_endpoint_in(\n        &mut self,\n        ep_type: EndpointType,\n        ep_addr: Option<EndpointAddress>,\n        max_packet_size: u16,\n        interval_ms: u8,\n    ) -> D::EndpointIn {\n        self.builder\n            .driver\n            .alloc_endpoint_in(ep_type, ep_addr, max_packet_size, interval_ms)\n            .expect(\"alloc_endpoint_in failed\")\n    }\n\n    fn endpoint_in(\n        &mut self,\n        ep_type: EndpointType,\n        ep_addr: Option<EndpointAddress>,\n        max_packet_size: u16,\n        interval_ms: u8,\n        synchronization_type: SynchronizationType,\n        usage_type: UsageType,\n        extra_fields: &[u8],\n    ) -> D::EndpointIn {\n        let ep = self.alloc_endpoint_in(ep_type, ep_addr, max_packet_size, interval_ms);\n        self.endpoint_descriptor(ep.info(), synchronization_type, usage_type, extra_fields);\n\n        ep\n    }\n","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-usb/src/builder.rs#L522-L558","documentation":"The USB builder's alloc_endpoint_in forwards to the driver's endpoint allocator and expects success via `.expect`. The driver returned None/Err, meaning it could not allocate an IN endpoint with the requested type/address/packet size — typically because the hardware's endpoint pool is exhausted or the request is unsupported. This aborts the descriptor-building task.","triggerScenarios":"Calling `endpoint_in(ep_type, ep_addr, max_packet_size, interval_ms)` on a Builder when the underlying USB driver has no free IN endpoint, or the requested ep_addr is already claimed, or the max_packet_size/ep_type combination is unsupported by hardware.","commonSituations":"Declaring many IN endpoints (multiple CDC-ACM interfaces, MIDI, UAC2, vendor bulk endpoints) exceeding the peripheral's endpoint count (e.g. 8 on some STM32 parts); requesting an explicit address that collides; wrong feature config limiting endpoint pool size.","solutions":["Reduce the number of IN endpoints in the class/composite configuration","Remove explicit `ep_addr` (Some(addr)) values so the driver can assign free endpoints automatically","Lower `max_packet_size` or change `ep_type` to one supported by the driver","Check the driver's max endpoint count / feature flags (e.g. embassy-stm32 synopsys-otg endpoint counts) and pick a chip variant with more endpoints"],"exampleFix":"// before\nlet ep = builder.endpoint_in(EndpointType::Bulk, Some(EndpointAddress::from_parts(0x81)), 512, 0);\n// after\nlet ep = builder.endpoint_in(EndpointType::Bulk, None, 64, 0); // let driver assign a free IN endpoint","handlingStrategy":"validation","validationCode":"// before building: count IN endpoints in your classes\n// and ensure count <= driver max IN endpoints (check chip datasheet / driver docs)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Budget endpoints per interface before configuring composite devices","Avoid pinning explicit endpoint addresses; let the driver allocate","Prefer smaller packet sizes on FS peripherals","Enable driver logging to see the allocation failure reason"],"tags":["rust","embedded","usb","allocation"],"backgroundTag":"resource-exhausted","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"}