I would like to write a driver that supports our custom USB-C connected device, which provides a serial port interface. USBSerialDriverKit looks like the solution I need. Unfortunately, without a decent sample, I'm not sure how to accomplish this. The DriverKit documentation does a good job of telling me what APIs exist but it is very light on semantic information and details about how to use all of these API elements. A function call with five unexplained parameters just is that useful to me.
Does anyone have or know of a resource that can help me figure out how to get started?
Drivers
RSS for tagUnderstand the role of drivers in bridging the gap between software and hardware, ensuring smooth hardware functionality.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Hi everyone.
I have an iOS application for work with an MFi-certified device connected to the iPhone via USB-C.
When I launch the app and attach the device, I can create an EASession and use the InputStream and OutputStream as usual.
But if I attach the device before launching the app I can't use the InputStream and OutputStream, because the hasBytesAvailable and hasSpaceAvailable properties are always false.
The NSStreamEventHasBytesAvailable and NSStreamEventHasSpaceAvailable events will never be triggered.
After I re-attach the device, the streams open fine and I can interact with the device.
What can be wrong with the case of attaching the device before the app launches?
Since updating to 18.0 & 18.1 I’ve have issues with CarPlay connected via usb, phone calls specifically where people would say I sound distant and robotic distortion. Tried other vehicles same issue new usb same issue, tried all recommendations with no success some one who refused to update theirs worked well without any issues I’m currently facing. Any suggestions or there gonna be an update that addresses this issue ?
Topic:
App & System Services
SubTopic:
Drivers
Hello
Currently, we are developing an application that collects measurement data from devices via USB port but we have some problems regarding input buffer size that might reduce the reading speed.
The data size is quite big (~1.5 million bytes).
For every read action, the app will check the available size in the input buffer by command:
ioctl(serialPort.hHandle, FIONREAD, readBuffSize)
Then that size will be passed as the desired size for the read command.
Between read actions, there will be a short sleep (1 - 3 ms).
Please confirm some points below:
Regardless of the size of the measure data, the available size will only be up to 1020 bytes, is it expected?
Is the above size OS defined or driver defined? Could we increase it?
As we checked, there were some missing bytes between the measure data and the actual read data. Is there any chance that the data in the input buffer be overwritten while the read thread is in sleep?
Any recommended technique that can increase reading speed while still maintaining the integrity of the data?
Tested OS: Sonoma 14.5
Hello, Apple developers. I have joined the MFi certification program. My Accessory to use USB HID IAP2 communication protocol and IOS devices connected, but in the first step, the Accessory to send the following data (0 XFF, 0 x55, 0 x02, 0 x00 to 0 xee, 0 x10) for IOS devices, but the IOS devices have no response, this is probably the reason why?
I have been working on a multi-platform multi-touch HID-standard digitizer clickpad device.
The device uses Bluetooth Low Energy (BLE) as its connectivity transport and advertises HID over GATT. To date, I have the device working successfully on Windows 11 as a multi-touch, gesture-capable click pad with no custom driver or app on Windows.
However, I have been having difficulty getting macOS to recognize and react to it as a HID-standard multi-touch click pad digitizer with either the standard Apple HID driver (AppleUserHIDEventDriver) or with a custom-coded driver extension (DEXT) modeled, based on the DTS stylus example and looking at the IOHIDFamily open source driver(s).
The trackpad works with full-gesture support on Windows 11 and the descriptors seem to be compliant with the R23 Accessory Guidelines document, §15.
With the standard, matching Apple AppleUserHIDEventDriver HID driver, when enumerating using stock-standard HID mouse descriptors, the device works fine on macOS 14.7 "Sonoma" as a relative pointer device with scroll wheel capability (two finger swipe generates a HID scroll report) and a single button.
With the standard, matching Apple AppleUserHIDEventDriver HID driver, when enumerating using stock-standard HID digitizer click/touch pad descriptors (those same descriptors used successfully on Windows 11), the device does nothing. No button, no cursor, no gestures, nothing. Looking at ioreg -filtb, all of the key/value pairs for the driver match look correct.
Because, even with the Apple open source IOHIDFamily drivers noted above, we could get little visibility into what might be going wrong, I wrote a custom DriverKit/HIDDriverKit driver extension (DEXT) (as noted above, based on the DTS HID stylus example and the open source IOHIDEventDriver.
With that custom driver, I can get a single button click from the click pad to work by dispatching button events to dispatchRelativePointerEvent; however, when parsing, processing, and dispatching HID digitizer touch finger (that is, transducer) events via IOUserHIDEventService::dispatchDigitizerTouchEvent, nothing happens.
If I log with:
% sudo log stream --info --debug --predicate '(subsystem == "com.apple.iohid")'
either using the standard AppleUserHIDEventDriver driver or our custom driver, we can see that our input events are tickling the IOHIDNXEventTranslatorSessionFilter HID event filter, so we know HID events are getting from the device into the macOS HID stack. This was further confirmed with the DTS Bluetooth PacketLogger app. Based on these events flowing in and hitting IOHIDNXEventTranslatorSessionFilter, using the standard AppleUserHIDEventDriver driver or our custom driver, clicks or click pad activity will either wake the display or system from sleep and activity will keep the display or system from going to sleep.
In short, whether with the stock driver or our custom driver, HID input reports come in over Bluetooth and get processed successfully; however, nothing happens—no pointer movement or gesture recognition.
STEPS TO REPRODUCE
For the standard AppleUserHIDEventDriver:
Pair the device with macOS 14.7 "Sonoma" using the Bluetooth menu.
Confirm that it is paired / bonded / connected in the Bluetooth menu.
Attempt to click or move one or more fingers on the touchpad surface.
Nothing happens.
For the our custom driver:
Pair the device with macOS 14.7 "Sonoma" using the Bluetooth menu.
Confirm that it is paired / bonded / connected in the Bluetooth menu.
Attempt to click or move one or more fingers on the touchpad surface.
Clicks are correctly registered. With transducer movement, regardless of the number of fingers, nothing happens.
I'm tryng to develop a software that can connect an iPhone to a HMI Box in order to use CarPlay and test an app for CarPlay.
Since the starting point is to ask the device, i.e. the iPhone, if it supports CarPlay, I have to write a USB Vendor-Specific Request that the accessory send to know for this capability.
I would like to know what are the specific parameters to include in the control transfer request from accessory to device, especially: bRequest, wValue, wIndex. I've studied the whole Accessory Interface Specification Carplay Addendum, but i couldn't find anything.
Thanks in advance for your support.
Hi, I’m developing my own Pcie Ethernet driverkit. My Pcie Ethernet card connect on Razor Core X and connect to MacBook via thunderbolt 3.
The Problem:
Click Driver application and send activate system extension request, then go to System setting -> Privacy & Security, in Extension section ->click “allow” , the peripherals malfunction immediately after "allow" clicked and type in the password.I can't control all peripherals devices like touchpad, keyboard and all of thunderbolt ports. However, it can regain functionality after plugging and unplugging the device.
results I expected:
User approve Driver Extensions enable and all peripherals work normally and Ethernet Card works.
Has anyone encountered this problem? maybe something wrong in "OSSystemExtensionRequestDelegate" but I have no idea how to fix it
Please Help.
My Xcode version is Version 15.3 (15E204a).
Thanks
I have a driver project where I'm opening and closing a connection to a custom driver.
If I do what I think I need to be doing to unmap the memory, when I try to open the service again, it fails. If I skip the step where I do that unmapping, the service opens successfully.
If I call unmap() before trying to call openConnection() again, it will fail with a -308 error return code. If I skip that call to unmap(), it works and I'm able to communicate with my device.
Here's the code where I open the service:
public func openConnection() throws {
guard !isOpen else { return }
// Open device
var connection: io_connect_t = IO_OBJECT_NULL
var result = IOServiceOpen(device, mach_task_self_, 0, &connection)
if result != kIOReturnSuccess {
NSLog("Failed opening device with error: 0x%08x.\n", result);
throw NSError.cdc_kernelReturnErrorWithError(result)
}
defer { IOConnectRelease(connection) }
if device == IO_OBJECT_NULL || connection == IO_OBJECT_NULL {
throw NSError.cdc_kernelReturnErrorWithError(result)
}
let receiveDataMappedMemory = ClientDriverMappedMemory(connection: connection, memoryType: MappedMemoryType_ReceiveDataBuffer)
try receiveDataMappedMemory.map()
let transmitDataMappedMemory = ClientDriverMappedMemory(connection: connection, memoryType: MappedMemoryType_TransmitDataBuffer)
try transmitDataMappedMemory.map()
// Setup async notification
IONotificationPortSetDispatchQueue(dataReceivedPort, dataReceivedQueue)
let callbackPort = IONotificationPortGetMachPort(dataReceivedPort)
let input = DataStruct(foo: 0, bar: 0)
var output = DataStruct(foo: 0, bar: 0)
var outputSize = MemoryLayout<DataStruct>.size
// Trampoline to C function because I don't quite know how to make this work in Swift
result = setupCallback(self, connection, callbackPort, input, &output, &outputSize)
if result != kIOReturnSuccess {
NSLog("Error registering async callback with driver: \(result)");
throw NSError.cdc_kernelReturnErrorWithError(result)
}
self.connection = connection
self.receivedDataMappedMemory = receiveDataMappedMemory
self.transmitDataMappedMemory = transmitDataMappedMemory
}
map() and unmap() functions:
- (BOOL)mapWithError:(NSError **)error
{
error = error ?: &(NSError * __autoreleasing){ nil };
kern_return_t result = IOConnectMapMemory64(self.connection,
self.memoryType,
mach_task_self(),
&_address,
&_size,
kIOMapAnywhere);
if (result != kIOReturnSuccess) {
*error = [NSError cdc_kernelReturnErrorWithError:result];
return NO;
}
self.mapped = YES;
return YES;
}
- (BOOL)unmapWithError:(NSError **)error
{
error = error ?: &(NSError * __autoreleasing){ nil };
kern_return_t result = IOConnectUnmapMemory64(self.connection,
self.memoryType,
mach_task_self(),
_address);
if (result != kIOReturnSuccess) {
*error = [NSError cdc_kernelReturnErrorWithError:result];
return NO;
}
self.mapped = NO;
return YES;
}
Any insights? What all should I be doing to close the service? Why would the unmapping create this issue or what else could the -308 error be indicated has gone wrong?
Is anyone having any luck getting there phone fixed?
I have recently done the iOS 18.1 update and then my phone camera has stopped working.
i don’t appear to be on my own either but burnt seeing any positive posts about apple cooperating?
not sure how it can be my fault if their software has caused it? I am out of warranty too
Topic:
App & System Services
SubTopic:
Drivers
#4 Thread
NSInternalInconsistencyException
Call must be made on main thread
CoreFoundation ___exceptionPreprocess + 164
libsystem_pthread.dylib _start_wqthread + 8
#0 Thread
semaphore_wait_trap
libsystem_kernel.dylib semaphore_wait_trap + 8
libdispatch.dylib 0x00000001b96ed000 + 457547470247841612
UnityFramework Staticburst_initialize + 17597401577822386088
UnityFramework DllCanUnloadNow + 52172
UnityFramework. DllCanUnloadNow + 51292
UnityFramework DllCanUnloadNow + 421068
UnityFramework. Unityplcrash_async_mach_exception_get_siginfo + 5073080
UnityFramework. GlobalizationNative_GetTimeZoneDisplayName + 1585284
UnityFramework. GlobalizationNative_GetTimeZoneDisplayName + 926212
UnityFramework. 0x000000010ce18000 + 77478852
UnityFramework. GlobalizationNative_GetTimeZoneDisplayName + 124804
UnityFramework. GlobalizationNative_GetTimeZoneDisplayName + 124592
UnityFramework. _ZdaPvRKSt9nothrow_t + 2445400
UnityFramework. _ZdaPvRKSt9nothrow_t + 2502608
UnityFramework. _ZdaPvRKSt9nothrow_t + 2556896
UnityFramework. _ZdaPvRKSt9nothrow_t + 2555820
UnityFramework. _ZdaPvRKSt9nothrow_t + 211836
UnityFramework. _ZdaPvRKSt9nothrow_t + 1216980
UnityFramework. _ZdaPvRKSt9nothrow_t + 1145620
UnityFramework. _ZdaPvRKSt9nothrow_t + 1145684
UnityFramework. _ZdaPvRKSt9nothrow_t + 1146408
UnityFramework. UnitySendMessage + 6940844
UnityFramework. _Z12DecodeBase64PKhPhi + 138076
QuartzCore. 0x00000001b2d06000 + 193228
UIKitCore. UIApplicationMain + 1589427071078105428
UnityFramework. _Z12DecodeBase64PKhPhi + 11056988545834161928
Topic:
App & System Services
SubTopic:
Drivers
Run on Xcode
Unchecked Scheme -> Run -> 'Debug excitable' is fine.
But, I need the debug log, how to fix?
i tried opening iMovie for the first time on my 2017 Macbook Air but i get an error saying that iMovie is too new to my mac but i was trying to run the built in one it says i need to downgrade it on the appstore but there is no option to downgrade
Topic:
App & System Services
SubTopic:
Drivers
Hi Team ,
I want to create a system where i can mirror the iPhone screen connected through USB and control it from the web browser.
can anyone help me ?
Thanks ,
Mukta
Topic:
App & System Services
SubTopic:
Drivers
Hi there. I inadvertently deleted the Passwords app. The App Store is telling me restrictions are enabled so I can’t reinstall from the cloud. Not sure where to go from here. Help.
Topic:
App & System Services
SubTopic:
Drivers
We are developing an iOS app that communicates with a device using an NXP NTAG 5 chip in ISO15693 pass-through mode. While the app works flawlessly on older iPhone models (iPhone 8, SE, X) and most Android devices, we are experiencing severe reliability issues on iPhone 12, 13, 14, and 15.
Issue Summary
On newer iPhones (12–15), 90% of communication attempts fail.
Retry strategies do not work, as the NFC session is unexpectedly canceled while handling CoreNFC custom commands.
The issue is not consistent—sometimes all requests fail immediately, while other times, a batch of reads might succeed unexpectedly before failing again.
Technical Details
The failure occurs while executing the following request, which should return 256 bytes:
tag.customCommand(requestFlags: .highDataRate, customCommandCode: commandCode, customRequestParameters: Data(byteArray)) { (responseData, error) in
}
The returned error is:
-[NFCTagReaderSession transceive:tagUpdate:error:]:897 Error Domain=NFCError Code=100 "Tag connection lost" UserInfo={NSLocalizedDescription=Tag connection lost}
For reference, we tested a comparable STM ST25 chip in ISO15693 and NDEF mode, and the exact same issue occurs.
Observations and Debugging Attempts
Positioning of the NFC antenna has been tested extensively.
Disabling Bluetooth and Wi-Fi does not improve reliability.
Rebooting the device or waiting between attempts sometimes improves success rates but does not provide a structural fix.
When reading multiple blocks (e.g., 15 blocks of 256 bytes each):
The process often fails within the first three blocks.
After multiple failures, it may suddenly succeed in reading all blocks in one go before returning to a series of failures.
The nfcd logs suggest issues at the low-level NFC and SPMI layers, indicating potential hardware or firmware-related problems:
error 17:36:18.289099+0100 nfcd phOsalNfc_LogStr:65 NCI DATA RSP : Timer expired before data is received!
error 17:36:18.292936+0100 nfcd NFHardwareSerialQuerySPMIError:1339 "Invalid argument" errno=22 setsockopt: SYSPROTO_CONTROL:IO_STOCKHOLM_SPMIERRORS
error 17:36:18.293036+0100 nfcd phTmlNfc_SpmiDrvErrorStatus:1157 "Invalid argument" errno=22 Failed to query SPMI error registers
error 17:36:18.293235+0100 nfcd phOsalNfc_LogStr:65 phLibNfc_SpmiStsRegInfoNtfHandler: Read Spmi Status Failed - pInfo set to NULL
error 17:36:18.293313+0100 nfcd _Callback_NFDriverNotifyGeneral:2353 Unknown notification: 0x5b
error 17:36:18.294163+0100 nfcd phOsalNfc_LogStr:65 Target Lost!!
error 17:36:18.294678+0100 nfcd -[_NFReaderSession handleSecureElementTransactionData:appletIdentifier:]:164 Unimplemented
error 17:36:18.294760+0100 nfcd -[_NFReaderSession handleSecureElementTransactionData:appletIdentifier:]:164 Unimplemented
error 17:36:18.320132+0100 nfcd phOsalNfc_LogStr:65 ISO15693 XchgData,PH_NCINFC_STATUS_RF_FRAME_CORRUPTED Detected by NFCC during Data Exchange
error 17:36:18.320291+0100 nfcd phOsalNfc_LogU32:74 phNciNfc_ChkDataRetransmission: Re-transmitting Data pkt Attempt..=1
error 17:36:18.622050+0100 nfcd phOsalNfc_LogStr:65 NCI DATA RSP : Timer expired before data is received!
error 17:36:18.625857+0100 nfcd NFHardwareSerialQuerySPMIError:1339 "Invalid argument" errno=22 setsockopt: SYSPROTO_CONTROL:IO_STOCKHOLM_SPMIERRORS
error 17:36:18.625919+0100 nfcd phTmlNfc_SpmiDrvErrorStatus:1157 "Invalid argument" errno=22 Failed to query SPMI error registers
error 17:36:18.626132+0100 nfcd phOsalNfc_LogStr:65 phLibNfc_SpmiStsRegInfoNtfHandler: Read Spmi Status Failed - pInfo set to NULL
error 17:36:18.626182+0100 nfcd _Callback_NFDriverNotifyGeneral:2353 Unknown notification: 0x5b
error 17:36:18.626899+0100 nfcd phOsalNfc_LogStr:65 Target Lost!!
error 17:36:18.627482+0100 nfcd -[_NFReaderSession handleSecureElementTransactionData:appletIdentifier:]:164 Unimplemented
error 17:36:18.627568+0100 nfcd -[_NFReaderSession handleSecureElementTransactionData:appletIdentifier:]:164 Unimplemented
error 17:36:18.833174+0100 nfcd -[_NFReaderSession handleSecureElementTransactionData:appletIdentifier:]:164 Unimplemented
error 17:36:19.145289+0100 nfcd phOsalNfc_LogStr:65 NCI DATA RSP : Timer expired before data is received!
error 17:36:19.149233+0100 nfcd NFHardwareSerialQuerySPMIError:1339 "Invalid argument" errno=22 setsockopt: SYSPROTO_CONTROL:IO_STOCKHOLM_SPMIERRORS
error 17:36:19.149353+0100 nfcd phTmlNfc_SpmiDrvErrorStatus:1157 "Invalid argument" errno=22 Failed to query SPMI error registers
error 17:36:19.149730+0100 nfcd phOsalNfc_LogStr:65 phLibNfc_SpmiStsRegInfoNtfHandler: Read Spmi Status Failed - pInfo set to NULL
error 17:36:19.149797+0100 nfcd _Callback_NFDriverNotifyGeneral:2353 Unknown notification: 0x5b
error 17:36:19.150463+0100 nfcd phOsalNfc_LogStr:65 Target Lost!!
Any solutions?
Has anyone else encountered similar behavior with CoreNFC on iPhone 12–15? Could this be related to changes in NFC hardware or power management in newer iPhone models? Any suggestions on possible workarounds or alternative approaches would be greatly appreciated.
Hello Everyone,
I am trying to develop a DriverKit for RAID system, using PCIDriverKit & SCSIControllerDriverKit framework. The driver can detect the Vendor ID and Device ID. But before communicating to the RAID system, I would like to simulate a virtual Volume using a memory block to talk with macOS.
In the UserInitializeController(), I allocated a 512K memory for a IOBufferMemoryDescriptor* volumeBuffer, but fail to use Map() to map memory for volumeBuffer.
result = ivars->volumeBuffer->Map(
0, // Options: Use default
0, // Offset: Start of the buffer
ivars->volumeSize, // Length: Must not exceed buffer size
0, // Flags: Use default
nullptr, // Address space: Default address space
&mappedAddress // Output parameter
);
Log("Memory mapped completed at address: 0x%llx", mappedAddress); // this line never run
The Log for Map completed never run, just restart to run the Start() and makes this Driver re-run again and again, in the end, the driver eat out macOS's memory and system halt.
Are the parameters for Map() error? or I should not put this code in UserInitializeController()?
Any help is appreciated!
Thanks in advance.
Charles
I'm trying to iterate through a USB device but the iterator is always empty or contains only the matched interface:
Single interface in Iterator
This happens when my driver matches against the interface. Because I need to use 2 interfaces (control and cdc), I try to open the IOUSBHostDevice (copied from the interface) and iterate through the rest, but I only get the interface my dext matched with.
Empty Iterator
I decided to match against USB communication devices, thinking things would be different. However, this time the interface iterator is completely empty (provider is IOUSBHostDevice).
Here's a snippet of my code before iterating with IOUSBHostDevice->CopyInterface():
// teardown the configured interfaces.
result = device->SetConfiguration(ivars->Config, true);
__Require_noErr_Action(result, _failure_Out,
ELOG("IOUSBHostDevice::SetConfiguration failed 0x%x", result));
// open usb device
result = device->Open(this, 0, 0);
__Require_noErr_Action(result, _failure_Out,
ELOG("Failed to open IOUSBHostDevice"));
// Get interface iterator
result = device->CreateInterfaceIterator(&iterRef);
__Require_noErr_Action(result, _failure_Out,
ELOG("IOUSBHostDevice::CreateInterfaceIterator failed failed: 0x%x", result));
Hello,
We are experiencing some issues with our USB accessory unexpectedly charging the iOS device it is connected with only when the iOS device supports USB-C and is on iOS 18+
The following is a description of the discrepancy we note between iOS versions:
After performing a USB Role switch, our Accessory becomes a typical USB Device and the Apple device becomes the USB host.
with iOS 17:
The Accessory then sends a PowerSourceUpdate message to the iOS 17 device via iAP2 protocol. Apple device has a USB Type C Connector. *
We are specifying:
AvailableCurrentForDevice = 0 mA
DeviceBatteryShouldChargeIfPowerIsPresent = 1.
Three observations:
iPad Battery Settings page - we observe 'Last charged to…' (indicating no charging)
On the Lumify App running (iOS 17), we observe that UIKit.current.batteryState indicated 'Not charging'
Battery icon on top right of the screen indicates 'No Charging'
with iOS 18:
The same Accessory sends the same PowerSourceUpdate message to the iOS 18 device via iAP2 protocol using USB Type C Connector.
We are specifying the same:
AvailableCurrentForDevice = 0 mA
DeviceBatteryShouldChargeIfPowerIsPresent = 1.
We observe:
iPad Battery Settings page - we observe 'Charging'
On the Lumify App running (iOS 18), we observe that UIKit.current.batteryState indicated 'Charging'
Battery icon on top right of the screen indicates 'No Charging'
Please could you help us understand why the Battery status is showing as 'Charging' in the Settings page and with the 'UIKit.current.batteryState' even though we have specified 'AvailableCurrentForDevice = 0 mA'?
Since our accessory is heavily reliant on the Battery status / Charging state, is there potentially another way we get an accurate battery charging status that we are missing? Or are there other suggestions outside of what we do currently to ensure our accessory does not place the iOS18 device into a charging state?
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