Skip to content

OpenWRT Mini Handbook

SlimYang edited this page Feb 19, 2011 · 12 revisions

The purpose of this handbook is to provide the necessary knowledge for the Airplug project. The background knowledge and command line information included here has been mostly verified and most references are listed or linked directly.


1. OpenWRT versions.

There are several versions (click here for OpenWRT History) of OpenWRT (e.g. Kamikaze, White Russian) and the latest version is Blackfire 10.03.1-rc4. The reason for introducing the different version here is that, OpenWRT in different version will have different packages (thus different addresses) to update and install (e.g. Kamikaze 7.06 and Kamikaze 8.09.2 have a different version of MPD).

To check your version of OpenWRT, type in command line:

cat /etc/banner

Watch a line like (however, there are some versions that do not look that obvious):

Kamikaze(7.06)---------------

The subversion of your OpenWRT is shown on the top if you are running on VMWare, should be something like:

OpenWrt Kamikaze (x86-2.6)

Thus your OpenWrt version is Kami



kaze/7.06/x86-2.6

2. How to download and update your OpenWRT packages

In most cases, with the following two simple stages, you can update your package lists and install a certain package you want. First you need to run

o(i)pkg update

This command will update the list of the packages on the website and then if you want to install mpd on the OpenWrt, simply run in the command line:

o(i)pkg install mpd

(If you can install mpd, you can simply ignore the following. However, the following graph introduced some other methods that might be useful later.)

If you cannot successfully install mpd using the previous steps, then things will be complicated as follows:

Assume your OpenWrt version is Kamikaze/7.06/x86-2.6, then simply go to

http://downloads.openwrt.org/

go click kamikaze->7.06->x86-2.6->packages

(if you are in a different version, you can simply do the similar things and you will find the corresponding packages for you to update). So the current address we are in is

http://downloads.openwrt.org/kamikaze/7.06/x86-2.6/packages/

The address line on your browser now is the address you need to remember and copy. In order to update your package update configuration document, type

vi etc/opkg.conf

(Before you change the opkg.conf document, please backup the configuration file because changing this file and then using the update command might cause a change in the architecture of your system!).

This is for the system with opkg package management system. There are two possible package management system on OpenWrt: ipkg and opkg. (For the ealier versions, they use ipkg. For the latter ones, they use opkg.) If you does not see an empty file after this command, this is to say that your package management system is opkg. Otherwise, your system is ipkg.

To edit the documents using vi, you need to click a button on the keyboard and then you are in the editing mode. When you finishes editing, press Esc or Del to get to the command mode.

In the editing mode, you need to delete all the lines starting with src and type in the following clause on the top:

src kamikaze-7.06 http://downloads.openwrt.org/kamikaze/7.06/x86-2.6/packages/

The address in this sentence should be the address where your update packages is settled. Then go to the command line by click Esc or Del then type

:w

This should write your document and then type:

:q

This should quit you from the vi and put you on the command line of OpenWRT.

Then you need to run

opkg update

This command will update the list of the packages on the website and then if you want to install mpd on the OpenWrt, simply run in the command line:

opkg install mpd

(Sometimes this command will fail because of the following two reasons: (1). your package does not have an mpd file: In order to solve this problem, you can try to find some other packages which includes an mpd file, i.e. you can type:

opkg install http://downloads.openwrt.org/kamikaze/7.06/brcm47xx-2.6/mpd_0.12.0-1_mipsel.ipk

This means, if we want to install our own version of mpc or mpd onto the router, we can first upload it into somewhere on the internet (e.g. dropbox) and download it to the router if we found that installation from the usb is unsafe! But we need to make sure that test first that the architecture of the OpenWrt and mpc are compatible.

(2.) you have chosen a wrong update package and the architecture has been changed. Then you need to recover the opkg.conf file and find some other solutions.)

3. How to install OpenWrt on a router.

There are one passage (working on Asus WL-500gx model), one video and many references on the official website of OpenWrt. As can be seen from the OpenWrt official website, the installation for different routers can be slightly different.

