DBZoo - Talent without discipline is like an Octopus on rollerskates.

Using an X330 without a C2T cable

c2t.jpg

It is possible to run the IBM X330 server without the C2T cable for keyboard, video and mouse. The X330 supports a PCI video card and it also supports USB keyboard & mouse. Installing a PCI video card is easy enough, the main problem is that legacy USB is disabled by default and without it the USB keyboard won't work. It can be enabled in the BIOS but that entails using the keyboard, which creates a bit of a catch-22. There is a work-around, that is to use the remote console option that the X330 provides through the RS232 serial port to change the BIOS settings. That enables console redirection to a terminal & one can set up the BIOS from that.

A null modem cable is required to connect the X330 to another PC running a terminal program such as Hyperterminal for Windows. Plug the cable into ComA (com1) of the X330. Set up the terminal software for a baud rate of 9600 (or 57,600), no parity, 1 stop bit and no flow control. Start the terminal software and turn the server power on, press Esc on the terminal to bring up the login screen. Log in as USERID and enter PASSW0RD for the password (all upper case, passw0rd with a zero). From the menu that appears select option Z - Start Remote Video. The line “0 - Write or 2 - Read” should appear then, press 0 (zero) to send the command to the service processor on the server & the console redirection should start. From there it's straightforward, when you power up the server the console will show the X330s boot routine on the terminal just like one sees it normally…..just a bit slow & jerky. Press F1 when the prompt comes up to get into the X330 BIOS and navigate the menus to the option that enables legacy USB. Save your changes, reboot when finished & you should have the USB keyboard working.

On the terminal you can Press Ctrl-R + Ctrl-E + Ctrl-T to redisplay the menu from console redirection mode. Esc returns to the main menu from any sub-menu. The server doesn't have to be running to bring up the terminal session, just needs power applied to it. You do of course need to start the server to get anything coming up on the console once console redirection is enabled. If the USERID and PASSW0RD are rejected you're in trouble, because that's the default login & someone would have changed them if they don't work. Double-check your typing & be sure you're using upper case, if it doesn't work then you need to borrow a C2T cable or read the manual for a way of clearing the NVRAM via jumper on the mainboard. If you get garbage on the screen with the terminal try a baud rate of 57,600. When setting up the BIOS it pays to disable boot error counting as well as that resets the BIOS back to defaults if it detects three interrupted boots in a row. (will lose your USB again if it does that).

2010/04/28 19:46

Home Theatre PC

This hardware is now a low powered Linux server and I've opted for the istar instead.

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:

2010/01/11 10:03

Sweex Router Hacking

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.

sweexrouter.jpg

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.

This router is also rebadged as an Edimax BR6104k.

Interesting to note that the Linux still booted correctly when a USB hub was plugged into the router and the USB pen was plugged into the hub. The OS on the router spotted the hub and installed it. This gives a possible route to adding extra I/O to the router.

Wiring / Hardware hack notes

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.

  1. Clean L14 and L15 with a fibreglass pen, then fit shorting links
  2. Clean the 15K resistor pads R127 and R128 with a fibreglass pen
  3. Fit the 15K resistors
  4. Clear holes for & fit the two capacitors (observe the polarity)
  5. Clear holes for and fit the Xtal
  6. Drill hole in PCB and mount 7805. Clean pads & solder tygadure flying leads to pads
  7. Clear holes for and fit the IDC8 connector
  8. Prepare wires for the USB lead and solder to pads

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.

Pinouts

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

Handy online resources

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

Digital I/O expansion unit

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

Cybiko Gateway aka CyWig

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.

Booting

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

Compiling Kernel

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
2010/01/11 10:00

Remote Monitoring with RRDTOOL

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 Server

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)

Remote Server

Database on elmo

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

Remote logging from bingo

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

Graphing

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"; }
}

Daily Graph (5 minute averages)

Daily Graph (30 minute averages)

2010/01/11 09:56

Mortgage Calculator

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

  • How much interest will I pay?
  • How much in total will I pay back?
  • If I pay more what will I save in money and time?
  • Getting a better interest rate will save how much?
  • Repaying fortnightly instead of monthly will save how much?

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!

loan_calculator.xls

2010/01/11 09:54

Older entries >>

tidbits.txt · Last modified: 2009/11/27 16:59 (external edit)