Well its actually built and I decided that I should get around to documenting what I did. In the meantime here are some pictures of what it looks like.
I was downloading various things onto it so it was convenient to put in next to the hub. I have now wireless enabled the box so it can be happy anywhere.
For the software:
This details our work with the Sweex LB000021 router. Hardware mods to allow an external USB pen to be fitted and the firmware to allow Linux to boot from this.
The unit has 2Mb of Flash ROM, a whopping 16Mb of RAM and 5 RJ45 ports. There is a (TTL level, with no external connector) serial port and a bootstrap loader that allows images to be loaded to the flash ROM via the XModem protocol.
Adding the USB port is a tricky job. The PCB on the router uses surface mount parts, and soldering to the empty pads is not easy. A good tip is to use a fibreglass pen to clean each pad before attempting to solder. A desoldering station can be used to clear out the PTHs for the Xtal, Caps and IDC8 connector.
Rewiring details and pics can be seen here.
Here is a suggested order of wiring.
Working from the edge of the board in, the USB cable colours are red,white,green,black. Fit the 22R resistors in series with the USB data lines inside the USB hub.
JP2
| 2 | 4 | 6 | 8 |
|---|---|---|---|
| +3v3 | n/c | n/c | Gnd |
| RxD | n/c | n/c | TxD |
| 1 | 3 | 5 | 7 |
ADM5120 routers has a serial/console port. On the PCB of the router there is a 8 pin connector called jp2. Here are the pins located for a serial console port (115 kBaud, 8 databits, no parity, 1 stopbit)
http://midge.vlad.org.ua/wiki/console_cable?DokuWiki=7894a2f2ce8c46fc6141ba03cbaa3e04
jp2 2-o o o o-8 1-o o o o-7 1 - Rx 2 - +3.3V 3 - nc 4 - nc (hardware hack: connect to pin #130 ADM5120 - Rx second UART) 5 - nc (hardware hack: connect to pin #131 ADM5120 - Tx second UART) 6 - nc 7 - Tx 8 - Gnd
http://www.linux-mips.org/wiki/Adm5120 - ADM5120 Chip info
http://sprite.student.utwente.nl/~jeroen/projects/lb000021/usb_tutorial/ - Adding the USB parts tutorial
http://vlad.org.ua/adm5120/ - Russian site with lots of info
http://www.norocketscience.com/router/upgrade.htm - Details of the firmware headers etc.
Copied from Google cache of a blog … kernel hack for bridge operation sweex_bridge.rtf
Since the hacked Sweex exposes an RS232 port, it seemed logical to add some I/O expansion capability. A little AVR microcontroller board, with a simple command interpreter can do the job. Since the hacked router uses a Max232, we need another Max232 to bring the levels back down to TTL again. So, the expansion board will have an AVR 2313, a Max232 connectors for I/O pins and RS232. Power can be leeched from the 7805 on the hacked Sweex.
A few lines of Bascom will implement the command interpreter.
Dioioioio - set port directions (i)nput or (o)utput
R - read port bits returning 01010101
W01010101 - write port bits
Using Greg Smiths TCPKIT port the PC based portion of this project the TCPGATE software to the sweex box this would recreate the functionality that the CyWig was suppose to perform.
A cybiko permenently wired to the Sweex RS232 port would act as an IP gateway so that any cybiko in range could access the internet or anything IP based.
Boot sequence from Sweex box
ADM5120 Boot: Linux Loader Menu ==================== (a) Download vmlinuz to flash ... (b) Download vmlinuz to sdram (for debug) ... (c) Exit Please enter your key :
Pressing the space bar three times will jump to the linux loader menu and not automatically boot the device.
Upgrade of the flash using option **a*
Linux Loader Menu ==================== (a) Download vmlinuz to flash ... (b) Download vmlinuz to sdram (for debug) ... (c) Exit Please enter your key : a Downloading.........PASS Eraseing nor flash.......PASS Programming nor flash...PASS
If you compile the kernel with the -mip3 flag on gcc the kernel will fail to boot.
linux-lanner/arch/mips/Makefile: ifdef CONFIG_CPU_MIPS32 # BME #GCCFLAGS += -march=r4600 -mips3 -Wa,--trap GCCFLAGS += -march=r4600 -mips2 -Wa,--trap endif
Problem: I wanted to monitor HDD temperatures and network statistics of machines on my network and feed all the data back to a central point for storage and charting. This page outlines a prototype for remote monitoring of a single machines HDD. I'll leave it as an excerise for the reader to extend to networking.
Reference
rrdtools in server mode require setting up the following:
/etc/xinet.d/rrdsrv
# default: on
# description: RRDTool as a service
service rrdsrv
{
disable = no
socket_type = stream
protocol = tcp
wait = no
user = apache
server = /usr/bin/rrdtool
server_args = - /var/lib/rrd
}
We will run the SERVER as a non-privileged user for protection. We choose the apache user as it's going to need access to the files later to graph them anyway. Make sure the rrdtool logging directory we specified for the server exists.
# mkdir /var/lib/rrd # chmod 755 /var/lib/rrd
Append the following to the /etc/services file. This is the well known port that rrdtools will use by default.
# Local services rrdsrv 13900/tcp # RRD server
Reload XINETD to start this service.
[root@elmo xinetd.d]# service xinetd reload Reloading configuration: [ OK ] [root@elmo xinetd.d]#
Verify that its up and running
[root@elmo xinetd.d]# lsof -i:13900 COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME xinetd 29549 root 5u IPv4 184497 TCP *:rrdsrv (LISTEN)
Before we create a cron job and start monitoring on bingo we need an initialized .RRD database for bingo to log to. We setup the server to log all data into /var/lib/rrd so we need to create an initialize an RRD database in this location.
Run the following script once on ELMO as root:
#!/usr/bin/perl use RRDs; my $rrd = '/var/lib/rrd'; &ProcessHDD("bingo", "hda"); sub ProcessHDD { my($server,$hdd) = @_; # if rrdtool database doesn't exist, create it if (! -e "$rrd/$server-$hdd.rrd") { print "creating rrd database for /dev/$hdd...\n"; RRDs::create "$rrd/$server-$hdd.rrd", "-s 300", "DS:temp:GAUGE:600:0:100", "RRA:AVERAGE:0.5:1:576", "RRA:AVERAGE:0.5:6:672", "RRA:AVERAGE:0.5:24:732", "RRA:AVERAGE:0.5:144:1460"; } }
This will create the file /var/lib/rrd/bingo-hda.rrd however it will be own by root, now remember that the RRDTOOL server is running as apache and will need write access to this file to record data so adjust the owner.
# chown apache /var/lib/rrd/bingo_hda.rrd
This perl fragment is ran on BINGO it will read the temperature of the HDD and make and push the data at an RRD database stored on ELMO.
#!/usr/bin/perl # # rrd_hddtemp.pl use IO::Socket; # Remote RRD server and port my $host = "elmo"; my $port = 13900; my $socket = IO::Socket::INET->new(PeerAddr=> $host, PeerPort=> $port, Proto=> 'tcp', Type=> SOCK_STREAM) or die "Can't talk to $host at $port"; &ProcessHDD($socket, "bingo", "hda"); close $socket; sub ProcessHDD { my($socket,$server,$hdd) = @_; my $temp=`/usr/sbin/hddtemp -n /dev/$hdd`; $temp =~ s/[\n ]//g; print "/dev/$hdd : $temp degrees C\n"; print $socket "update $server-$hdd.rrd -t temp N:$temp\n" ; $answer = <$socket>; print $answer; }
Crontab entry on BINGO to push data to ELMO every 5 mins.
*/5 * * * * /usr/local/bin/rrd_hddtemp.pl >/dev/null
It wouldn't be much of a solution without being able to chart and graph that data that is being collected. To do this we create a CGI script that will dynamically generate a PNG file of the data.
This scripts will accept two arguments as part of the URL - the server and harddrive we are charting. So a query URL will look like this
http://localhost/hdd_temp.cgi?server=bingo&drive=hda
hddtemp.cgi - Place this script in /var/www/html
#!/usr/bin/perl use RRDs; use CGI qw/:standard/; my $rrd = '/var/lib/rrd'; my $img = '/var/www/html'; print header; $server = param('server'); $drive = param('drive'); if ("$server" && "$drive" ) { &ProcessHDD($server, $drive); } else { print "Invalid query parameters"; } sub ProcessHDD { my($server, $hdd) = @_; &CreateGraph($server, $hdd, "day" ); &CreateGraph($server, $hdd, "week"); &CreateGraph($server, $hdd, "month"); &CreateGraph($server, $hdd, "year"); &HTML_Page($server, $hdd); } sub HTML_Page { my ($server, $name) = @_; print start_html(-title=>"$server HDD temps", -meta=>{'refresh'=>'200', 'cache-control'=>'no-cache', 'pragma'=>'no-cache'}, ), h1("$server HDD temps"), h2('Daily Graph (5 minute averages)'), img{src=>"$server-$name-day.png"}, h2('Weekly Graph (30 minute averages)'), img{src=>"$server-$name-week.png"}, h2('Monthly Graph (2 hour averages)'), img{src=>"$server-$name-month.png"}, h2('Yearly Graph (12 hour averages)'), img{src=>"$server-$name-year.png"}, end_html; } # creates graph # inputs: $hdd: hdd name (ie, hda, etc) # $interval: interval (ie, day, week, month, year) sub CreateGraph { my ($server, $hdd, $interval) = @_; RRDs::graph "$img/$server-$hdd-$interval.png", "--lazy", "-s -1$interval", "-t hdd temperature (/dev/$hdd)", "-h", "180", "-w", "600", "-a", "PNG", "-v degrees C", "DEF:temp=$rrd/$server-$hdd.rrd:temp:AVERAGE", "LINE2:temp#0000FF: (/dev/$hdd)", "GPRINT:temp:MIN: Min\\: %2.lf", "GPRINT:temp:MAX: Max\\: %2.lf", "GPRINT:temp:AVERAGE: Avg\\: %4.1lf", "GPRINT:temp:LAST: Current\\: %2.lf degrees C\\n"; if ($ERROR = RRDs::error) { print "$0: unable to generate $hdd graph: $ERROR\n"; } }
The Mortgage calculator is an excel spreadsheet that is useful for calculating the cost of repaying your house loan back to the lender.
It answers such questions as
If these are the types of questions are you been asking then the loan calculator is just what you are looking for.
It even has a section so that you can calculate what these figures mean in a different currency!
Perle Sun | RJ 45 RJ45 RJ45 | Sun Pin Pin | 1 (DCD) Green White n/c | 1 Blue 2 (DSR) Green --- 7 DSR | 2 Orange White 3 (DTR) Orange White --- 2 DTR | 3 Brown 4 (GND) Orange --------- 4 GND | 4 Orange 5 (TXD) Brown White ---- 6 RXD | 5 n/c 6 (RXD) Brown ---------- 3 TXD | 6 Brown White 7 (CTS) Blue White ----- 8 CTS | 7 Green 8 (RTS) Blue ----------- 1 RTS | 8 Blue White
CS9000/JETSTREAM CONVRT RJ45 DB25 CONVRT TO SUN Part #: 04024520
CS9000/JETSTREAM Cable 3M RJ45 SUN/CISCO To Perle For Sun Part #: 04024500
RJ45 serial port wiring info for Perle here
This is the output from attaching a serial cable to the ADMIN port and powering on the unit. Hyperterminal set to 9600,8,N, 1
At the login prompt try Username 'admin' with no password.
Board id : 4300085R3.1 ROM size : 1 x 1MB RAM size : 2 x 2MB Num ports : 8 Diag codes : 01 03 04 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 08 09 0A 0A 0B 0C 14 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 16 18 19 ÏÙÏÙ1B 1C 1E 33 35 2B 25 26 28 27 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 28 29 6A 6B 2C 32 37 3A 46 48 92 93 94 95 Decompressing - ................................................................ ................................................................................ .........................................done B0 B1 B2 B3 B4 B5 B6 B7 B8 B9 BA BB INIT: booting... INIT: parallel ports found: 1 INIT: serial ports found: 8 Time: 16:34:23 Date: 19/06/2007 File sytem has 30 blocks, 30 are free INIT: TCP stack initialised Perle JETSTREAM 4000 Version 2.6.1.G login: admin password: JS_4000# show hardware mac address 0080ba601d9a board id JS4300085R3.1 processor 80386 uarts 1 * Serial ASIC flash rom 1 x 1MB ram 2 x 2MB battery ram 32kB serial ports 8 parallel ports 1 ethernet interface RJ45 ethernet speed auto date 19/6/2007 time 16:38:05 JS_4000#
These images are for Board revision: 4300085R3.1
Click for a full 1600×1200 resolution image
Bootup dump from Admin (RS232) port : Board id : 4300085R1.0 ROM size : 1 x 1MB RAM size : 2 x 2MB Num ports : 8 Diag codes : 01 03 04 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 06 08 09 0A 0A 0B 0C 14 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 16 18 ÏÙÏÙ1B 1C 1E 33 35 2B 36
Note: The Diag codes above contains a couple of 'unprintable' chars. The unit always seems to freeze after printing the '36' with the Power LED at solid amber and no other lights visible. Pressing the 'factory reset' button does nothing (held in for 5 secs).
Trueport drivers install on Windows and create 'virtual' comm ports on the Perle box.
To allow the Trueport drivers to connect to the Perle box, some commands must be run on the Perle box.
First, the details of the host that will connect need to be specified … e.g. 'add host hostname 192.168.11.1'
Then each port that is to be used needs to be configured …
e.g. 'set line 1 service silent raw hostname 10000'
Thinking of hooking up a DS1820 temperature kit via the Perle box. This kit looks good. However, it seems to source its power directly from the RS232 port. Can the Perle box supply sufficient current? Can't find anything in the Perle documentation re the hardware specs for the ports.
DB9 female to RJ45 female adaptors - http://www.microwarehouse.co.uk/catalogue/item/STARAD17?cidp=NexTag&utm-source=nextag&utm_medium=pcc