In a previous post, I showed you how to listen on any device the music you have stored on a Symbian phone. In this post, I will teach you to do the opposite: control the music being played on your N900 with any device. The nice thing about this is that you can connect your N900 to your main speakers. That way, you will be using your Nokia N900 as a wireless home music system that is small, quiet and portable. After finishing this tutorial, you will also be able to connect to your N900 via SSH and FTP, manage your software repositories, compile applications, and setup scripts to be run at boot time.
First of all make sure that you back up all your N900 data. No kidding. We are going to make some changes that could possibly brick your phone. This means that you may need to re flash your firmware if anything goes wrong. If you are not OK with this, stop reading. I will not be held responsible for any problems you may encounter. You have been warned.
The N900 is an awesome device, it is a Linux computer in the form of a smartphone. Because of that, you can do pretty much anything you could do on a regular Linux computer and more, since you have all the extra features of a smartphone like sensors and a battery. One of the things a regular Linux computer can do is to play music with a great program called Music Player Daemon (MPD), which is the program we are going to install on the N900.
The first step is to configure the repositories. A repository is a place where programs are stored. You can have different repositories available on your system. Each repository that you have enabled in your system allows you to install different sets of programs. Note that on the N900, repositories are called catalogs.
To manage your repositories on your N900, go to the App. Manager and click on the menu on top. There, select Application Catalogs.
Here (maybe after waiting a little) you will see the current list of enabled and disabled catalogs. Disabled catalogs are not considered by the system, so all the applications you can install come from the enabled catalogs. Write down which catalogs are enabled and which ones are disabled as this is your original configuration and you may want to go back to it after we are finished.
Now, let’s add some catalogs. Click on the New button and fill in the information provided for the four following catalogs:
Maemo SDK: This catalog provides core system utilities that we will need to build programs.
Catalog Name: Maemo SDK Web address: http://repository.maemo.org/ Distribution: fremantle/sdk Components: free non-free Disabled: Unchecked
Maemo tools: This catalog provides tools that are very useful, like nano or wget.
Catalog Name: Maemo tools Web address: http://repository.maemo.org/ Distribution: fremantle/tools Components: free non-free Disabled: Unchecked
Maemo extras-testing: This catalog provides more applications than the ones in the default Maemo catalog (extras), although they are not as thoroughly tested.
Catalog Name: Maemo extras-testing Web address: http://repository.maemo.org/extras-testing/ Distribution: fremantle Components: free non-free Disabled: Unchecked
Maemo extras-devel: This catalog contains many useful applications but some of them are in heavy development. This catalog should be disabled by default and enabled only temporarily to install specific applications. Make sure that you disable Maemo extras-devel when you add it.
Catalog Name: Maemo extras-devel Web address: http://repository.maemo.org/extras-devel/ Distribution: fremantle Components: free non-free Disabled: Checked
These catalogs provide different applications that we will need later. Disable Maemo extras-devel and enable the other three.
Now exit the Application Catalogs screen. The N900 will automatically update the list of applications after you changed the repositories. If you didn’t see any update, click on the Update button just to be sure. Now click on Download->All to see the list of applications available to install. You should install the following apps:
openssh client and server rootsh sudser Personal IP Address
When you install OpenSSH, you will be asked for a password. This is the root password, so keep it safe.
Now close the application manager and open the console (X Terminal). In there, you will setup a password for the default user, which is user. Write this:
sudo passwd user
And write a password for the user user, which is the default user (non root privileges). Close the console or write exit to exit.
OK, on the desktop you now should be able to see your current IP address. You can use that IP to connect via SSH or FTP to your N900 with either root or user using the passwords you just set for them. If you don’t have Linux installed on your computer, you can use Filezilla for FTP and PuTTy for SSH. Make sure that you can connect to your N900 with the user account.
Now we will be working with the command line only, so I suggest you to connect from your computer via SSH (as user) for easier writing (or copy pasting). Make sure that the App. Manager is closed before continuing.
On the console, write the following:
sudo apt-get install build-essential wget grep-gnu libglibmm-2.4-dev nano mpc libao0 libaudiofile-dev libaudiofile0 libcurl3-dev libcurl3 libpulse-dev pulseaudio libavcodec-dev
It should install all these packages without a problem. When it is finished, go to the App. Manager, enable Maemo extras-devel and then close the App. Manager. Ignore any updates that are offered by your phone at this point.
Now go back to the console, and write the following (make sure that the App. Manager is closed before you do so):
sudo apt-get install libasound2-dev libmad0-dev libid3tag0-dev libflac-dev libflac++-dev
If it asks “Install these packages without verification?” Answer yes.
Once it is finished installing the packages, go to the App. Manager and disable all of the four repositories we used (Maemo SDK, Maemo Tools, Maemo extras-testing, Maemo extras-devel).
OK, now your N900 is ready to compile software. We are now going to get and compile Music Player Daemon (MPD).
Open the console (X Terminal) and write the following:
cd mkdir tempdelme cd tempdelme wget http://downloads.sourceforge.net/project/musicpd/mpd/0.16.6/mpd-0.16.6.tar.gz tar -xvzf mpd-0.16.6.tar.gz cd mpd-0.16.6/ ./configure make sudo make install
After some time, it should be ready. Now MPD is installed in /usr/local/bin/mpd. Check that everything is OK with this command (Thanks Martin for suggesting the –no-daemon option):
/usr/local/bin/mpd --version --no-daemon
It should display the formats it is able to play (i.e. mp3, flac, wav, etc). If you need more functionality than what is presented, install the extra needed libraries and then run ./configure; make; sudo make install again. Most people should be OK with the current settings.
Now that we have MPD installed, we need to configure it. Write this:
nano /home/user/.mpdconf
This will open a text editor. Write the following in there:
port                   "6600" music_directory        "/home/user/MyDocs/music" playlist_directory     "/home/user/.mpd/playlists" db_file                "/home/user/.mpd/mpd.db" log_file               "/home/user/.mpd/mpd.log" user "user" bind_to_address "any" audio_output { type "alsa" name "MPD ALSA" mixer_type "software" }
Make sure that all your music files and folders are inside the defined music_directory.
Now let’s create those directories
mkdir -p /home/user/.mpd/playlists mkdir -p /home/user/MyDocs/music
And now put some music files in the music_directory that you defined previously. You can use FTP to easily transfer music from your PC to that folder in the N900. After you put some music, generate the MPD database:
sudo /usr/local/bin/mpd --create-db
Now we can start MPD with this:
sudo /usr/local/bin/mpd /home/user/.mpdconf
Test that everything is working:
mpc update mpc add / mpc play
If you hear music, then everything is great. You can stop the music with:
mpc stop
You can now delete the temporary files we used for the compilation:
cd rm -r tempdelme
OK, so now MPD is installed on your N900. You can connect with any client to it. Actually, we just connected with one of them, mpc, a console client for MPD.
If you are using firefox, you can use Music Player Minion. If you have an IPod/IPhone/IPad/etc… you can use MPoD. There are many clients for MPD, virtually for any device that you may have at your house.
Enjoy playing with your cool new wireless home sound system.
The last (optional) step is to launch MPD automatically when you power up your phone. The N900 uses upstart to control the boot scripts, so let’s create an upstart script for MPD:
sudo nano /etc/event.d/mpd
In that file, write the following:
start on started hildon-desktop script exec /usr/local/bin/mpd /home/user/.mpdconf end script stop on starting shutdown
That’s it. Reboot your phone and MPD should be running. You can check it by using the same music test from before, or directly looking at the process:
ps aux | grep mpd
If it says something like this:
1630 user    46276 S   /usr/local/bin/mpd /home/user/.mpdconf 1642 user     2088 S   grep mpd
It means that MPD is running. If on the other hand only the second line appears, it means it is not running.
You can close MPD by killing the process like this:
killall mpd
Finally, note that depending on your battery saving settings your N900 may disable wifi connections initiated from outside (like your SSH or FTP connections) after some inactivity time. You can make sure that the wifi connection keeps open by just pinging the router:
sudo ping 192.168.0.1
Enjoy.
Great tutorial, thank you very much, I’ve been wanting MPD on my N900 for a couple of years!
One thing to note that when you suggest checking the version after “make install” it actually starts the daemon, the next time you try to run the mpd command it complains about not being able to bind to port 6600 (because the previous instance is bound to port 6600 already).
Checking version like this “/usr/local/bin/mpd –version –no-daemon” should prevent this error.
Again, thanks for the guide, I would have never gotten around to attempting to compile it myself if I hadn’t have found these instructions.
I’m glad I could help.
Thanks for the comment Martin, I updated the post with the –no-daemon option as you suggested.
Works great, thank you
this i great piece of work . one thing which i miss on n900 maybe their is a mod available but i cdnt get it ,how to shutdown ,reboot n900 without using hardware keys . creating touch button with scripts . i tried but cudnt , hope somebody cud help me do it.
Thanks!…
Well, you can control your N900 via a web based interface… that way you can reboot or do anything you want with touch buttons locally or over the network.
Take a look at this article:
http://talk.maemo.org/showpost.php?p=859488&postcount=24
Fantastic!
Being that the sound chip in N900 is extremely good it make for a much better listening device than most laptops. Using MPD it is of course controllable from the very laptop anyway.
A big thanks for the tutorial!
Hi, I’m trying to follow your instructions, but must be doing something wrong, as I can’t manage to install eg. “build-essential”. This is what I get:
Nokia-N900-51-1:~$ sudo apt-get update
Hit http://repository.maemo.org fremantle-1.3 Release.gpg
Ign http://repository.maemo.org fremantle-1.3/free Translation-no
Hit https://downloads.maemo.nokia.com ./ Release.gpg
Ign http://repository.maemo.org fremantle-1.3/non-free Translation-no
Hit http://repository.maemo.org fremantle Release.gpg
Ign http://repository.maemo.org fremantle/free Translation-no
Ign http://repository.maemo.org fremantle/non-free Translation-no
Hit http://repository.maemo.org fremantle Release.gpg
Ign http://repository.maemo.org fremantle/free Translation-no
Ign http://repository.maemo.org fremantle/non-free Translation-no
Ign https://downloads.maemo.nokia.com ./ Translation-no
Ign http://repository.maemo.org fremantle/tools Release.gpg
Ign http://repository.maemo.org fremantle/tools/free Translation-no
Ign http://repository.maemo.org fremantle/tools/non-free Translation-no
Ign http://deb.opera.com fremantle-1.3 Release.gpg
Ign http://deb.opera.com fremantle-1.3/non-free Translation-no
Hit http://repository.maemo.org fremantle-1.3 Release
Hit http://repository.maemo.org fremantle Release
Hit http://repository.maemo.org fremantle Release
Hit https://downloads.maemo.nokia.com ./ Release.gpg
Ign http://repository.maemo.org fremantle/tools Release
Hit http://deb.opera.com fremantle-1.3 Release
Ign http://repository.maemo.org fremantle-1.3/free Packages/DiffIndex
Ign http://repository.maemo.org fremantle-1.3/non-free Packages/DiffIndex
Ign http://repository.maemo.org fremantle/tools/free Packages/DiffIndex
Ign https://downloads.maemo.nokia.com ./ Translation-no
Ign http://repository.maemo.org fremantle/tools/non-free Packages/DiffIndex
Ign http://deb.opera.com fremantle-1.3/non-free Packages/DiffIndex
Hit https://downloads.maemo.nokia.com ./ Release.gpg
Ign http://repository.maemo.org fremantle/free Packages/DiffIndex
Ign http://repository.maemo.org fremantle/non-free Packages/DiffIndex
Ign http://repository.maemo.org fremantle/free Packages/DiffIndex
Ign http://repository.maemo.org fremantle/non-free Packages/DiffIndex
Hit http://repository.maemo.org fremantle-1.3/free Packages
Hit http://repository.maemo.org fremantle-1.3/non-free Packages
Hit http://repository.maemo.org fremantle/tools/free Packages
Hit http://repository.maemo.org fremantle/tools/non-free Packages
Ign https://downloads.maemo.nokia.com ./ Translation-no
Hit http://deb.opera.com fremantle-1.3/non-free Packages
Hit https://downloads.maemo.nokia.com ./ Release
Hit https://downloads.maemo.nokia.com ./ Release
Hit http://repository.maemo.org fremantle/free Packages
Hit https://downloads.maemo.nokia.com ./ Release
Hit http://repository.maemo.org fremantle/non-free Packages
Hit http://repository.maemo.org fremantle/free Packages
Hit http://repository.maemo.org fremantle/non-free Packages
Ign https://downloads.maemo.nokia.com ./ Packages/DiffIndex
Ign https://downloads.maemo.nokia.com ./ Packages/DiffIndex
Ign https://downloads.maemo.nokia.com ./ Packages/DiffIndex
Hit https://downloads.maemo.nokia.com ./ Packages
Hit https://downloads.maemo.nokia.com ./ Packages
Hit https://downloads.maemo.nokia.com ./ Packages
Reading package lists… Done
Nokia-N900-51-1:~$ sudo apt-get install build-essential
Reading package lists… Done
Building dependency tree
Reading state information… Done
E: Couldn’t find package build-essential
What am I missing here?
Replying to my previous comment: I double checked my repositories – and found that I had typed “fremantle/tools” instead of “fremantle/sdk”. Now it seems to work :).
The mpd seems to be running and working on my N900 now, but I can’t hear any music. mpc status show that a song is playing, and if I check with “top”, I see mpd and pulseaudio are running at about 4-9% CPU each.
I have tried to connect with mini-jack. I have also restarted the phone, but it doesn’t seem to help.
Is there something I’m missing in the .mpdconf file? I have set the audio_output as describe in you post. There’s nothing special in the /home/user/.mpd/mpd.log file.
Output of “mpd –no-daemon –version” is:
Supported decoders:
[mad] mp3 mp2
[oggflac] ogg oga
[flac] flac
[audiofile] wav au aiff aif
Supported outputs:
null fifo alsa oss pulse httpd recorder
Supported encoders:
null wave flac
Supported protocols:
file:// http://
Any suggestions?
Oh boy, I had the silent profile active, switching to the general profile solved the problem.
Thanks so much for this post – I now got it working so that I can choose songs from my N9 and play them on the N900.
Great!
Thanks Martin for sharing your troubleshooting steps… maybe they will help somebody else.
And that’s a nice mobile setup you have there, N9 and N900, very linuxy :)
My n900 recently became to worn to use as a phone, since it now gets disconnected from the SIM whenever I use the keyboard. Following your guide, I now have a mpd server. Thanks!
For what it is worth, I did compile the newer version mpd-0.17.2 without any problems. My attempts at building a debian package of it did however not work out, due to watchdog reboots from system resource exhaustion on every attempt. So kids, don’t bother trying to generade deb packages for maemo without cross compiling.
Using the fm sender was my primary motivation for using the n900. To fully transform my old phone into a music server, the following two scripts are scheduled to be run from alarmd. The first one, setup_mpd_and_fm_sender, runs every minute, while shutdown_if_unplugged only runs once an hour to shutdown the device cleanly when the power strip for my stereo is turned off.
#!/bin/sh
# setup_mpd_and_fm_sender
is_mpd_running()
{
netstat -nat|egrep ‘^tcp.*:6600.*LISTEN’
}
is_fm_enabled()
{
/usr/bin/fmtx_client|grep -q state=enabled
}
is_mpd_running || /usr/local/bin/mpd /home/user/.mpdconf
is_fm_enabled || /usr/bin/fmtx_client -p1
/usr/bin/fmtx_client -s`date “+%H.%M”`
#!/bin/sh
# shutdown_if_unplugged
is_charger_connected()
{
lshal|grep -q “maemo.charger.connection_status = ‘connected'”
}
do_power_off()
{
dbus-send –system –type=method_call –print-reply –dest=com.nokia.dsme “/com/nokia/dsme/request” com.nokia.dsme.request.req_shutdown
}
if ( ! is_charger_connected );
then
sleep $(( 5 * 60 ))
is_charger_connected || do_power_off
fi
Hey Sampi, that is a great addition, thanks!
Would be nice if someone made a package of mpd available in the repositories. Anyone up for that?
I totally agree on that Jesper, although I think that maemo.org is a better place for that kind of discussion.
Here is a thread about mpd:
http://talk.maemo.org/showthread.php?t=65647
Very cool. Thanks very much for this tutorial. Worked like a charm.
I only had two small issues.
Looks like the mpd source may not be hosted on source forge anymore. Didn’t look into it much. Got a 404 on the wget step, so I just manually got the source from musicpd.org. Was not as adventurous as the other guy and stayed with 0.16.6 to be safe with the dependencies..
Following your instructions, I got an error when starting mpd that it could not find the database. I ended up running ‘sudo /usr/local/bin/mpd –create-db’ with a parameter specifying the db file from .mpdconfig and that resolved it.
So thanks again for the instructions. My N900 has been sitting in a drawer for months and it now has use again. Now to load a web server and host a php mpd client.
Thank you! Worked for me.
Hey!
I was trying to make a backport and ran into a lot of issues, then decided to google a little more hoping someone have compiled mpd for n900
THANK YOU A LOT ! your article was very helpful
If its useful for someone mpd >=0.18 won’t compile since it requieres libglib >2.25 while maemo has 2.20, so just use 0.17.6, must clients requires >0.15 so wont be problems for most people.
regards
You’re welcome maop. I’m glad it helped you.
Thanks for your guide, but I cannot get any music out of the device: error.log always says:
Jan 17 13:09 : player process died from signal: 11
whenever I try to play a mp3.
mpd is run as user and my config is:
~ $ cat .mpdconf
port “6600”
music_directory “/home/user/”
playlist_directory “/home/user/.mpd/playlists”
db_file “/home/user/.mpd/mpd.db”
log_file “/home/user/.mpd/mpd.log”
error_file “/home/user/.mpd/error.log”
user “user”
bind_to_address “any”
audio_output {
type “alsa”
name “MPD ALSA”
mixer_type “software”
}
Additional info:
~ $ mpd –version
mpd (MPD: Music Player Daemon) 0.13.0
Copyright (C) 2003-2007 Warren Dukes
This is free software; see the source for copying conditions. There is NO
warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Supported formats:
mp3 mp2 ogg flac wav au aiff aif mpc amf dsm far gdm imf it med mod mtm s3m stm stx ult uni xm
Supported outputs:
alsa ao oss
When I use mplayer to play one of these mp3 it works:
~ $ mplayer /home/user/MyDocs/mp3/abc/A-Ha/Hunting\ High\ And\ Low/01\ -\ Take\ On\ Me.mp3
MPlayer SVN-r30099-4.2.1 (C) 2000-2009 MPlayer Team
Playing /home/user/MyDocs/mp3/abc/A-Ha/Hunting High And Low/01 – Take On Me.mp3.
Audio only file format detected.
Clip info:
Title: Take On Me
Artist: A-Ha
Album: Hunting High And Low
Year: 1985
Comment:
Track: 1
Genre: Pop
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 44100 Hz, 2 ch, s16le, 128.0 kbit/9.07% (ratio: 16000->176400)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
[AO OSS] audio_setup: Can’t open audio device /dev/dsp: No such file or directory
AO: [alsa] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback…
A: 3.6 (03.6) of 322.0 (05:22.0) 39.6%
any suggestions?
Thanks in advance!
CU Michael