{"id":31,"date":"2011-02-03T12:21:45","date_gmt":"2011-02-03T11:21:45","guid":{"rendered":"http:\/\/paguilar.org\/?p=31"},"modified":"2011-02-03T12:21:45","modified_gmt":"2011-02-03T11:21:45","slug":"mounting-an-ipodiphone-on-a-linux-device","status":"publish","type":"post","link":"https:\/\/paguilar.org\/?p=31","title":{"rendered":"Mounting an iPod\/iPhone on a Linux device"},"content":{"rendered":"<p>These days mounting an iPod\/iPhone\/iPad on a Linux PC is an automatic task and all the synchronization operations, such as the music sync with Rythmbox, are supported or at least partially supported.<\/p>\n<p>The communication with these devices can take place thanks to the <a href=\"http:\/\/www.libimobiledevice.org\/\">libimobiledevice<\/a> library with the help of <a href=\"http:\/\/fuse.sourceforge.net\/\">fuse<\/a> (filesystem in userspace) and several other libraries and applications. For a clearer picture of the involved libraries you can have a look at this <a href=\"http:\/\/www.libimobiledevice.org\/am-stack-fig-4.png\">software stack diagram<\/a>. <\/p>\n<p>Unfortunately, having the same functionality in a Linux embedded device such as a Set-Top-Box or a Digital Receiver is not easy because all the applications are part or depend strongly on GNOME or KDE that normally are not available in these systems.<br \/>\nHowever, all the libraries can be cross-compiled allowing to mount an iPod\/iPhone\/iPad as a storage device.<br \/>\nOf course, if you want to synchronize your data such as music or videos, you&#8217;ll have to develop your own application or port an existing one.<\/p>\n<p>In this post I focus only on how to compile all the required libraries for mounting an iPod\/iPhone\/iPad as a storage device.<br \/>\nIf the Set-Top-Box have a media player with the required codecs, they will be able, at least, to play the content.<\/p>\n<p><font size=\"3\"><strong>Requirements<\/strong><\/font><\/p>\n<p>Fuse needs a kernel driver that is already included in the mainline kernel. In the kernel configuration you find this option under the Filesystem menu. You can compile it as a module or in-kernel. If you choose the former, the module will be called fuse.ko.<\/p>\n<p><font size=\"3\"><strong>Environment configuration<\/strong><\/font><\/p>\n<p>Suppose that we want to install all the libraries in <em>\/mnt\/target\/usr\/local<\/em>.<br \/>\n\/mnt\/target is the top directory of the target&#8217;s filesystem that could be mounted via NFS.<br \/>\nAssume that the cross-toolchain (compiler, linker\u2026) is already in your path.<\/p>\n<p>Set the following environment variables:<\/p>\n<pre lang=\"bash\">\n$ export PREFIX=\/mnt\/target\/usr\/local\n$ export HOST=sh4-linux\n$ export BUILD=i386-linux\n$ export LD_LIBRARY_PATH=$PREFIX\/lib\n$ export PKG_CONFIG_PATH=$LD_LIBRARY_PATH\/pkgconfig\n<\/pre>\n<p><font size=\"3\"><br \/>\n<strong>libusb<\/strong><\/font><\/p>\n<p>Package: <a href=\"http:\/\/sourceforge.net\/projects\/libusb\/files\/libusb-1.0\/libusb-1.0.8\/libusb-1.0.8.tar.bz2\/download\">libusb-1.0.8.tar.bz2<\/a><\/p>\n<p>This package is required by <em>libimobiledevice<\/em>.<\/p>\n<pre lang=\"bash\">\n$ .\/configure --build=$BUILD --host=$HOST --prefix=$PREFIX --disable-static --disable-log\n$ make\n$ make install\n<\/pre>\n<p><font size=\"3\"><strong>libplist<\/strong><\/font><\/p>\n<p>Package: <a href=\"http:\/\/github.com\/downloads\/JonathanBeck\/libplist\/libplist-1.3.tar.bz2\">libplist-1.3.tar.bz2<\/a><\/p>\n<p>This package is required by <em>libimobiledevice<\/em>.<\/p>\n<p>The compilation of libplist is different because it uses cmake.<br \/>\nCreate a file <em>toolchain.cmake<\/em> with the following contents. Modify the cross-compiler variables according to your path:<\/p>\n<pre lang=\"bash\">\n# this one is important\nSET(CMAKE_SYSTEM_NAME Linux)\n#this one not so much\nSET(CMAKE_SYSTEM_VERSION 1)\n\n# specify the cross compiler\nSET(CMAKE_C_COMPILER   \/opt\/STM\/STLinux-2.3\/devkit\/sh4\/bin\/sh4-linux-gcc)\nSET(CMAKE_CXX_COMPILER \/opt\/STM\/STLinux-2.3\/devkit\/sh4\/bin\/sh4-linux-g++)\n\n# where is the target environment \nSET(CMAKE_FIND_ROOT_PATH  \/mnt\/target\/usr\/local)\n\n# search for programs in the build host directories\nSET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\n# for libraries and headers in the target directories\nSET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\nSET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)\n<\/pre>\n<p>Then create the build directory, compile and install:<\/p>\n<pre lang=\"bash\">\n$ mkdir build\n$ cd build\n$ cmake -DCMAKE_TOOLCHAIN_FILE=..\/toolchain.cmake ..\n$ make DESTDIR=$PREFIX install\n<\/pre>\n<p><font size=\"3\"><br \/>\n<strong>usbmuxd<\/strong><\/font><\/p>\n<p>Package: <a href=\"http:\/\/marcansoft.com\/uploads\/usbmuxd\/usbmuxd-1.0.4.tar.bz2\">usbmuxd-1.0.4.tar.bz2<\/a><\/p>\n<p>This package is needed by <em>libimobiledevice<\/em>.<\/p>\n<p>usbmux uses cmake too. Therefore, the procedure is the same as liplist:<\/p>\n<p>Create the file <em>toolchain.cmake<\/em> with the same contents as with <em>libplist-1.3<\/em> or just copy it to the current directory <em>usbmuxd-1.0.4<\/em>.<\/p>\n<pre lang=\"bash\">\n$ cd usbmuxd-1.0.4\n$ cp ..\/libplist-1.3\/toolchain.cmake .\n<\/pre>\n<p>Then create the build directory, compile and install:<\/p>\n<pre lang=\"bash\">\n$ mkdir build\n$ cd build\n$ cmake -DCMAKE_TOOLCHAIN_FILE=..\/toolchain.cmake ..\n$ make DESTDIR=$PREFIX install\n<\/pre>\n<p><font size=\"3\"><strong>libgpg-error<\/strong><\/font><\/p>\n<p>Package: <a href=\"ftp:\/\/ftp.gnupg.org\/gcrypt\/libgpg-error\/libgpg-error-1.7.tar.gz\">libgpg-error-1.7.tar.gz<\/a><\/p>\n<p>This package is needed by <em>libgcrypt<\/em>.<\/p>\n<pre lang=\"bash\">\n$ .\/configure --build=$BUILD --host=$HOST --prefix=$PREFIX\n$ make\n$ make install\n<\/pre>\n<p><font size=\"3\"><strong>libgcrypt<\/strong><\/font><\/p>\n<p>Package: <a href=\"ftp:\/\/ftp.gnupg.org\/gcrypt\/libgcrypt\/libgcrypt-1.4.6.tar.gz\">libgcrypt-1.4.6.tar.gz<\/a><\/p>\n<p>This package is needed by <em>gnutls<\/em><\/p>\n<pre lang=\"bash\">\n$ .\/configure --build=$BUILD --host=$HOST --prefix=$PREFIX --with-gpg-error-prefix=$PREFIX\n<\/pre>\n<p><strong>Note:<\/strong> I didn&#8217;t need to modify these Makefiles when using an updated STLinux2.3. But if you haven&#8217;t done an <em>&#8216;stmyum update&#8217;<\/em> lately, maybe you&#8217;ll need to modify them.<br \/>\nEdit the <em>Makefile<\/em>:<br \/>\nRemove from the variables <em>DIST_SUBDIRS<\/em> and <em>SUBDIRS<\/em> the directory &#8216;tests&#8217;<\/p>\n<p>Edit the <em>src\/Makefile<\/em>:<br \/>\nSet the following variables to the given values:<\/p>\n<pre lang=\"bash\">\nGPG_ERROR_CFLAGS = \/mnt\/target\/usr\/local\/include\nGPG_ERROR_CONFIG =\nGPG_ERROR_LIBS = \/mnt\/target\/usr\/local\/lib\/libgpg-error.so.0.7.0\nlibgcrypt_la_LIBADD = \n\t..\/cipher\/libcipher.la \n\t..\/random\/librandom.la \n\t..\/mpi\/libmpi.la \n\t\/mnt\/target\/usr\/local\/lib\/libgpg-error.so.0.7.0\n<\/pre>\n<p>Compile and install:<\/p>\n<pre lang=\"bash\">\n$ make\n$ make install\n<\/pre>\n<p><font size=\"3\"><strong>libtans1<\/strong><\/font><\/p>\n<p>Package: <a href=\"ftp:\/\/ftp.gnu.org\/gnu\/libtasn1\/libtasn1-2.7.tar.gz\">libtasn1-2.7.tar.gz<\/a><\/p>\n<p>This package is needed by <em>libimobiledevice<\/em>.<\/p>\n<pre lang=\"bash\">\n$ .\/configure --build=$BUILD --host=$HOST --prefix=$PREFIX\n$ make\n$ make install\n<\/pre>\n<p><font size=\"3\"><strong>gnutls<\/strong><\/font><\/p>\n<p>Package: <a href=\"ftp:\/\/ftp.gnupg.org\/gcrypt\/gnutls\/gnutls-2.8.6.tar.bz2\">gnutls-2.8.6.tar.bz2<\/a><\/p>\n<p>This package is needed by <em>libimobiledevice<\/em>.<\/p>\n<pre lang=\"bash\">\n$ .\/configure --build=$BUILD --host=$HOST --prefix=$PREFIX \n--with-libgcrypt-prefix=$PREFIX --enable-large_files --disable-gtk-doc-html\n<\/pre>\n<p>Edit the files <em>src\/Makefile<\/em>, <em>doc\/Makefile<\/em> and <em>doc\/examples\/Makefile<\/em>:<br \/>\nSet <em>LDFLAGS<\/em> to this value:<\/p>\n<pre lang=\"bash\">\nLDFLAGS = \/mnt\/target\/usr\/local\/lib\/libgcrypt.so \/mnt\/target\/usr\/local\/lib\/libgpg-error.so\n<\/pre>\n<pre lang=\"bash\">\n$ make\n$ make install\n<\/pre>\n<p><font size=\"3\"><strong>libimobiledevice<\/strong><\/font><\/p>\n<p>Package: <a href=\"http:\/\/www.libimobiledevice.org\/downloads\/libimobiledevice-1.0.2.tar.bz2\">libimobiledevice-1.0.2.tar.bz2<\/a><\/p>\n<pre lang=\"bash\">\n$ .\/configure --build=$BUILD --host=$HOST --prefix=$PREFIX \nlibusbmuxd_CFLAGS=\"-I$PREFIX\/include\" libusbmuxd_LIBS=\"-L$PREFIX\/lib\" \nlibgnutls_CFLAGS=\"-I$PREFIX\/include\" libgnutls_LIBS=\"-L$PREFIX\/lib\" \nlibtasn1_CFLAGS=\"-I$PREFIX\/include\" libtasn1_LIBS=\"-L$PREFIX\/lib\" \nlibplist_CFLAGS=\"-I$PREFIX\/include\" libplist_LIBS=\"-L$PREFIX\/lib\" \nlibglib2_CFLAGS=\"-I$PREFIX\/include -I$PREFIX\/lib\/glib-2.0\/include\" libglib2_LIBS=\"-L$PREFIX\/lib\" \n--without-swig\n<\/pre>\n<p>Edit the file <em>tools\/Makefile<\/em>:<br \/>\nSet <em>LDFLAGS<\/em> to this value:<\/p>\n<pre lang=\"bash\">\nLDFLAGS = \/mnt\/target\/usr\/local\/lib\/libgcrypt.so \/mnt\/target\/usr\/local\/lib\/libgpg-error.so \/mnt\/target\/usr\/local\/lib\/libplist.so \/mnt\/target\/usr\/local\/lib\/libtasn1.so \/mnt\/target\/usr\/local\/lib\/libusbmuxd.so \/mnt\/target\/usr\/local\/lib\/libgnutls.so\n<\/pre>\n<p>Compile and install:<\/p>\n<pre lang=\"bash\">\n$ make\n$ make install\n<\/pre>\n<p><font size=\"3\"><strong>fuse<\/strong><\/font><\/p>\n<p>Package: <a href=\"http:\/\/sourceforge.net\/projects\/fuse\/files\/fuse-2.X\/2.8.4\/fuse-2.8.4.tar.gz\/download\">fuse-2.8.4<\/a><\/p>\n<pre lang=\"bash\">\n$ .\/configure --build=$BUILD --host=$HOST --prefix=$PREFIX\n$ make\n$ make DESTDIR=$PREFIX install\n<\/pre>\n<p><font size=\"3\"><strong>ifuse<\/strong><\/font><\/p>\n<p>Package: <a href=\"http:\/\/www.libimobiledevice.org\/downloads\/ifuse-1.0.0.tar.bz2\">ifuse-1.0.0.tar.bz2<\/a><\/p>\n<pre lang=\"bash\">\n$ .\/configure --build=$BUILD --host=$HOST --prefix=$PREFIX \nCFLAGS=-D_FILE_OFFSET_BITS=64 \nlibimobiledevice_CFLAGS=\"-I$PREFIX\/include\" libimobiledevice_LIBS=\"-L$PREFIX\/lib\" \nlibglib2_CFLAGS=\"-I$PREFIX\/include\/glib-2.0 -I$PREFIX\/lib\/glib-2.0\/include\" libglib2_LIBS=\"-L$PREFIX\/lib\" \nlibgthread2_CFLAGS=\"-I$PREFIX\/include\" libgthread2_LIBS=\"-L$PREFIX\/lib\" \nlibfuse_CFLAGS=\"-I$PREFIX\/include\" libfuse_LIBS=\"-L$PREFIX\/lib\"\n<\/pre>\n<p>Edit the file <em>src\/Makefile<\/em>:<br \/>\nSet <em>libfuse_LIBS<\/em> to this value:<\/p>\n<pre lang=\"bash\">\nlibfuse_LIBS = -L\/mnt\/target\/usr\/local\/lib -lfuse -limobiledevice -lgnutls -lplist -lusbmuxd\n<\/pre>\n<p>Compile and install:<\/p>\n<pre lang=\"bash\">\n$ make\n$ make install\n<\/pre>\n<p><font size=\"3\"><strong>Mounting the device<\/strong><\/font><\/p>\n<p>At this point you should be able to mount your iPod\/iPhone as a storage device. Some iPods can have a partition, like \/dev\/sda1, formatted as VFAT of HFS+, depending on where you use it. Some others, like the iPod shuffle, doesn&#8217;t have a partition, so you&#8217;ll see them as \/dev\/sda.<\/p>\n<p>Assuming that you want to mount it in <em>\/media\/ipod<\/em>, that it has partition <em>\/dev\/sdb1<\/em>, and it&#8217;s formatted in VFAT, you can mount it as a normal storage device:<\/p>\n<pre lang=\"bash\">\n$ mount -t vfat -o usefree \/dev\/sdb1 \/media\/ipod\n<\/pre>\n<p>For HFS+ is the same. Notice that your kernel must be compiled for supporting this filesystem:<\/p>\n<pre lang=\"bash\">\n$ mount -t hfsplus -o ro \/dev\/sdb1 \/media\/ipod\n<\/pre>\n<p>Now you can browse in <em>\/media\/ipod<\/em> and you&#8217;ll see the contents of your iPod&#8217;s filesystem!<\/p>\n<p><font size=\"3\"><strong>References<\/strong><\/font><\/p>\n<ul>\n<li><a href=\"http:\/\/www.libimobiledevice.org\/\">libimobiledevice<\/a><\/li>\n<li><a href=\"http:\/\/fuse.sourceforge.net\/\">fuse<\/a>\n<li><a href=\"http:\/\/www.cmake.org\/Wiki\/CMake_Cross_Compiling\">Cross-compiling using cmake<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>These days mounting an iPod\/iPhone\/iPad on a Linux PC is an automatic task and all the synchronization operations, such as the music sync with Rythmbox, are supported or at least partially supported. The communication with these devices can take place thanks to the libimobiledevice library with the help of fuse (filesystem in userspace) and several\u2026 <span class=\"read-more\"><a href=\"https:\/\/paguilar.org\/?p=31\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,12],"tags":[],"class_list":["post-31","post","type-post","status-publish","format-standard","hentry","category-compiling","category-ipod"],"_links":{"self":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/31","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=31"}],"version-history":[{"count":0,"href":"https:\/\/paguilar.org\/index.php?rest_route=\/wp\/v2\/posts\/31\/revisions"}],"wp:attachment":[{"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/paguilar.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}