[Tutorial] Building ShairPort from scratch!

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware
Author Message
Eric Rwnage
DD-WRT Novice


Joined: 24 Dec 2011
Posts: 7

PostPosted: Mon Dec 26, 2011 7:36    Post subject: [Tutorial] Building ShairPort from scratch! Reply with quote
Quote:
If you wish to make an apple pie from scratch, you must first invent the universe.
— Carl Sagan


ShairPort is an open source implementation of the RAOP protocol. It allows AirPlay clients (iTunes, iPods, etc.) to stream music through your attached speakers.

The goal of this guide is to build a ShairPort package and deploy it on DD-WRT.

Step 0: Prerequisites

We're going to build inside a virtual machine. Setting up the virtual machine is outside the scope of this guide. I used Debian 6.0.3 for amd64.

You should also have Optware installed. I don't care for Optware, the Right Way because it installs so much crap on your router. I've attached a simplified script you may use that should be exactly what you need.

Both OTRW and my script install important kernel drivers for audio output over USB. You should also appropriately configure USB support; this too is out of scope.

Step 1: Building the toolchain

Now we will build Optware inside the VM. The basis for this part is "Add a Package to Optware" though I hit some bumps.

As the page says, you'll need to install a handful of packages:

Code:

# apt-get install gcc cvs flex bison make pkg-config rsync gettext libglib2.0-dev autoconf libtool automake automake1.9 sudo patch bzip2 wget sed texinfo subversion


Now check out the Optware source and prepare our dd-wrt build directory:

Code:

# cd ~ && svn co http://svn.nslu2-linux.org/svnroot/optware/trunk optware
# cd optware && make ddwrt-target


At this point Optware has created a directory called 'downloads' where it will cache downloaded source bundles. Since Optware requires some packages that aren't available from their default download locations, we can put files here to prevent a build error:

Code:

# wget -P downloads ftp://debian.lcs.mit.edu/pub/linux/devel/binutils//binutils-2.17.50.0.8.tar.bz2
# wget -P downloads http://ftp.gnu.org/gnu/gdb/gdb-6.5a.tar.bz2
# mv downloads/gdb-6.5a.tar.bz2 downloads/gdb-6.5.tar.bz2


With those in place we can continue on to building our toolchain. This takes quite a while, so be patient.

Code:

# cd ddwrt && make directories toolchain ipkg-utils



optwarethewrongway.txt
 Description:
Alternative, minimal Optware script. Rename to "optwarethewrongway.sh" after download.

Download
 Filename:  optwarethewrongway.txt
 Filesize:  4.59 KB
 Downloaded:  890 Time(s)



Last edited by Eric Rwnage on Tue Dec 27, 2011 4:41; edited 3 times in total
Sponsor
Eric Rwnage
DD-WRT Novice


Joined: 24 Dec 2011
Posts: 7

PostPosted: Mon Dec 26, 2011 8:32    Post subject: Reply with quote
Step 2: Building ShairPort

I've attached a Makefile for building ShairPort. It is probably not up to the same standards as other Optware build scripts, but it should work. Be sure to put it in optware/make not optware/ddwrt/make, and rename it to "shairport.mk". The forum does not allow me to upload with the correct extension.

However, esound, a dependency if libao and hence of ShairPort, does not compile correctly because it uses a variable named $echo which is not defined. So, we'll modify the esound Makefile to fix this.

Edit optware/make/esound.mk and find this line:

Code:

$(PATCH_LIBTOOL) $(@D)/libtool


After it, add these two. Indent the 'sed' line with one tab (omitted below due to phpBB).

Code:

sed -i -e '1 a\
echo=/bin/echo' $(@D)/libtool


With that fix, compiling ShairPort is as easy as this:

Code:

# make shairport-ipk


When finished, it will have built a .ipk in optware/ddwrt/builds named something like "shairport_0.05-1_mipsel.ipk".

