Apple iPhone (3G) vs. FreeBSD, take I

No, this post won’t be able to tell you how to synchronize contacts, calendar, bookmarks etc. from your FreeBSD box to your iPhone or iPhone 3G, sorry – still working on that. It will, however, show you how to make FreeBSD recognize your iPhone as a camera device, so that you can download the photos taken with your iPhone to a FreeBSD host.

First of all, make sure you’re using a kernel with ugen(4) support – but either without uhid(4) support or FreeBSD 8-CURRENT in SVN revision 181482 or newer – or manually apply this patch:

[Update: I have just MFC’ed this patch to RELENG_7 (SVN revision 181636) and RELENG_6 (SVN revision 181637), so this patch will be included in FreeBSD 7.1 and 6.4].

Index: sys/dev/usb/usb_quirks.c
--- sys/dev/usb/usb_quirks.c	(revision 181481)
+++ sys/dev/usb/usb_quirks.c	(working copy)
@@ -106,6 +106,10 @@
  /* Devices which should be ignored by both ukbd and uhid */
Index: sys/dev/usb/usbdevs
--- sys/dev/usb/usbdevs	(revision 181481)
+++ sys/dev/usb/usbdevs	(working copy)
@@ -853,6 +853,8 @@
 product APPLE IPOD_08		0x1208	iPod '08'
 product APPLE IPODVIDEO		0x1209	iPod Video
 product APPLE IPODNANO		0x120a	iPod Nano
+product APPLE IPHONE		0x1290	iPhone
+product APPLE IPHONE_3G		0x1292	iPhone 3G
 product APPLE ETHERNET		0x1402	Ethernet A1277
 /* Arkmicro Technologies */

Next, make sure you have graphics/gphoto2 and graphics/libgphoto2 (the latter needs to be 2.4.2_1 or later for the iPhone 3G to work) installed.

Plug in the USB cable from your iPhone and verify using dmesg(8) that it shows up as an ugen(4) device as shown below:

kernel: ugen1: <Apple Inc. iPhone, class 0/0, rev 2.00/0.01, addr 2> on uhub4

That’s it – you should now be able to access the photos on your iPhone using ghoto2(1) – just replace ‘Apple iPhone (PTP Mode)’ with ‘Apple iPhone 3G (PTP Mode)’ for the iPhone 3G:

$ gphoto2 --camera 'Apple iPhone (PTP Mode)' -L
There is no file in folder '/'.                                                
There is no file in folder '/store_00010002'.
There is no file in folder '/store_00010002/DCIM'.
There are 7 files in folder '/store_00010002/DCIM/100APPLE'.
#1     IMG_0007.JPG                   49 KB image/jpeg
#2     IMG_0013.JPG                  389 KB image/jpeg
#3     IMG_0022.JPG                   26 KB image/jpeg
#4     IMG_0026.JPG                  358 KB image/jpeg
#5     IMG_0027.JPG                  357 KB image/jpeg
#6     IMG_0028.JPG                  381 KB image/jpeg
#7     IMG_0029.JPG                  377 KB image/jpeg
There is no file in folder '/store_00010002/DCIM/999APPLE'.

See the gphoto2(1) man page for further usage instructions.

Of course, you can also use a graphical client such as graphics/gtkam as long as it uses libgphoto2 for camera access.

Leave a Reply

Your email address will not be published. Required fields are marked *