Apr 26

DIY LCD monitor fix

If your LCD monitor (or television) turns on but the screen is blank (or goes blank after a few seconds) chances are the back-light is not receiving sufficient power. You can check by shining a torch on the screen – you’ll see the images are still there, just to dark to be visible.  The LCD back-light is powered from the monitor’s internal power-supply and in most cases the black screen is caused by a faulty capacitor.

You can check by removing the back from the monitor and inspecting the PSU board, the faulty capacitors will be easy to spot:

 

They bulge at the top and in some cases, the bottom. Replacement parts can be found at stores such as Jaycar Electronics and will cost around $1. Make sure you get one with the same capacitance and with at least the same voltage rating. Unsolder the faulty capacitor (note the polarity) and solder in the replacement, reassemble the monitor, plugin and continue to enjoy.

Oct 07

Reading fan tacho with Arduino

3 wire fans are commonly found in computers such as CPU coolers, PSU fans, etc. If you have a spare one laying around, here is a quick and fun experiment to try.  The three wires consists of (usually) red (positive), black (negative) and tacho (yellow). Some fans will have a white tacho wire, it seems to depend on what colour the factories happen to have on hand at the time.

 

Left: 40MM fan with yellow tacho wire. Right: 120MM fan with white tacho wire.

 

The tacho output is triggered twice per revolution, so on the ‘scope we see:

 

To read the fan RPM with the Arduino, hook the fan up to a appropriate external power supply, usually 12 volts.

What I have done is setup two interrupts, one to count the pulses from the fan tacho wire, the other one calculates the RPM. To count the pulses, connect the fan tacho lead to digial pin two on the Arduino via a 10K pull up resistor, in this example, I use the attachInterrupt call which takes three parameters:

  1. Set which interrupt pin to use, ’0′ (pin 2) or ’1′ (pin 3).
  2. The function to call
  3. The condition to trigger the interrupt, in this case on a RISING signal.

The source code for the Arduino:

 

volatile int counter = 0;
volatile int result = 0;
volatile int led = 13;
void setup() {
 cli();
 TCCR1A = 0;
 TCCR1B = 0;
 TCNT1 = 0;
 OCR1A = 15624; //(16*10^6) / (1024 * 1) -1
 TCCR1B |= (1 << WGM12);
 TCCR1B |= (1 << CS12) | (1 >> CS10);
 TIMSK1 |= (1 << OCIE1A);
 sei();
 pinMode(led, OUTPUT);
 attachInterrupt(0,rpm,RISING);
 Serial.begin(9600);
 }
ISR(TIMER1_COMPA_vect) {
 result = (counter / 2) * 60;
 counter = 0;
 }|
void rpm() {
 counter++;
 }
void loop() {
 Serial.println(result);
 }

 

The results are simply printed to the serial line which can be viewed using the serial monitor option in the Arduino IDE, but you could attach an LCD display or log the data, etc. For an fuller explanation of how to program the timers, see the links below.

 

References:

Sep 22

Watch this video if you are using disk encryption



There is a patch available for Linux that stores the key in the CPU registers rather than RAM, making it impossible to use the techniques outlined in the video.

Sep 22

Battlefield 10th anniversary

Its been ten years since EA released Battlefield 1942 and the Battlefield series has gone from strength to strength. However BF1942 is still my all time favourite game.


Sep 18

Trancoding your movies for viewing on ipad.

I like to lay around and watch movies on my iPad but as my movies are all on DVD, this represents a bit of a challenge. However for Linux users there are some great utilities that will allow you to transcode your DVDs so you can view them on your ipad.  The first thing you’ll need to do is visit the App store and grab a copy of ‘Oplayer‘ which like vlc player, can play just about any video codec you can think of.

To create playable copies of  your favourite DVDs, you’ll need to install ‘dvd::rip‘ on your Linux host. The ripping process will take a little time, depending on your hardware and the encoding options you chose. When it is complete, you can use vlc player to check the results. dvd::rip produces great results but from time to time you’ll get rips where the sound is way out of sync with the video, I find such videos unbearable.