Step 3: Building D-Bus

The D-Bus that currently builds with Optware does not work on dd-wrt due to the -fPIE compiler flag, as noted (incorrectly) on "Adventures with DD-WRT Part 5".

I'm working on compiling this properly. For now, elsewhere on the forum you can find a prebuilt .ipk with a fixed D-Bus.



shairport.txt
 Description:
Makefile for ShairPort. Rename to "shairport.mk" after download.

Download
 Filename:  shairport.txt
 Filesize:  7.47 KB
 Downloaded:  838 Time(s)

Eric Rwnage
DD-WRT Novice


Joined: 24 Dec 2011
Posts: 7

PostPosted: Mon Dec 26, 2011 8:56    Post subject: Reply with quote
Step 4: Installing dependencies

You should transfer your ShairPort and D-Bus .ipk files to your dd-wrt router now. We'll go ahead and install dependencies first:

Code:

# ipkg-opt install libao openssl avahi


Note though that we need to replace D-Bus with our own build:

Code:

# ipkg-opt remove -force-depends dbus
# ipkg-opt install dbus_1.2.16-2_mipsel.ipk


Next we need to add our daemon user and group, per "Adventures with DD-WRT Part 5". N.B.: These will be wiped on reboot, so you should configure a script to do this automatically.

Code:

# echo "netdev:x:1:" >> /tmp/etc/group
# echo "avahi:x:2:" >> /tmp/etc/group
# echo "avahi:x:2:2:avahi daemon:/opt/sbin/avahi-daemon:/bin/false" >> /tmp/etc/passwd


Next we will install the Avahi daemon init.d script, once again courtesy of "Adventures with DD-WRT Part 5". Drop the attached script in /opt/etc/init.d/ and rename it to "S21avahi-daemon" (removing the extension). Don't forget to change its permissions:

Code:

# chmod +x /opt/etc/init.d/S21avahi-daemon


Now you can run both D-Bus and Avahi with:

Code:

# /opt/etc/init.d/S20dbus start
# /opt/etc/init.d/S21avahi-daemon start



Step 5: Installing ShairPort

Like installing any package, it's straightforward:

Code:

# ipkg-opt install shairport_0.05-1_mipsel.ipk



Step 6: Running ShairPort

TODO: I should write an init script to run this in the background. But you can start Shairport as simply as this:

Code:

# /opt/etc/init.d/S45soundmodules start
# shairport


it will show up in iTunes or wherever with the name "ShairPort".

TODO: Device name configuration, so it's not "ShairPort".

TODO: Performance isn't great; audio can sound choppy. I should investigate how to improve this.



S21avahi-daemon.txt
 Description:
Avahi daemon init script. Rename to "S21avahi-daemon" after download.

Download
 Filename:  S21avahi-daemon.txt
 Filesize:  434 Bytes
 Downloaded:  637 Time(s)

quihong
DD-WRT Novice


Joined: 09 Sep 2009
Posts: 6

PostPosted: Tue Oct 23, 2012 0:29    Post subject: Reply with quote
Hello,

I'm trying to compile Shairport using these instructions but need some help.

When I try "make shairport-ipk" I'm getting a compile error related to gcc/collect2.c

"declared with attribute error: open with O_CREAT in second argument
needs 3 arguments"

I've googled this error and the suggestion is to edit the collect2.c file and add the extra argument, however the file gets replaced and I'm not sure where its coming from or how to make my edit stick.

I'm using the latest version of Ubuntu (also tried Debian but ran into a different error). Any help is appreciated. Thanks

Code:

