Custom USB Network Device Driver on iPhone

Hi,

We are using the AX88772C as a USB->Ethernet bridge in a product we are developing. Due to the chip not following the NCM protocol, it is not supported by the default networking drivers on the iPhone. Initially, we intended on using DriverKit to develop a userspace driver for this device. However, we have been informed DriverKit is only available on iPad OS, not iOS.

As such is the case, we have found two possible alternatives. First being IOkit, and the second being External Accessory Session (EASession).

What are the limitations of each of these options? We need the ability to send and receive USB packets to Control and Bulk endpoints. Is this possible with either of the options defined above? Would either of these options require the device to be MFi certified?

We have read that some APIs within IOkit require the apple device to be jailbroken. Is there a list of features that can be used without a jailbroken device? Documentation on these 2 options is limited, so any official documentation would be great.

Thanks!

Answered by DTS Engineer in 860672022

You don’t have a lot of options in this space.

we have been informed DriverKit is only available on iPadOS, not iOS.

That’s correct.

First being IOkit

macOS is the only platform that supports I/O Kit drivers [1].

the second being External Accessory Session (EASession).

There are two problems here:

  • External Accessory framework can only talk to accessories that are built under the aegis of the MFi programme. If you have an existing accessory that wasn’t built that way, you can’t talk to it with EA.
  • External Accessory framework allows apps to talk to hardware. It doesn’t let you publish a network driver that’s visible to the rest of the system.

I think your best option here is to work with your chip vendor to update their firmware to work with iOS’s built-in USB Ethernet driver.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Lemme tackle this:

We have read that some APIs within IOkit require the apple device to be jailbroken.

I/O Kit is an implementation detail on iOS. As such, that’s not something we can talk about here on the Apple Developer Forums, which is primarily focused on APIs (things that you can reasonably expect to work today and in the future). If you want to talk about iOS’s implementation at that level, there are plenty of other places on the ’net for that.

I should note that I/O Kit is both an API and a KPI (Kernel Programming Interface). A lot of the info out there on the ’net is about the API, but an I/O Kit network driver is an in-kernel thing.

You don’t have a lot of options in this space.

we have been informed DriverKit is only available on iPadOS, not iOS.

That’s correct.

First being IOkit

macOS is the only platform that supports I/O Kit drivers [1].

the second being External Accessory Session (EASession).

There are two problems here:

  • External Accessory framework can only talk to accessories that are built under the aegis of the MFi programme. If you have an existing accessory that wasn’t built that way, you can’t talk to it with EA.
  • External Accessory framework allows apps to talk to hardware. It doesn’t let you publish a network driver that’s visible to the rest of the system.

I think your best option here is to work with your chip vendor to update their firmware to work with iOS’s built-in USB Ethernet driver.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] Lemme tackle this:

We have read that some APIs within IOkit require the apple device to be jailbroken.

I/O Kit is an implementation detail on iOS. As such, that’s not something we can talk about here on the Apple Developer Forums, which is primarily focused on APIs (things that you can reasonably expect to work today and in the future). If you want to talk about iOS’s implementation at that level, there are plenty of other places on the ’net for that.

I should note that I/O Kit is both an API and a KPI (Kernel Programming Interface). A lot of the info out there on the ’net is about the API, but an I/O Kit network driver is an in-kernel thing.

It’s better to reply as a reply, rather than in the comments; see Quinn’s Top Ten DevForums Tips for this and other titbits.

we do not wish to create a driver visible by the entire system.

Well, that certainly simplifies things. For example, it makes an EA-based solution feasible (although the EA-based solution still requires MFi hardware).

Are there any APIs that give an application access to a raw USB interface … in userspace?

Not on iOS.

On macOS you can do this using the I/O Kit API [1]. And on iPadOS you can achieve similar functionality using DriverKit. But iOS has neither of those options.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] You can also do it using the KPI, but that just complicates things unnecessarily.

Hi Quinn, Noted, will use reply feature from now on.

We are in the process of applying for MFi. Apart from the MFi certification, are there any other requirements for an EA-based solution? For example are there limits to how we can interact with the device?

From what I have read about EASessions, we provide the communication protocol that will be used. Will this allow us to create custom protocols? Does this include selecting the USB interface/interfaces?

We are just trying to determine the feasibility of developing an app to communicate with this device.

If we are able to create custom protocols, and send USB packets to the device this way; what is the best way for us to create a test implementation in which we validate the solution will work?

Thanks, Mike

For example are there limits to how we can interact with the device?

An MFi accessory can support the External Accessory framework, which has a very specific communication model. Notably, it doesn’t expose a USB-like API. Rather, your accessory has to implement an MFi-specific on-the-wire protocol that ‘connects’ it to the input and output streams exposed to EA. After that, it’s up to you what commands to run over those streams.

I can’t go into the details about the MFi side of this because that info isn’t public.


Creating an EA-compatible accessory is a bit of a faff, so I’d definitely explore options outside of that space. For example, an off-the-shelf USB Ethernet dongle will Just Work™ with iOS, at which point you can communicate using standard networking APIs. That definitely has its limitations [1], but EA also has a bunch of limitations. And the advantage with a USB Ethernet dongle is that you can explore those limitations without getting any special permission from Apple.

Likewise with Bluetooth LE and the Core Bluetooth framework.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] For example, you’ll likely bump into local network privacy.

your accessory has to implement an MFi-specific on-the-wire protocol

FYI, that protocol is called iAP.

That stands for i Accessory Protocol, where the i expands as it does with MFi.

I didn’t mention that earlier because much of MFi is not disclosed publicly and, as I don’t support it day-to-day, it’s hard for me to keep track of what is or isn’t public info. However, I found the protocol name on the public MFi Program > FAQs page.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Custom USB Network Device Driver on iPhone
 
 
Q