Tuesday, 27 December 2011

TP-Link WR703N, OpenWRT, MPD et al

Finally, a post....
I bought a TP-Link WR703N [1], it's a little router meant to be used in conjunction with a 3G Modem, it works as an access point broadcasting a wireless connection allowing multiple devices to utilize the modem at once (quite a clever idea, however, not one I'm interested in using), hence I decided to flash it with OpenWRT [2]

Specs:

RAM - 32Mb
ROM - 4Mb
USB port (USB2)
CPU - Atheros AR7240 - 400Mhz
Wireless - Atheros AR9331 - b/g/n

Powered by a micro usb port, 5.7cm x 5.7cm, serial interface.
(These are just the basics, more here [3])

OpenWRT Install:
The device comes preinstalled with Chinese firmware, I connected the router via ethernet and configured Arch to have the IP 192.168.1.2 (in /etc/rc.conf) but you could also easily use wifi to upload the new firmware.

After connecting to the router, keep hovering over the menu items, the page file names are in English, keep expanding the drop down menus until you find one with a page name similar to 'software upgrade', something along those lines (I do believe it's in one of the last sections). Go to the OpenWRT wiki and download the 'vanilla' firmware for the router, upload this, once the router has upgraded the firmware, it should reboot.

Having now installed the OpenWRT firmware, you can connect to the router via the ethernet port if you configure your computer's IP to be 192.168.1.2, telnet into the router using:
telnet 192.168.1.1
There you are presented with the CLI of the router where you can start manipulating things. Use opkg update to update the packages list and opkg install *package name* to install applications

These are simply the basics and much more informative instructions can be found on the OpenWRT forums and wiki.

OpenWRT Configuration:
I wanted to use the router as a wireless client (i.e. similar to a computer), I used the following network configurations

/etc/config/network

config 'interface' 'loopback'
option 'ifname' 'lo'
option 'proto' 'static'
option 'ipaddr' '127.0.0.1'
option 'netmask' '255.0.0.0'


config 'interface' 'lan'
option 'ifname' 'eth0'
option 'type' 'bridge'
option 'proto' 'static'
option 'ipaddr' '192.168.1.1'
option 'netmask' '255.255.255.0'


config 'interface' 'wan'
 option 'proto' 'dhcp'

/etc/config/wireless
config 'wifi-device' 'radio0'
option 'type' 'mac80211'
option 'channel' '11'
option 'macaddr' '38:83:45:a2:14:18'
option 'hwmode' '11ng'
option 'htmode' 'HT20'
list 'ht_capab' 'SHORT-GI-20'
list 'ht_capab' 'SHORT-GI-40'
list 'ht_capab' 'RX-STBC1'
list 'ht_capab' 'DSSS_CCK-40'

config 'wifi-iface'
option 'device' 'radio0'
option 'network' 'wan' #Set the adapter to act as a wide area network -- not sure why
option 'ssid' 'Price LAN'
option 'key' '*******'
option 'encryption' 'psk2' # My network uses psk2 security
option 'mode' 'sta' #Setup client mode

In the section 'config 'wifi-iface'' I've setup the router to act as a client by setting the 'mode' to 'sta' which sets the router to act as a client rather than an access point.

USB Support:
I needed USB support as the router only has a 4mb flash which isn't sufficient to install transmission, mpd, mpc etc. I updated
/etc/opkg.conf to remedy this (look at the wiki page on opkg, there is a section on how to do this).

Now I could install to my memory stick using the command
opkg -d usb install *package name*
This usually works fairly well, I had to update my PATH variable in /etc/profile to reflect the new install directories.

I've also played around in /etc/rc.local setting up some startup applications.
I've got mpd, transmission-daemon and mpc (adding playlists) on startup. 

Links:
[1] - $22/£15 - http://www.volumerates.com/product/genuine-tp-link-tl-wr703n-150m-11n-mini-wifi-wireless-router-for-instant-wifi-connection-99273
[2] - https://openwrt.org/
[3] - OpenWRT wiki page on WR703N - http://wiki.openwrt.org/toh/tp-link/tl-wr703n

I might continue to update this post as I progress with the project. I aim to use this router to act as a internet radio, I'll probably use an arduino to interface it with an LCD and rotary encoder.

Wednesday, 17 August 2011

A little bit about Arch Linux

I've recently switched from Ubuntu to Arch, which I have always wanted to do but time restrictions have been in the way, since it's summer I've been able to dedicate a good chunk of time to do this. I have a few things I'd like to note about it for myself as a historical record.

The installer did not work for me on the official download page. I downloaded multiple isos from the releng arch site which proved futile, again with installer problems, I finally downloaded 08.15 which worked flawlessly from a local-core install (I didn't want to download the packages from the internet - netinstall as I have a rubbish connection). After this install I had my arch installation up and running, command line only using the nouveau kernel module I do believe (The terminal was full screen, which isn't the case without nouveau, nvidia doesn't run it fullscreen either)

A few bits and pieces on config files:
Added net-profiles and net-cfg to start my wireless connection at boot up (init level 3) that way I wouldn't have to touch it when I launch X. I had to add a config file in /etc/network.d/ for netcfg to work, which was based on wireless-wpa in the examples folder, this was easy, added pricelan, the name of my netcfg profile to rc.conf in the NETWORKS=() section. Installed dbus and ntfs-3g, the latter I edited my fstab to automatically mount on startup. I had to add avahi-daemon to daemons in rc.conf for rhythmbox to start properly otherwise it would take ages to start up.

So now I wanted to setup my system, for the basics I Installed:
- Xorg & nvidia for a graphical interface
- Xmonad for window managing (wonderful!)
- Links to browse the internet from the command line so I could read the wiki as I installed xorg etc, highly recommended.
- Dmenu to launch programs in xmonad

Once I could launch X using the basic twm wm, I changed to xmonad, I did this by changing my ~/.xinitrc to launch xmonad, just placing 'xmonad' at the bottom of the file, nice and easy. When you launch X this time, you'll notice you just have a cross, press 'Alt-P' to launch d-menu and then some applications, 'man xmonad' has a good summary of the window tiling algorithm commands.

Now to install my essential applications:
- Chromium for web browsing
- Rhythmbox for music
- gnome-terminal
- Nautilus for file browsing

After installing these I couldn't get chromium to launch nautilus from the "Show in folder" dialog in downloads, I ammended this by installing 'perl-file-mimeinfo' which has the command 'mimeopen', it handles all the mimetypes so when you open files, it opens the proper program. After installing this chromium launched fine, however I had added the following lines to
~/.local/share/applications/defaults.list and ~/.local/share/applications/mimeapps.list
"inode/directory=nautilus-folder-handler.desktop"
which may be needed, I don't know, I didn't try it without adding these lines.

Rhythmbox won't open .pls files in the radio section as some gnome services aren't running, I know it isn't gnome-settings-daemon, or obviously the keyring daemon. I'll have to look further into this to try and remedy the issue, I hope to find the right service to run rather than running xmonad ontop of gnome, I prefer xmonad neat, gnome3 is horrid. Anyway, I don't need a DE, WM will do me fine.

I'm still fiddling about with setting the wallpaper in xmonad, I'm using "xloadimage -onroot -fullscreen $path to image" at the moment which isn't stretching my 1980x1200 wallpapers to 1980x1080, A bit more exploration is required on my part to sort this out, once I have I'll be adding it to my ~/.xinitrc so when X starts my wallpaper will be set.

I have dipped my toes into xmonad configuration but the haskell syntax is a bit off-putting and I'm struggling with it at the moment but this holds your hand quite well and I'm currently going through it. The xmonad wiki is pretty handy as well, I think this will take a while to produce decent results though.


I'd finally like to say I only switched to arch based on it's philosophy and beautiful wiki.

P.s. man does jekyll look good...

Friday, 10 June 2011

The Blogs moved to wordpress!

I was a bit bored with blogger seeing as there are many limitations which I'd like to get rid of, so I've installed wordpress on some free hosting
Please tell me what you think, from an authors point of view, posting is now far more powerful and I can do lots more, e.g. use LaTeX to format equations, better support for embedding code etc. It makes my life easier.

I'm still in the process of sorting everything out, and moving the blog over, but it should be done pretty soon. I'll also be able to start blogging again quite soon (Exams are nearly over!)