gcc   -g -O2 -DIN_GCC -DCROSS_COMPILE  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic -Wno-long-long   -DHAVE_CONFIG_H  gcov.o intl.o version.o   ../libiberty/libiberty.a -o gcov
gcc   -g -O2 -DIN_GCC -DCROSS_COMPILE  -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wtraditional -pedantic -Wno-long-long   -DHAVE_CONFIG_H    -I. -I. -I/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc -I/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/. -I/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/config -I/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/../include  \
        -DTARGET_MACHINE=\"armv5b-softfloat-linux\" \
        -c /home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c -o collect2.o
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c: In function ânoticeâ:
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:362:1: warning: traditional C rejects ISO C style function definitions [-Wtraditional]
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c: In function âfatal_perrorâ:
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:374:1: warning: traditional C rejects ISO C style function definitions [-Wtraditional]
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c: In function âfatalâ:
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:392:1: warning: traditional C rejects ISO C style function definitions [-Wtraditional]
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c: In function âerrorâ:
/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:408:1: warning: traditional C rejects ISO C style function definitions [-Wtraditional]
In file included from /usr/include/fcntl.h:252:0,
                 from /home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/system.h:208,
                 from /home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:30:
In function âopenâ,
    inlined from âcollect_executeâ at /home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:1575:20:
/usr/include/i386-linux-gnu/bits/fcntl2.h:51:24: error: call to â__open_missing_modeâ declared with attribute error: open with O_CREAT in second argument needs 3 arguments
make[2]: *** [collect2.o] Error 1
make[2]: Leaving directory `/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/build-gcc-core/gcc'
make[1]: *** [all-gcc] Error 2
make[1]: Leaving directory `/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/build-gcc-core'
make: *** [/home/user1/optware/optware/toolchain/crosstool/.built] Error 2


I attempt to edit line 1575 of collect2.c
Code:

Change: redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT);

To: redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT, 0777);



Rerun "make shairport-ipk" but get the same error.
tjma
DD-WRT Novice


Joined: 11 Dec 2012
Posts: 2

PostPosted: Tue Dec 11, 2012 8:55    Post subject: Reply with quote
quihong wrote:


Code:

In file included from /usr/include/fcntl.h:252:0,
                 from /home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/system.h:208,
                 from /home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:30:
In function âopenâ,
    inlined from âcollect_executeâ at /home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c:1575:20:
/usr/include/i386-linux-gnu/bits/fcntl2.h:51:24: error: call to â__open_missing_modeâ declared with attribute error: open with O_CREAT in second argument needs 3 arguments
make[2]: *** [collect2.o] Error 1
make[2]: Leaving directory `/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/build-gcc-core/gcc'
make[1]: *** [all-gcc] Error 2
make[1]: Leaving directory `/home/user1/optware/optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/build-gcc-core'
make: *** [/home/user1/optware/optware/toolchain/crosstool/.built] Error 2


I attempt to edit line 1575 of collect2.c
Code:

Change: redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT);

To: redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT, 0777);



Rerun "make shairport-ipk" but get the same error.

Hello! to fix this error need todo:
edit optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c
Code:

-  redir_handle = open (tracefn, O_CREAT|O_TRUNC|O_WRONLY);
+  redir_handle = open (redir, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR|S_IWUSR);

makeing chmod 0400 to optware/toolchain/crosstool/build/armv5b-softfloat-linux/gcc-3.3.5-glibc-2.2.5/gcc-3.3.5/gcc/collect2.c

PS worked on ubuntu 12


Last edited by tjma on Fri Dec 14, 2012 13:02; edited 1 time in total
quihong
DD-WRT Novice


Joined: 09 Sep 2009
Posts: 6

PostPosted: Wed Dec 12, 2012 18:21    Post subject: Reply with quote
Thanks for the reply @tjma

The collect2.c file keeps getting replaced and I can't figure out how to stop it from doing it. I attempted to change ownership of the file and chmod-ing it to read only, but it still gets replaced.

I also attempted to download the gcc lib (untar, modify file, and retar) to have a local cache version, but that didn't work either. I'm obviously doing something wrong.

Can you share your compiled packaged? Thanks
tjma
DD-WRT Novice


Joined: 11 Dec 2012
Posts: 2

