Skip to main content

Making a Mac OS X driver for the Toshiba G450 3G modem

About 3 weeks ago, I had to buy the 3G modem Toshiba G450 because Polish operator Play would not let me get the plan I wanted without it.

A few hours later, I had to accept that there are no Mac OS X drivers for it! Which would have made me, say, unhappy, had I not had my trusty Huawei E220. The only information I have been able to come up with are amazed reviews from gadget websites. Not even a driver for Linux... And this happens when I was thinking about polishing my low-level development powers (there is more to life than Java and C#, you know!)... so, why not take the chance to learn about what is needed to make a driver?

The modem uses the ZeroCD "trick" of appearing as a USB drive to the OS, until it receives an existent-but-generally-unused-in-USB-drives command; at that moment, the drive is "unplugged" and a new device appears in the bus: the modem. So in the USB drive that appears first, there is a driver installer (for Windows, of course). The user (or the autorun) installs the driver, and it sends the switching command to the USB drive it recognizes as the masked modem. Drive goes away, modem appears, and driver finally does its thingy with the modem.

Up to now, I have been successful in capturing the appropiate command with usbsniff and making the USB drive switch in Linux and Mac OS X, with the help of usb_modeswitch (http://www.draisberghof.de/usb_modeswitch/ , where I have already sent the info so they can use it in later versions). So now the modem is waiting for my next move. I was half expecting it to just be recognized by the serial driver, but that would have been too easy, wouldn't it?

So I have been reading about the internals of USB, now about IOKit (the driver subsystem in OS X), have re-learnt C in a rush, and now am contemplating starting with C++, of which IOKit uses "a restricted subset" (no RTTI, no templates, no exceptions... which in part I guess will make the thing easier, although I am afraid those were the interesting parts of it). And yet looks like I will have to read a bit about kernel programming in OS X. Which is also something I wanted to do, but... I was expecting this first project to be a little lighter!

On the other hand, I am suspecting this won't be THAT difficult. The Huawei E220's software for OS X (driver and app) doesn't look exactly brilliant, which makes me think someone hacked it together somewhat quickly; and it works in a similar way to the Toshiba G450. I even thought about hacking a bit the Huawei's kernel extension (looks like I should only edit an XML file in the bundle), but even if it worked I don't think I would be able to distribute it nor would I learn anything. And I don't actually need the modem ;P.

Also, the Darwin open source repositories have an example driver for USB modems. And after all we are only talking about making the OS see "the serial ports" in the USB interfaces... I mean, it should be as easy as it can get, since everything beyond that point will be taken care of by other parts of the OS. But still this is about kernel programming in C++ for a novice. Lots of little interestingly nasty ways to hose the whole OS. Nice!

Of course, no small part of the problem is making sense of all of this and still having time for language courses, travelling, personal life... and my regular job - and searching for a new one. Sounds a bit like DDoS, doesn't it? :)

Comments