John's Suggested MP3 Player
From NAS-Central Buffalo - The Linkstation Wiki
NOTE: THIS ARTICLE IS STILL IN PROGRESS.
It seems that John likes his gadgets just as much as the next guy, maybe even more. At any rate John described a portable mp3 player that uses his Nintendo DS with the web browser cartridge which is set to be released soon. I’ll make no comments regarding whether or not John has his name on a waiting list at the local video game store so he can be the first guy on the block to get one of these. Hey; whatever makes you happy. In any event, John described a wireless connection from the mp3 player that would automatically link up to his home network and sync with his music collection when the mp3 player is in range. Of course, this whole system is based on the Kurobox.
I decided to give it a shot, and although my gadget budget might be a bit skimpy in comparison, all of John’s described functionality is included. The standard setup uses a text based interface that is very light and robust as well as some scavenged hardware. It also has an optional section for access with a standard web browser, so I think I came up with what he described.
This project uses some of the “building blocks” I developed/used for the All in One. In particular, it uses a ZD1211 based wireless G USB dongle for syncing with my home network, the bootloader, Apache, MySQL, PHP, Jinzora, and SaMBa.
For audio, it uses a Turtle Beach Audio Advantage USB dongle ($28.88 at Best Buy – Yes, I actually bought some new hardware for this project.) which is capable of analog stereo (for those of us with standard car stereos) and digital 5.1 audio via a toslink fiber connection for the most extreme of gadgeteers.
Since I have a (small) budget for experimenting and don’t have a Nintendo anything, I came up with a different plan. In place of John’s Nintendo DS I have substituted an old Palm M100 (it was a freebie) which is capable of full alphanumeric input and display. Connection is currently via a serial port which I had installed in my Kuro. Two way serial communication is essential so get your magnifying glass out and move r76. I have most of the parts to build a standard serial to IRDA converter. I just need a crystal and I can complete it (although a complete converter is available for about $15 online). Once it is completed and installed, communication via the Palm M100 will be wireless since the M100 has a built in IRDA port.
It occurred to me that using the Nintendo DS and web browser would have been much simpler as I could have just setup Jinzora in jukebox mode (and instructions to do so are included in the section titled “Making it all work with the Nintendo DS”. As is usual, budget constraints increase the time and effort required to bring a project to completion, and for those of us with tight budgets....
Several of the steps may be omitted depending on how you would like to use the device such as wireless access, the car power supply, Setting up the Palm M100 (the setup will run through an SSH terminal), making it foolproof, and even the sync section, but all of the steps are included so John can be the first guy on the block with a confirmed wireless Kurobox media system with Nintendo access and control. He'll be the envy of all of the other gadgeteers at Revolution (unless they read this first).
The steps required to make John’s Suggested MP3 Player function are as follows:
Compile a 2.6.15 kernel with the following functionality:
a. IEEE 802.11 encryption
b. Net radio
c. Wireless Ethernet support
d. USB /proc filesystem support
e. ALSA support
f. SMB support
Once the kernel is compiled we setup a bootloader to start the new kernel. There are several bootloaders based on init.d scripts available on the Kurobox forums. The one written by Gordo works well and is the one I use. It can be found at http://www.kurobox.com/forums/viewtopic.php?t=665
Getting the wireless portion working
Once again, we are using a ZyXEL G-220 wireless G network adapter Which is based on the ZD1211 chipset. The G-220 is plugged into a rear USB port via a short USB extension cable. This allows me to raise the device for better reception and transmission since it will be connecting from my car (in my driveway).
I had good luck with the r76 version of the zd1211 driver. There has since been an r77 version released. We’ll use the r77 this time.
wget http://zd1211.ath.cx/download/zd1211-driver-r77.tgz tar zxvf zd1211-driver-r77.tgz cd zd1211-driver-r76
change directories into the zd1211-driver-r77 directory and edit the makefile. Change the KERNEL_SOURCE lines to match these:
Save the file and compile the driver.
make make install
Next we add the module name (zd1211) to /etc/modules/autoload.d/kernel-2.6. This will make the module automatically load on booting the 2.6.15 kernel.
We configure the wireless device next. Since we don’t want the network up all of the time broadcasting its existence to the whole world we’ll start and stop the wireless network with a script that also performs the media sync in a later step.
You need wireless-tools to configure wlan0.
If you are working through a serial console now would be a good time to remove eth0 from the default runlevel. Do not do this if you are connected via SSH through the wired network as you will lose connectivity.
Setup the Kuro to synchronize with your home network:
It occurred to me my car is usually parked in my driveway at 3:00 in the morning. It seemed to me that the easiest way to synchronize my music collection with my Kuro would be to setup a cron job that runs at 3:00 in the morning using rsync to duplicate my home network media directory (stored on my new TeraStation) with the one on my Kuro. Rsync is part of the base system. All that is necessary is to install a cron daemon if you haven’t already installed one.
emerge fcron rc-update add fcron default
If you haven’t done so, you need to install the fcron crontab. Be aware that this will overwrite your existing /etc/crontab, so if you have customized your crontab you should make a backup prior to executing the next command.
We need to create the mount point for the master set of media files.
Since I will be storing my media files on my Terastation Pro, I need to install SaMBa and configure it as an SMB client. This is because the Terastation Pro uses SMB for network file sharing. Follow the Samba how-to at http://www.gentoo.org/doc/en/quick-samba-howto.xml. We already compiled SMB functionality into our kernel. We just need to create a script to bring up the wireless network, mount the SMB share where we keep our media files, run the rsync command, and bring the network down. This is done for security reasons. In the unlikely event that someone discovers our device they will only have access to it when the wireless is up which should be for a very short amount of time. The following script does that. We name the file /etc/sync-with-home. You need to modify the essid and key to match those of your home network. You also need to assign a unique IP address to wlan0. we add the sleep line to give the kuro some time to connect before we mount the the server on /media.
ifconfig wlan0 up iwconfig wlan0 essid Kuro iwconfig wlan0 key 1234567890abcdef1234567890 iwconfig wlan0 mod managed ifconfig wlan0 up 192.168.0.x sleep 15 mount -t smbfs -o username=USERNAME,password=PASSWORD //SERVER/PATH /media rsync /media /datafiles/media/music umount /media ifconfig wlan0 down
We need to make this file executable.
chmod 777 /etc/sync-with-home
Now lets add a cron job so it connects up at 3:00am, syncs the media directory and umounts the Terastation.
0 3 * * * /etc/sync-with-home
Setup the Sound device
We compiled the ALSA driver into the kernel. Now we need to emerge the ALSA utilities. This will also emerge the 2.6.15-r1 kernel source. It can be deleted later since we already have the patched 2.6.15 kurobox kernel source installed.
emerge alsa-utlis cd /usr/src/ rm –R linux 2.6.15-gentoo-r1 rm linux
We make the kuro initialize the sound device on boot:
rcupdate add alsasound boot
Install the music and interface applications
We will be using MOP-2.4.0 for our front end as it uses very little processing power and does not require any expensive gadgets like a Nintendo DS for those of us on a budget. It is a curses based front end and will work with any terminal program, including the one we will be running on our Palm device. There are a good amount of dependencies you need so lets get started emerging them. We’ll do this in stages so we can test the hardware as we go. Although we don’t need MPG321, we do need all of its dependencies and MPG321 will allow us to test the sound card and kernel, so lets emerge it first.
If you have booted to your new kernel, you can now test your sound card. You need to unmute the card (both master and pcm channels) and adjust the volume with alsamixer and then you can play one of your mp3 files.
alsamixer mpg321 –v /path/to/mp3-file.mp3
Now that we know out hardware and kernel are properly configured we can proceed with emerging some libraries:
emerge libvorbis libsndfile
Tie it together with JACK
And last we install moc-2.4.0. Moc needs to be emerged last or the conduits to the codecs will not be installed and although moc will launch, your system will remain silent. This little fact was learned the hard way. There is a big-endian patch that also needs to be installed. We will add a user named moc and su to moc for this one. We will exit the su environment for the last step.
useradd moc -m -G users,,wheel,audio -s /bin/bash su moc cd / wget ftp://ftp.daper.net/pub/soft/moc/stable/moc-2.4.0.tar.bz2 tar jxvf moc-2.4.0.tar.bz2 cd moc-2.4.0 wget ftp://ftp.daper.net/pub/soft/moc/patches/2.4.0-endianess.patch patch -p1 < 2.4.0-endianess.patch #the file to patch is audio.c ./configure make exit make install
Moc works straight out of the box. If you want, you can change the appearance by editing the config file. It is also possible to change the keyboard mappings to suit your particular taste. Instructions for changing the keyboard layout are included in the config file. So, since moc and its dependencies are all installed, lets try it out. We launch moc with the following command:
Setting up the Palm M100
Note: you can access the music console through an SSH session. This step is optional, but allows access and control from the Kurobox without a separate computer (although the palm is a computer) for controlling the console
The application that allows us to use a Palm device as a terminal is Ptelnet (there are others available that will also work). It is a free terminal application that allows us to connect via telnet through the serial port. Ptelnet can be found at http://netpage.estaminas.com.br/mmand/ptelnet.htm . Download it and load it into your Palm device. Next, hook your palm device to your Kuro. The palm device is wired as a null modem. If you followed the “Add a Serial Port” instructions on the wiki you likely have the port on your Kuro wired as a null modem too. This allows the use of a straight through cable to attach to your computer. You will need to install a null modem connector between your Kuro and your Palm device cable to allow proper communication. Once you start Ptelnet on your Palm device, all that is necessary to control the media player is to login as the user “moc”, but that won’t work until you setup the “moc” user account which is described at the end of this document.
Making it all work with the Nintendo DS with web browser cartridge (optional)
Jinzora runs somewhat slow on the Kurobox, but if you aren’t in a hurry, it does work. We can setup Jinzora in jukebox mode and access it with any standard web browser – including a Nintendo DS with web browser cartridge, although I haven't specifically tested tested this part with a wireless network connection. It does work through the wired network so I have no reason to believe that it won't work.
We installed Jinzora and its dependencies (Apache, PHP, MySQL) as part of the All in One project. If you don’t have them installed the All in One instructions are available on the Kurobox wiki. There are only a few easy steps necessary to configure Jinzora as a jukebox. The following instructions are taken from www.jinzora.com (giving credit where credit is due). Lets get started. First we need to install the Music Player Daemon (mpd).
Next we edit the /etc/mpd.conf:
We change the directories in the configuration file to point to our music. Alternately, we can add symlinks to the directories already defined in mpd. Next we set mpd to automatically start:
rc-update add mpd default
We need to create the log file for mpd:
We create the MPD database:
and start MPD:
All that is left to do is to reconfigure Jinzora. Make sure Jinzora is up and running fully before beginning. Edit the Jinzora settings.php file and set $jukebox = "true".
In your web browser refresh your Jinzora interface. You should now have a "Jukebox bar". You'll now need to edit settings.php in the Jinzora "jukebox" directory (not the root one). The file is documented internally. Please copy the section you plan on using into the section above. Ensure that all the settings you use here match the settings for your player.
We also need to make the wireless network run all of the time since the Nintendo DS works wirelessly. Basically we edit the /etc/sync-with-home script and remove the lines that configure the network, basically making it only mount the master media directory and run the rsync command and edit /etc/net and add the symlink described in the All in One writeup so wlan0 runs constantly. This might be a big security hole depending on your password assigned to moc, so make sure it isn't easy to guess.
Installing a car power supply
We need this whole system to run from a car’s power system. The Kuro requires 12v for the harddisk and 5v for the remaining hardware. There are several options, but the easiest is to purchase a Mini-ITX 12V power supply. They can be purchased on ebay for about $40 shipped and are made specifically for automobiles. All that is necessary is to remove the existing power supply and wire the Mini Itx supply in place. Another less expensive option (since I already had the equipment) is to use the Kuro’s original power supply with a 12V to 120v power inverter. Inverters can be purchased for about $20 (even less at a flea market). This is the option I used.
Making it foolproof
The last thing we want to do is edit the user moc and remove some of its rights. We'll also set its default shell to /usr/local/bin/mocp. This will automatically execute mocp when somebody logs in with the username moc and close the session when they logout. Make moc's password simple if you want, like a single character. This is a potential security hole, but since we are connecting through the serial console and the network is only up when it does an rsync it shouldn’t be too much of a problem once your initial collection is copied to the Kuro as long as you don’t make huge changes to your media collection in any one day. Gentoo will complain about the short password, but it will accept it. You can also remove the login requirement all together, but I wouldn’t recommend that.
useradd moc -m -G users,audio -s /usr/local/bin/mocp passwd moc
Now all that you need to do is login as “moc” and you are good to go.
Where to go from here
There are all sorts of possibilities for future upgrades. Here are some possibilities:
Install lirc and control it with an IR remote control
Install a serial to IRDA converter and use the Palm device wirelessly.
Add an on screen display like the BOB-3 (http://www.decadenet.com/) and use a TV for the display.
Add a video camera and motion detection software for video monitoring of your car when you are away. Also make it connect to the Terastation and upload the video it captures so you have video/photos of the guy who broke into your car and stole your cool media player.
The following is a list of the more useful web pages referenced for this project:
Music on Console (moc): http://moc.daper.net/
Music Player Daemon: http://mpd.wikia.com/wiki/Main_Page
The ALSA Project: http://www.alsa-project.org/
Easy automated snapshots: http://www.mikerubel.org/computers/rsync_snapshots/
ZD1211 wireless network project: http://zd1211.ath.cx