To fix any sound sync. problems, first use the track synchronisation controls in vlc to discern how many seconds forward or backwards the sound track has to be adjusted. Once you have worked that out, you can can use mencoder to easily fix the sync issue:

mencoder myrip.avi  -oac copy -ovc copy  -delay -4.8 -o myripp-fixed.avi

The crucial setting is the ‘delay’ option where ‘-4.8′ will delay the sound by minus 4.8 seconds. You would use the minus option if the sound was ahead of the video. Similarly, you would use ‘-delay 4.8′ if the sound was behind the video. You can test your settings by only copying a small amount of the video:

mencoder myrip.avi  -oac copy -ovc copy  -delay -4.8 -o myripp-fixed.avi -endpos 240

This will only copy (and adjust the sound) for the first 240 seconds of the film, so you can quickly view it to ensure the sound is right. When you’re  happy, just re-run the original command and happy viewing!

 

 

 

Sep 09

Chroot voodoo

I’ve picked up on the dark-arts of ‘architectural chroot‘. Normally chroot is used to restrict a program to a certain directory structure and prevent it from see anything outside of it. For example, you can run an apache server in a chroot for extra security. The advantage of this is that if the apache process is compromised, the damage is limited to the chroot’d environment.

We can also use chroot to emulate an environment for computer architectures other than what the host is running on. In this example, we going to set up a chroot for the Raspberry Pi. The advantage of doing this is that we can  compile programs within a ‘native’ environment for the Pi with the speed of the much faster host.

First, we need a static version of qemu. If you are using Debian/Ubuntu, I believe there is a static qemu package available, otherwise you can grab the source from http://wiki.qemu.org/Download.

Building static qemu binary for ARM

Unpack the qemu source and change into the source directory and build qemu:

./configure –disable-kvm –target-list=arm-linux-user –static –disable-werror –prefix=/usr/local/qemu

make

sudo make install

You can set the –prefix option to whatever suits. When the build is complete, you can test the result with this simple “hello world” ARM binary:

/usr/local/qemu/bin/qemu-arm ./test

Preparing the environment

Now comes the interesting part. First we register the qemu-arm interpreter with its binary format with the kernel:

sudo -s

echo   ‘:arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-arm:’ > /proc/sys/fs/binfmt_misc/register

Note that you should change the ‘/usr/local/bin/qemu-arm’ path to where ever you installed the qemu-arm program. The code was taken from the qemu-binfmt-conf.sh found in the qemu build directory. Mount the Raspberry PI SD card somewhere, eg /media/rpi and copy the qemu-arm program into the same location (relative to /media/rpi) as you did on the host system:

sudo mkdir -p /media/rpi/usr/local/qemu/bin

sudo cp/usr/local/qemu/bin/qemu-arm /media/rpi/usr/local/qemu/bin/qemu-arm

You may also want to mount the following:

sudo mount –rbind /dev /media/rpi/dev

sudo mount –rbind /proc /media/rpi/proc

sudo mount –rbind /sys /media/rpi/sys

 

Now for the magic part:

chroot /media/rpi

And if all is well, ‘uname -a’ will display:

Linux bofh.localdomain 3.5.1-1.fc17.x86_64 #1 SMP Thu Aug 9 17:50:43 UTC 2012 armv7l GNU/Linux

If you instead get an error like

