{"record":{"id":"d2e59f34b62956fe","repo":"embassy-rs/embassy","slug":"alloc-endpoint-out-failed","errorCode":null,"errorMessage":"alloc_endpoint_out failed","messagePattern":"alloc_endpoint_out failed","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"embassy-usb/src/builder.rs","lineNumber":572,"sourceCode":"        self.endpoint_descriptor(ep.info(), synchronization_type, usage_type, extra_fields);\n\n        ep\n    }\n\n    /// Allocate an OUT endpoint, without writing its descriptor.\n    ///\n    /// Use for granular control over the order of endpoint and descriptor creation.\n    pub fn alloc_endpoint_out(\n        &mut self,\n        ep_type: EndpointType,\n        ep_addr: Option<EndpointAddress>,\n        max_packet_size: u16,\n        interval_ms: u8,\n    ) -> D::EndpointOut {\n        self.builder\n            .driver\n            .alloc_endpoint_out(ep_type, ep_addr, max_packet_size, interval_ms)\n            .expect(\"alloc_endpoint_out failed\")\n    }\n\n    fn endpoint_out(\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::EndpointOut {\n        let ep = self.alloc_endpoint_out(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":554,"sourceCodeEnd":590,"githubUrl":"https://github.com/embassy-rs/embassy/blob/463a07b963419a1bfe61d5d597c44acb810afb8b/embassy-usb/src/builder.rs#L554-L590","documentation":"The USB builder's alloc_endpoint_out forwards to the driver's endpoint allocator and expects success via `.expect`. The driver could not allocate an OUT endpoint with the requested type/address/packet size, usually because all hardware OUT endpoints are in use or the request is unsupported. This aborts the descriptor-building task.","triggerScenarios":"Calling `endpoint_out(ep_type, ep_addr, max_packet_size, interval_ms)` on a Builder when the driver has no free OUT endpoint, the requested ep_addr is already allocated, or the type/size combination exceeds peripheral capabilities.","commonSituations":"Composite USB configurations with many OUT endpoints (CDC + MSC + HID + vendor) exceeding hardware endpoint count; explicit address collisions; requesting bulk with packet sizes unsupported by the peripheral.","solutions":["Reduce the number of OUT endpoints in the class/composite configuration","Pass `None` for ep_addr to let the driver pick a free endpoint","Lower `max_packet_size` or use an endpoint type the hardware supports","Check the driver/peripheral endpoint budget (e.g. OTG-FS supports fewer endpoints than HS) and adjust device selection"],"exampleFix":"// before\nlet ep = builder.endpoint_out(EndpointType::Bulk, Some(EndpointAddress::from_parts(0x01)), 512, 0);\n// after\nlet ep = builder.endpoint_out(EndpointType::Bulk, None, 64, 0);","handlingStrategy":"validation","validationCode":"// before building: count OUT endpoints in your classes\n// and ensure count <= driver max OUT endpoints","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Budget endpoints per interface before configuring composite devices","Pass None for endpoint addresses to avoid collisions","Match packet sizes to bus speed limits (64 bytes for FS)","Check chip variant endpoint capacity when switching targets"],"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"}