How does VMWare access USB devices without have any specifics of the USB device? Does it use the same profile/entitlement process or does it take a different approach?
IOUSBHost
RSS for tagCreate host-mode user space drivers for USB devices using IOUSBHost.
Posts under IOUSBHost tag
25 Posts
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi Folks,
We are reading the USB device data from our app using libusb/iokit libraries.
Before updating the MacOS to the 15.3 we never faced any issue but after updating OS to 15.3 Sequoia we started facing issue to access the USB device's information.
We are not getting the device endpoints for the matching service and fails with below error-
Error:Failed to create IOUSBHostObject. with reason: IOServiceOpen failed.
Respective code snippet-
service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDictionary);
IOUSBHostInterface* interface = [[IOUSBHostInterface alloc] initWithIOService:service
options:IOUSBHostObjectInitOptionsDeviceCapture
queue:*queue
error:&error
interestHandler:nil];
We get the denial message during accessing the IOService
error 23:17:30.691934-0800 kernel 41 duplicate reports for Sandbox: spotlightknowledged(1399) deny(1) mach-lookup com.apple.diagnosticd
error 23:17:30.691945-0800 kernel System Policy: com.prograde.pgdrefreshpro.helpe(70515) deny(1) iokit-open-service IOUSBHostInterface
Also when we checked the IOUSBHOST logs we can see pipes are stalled while running the RefreshPro app as below-
2025-02-05 22:06:31.838141-0800 0x25913e Error 0x0 0 0 kernel: (IOUSBHostFamily) AppleUSBIORequest: AppleUSBIORequest::complete: device 8 (SD PG05.5@08210000) endpoint 0x00: status 0xe0005000 (pipe stalled): 0 bytes transferred
We need an assistance here to know what exactly could be the cause and how can we elevate the permissions to access the USB device on MacOS15.3.
Do we need other entitlements? As we never faced such issue with our certificate and Identifier on any MacOS versions and with the current entitlements we have.
Do we need to include any entitlement in the code?
Thanks.
I have an app that captures USB storage device and sends some commands to it. The app has a privilege helper tool which captures the USB device. Everything was working fine upto macOS 15.2 but it 15.3 update broke the functionality.
When the helper tool tries to capture the USB device, it is able to capture IOUSBHostDevice but fails to capture IOUSBHostInterface. The error is
Code: 3758097097; Domain: IOUSBHostErrorDomain; Description: Failed to create IOUSBHostInterface.; Reason: Failed [super init]
I have verified the UID, EUID, GID, EGID = 0 for the helper process. So by IOUSBHost documentation it should have worked. The code that cause the error inside the helper tool is
func captureUSBInterface(interface: io_service_t) -> IOUSBHostInterface? {
let queue = DispatchQueue(label: "com.example.usbdevice.queue2")
var capturedInterface: IOUSBHostInterface?
do {
capturedInterface = try IOUSBHostInterface(__ioService: interface, options: .deviceCapture, queue: queue, interestHandler: nil)
} catch {
NSLog("Failed to capture USB interface: \(error)")
return nil
}
return capturedInterface
}
The app has sandbox=False and is distributed outside of the App Store.
Please advise (long-term, short-term solutions) on how to make this work.
1) The circumstances:
iPADOS~>18, USB still-imaging-gadget, 1-3 gadgets might connect simultaneously via USB-hub, proprietary DExt,
UserClient App in developers' iPADs or in TestFlight.
= 1 variation A) UserClientApp has attribute [Background modes][Enable external communications].
= 1 variation B) "active USB-hub" vs "passive".
= 1 variation C) "ConsoleApp logs iPAD" vs "ConsoleApp is not started".
= 1 the term "zombie" below assume issue:
== after plug-in ConsoleApp logs "IOUsbUserInterface::init", "::start";
== UserClient never receives respective callback from IOServiceAddMatchingNotification
== further IOKit APIs "teardown", "restart" and "re-enumeration of connected gadgets" doesn't reveal the zombie (while it sees another simultaneous gadget);
== unplug of the gadget logs "IOUsbUserInterface::stop".
=2) The situation when UserClient is in foreground:
~ everything is fine.
Note in MAC OS everything (same DExt and UserClient-code) works fine in background and in foreground.
=3) The situation when UserClient is in background (beneath ~"Files" or "Safari"):
=3A) "1A=true" phys plugin causes zombie in ~1/20 cases (satisfactory)
=3B) "1A=false" phys plugin causes zombie in ~1/4 cases (non-satisfactory)
=3C) "1 variation B" and "1 variation C" reduce zombies by ~>30%.
=3D) ConsoleApp logs with filter "IOAccessory" (~about USB-energy) always look similar by my eyes.
=4) From Apple-store:
"The app declares support for external-accessory in the UIBackgroundModes"..."The external accessory background mode is intended for apps that communicate with hardware accessories through the External Accessory framework."..."Additionally, the app must be authorized by MFi,"
=5) My wish/ask:
=5 option A) A clue to resolve the "zombie-plugin-issue in background" in a technical manner.
= E.g. find a straightforward solution that ~elevates UserClient's "privileges" in background like [Enable external communication]...
E.g. what ConsoleApp-logs to add/watch to reveal my potential bugs in DExt or in UserClient?
=5 option B) A way to pursue Apple-store to accept (without MFI) an UserClientApp with [Enable external communication].
Hi everyone,
I am seeking clarification regarding the communication capabilities between an ESP32 microcontroller and Apple's latest devices, specifically the iPhone 16 Pro Max and iPad Pro, both equipped with USB-C ports.
Background:
MFi Certification: Historically, establishing communication between external devices and iOS devices required MFi (Made for iPhone/iPad) certification. But I remember this being necessary in the Lightning Cable to USB era.
With the introduction of USB-C ports in recent iPhone and iPad models, there is an indication that MFi certification may no longer be necessary for certain peripherals. Perhaps I'm not confident on the terminology here: https://mfi.apple.com/en/who-should-join
Project Requirements: I am working on a sensor research project that necessitates the collection of low-latency time-series data from an ESP32 microcontroller, which features a USB-C port. The data needs to be transmitted to an iPhone 16 Pro Max or iPad Pro. Bluetooth communication has proven insufficient due to its limited data transfer rates (~1.2 Mbps with L2CAP). While NEHotspot could be an alternative, it restricts the iPad's internet connectivity. Therefore, establishing a direct USB-C connection between the ESP32 and the iOS device appears to be the most viable solution.
Questions:
MFi Certification Necessity: Is MFi certification still required for an ESP32 microcontroller to communicate with iPhone 16 Pro Max or iPad Pro via USB-C?
USB-C Communication Support: Do the iPhone 16 Pro Max and iPad Pro natively support serial communication over USB-C with microcontrollers like the ESP32? If not, are there recommended protocols or interfaces to facilitate this communication?
App Development Considerations: Would developing a custom iOS application be necessary to handle data transmission from the ESP32 over USB-C? If so, are there specific APIs or frameworks provided by Apple to support this functionality?
Data Transfer Rates: Considering the need for high-speed data transfer, are there any limitations or considerations regarding the data transfer rates achievable through a USB-C connection between the ESP32 and iOS devices?
Thank you!
I have an app that needs to seize USB devices, in particular it needs the USBInterfaceOpenSeize call to succeed. I've got a provisioning profile with this entitlement, I've added this plus this entitlement to my app but the USBInterfaceOpenSeize still fails.
Am I correct in thinking this is the correct/only entitlement I need for this?
If so how do I check if I'm using the profile/entitlements correctly?
The call succeeds if I run the application as root which makes me think it's a permissions issue.
Thanks.
Can i use iokit usb lib to disable build-in camera?
Every week or so, mouse driver locks up. The LED laser goes out and none of the buttons operate. It's a generic 7 button USB mouse with my USB keyboard still active. I do not know what precipitates the lockup and a system diagnostic request (Sft-Alt-Ctl-Cmd .) does not seem to yield anything useful.
> ps -ef|grep -i mouse
501 579 1 0 Mon01PM ?? 0:04.42 /System/Library/ExtensionKit/Extensions/MouseExtension.appex/Contents/MacOS/MouseExtension
code-block
so the mouse extension was running at the time. With a "sudo kill -HUP 579" it did not restart.
Also, switching to a different mouse did no good. The mouse driver was behaving like it was deadlocked and I didn't know the correct incantation for restarting it. I power cycle reset the box.
SO:
you have a mouse driver problem
it cannot be just me
It behaves like a deadlock, but not knowing how to get a mouse driver dump, I cannot tell what lock(s) its waiting for.
Hi,
I need to write an application (possibly using C) to communicate with a USB High Speed Device CDC class I am developing, but unfortunately I have no development experience under Mac OS, so I am here to ask for a few help/advice. I hope I am in the right place.
Since I have a working code using libusb on Linux, I have first tried to use such lib on a Mac OS without success. The device is listed correctly using
ioreg -w0 -l -p
but it seems to be always busy:
MYUSBDEVICE@fa410000 <class IOUSBHostDevice, id 0x100001769, registered, matched, active, busy 0 (262 ms), retain 24>
in fact, attempting to use libusb always results in error:
LIBUSB_ERROR_NOT_FOUND
libusb_bulk_transfer: Entity not found
After searching a bit, I have read that it is impossible (?) to use libusb on MacOS.
Then I came across these following pages:
https://developer.apple.com/library/archive/documentation/DeviceDrivers/Conceptual/USBBook/USBDeviceInterfaces/USBDevInterfaces.html
https://developer.apple.com/documentation/usbdriverkit
I would possible avoid to write a CDC kernel driver for my application, so link #2 seems more appropriate to what I need.
But isn't it available any API to develop USB CDC communications C application on MacOS ?
Any suggestion is appreciated.
Thanks in advance.
Regards,
Simon
Hi,
This is the code snippet in my driver for an usb uart device. I am trying to call standard cdc-acm command to set the Line Coding in the device, but fails with this error:
"USBSendSetLineCoding - Failed : 0xe0005000, bytes transferred: 0"
I guess the USB device is returning this error due to incorrect buffer or format. There is no proper documentation on how to use IOMemoryDescriptor when the data has to be passed down in a buffer to the usb stack. (IOUSBHostInterface->DeviceRequest())
Can anyone please point out what is wrong with this code and suggest a right method?
void MyDriver::USBSendSetLineCoding(uint32_t BaudRate, uint8_t StopBits, uint8_t TX_Parity, uint8_t CharLength)
{
kern_return_t ret = kIOReturnSuccess;
LineCoding *lineParms;
uint16_t lcLen = sizeof(LineCoding)-1;
lineParms = (LineCoding *)IOMalloc(lcLen);
if (!lineParms)
{
MyDebugLog("USBSendSetLineCoding - allocate lineParms failed");
return;
}
bzero(lineParms, lcLen);
lineParms->bCharFormat = StopBits - 2;
lineParms->bParityType = TX_Parity - 1;
lineParms->bDataBits = CharLength;
OSSwapBigToHostInt32(BaudRate);
lineParms->dwDTERate = BaudRate;
IOBufferMemoryDescriptor* bufferDescriptor = nullptr;
_controlInterface->CreateIOBuffer(kIOMemoryDirectionOut, lcLen, &bufferDescriptor);
IOMemoryMap *map = nullptr;
bufferDescriptor->CreateMapping(kIOMemoryMapReadOnly, 0, 0, 0, 0, &map);
if(map == nullptr)
{
MyDebugLog("USBSendSetLineCoding - Failed to map memory in CreateMapping\n");
IOFree(lineParms, lcLen);
bufferDescriptor->release();
return;
}
uint64_t ptr = map->GetAddress();
if(!ptr)
{
MyDebugLog("USBSendSetLineCoding - Failed to get Memory Address\n");
IOFree(lineParms, lcLen);
bufferDescriptor->release();
map->release();
return;
}
memcpy(&ptr, lineParms, lcLen);
uint8_t bmRequestType = kIOUSBDeviceRequestDirectionOut | kIOUSBDeviceRequestTypeClass | kIOUSBDeviceRequestRecipientInterface;
uint16_t wValue = 0;
uint16_t wIndex = _bControlInterfaceNumber;
uint16_t bytesTransferred = 0;
ret = _controlInterface->DeviceRequest(bmRequestType, kUSBSET_LINE_CODING, wValue, wIndex, lcLen, bufferDescriptor, &bytesTransferred, 1000);
IOFree(lineParms, lcLen);
map->release();
bufferDescriptor->release();
if (ret != kIOReturnSuccess) {
MyDebugLog("USBSendSetLineCoding - Failed : 0x%x, bytes transferred: %d\n", ret, bytesTransferred);
return;
}
return;
}
I am able to call DeviceRequest() successfully on the same interface for any other setting that requires no data buffer, such as,
"ret = _controlInterface->DeviceRequest(bmRequestType, kUSBSEND_BREAK, wValue, wIndex, 0, NULL, &bytesTransferred, 1000);"
So I think the "bufferDescriptor" is not properly created or the data is not copied correctly in this function for the failure.
"ret = _controlInterface->DeviceRequest(bmRequestType, kUSBSET_LINE_CODING, wValue, wIndex, lcLen, bufferDescriptor, &bytesTransferred, 1000);"
Any help is very much appreciated. Thanks in advance.
Background Information
In the macOS operating system environment, Program A uses libusb to access USB devices that comply with the USB Mass Storage protocol. To enable Program A to start automatically after macOS boots, its corresponding plist file has been placed in the /Library/LaunchDaemons directory.
Problem and Phenomenon Description
Program A works well on macOS versions prior to 15.3, and it can access USB devices normally. However, on macOS 15.3, the following abnormal situations have occurred:
A. Program A launched by launchd cannot access the USB device. Checking the logs reveals that the IOCreatePlugInInterfaceForService call in the darwin_claim_interface function returns the error code e00002be.
B. Program A launched from the terminal command line with sudo privileges can access the USB device normally, and the return value of the IOCreatePlugInInterfaceForService call is 0.
I developed a driverkit extension based on overriding-the-default-usb-video-class-extension, but the link didn’t give the details of realization. I asked DTS who gave two tips:
1, Do you also have a CMIO extension to load in place of the default overriding-the-default-usb-video-class-extension
2, Your DriverKit extension’s info.plist is also missing the CameraAssistantBundleID.
I want to know why a driverkit extension needs a CMIO extension, what’s the data and control flow?
I am trying to open the CommunicationControl class IOUSBHostInterface in my USB driver, but it only seems to open on iPad Airs and not iPad Pros.
I'm calling
ivars->interruptInterface->Open(this, 0, NULL);
After retrieving the interruptInterface from the device's InterfaceIterator. I try and open this, but on iPad Pros it returns kIOReturnNotOpen. I've tried closing and reopening the IOUSBHostDevice, closing and reopening the Interface, AbortDeviceRequests before opening, etc. but it just seems to work on iPad Air and not iPad Pro.
I've tried on both iPadOS 17.6.1 and 18.2
Has anyone else seen this?
Hello!
We currently require the development of an iOS system for encrypting and authorizing photos, videos, voice memos, or other files stored on our devices to a connected USB-C storage. The encrypted files can be accessed through authorization. We have already encrypted and authorized the files to be stored on the app's mobile storage, and cannot directly store them to USB-C (this requirement is based on the Apple camera RroRes, which uses external storage for direct storage). We are seeking technical support from Apple.
สินค้าที่เกี่ยวข้องกับการใช้งานประจำวัน
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
APNS
APFS
IOUSBHost
Design
I'm working on a project to allow HID input from macOS to a connected iOS device. Are we prohibited from matching to a connected iPhone with DriverKit? I see the attribute kCDCDoNotMatchThisDevice for my iPhone is YES when looking at the IO registry and my dext does not initialize
When plugging in my matched USB device I see the logs below. It seems the kernelmanagerd process is sandboxed and can't write out the reason my Dext failed to load. Is there somewhere else I can look for this info?
default 11:03:22.175152-0700 kernelmanagerd Received kext load notification: me.keithg.MyUserUSBInterfaceDriver
default 11:03:22.177637-0700 kernel 1 duplicate report for Sandbox: icdd(2124) allow file-read-data /Library/Image Capture/Devices
error 11:03:22.177681-0700 kernel Sandbox: kernelmanagerd(545) deny(1) file-write-create /private/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/com.apple.kernelmanagerd/TemporaryItems
com.apple.libcoreservices error 11:03:22.177711-0700 kernelmanagerd mkdir: path=/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T/com.apple.kernelmanagerd/TemporaryItems/ mode= -rwx------: [1: Operation not permitted]
error 11:03:22.179361-0700 kernel Sandbox: kernelmanagerd(545) deny(1) file-write-create /private/var/db/loadedkextmt.plist.sb-5a00fc77-LNttZF
com.apple.libcoreservices error 11:03:22.177755-0700 kernelmanagerd _dirhelper_relative_internal: error for path <private>: [1: Operation not permitted]
com.apple.accessories default 11:03:22.177674-0700 WindowServer Sending analytics event... (eventName: com.apple.ioport.transport.USB.published)
error 11:03:22.179913-0700 kernelmanagerd Failed to write extension load report plist.
We have a macOS application which interacts with our USB and PCI devices to perform SCSI and NVME commands on them.
We use IOUSBHost, IOUSBLib and IOKitLib for USB interface and have created a custom driver to interact with PCI devices.
Is there a way we can implement a similar functionality for iOS as well if we connect the cards and readers using OTG?
Hi all,
In MacOS, how can I disable or enable build-in camera by program or script?
Hello everyone,
We're working on an iOS app that needs to connect to a non-Apple pre-operating system using USB for serial communication. Our goal is to send and receive data between an iPhone and a UEFI-based system directly over USB.
We've created a proof of concept using the USBMux protocol, which let us exchange basic messages. However, we're running into problems with the USB endpoint setup. In some cases, the USB communication doesn't start or stay connected.
Since this is for a pre-boot environment, it might not fit into the usual iOS USB communication frameworks. We're looking for help with the following:
Any guidance or documentation on setting up USB serial communication between an iPhone and a non-Apple pre-boot system
Information on system APIs, frameworks, or protocols that iOS supports for direct USB communication in this scenario
Access to official USBMux documentation or specs to understand its limitations and capabilities better
Whether this communication requires MFi certification or if there are other Apple-supported interfaces we can use
Thank you!