chroot: failed to run command `/bin/bash’: No such file or directory

It means that you have not placed the ‘qemu-arm’ program in the correct place on the PI SD disk or have given the wrong path when registering it with the kernel.

Sep 03

PI. Raspberry PI.

If you haven’t yet heard about it, Raspberry PI is a complete PC on a board just bigger than a credit card. The ‘B’ model contains a 700Mhz ARM processor and GPU. 256Mb RAM, HDMI, video, network, USB and sound. It runs of a flashcard of the type typically used in digital cameras. It also run on Linux and will boot into LXDE by default,

 

The Raspberry PI development board. That is a $1 coin at the top of the picture.

And it can be yours for a measly $25.00. Yes, a complete working computer for $25.00! So what can you do with a $25.00 computer the size of a credit card? Aside from using as a mere PC, you can install XBMC and use it as a multimedia center as its capable of playing full screen HD video:

Presently I plan to install MAME on it, its compiling as I speak and when its finished I can relive the glory days of arcade games!

 

Update #1: Compiling MAME on the PI directly results in a ‘Unrecognizable insn’. I’ve tried reducing the optimization from to 1 (-O1), we’ll see if that works.

Update #2: -O1 did not work either. Adding ‘ -fno-optimize-sibling-calls’ moved it along a bit, but still no joy. Trying -O0.

Update #3: So far so good!

Update #4: Compiling finished successfully, but I forget to setup the SDL libraries.  Install SDL libraries and go again.

Update #5: Success! You can get the binaries from my github:

git clone git://github.com/darrinh/mame-arm-bin.git mame

cd mame

chmod 755 *

You can run most games straight from the console without having to start X-Windows. Also don’t forget to run ./advcfg to setup your screen resolutions first. Enjoy!

Aug 14

Open-source Education

In a sunny Bay Area classroom, twenty sixth graders are working at computers. They are making websites—”MySpace” pages for figures from American History. One student is researching Frederick Douglass’s five greatest accomplishments. Another is showing a classmate how to search for pictures of Susan B. Anthony. They’re all learning how to use Google Sites, helping each other along the way. Earlier this week, this class learned how to add numbers in a spreadsheet. Last week, they learned how to make music on a simple synthesizer. People often assume that getting technology into classrooms is expensive, but this lab cost absolutely nothing.

The problem? An underfunded school needed computers for the classroom. Budget? $0. Staff involved? Just one: Robert Litt, a sixth-grade teacher.

Robert teaches at ASCEND, a small arts K-8 school in the Alameda County School District. He’s a fan of technology and believes that it’s an important part of K-12 education. Yet ASCEND had no computer lab and no computers in classrooms. So in 2007, Robert acquired 18 donated computers. But these computers were less help than he’d anticipated. The operating systems were slow. Some computers had viruses or malware. Students became frustrated.

Read more – http://ifixit.org/3001/how-one-teacher-built-a-computer-lab-for-free/

Aug 04

Extreme secure shelling!

If you maintain multiple Linux servers like load-balanced pairs for example, then you should install and use the cluster ssh client – it will change your life.  In short, it allows you to open multiply ssh connections and any commands you type into the cssh window will be mirrored on the clustered connections. Cluster ssh is the best thing since sliced bread.

 

Jul 26

NIC bonding in Linux (Ubuntu 12.04)

Bonding is a method of grouping or aggregating Ethernet interfaces to provide higher throughput and/or fault tolerance. To use bonding in Linux, you’ll need to install the ‘ifenslave’ package. In Ubuntu you’d run:

sudo apt-get install ifenslave

With the package installed, you can being creating your bond interface. In the following example, two NICs are aggregated and as a bonus, we create virtual interface for an additional IP address:

auto eth0
iface eth0 inet manual
bond-master bond0

auto eth1
iface eth1 inet manual
bond-master bond0
auto bond0
iface bond0 inet static
mtu 9000
address 192.168.0.1
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
dns-nameservers 192.168.0.254
bond-miimon 50
bond-mode balance-rr
bond-slaves none

auto bond0:1
iface bond0:1 inet static
address 192.168.0.2
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
dns-nameservers 192.168.0.254

Youcan can also set a high MTU if your NIC supports it. Linux bonding supports seven modes:

  • Mode 0 (balance-rr)
  • Mode 1 (active-backup)
  • Mode 2 (balance-xor)
  • Mode 3 (broadcast)
  • Mode 4 (802.3ad)
  • Mode 5 (balance-tlb)
  • Mode 6 (balance-alb)

Some modes require configuration on the switch as well, particularly for Mode 4. Modes 0 and 1 should provide fault tolerance and load balancing to suit most applications.

References:

http://unixfoo.blogspot.com.au/2007/10/yet-to-add.html

http://unixfoo.blogspot.com.au/2008/02/network-bonding-part-ii-modes-of.html

Older posts «