Detailed installation procedure will not be stated here. The possible software required are:

  • Router Firmware (please visit and download the latest version for your router from here).

  • Your router utility (this will help you to install the new firmware of the router.

  • PuTTy (Allows SSH into the router, which makes the communication easier and safer).

  • Some other software depending on the actual design.


3.1 How to install OpenWrt on a router (Buffalo WZR-HP-G300NH).

The reason why this WZR-HP-300NH router solution is introduced here is this model is one of our vehicle.

There is a dedicated wiki site how to install OpenWRT on Buffalo WZR-HP-G300NH


3.1.1 Flash from Buffalo original DD-WRT to OpenWRT

Basically, please above wiki instruction. OpenWRT compiled image can be download from here Select either

openwrt-ar71xx-wzr-hp-g300nh-jffs2-tftp.bin

Or

openwrt-ar71xx-wzr-hp-g300nh-squashfs-tftp.bin

There may be a few hiccups during flashing process (on Windows PC). Below is the memo that needs to be added on the top of Wiki

  1. arp command needs to be executed under administrator privilege. In order to execute arp command with administrator privilege, follow below step

    Goto Windows -> Run -> Specify "cmd" -> SHIFT+CTRL+ENTER Execute below arp command

arp -s 192.168.11.1 [MAC ADDRESS OF ROUTER]
  1. TFTP program included with Vista,it not install by default. To install tftp in vista Open the Control Panel and select "Turn Windows features" on or off form program list entry. Check in the box next to TFTP Client. Click OK.

  2. Timing that router allow TFTP is very limited. (I was able to execute TFTP following procedure)

    • Plug power cable
    • Wait until window(OS) recognizes cable connection.
    • When windows show connections on task panel, execute TFTP within 3 seconds
  3. After successfuly flashing OpenWRT, connect to Router by TELNET to 192.168.1.1 NOT 192.168.11.1 (since OpenWRT default IP address is 192.168.1.1)


3.1.2 Flash from old OpenWRT to new OpenWRT

Once OpenWRT was installed on Router, flashing different version of OpenWRT is quite easy. OpenWRT has web I/F (called Luci) and by using this web I/F flashing can be done.

  1. Download OpenWRT image that needs to be flashed Image can be download from here

    Select either

openwrt-ar71xx-wzr-hp-g300nh-jffs2-sysupgrade.bin

Or

openwrt-ar71xx-wzr-hp-g300nh-squashfs-sysupgrade.bin
  1. Access to Luci (default is 192.168.1.1)
  2. Navigate menu to flash
  3. Specify OpenWRT Image file
  4. Click Flash

4. How to install MPD, MPC on OpenWRT

Running Environment:

  1. OpenWRT Backfire 10.03 (x86)
  2. Buffalo WZR-HP-G300NH (for more information about how to install Openwrt on this router, please click here.
  3. A USB soundcard.

Necessary Testing Environment:

  1. Windows System
  2. ario-1.5-win32.msi (ario installation file can be download from here, you might also need another library libgtk to enable you to install the ario, which can be download from here.

MPD MPC Installation Procedure:

  1. Run
    root@OpenWrt:/# opkg update
  1. Run
    root@OpenWrt:/# opkg install mpd mpc
  1. Run MPD to see whether you need some other libraries, by typing
    root@OpenWrt:/# mpd
You might face some error message telling you that you are missing some libraries, e.g.,
    mpd: can't load library 'libdns-sd.so'
    mpd: can't load library 'libavformat.so.52'
    mpd: can't load library 'libspeex.so.1'
You might need to install some other packages to get these libraries, e.g.,
    root@OpenWrt:/# opkg install mdnsresponder libspeex libffmpeg alsa-lib
If you are facing some problems regarding the audio output, ignore it.     
  1. make some new directories under "root" directory by typing:
    root@OpenWrt:~# mkdir .mpd
    root@OpenWrt:~# mkdir music
    root@OpenWrt:~# mkdir .mpd/playlists
You may put some music into the /root/music directory for the testing later.
  1. To edit the MPD configuration file, type
    root@OpenWrt:/#  vi /etc/mpd.conf
Uncomment all the following:
    music_directory                	"~/music"
    playlist_directory              	"~/.mpd/playlists"
    db_file			"~/.mpd/database"
    log_file			"~/.mpd/log"
    pid_file			"~/.mpd/pid"
    state_file		"~/.mpd/state"
    
    input {
	    plugin		"curl"
    }
    
    audio_output {
	    type		"oss"
	    name		"My OSS Device"
	    device		"/dev/dsp"
	    format		"44100:16:2"
	    mixer_device	"/dev/mixer"
	    mixer_control	"PCM"
    }

save and quit and reboot the Openwrt.

  1. install the usb-audio package by typing:
     root@OpenWrt:/# opkg install kmod-usb-audio kmod-usb-ohci
If you saw an error message ask you to downgrade error, you can still install the package by typing
     root@OpenWrt:/# opkg -force-downgrade kmod-usb-audio kmod-usb-ohci
However, this might have an strong influence on the kernel from not allowing you to install some other packages unless you flush the firmware again.
  1. Then plug in the usb sound card onto the router and type:
    find -name dsp
This will help you to find the position of dsp file on your router, if the route to dsp is the same as the one in mpc.conf file, i.e.
     /dev/dsp
Then there is no need to change anything on the settings. However, if the dsp is on another directory, e.g.,
    /dev/sound/dsp
Then you need to change the mpd.conf file by tying 
    root@OpenWrt:/#  vi /etc/mpd.conf
and set the audio-output part you just uncommented into the follows:
    audio_output {
	    type		"oss"
	    name		"My OSS Device"
	    device		"/dev/dsp"
	    format		"44100:16:2"
	    mixer_device	"/dev/mixer"
	    mixer_control	"PCM"
    }
And save and quit.
  1. Change the localhost by typing
    vi /etc/localhost
change the settings into the following
    127.0.0.1 localhost
    78.24.191.177	downloads.openwrt.org
  1. Open the ario on windows, add the ip address and nameof your router then click connect. Then find the file system tag and play your local music under music directory on OpenWrt. You can also choose to listen to the radio from the internet.