I've just taken delivery of an iriver iHP-120 digital audio player, and I've gotta say it's fantastic. This thing really is an iPod killer; it's the same size, but it does so much more:
- It doesn't just play mp3s; it can handle several other formats, including ogg
- The drive shows up as a USB Mass Storage Device, so no client software is required on your PC
- It's got an FM radio in it
- The firmware is upgradeable to allow for new features and codecs
This page is about my adventures with this device on FreeBSD, although some of it may be relevant to other *Nix-ish operating systems.
Getting started
It runs over USB2, so I got myself a USB2 card and stuck it in my desktop machine (which dual boots Windows 2000 and FreeBSD 4.9). I thought I'd get it going with Windows before I tried to get it to play with BSD, so I rebooted, plugged the cable in and there it was, a new removable device, just like that. I dragged a couple of files across to it as a test, and was blown away by the blinding speed of USB2 (having previously chugged along with USB1.1 on my camera).
My music lives on my BSD server under the stairs, ordered alphabetically (so I have /export/media/mp3/B/Beastie_Boys/, /export/media/mp3/B/Beatles/ and so on). I set up the same tree on the iHP and started dragging the tunes across. It took about an hour to pick and transfer something like 10 Gigs.
The player has a rather nifty feature whereby it creates a database from the id3 tags in your mp3s. This has to be done from Windows Explorer, however, and it only works on mp3s, not any of the other supported formats (at present; maybe this will change in a future firmware revision?), but it does then give you a rather spiffy navigation interface. Oh yes, and it also supports Winamp m3u playlists.
Of course if you already own one of these things, then you'll know most of this already because you'll have read the manual (yes, as much as it goes against my SysAdmin instincts, I read it all ;). What the manual doesn't tell you is how to get this thing working on FreeBSD...
When iriver meets FreeBSD
My desktop machine is running FreeBSD 4.9, and I've never had much luck with USB devices on it. My laptop, however, is running FreeBSD 5.2, and it works with my Olympus camera over USB, so the signs are good. Unfortunately the laptop only has USB1.1, but I can live with that as I've transferred most of favourite music across to the iHP already, so it'll just be a few deltas from now on.
Kernel configuration
You can read all about building custom kernels here, although I don't imagine there are many people running FreeBSD desktops who haven't rolled their own kernel before. Whatever, you need to edit your kernel configuration file to contain at least the following lines:
device scbus # SCSI bus (required for SCSI) device da # Direct Access (disks) device uhci # UHCI PCI->USB interface device usb # USB Bus (required) device umass # Disks/Mass storage - Requires scbus and da
Yes, this thing is going to show up as a SCSI device. Also, your kernel may require ohci instead of uhci (and it's ehci if you've got a USB2 card, and if you can get this to work then I really want to hear about it); check your dmesg.
Now it's time for make buildkernel && make installkernel then reboot, and you should be ready to test...
Plugging it in
OK, let's switch the iHP on, plug the cable in at both ends, and have a look at dmesg:
umass0: iRiver iRiver iHP-100 Series, rev 2.00/1.00, addr 2 GEOM: create disk da0 dp=0xc2011c50 da0 at umass-sim0 bus 0 target 0 lun 0 da0: <TOSHIBA MK2004GAL JA02> Fixed Direct Access SCSI-0 device da0: 1.000MB/s transfers da0: 19073MB (39063024 512 byte sectors: 255H 63S/T 2431C)
And the player is displaying 'connected', so once again the signs are good.
Mounting the device
The disk is formatted with the ubiquitous FAT32 filesystem, which is mostly a Good Thing (it may not be the best filesystem in the world, but just about every OS I've ever seen can read and write it. There is a problem where I can't change the file permissions so I can only write to it as root; anybody know how to get round this?). Whatever, you should be able to mount it with
[root@willow:~] # mount -t msdosfs /dev/da0s1 /mnt/
This command took a worryingly long time (about 25 seconds) to return, and I had terrible visions of it failing with some message about 'device not configured' or 'incorrect superblock', but no, it worked:
[root@willow:~] # mount <snip> /dev/da0s1 on /mnt (msdosfs, local) [root@willow:~] # ls /mnt/ A K S B L T C M W <snip>
OK, so it's mounted just like any other filesystem; if you're running a nice graphical file manager, you can drag-and-drop to it. One thing to note, however: Make sure you umount it before you disconnect, or Bad Things will happen: kernel panics, that kind of thing. You have been warned!. Also, depending on what else your machine is doing, the device may have shown up as a different device in your dmesg, da1 or something, and you'll have to sweeten to taste.
/etc/fstab
If you add a line like this to /etc/fstab
/dev/da0s1 /iriver msdosfs rw,noauto 0 0
and create the /iriver directory, then you can mount the device whenever you plug it in with mount /iriver
OK, now what?
So you've got it to talk to your BSD machine. Now what clever stuff can you do with it?
Playlists
As mentioned previously, it's supposed to support Winamp playlists, but my intial forays in this direction were unsuccessful. Anyway, seeing as this is a FreeBSD page, let us look at the playlists produced by xmms. The format of these is something like this:
///export/media/mp3/S/Smiths/The_Smiths_-_1984-11_-_Hatful_of_Hollow/06_Handsome_Devil.ogg
which is no good, mainly because the player has no idea what ///export/media/mp3 is. However, if you install /usr/ports/converters/unix2dos, then this little bit of bash
#!/usr/local/bin/bash
LEADINGPATH=[/]*iriver ; export LEADINGPATH
CAT=/bin/cat ; export CAT
SED=/usr/bin/sed ; export SED
TR=/usr/bin/tr ; export TR
ECHO=/bin/echo ; export ECHO
UNIX2DOS=/usr/local/bin/unix2dos ; export UNIX2DOS
DOS2UNIX=/usr/local/bin/dos2unix ; export DOS2UNIX
TMPLIST=/tmp/tmplist ; export TMPLIST
CP=/bin/cp ; export CP
RM=/bin/rm ; export RM
if [ ! ${1} ] ;
then
${ECHO} "Usage: `basename ${0}` "
exit 1
fi
${CP} ${1} ${TMPLIST}
${DOS2UNIX} ${TMPLIST}
${CAT} ${TMPLIST} | ${SED} "s:${LEADINGPATH}::g" | ${TR} '/' '\' | ${UNIX2DOS}
${RM} ${TMPLIST}
will zap the leading paths, translate forward slashes into backslashes and add the dos-style carriage-return-line-feed at the end of each line. You can grab it here; you'll probably want to change at least the LEADINGPATH variable, then redirect the output to your new playlist. The playlists need to reside in the root of the player, and you access them with a click of the 'A-B' button.
The database
The database is a very cool idea; however, as mentioned above, it only works on mp3 files, which is not a lot of good to me as about 70% of my music is oggs. A bit of judicious Googling unearthed this, but it wouldn't build on FreeBSD. So we patched it...
My friend Al Cutter wrote this patch. You'll need to download the iRipDB tarball, unpack it and then run the source through dos2unix to remove those oh-so-irritating CRLFs (surely DOS's greatest gift to the world). Then from the source directory do patch -p1 </path/to/patch, then make, and you should have an executable called iripdb. (This all depends on at least libogg, libvorbis and id3lib, I think, which are all in the ports tree; install those before you try to build it.)
This patch fixes up some memory leaks, adds support for ogg files and adds an option to update an existing database. If only there was some standard for the tags... ;) One thing to bear in mind: having a database on your player will increase its startup time from ~15 seconds to ~45 seconds
The file format is documented here, if you're interested.
Flashing the firmware
One of the best things about this player is that the firmware is upgradeable. Mine shipped with version 1.17; the latest is 1.40. The upgrade procedure is very easy indeed: download and unzip the file to extract the 'hex' file, drop it onto the root of the player, then choose 'General -> Firmware Upgrade' from the main menu, and away you go. It rather disconcertingly switched itself off when it was done, but when I turned it on again it proudly informed me that it was now running 'VER 1.40 E', which brings these great new features and bugfixes. I've really gotta congratulate iriver on this idea, it's very cool.