PostPosted: Fri Dec 14, 2012 13:14    Post subject: Reply with quote
quihong wrote:
Thanks for the reply @tjma

The collect2.c file keeps getting replaced and I can't figure out how to stop it from doing it. I attempted to change ownership of the file and chmod-ing it to read only, but it still gets replaced.

I also attempted to download the gcc lib (untar, modify file, and retar) to have a local cache version, but that didn't work either. I'm obviously doing something wrong.

Can you share your compiled packaged? Thanks

if you are using ubuntu it can help you (see attach) it is my collect2.c with revisions.
If it can't help, sorry, I don't know any more
PS I had a mistake in the code, sorry, edited prev message



collect2.c
 Description:
you must change the rights to 0400 before compiling

Download
 Filename:  collect2.c
 Filesize:  93.3 KB
 Downloaded:  1374 Time(s)

quihong
DD-WRT Novice


Joined: 09 Sep 2009
Posts: 6

PostPosted: Fri Dec 14, 2012 18:07    Post subject: Reply with quote
Thanks for the reply @tjma

I understand the changes I need to make to the collect2.c file. My changes just isn't sticking, meaning the file get replaced eventhough I used chmod 0400.

Can you please share this file - "shairport_0.05-1_mipsel.ipk"?
blueman2
DD-WRT User


Joined: 24 Nov 2008
Posts: 62

PostPosted: Fri Dec 28, 2012 5:21    Post subject: Reply with quote
Wow, this is EXACTLY what I have been looking for. I want to use my Belkin N300 router as an Airport device to stream music from my Ipad and Ipod (and Android using iRemote). Has anyone else had success with this procedure?
blueman2
DD-WRT User


Joined: 24 Nov 2008
Posts: 62

PostPosted: Sat Dec 29, 2012 6:46    Post subject: Reply with quote
Well, I have been working on this but am failing in compiling the shairport_0.05-1_mipsel.ipk. Would anyone who has succeeded in creating this ipk be willing to share it with me?
davy_gravy
DD-WRT User


Joined: 05 Jun 2010
Posts: 159

PostPosted: Sat Mar 09, 2013 3:41    Post subject: Reply with quote
here: http://tomatousb.org/forum/t-573238#post-1727034

and here is my own roll of shairport for Broadcom routers:
http://dl.dropbox.com/u/1015928/ddwrt/shairport/shairport_0.05-1_mipsel.ipk
anees.sw
DD-WRT User


Joined: 17 Sep 2010
Posts: 267
Location: India

PostPosted: Sat Mar 23, 2013 8:28    Post subject: Reply with quote
davy_gravy wrote:
here: http://tomatousb.org/forum/t-573238#post-1727034

and here is my own roll of shairport for Broadcom routers:
http://dl.dropbox.com/u/1015928/ddwrt/shairport/shairport_0.05-1_mipsel.ipk

Thanks for the share!
Iv installed without any errors. But when I run shairport I get the error
Code:
buffer value must be > 30 and < 512
davy_gravy
DD-WRT User


Joined: 05 Jun 2010
Posts: 159

PostPosted: Sat Mar 23, 2013 22:29    Post subject: Reply with quote
Sorry, I've not used it... just rolled it as a convenience to others...
smokinabowl
DD-WRT User


Joined: 21 Sep 2007
Posts: 373
Location: pittsburgh pa

PostPosted: Sun Mar 24, 2013 17:57    Post subject: Reply with quote
i've been part of the communication over on that forum as well (Mike M)

your "buffer must be between 30-512" message means you need to specify the buffer (-b) option:

shairport -a "Your_Desired_Name" -b 282 -d

read the entire thread over there to see how to get everything up and running, all the info is there.

I tried experimenting with different buffer sizes, anything less than 250ish it will be choppy when first starting then smooth out. 282 gives good results, and about 1-2 seconds of lag when changing volume/switching songs.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum