Mini howto ghetto wgt634u mpd and upmpdcli wireless upnp media receiver

I have successfully configured a small wifi audio setup.
Hardware used:
-Netgear wgt634u (runs openwrt 18.06.02, has one usb port). Should work with any other router running openwrt and having at least one usb port. If the router has 2 ports then the usb hub isnt needed or if the router has enough flash to install mpd full package (8meg on the wgt634u is not enough and will fail reporting not enough space to complete).
I flashed openwrt on the wgt634u over serial using tftp so i assume openwrt is already installed on your router.
-SMSL q5 pro amp with 2 old 8ohms bookshelf speakers connected to usb.
-usb2 hub, any should do since the wgt634u is usb1 only, it does not matter. needed to run extroot and the smsl q5 pro over usb both at the same time.
-any usb pendrive (I use a basic 4GB one) to run extroot, formatted to ext4.
I use a tplink archer c7 v2 as my main router, also running openwrt. This one has a WDS access point virtual SSID to allow the wgt634u as client WDS ap. WDS virtual interface bridged to lan interface on both sides.

I assume wds is properly running, and you can access the wgt634u ip over wifi from the lan.

On the wgt634u:

opkg update
opkg install kmod-usb-ohci-pci usbutils

This will fire up usb on the wgt634u and you should be able to show the usb key and the amp:

root@wgt634u:~# lsusb
Bus 002 Device 004: ID 054c:0243 Sony Corp. MicroVault Flash Drive
Bus 002 Device 003: ID 0451:0003 Texas Instruments, Inc.

Then, extroot:
follow this guide: This is required to run the needed full mpd package cause it did not work using the mini-mpd package. I was getting a decoding issue for http requests in the mini-mpd package cause apparently it is missing some libraries to decode the stream coming from upnp server/upmpclid.

Worked perfectly for me.

reboot router and check everything is detected and running properly:

root@wgt634u:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 2.5M      2.5M         0 100% /rom
tmpfs                    13.6M    696.0K     12.9M   5% /tmp
/dev/sda1                 3.6G     27.6M      3.4G   1% /overlay
overlayfs:/overlay        3.6G     27.6M      3.4G   1% /
tmpfs                   512.0K         0    512.0K   0% /dev

/overlay reporting 4g so extroot is working.

At this point, we have space to install the mpd package, kernel sound support and upmpdcli.

opkg install kmod-usb-audio kmod-sound-core usbutils
opkg install mpd upmpdcli

The wgt634 does not have the alsa package in openwrt, so just stick to OSS, no other package needed. MPD supports oss just fine.

What I had to do next:
Create a /mpd dir at the root of the flash with 777 permission, this is ghetto style. I tried to run mpd as user nobody but it creates permission issues to /dev/dsp and /dev/mixer. Tried to chmod them to 777 but its back to 700 after a reboot since they are character devices, so I run mpd as root damn it.

mkdir /mpd
mkdir /mpd/music
mkdir /mpd/playlists
touch /mpd/database
touch /mpd/log
chmod -R 777 /mpd
# ls -la /mpd
drwxrwxrwx    4 root     root          4096 Apr 28 12:17 .
drwxr-xr-x    1 root     root          4096 Apr 28 12:11 ..
-rwxrwxrwx    1 nobody   nogroup        146 Apr 28 12:13 database
-rw-r--r--    1 root     root          3773 Apr 28 12:34 log
drwxrwxrwx    2 root     root          4096 Apr 28 12:12 music
-rw-r--r--    1 root     root             5 Apr 28 12:18 pid
drwxrwxrwx    2 root     root          4096 Apr 28 12:12 playlists

Edit /etc/mpd.conf

music_directory         "/mpd/music"
playlist_directory              "/mpd/playlists"
db_file                 "/mpd/database"
log_file                        "/mpd/log"
pid_file                        "/mpd/pid"
#state_file                     "/mpd/state"
sticker_file                    "/mpd/sticker.sql"
#user                           "nobody"
#group                          "nogroup"
user                           "root"
group                          "root"
bind_to_address         ""
port                            "6600"
save_absolute_paths_in_playlists        "no"
metadata_to_use "artist,album,title,track,name,genre,date,composer,performer,dis
auto_update     "yes"
input {
        plugin "curl"
audio_output {
        type            "oss"
        name            "My OSS Device"
        device          "/dev/dsp"      # optional
        mixer_type      "hardware"      # optional
        mixer_device    "/dev/mixer"    # optional
        mixer_control   "PCM"           # optional
buffer_before_play              "35%"

Added this since the wgt634u is a bit slow cpu-wise (top shows 1-2 about cpu load continuous while playing :)) and is skipping a little at the start of a track but plays smoothly after the beginning:

buffer_before_play              "35%"

Everything else commented out.

Then for upmpdcli:
Edit /etc/config/upmpdcli.conf:

# cat /etc/config/upmpdcli
config upmpdcli lan
        option interface 'br-lan'
        option friendly_name 'upmpdcli'
        option mpd_host ''
        option mpd_port '6600'
        option upmpd_port '0'
        option config '/etc/upmpdcli.conf'

# Add additional interfaces
#config upmpdcli wifi
#       option interface 'wlan0'

#config upmpdcli wan
#       option interface 'eth0'

Fire up upnplay (my prefered upnp controller, available at on the android phone, browse to music file and pick the upmpdcli receiver to play to.

For troubleshooting purposes:
Run upmpdcli and mpd like so to check what is happening:

mpd --no-daemon --stderr
upmpdcli -h -p 6600 -f wgt -i br-lan

both at the same time, since they talk to each others.

Enjoy music.


Just installed, very nice and useful
but my openwrt router is connected to the network via wan with a different ip address, i tried this configuration but i don't see the reader in the network resources
could you help me ?

config upmpdcli lan
	option interface 'br-lan'
#	option friendly_name 'upmpdcli'
#	option mpd_host ''
#	option mpd_port '6600'
#	option upmpd_port '0'
#	option config '/etc/upmpdcli.conf'

# Add additional interfaces
#config upmpdcli wifi
#	option interface 'wlan0'

config upmpdcli wan
	option interface 'eth0.2'
    option friendly_name 'Mp3Stream'
    option mpd_host ''
	option mpd_port '6600'
	option upmpd_port '0'
	option config '/etc/upmpdcli.conf'

not sure what you are trying to do. Usually you want to run upmpdcli on the lan interface, not wan.
If you want to reassign the port assigned to wan from wan to lan, then you can do it in the switch menu in luci.
Also, wan probably has a default set of iptables, meaning incoming trafic might be dropped by default.