Wednesday, October 14, 2009

Linux BIOS flash program

One of my many complaints about computers is BIOS upgrades. First, they usually require a floppy drive. Who uses those anymore??? Second, they usually require a bootable, DOS-formatted floppy disk. That's not too convenient if you never buy a Windows license.

If you're not using Windows, then you have a few choices:
- format your floppy disk using FreeDOS
- set up a bootloader entry with a FreeDOS image containing the BIOS update
- create a bootable CD with the FreeDOS image

Assuming the first option works, you'll still need a floppy drive. If you use the other methods and it fails, good luck explaining what FreeDOS is to your motherboard tech support agent!

There is another way that worked for me: flashrom. This is a program that can be used to program many kinds of ROMs, including BIOS chips. The list of supported motherboards at showed support for the ASUS A8V-E Deluxe and SE boards. I have a plain ol' A8V, so I figured it was likely to work.

I first backed up my current BIOS image
$ sudo flashrom -r A8V-GOOD.ROM
flashrom v0.9.1-r706
No coreboot table found.
Found chipset "VIA VT8237", enabling flash write... OK.
This chipset supports the following protocols: Non-SPI.
Calibrating delay loop... OK.
Found chip "PMC Pm49FL004" (512 KB, LPC,FWH) at physical address 0xfff80000.
Reading flash... done.

Then I unzipped the latest ASUS BIOS image and loaded it up.
$ sudo flashrom -w A8V-0229.ROM
flashrom v0.9.1-r706
No coreboot table found.
Found chipset "VIA VT8237", enabling flash write... OK.
This chipset supports the following protocols: Non-SPI.
Calibrating delay loop... OK.
Found chip "PMC Pm49FL004" (512 KB, LPC,FWH) at physical address 0xfff80000.
Flash image seems to be a legacy BIOS. Disabling checks.
Writing flash chip... Programming page: 0007 at address: 0x00070000
Verifying flash... VERIFIED.

When I rebooted, the BIOS complained that the checksum didn't match, so I loaded up the default settings. The upgrade was successful and it's running great!

Oddly enough, I trust the gurus on the flashrom mailing list more than I would most motherboard tech support agents. I've been lurking on the list for a few days and they're very quick to answer questions and help with issues. Long live open source.

Thursday, September 17, 2009

Control routing with multiple DHCP-enabled interfaces

I have 2 network interfaces on my Ubuntu Linux development machine: one on the "secure corporate" network (eth0) and one on the "test development" network (eth1). Our network admins are trusting that I won't route between them (and I don't). I use DHCP on both interfaces, which usually leaves me with 2 default gateways set.

The default routing behavior is to use the last default gateway. This ends up being the gateway on the development network. That's bad because access on this network is a bit more locked down. If I try to access corporate resources on a remote subnet, chances are the router will deny me. Also, dynamic DNS registration ends up resolving my hostname to the development network IP address, so accessing my machine by name remotely isn't usually possible.

There are lots of tutorials about load-balancing using ip route, and about making sure that routing is symmetrical. In my case, I don't care about any of that. Here are my goals:
1. continue using DHCP
2. register my machine's DNS name using the corporate IP address
3. use the default gateway assigned by the corporate network

The solution is actually quite simple: configure the DHCP client to ignore or override the undesired DHCP options for eth1. I use dhclient, which is very flexible and has great documentation. The manpage (dhclient.conf(5)) was googling necessary! From the manpage:

interface "name" { declarations ... }

A client with more than one network interface may require different behaviour depending on which interface is being configured. All timing parameters and declarations other than lease and alias declarations can be enclosed in an interface declaration, and those parameters will then be used only for the interface that matches the specified name. Interfaces for which there is no interface declaration will use the parameters declared outside of any interface declaration, or the default settings.

With that nifty bit, I used the examples in the dhclient config file (/etc/dhcp3/dhclient.conf) to build this simple addition:

interface "eth1" {
    send host-name "";
    supersede routers;

interface "eth0" {
    send host-name "";

I simply tell it to send a blank hostname for dynamic DNS registration, and then give it a bogus default gateway. Restart networking or reboot and voila! DNS resolves to the IP address on the corporate network and my default gateway is the corporate side router. Mission accomplished.


Saturday, July 04, 2009

Linux video surveillance, part 2

Because my first go at Linux-based home video surveillance was successful, I went to Fry's and bought components for a dedicated machine. I went with a MicroATX Gigbyte motherboard, small Antec Case, a 64-bit dual-core AMD X2 processor, 2 GB Kingston RAM, and a Seagate 750GB SATA drive. I figured this system wouldn't need an optical drive after the OS was installed, so I didn't bother buying one. The total for the system was about $300, and the most expensive part was the Antec case (about $100).

The best part is that my wife, Anna, assembled the whole system and installed Xubuntu Jaunty 9.04. She isn't very into this stuff, but she did it with very little direction and no physical help. What a sport!

After she installed the OS, I installed the packages needed for video surveillance:
sudo apt-get update
sudo apt-get install zoneminder

This doesn't get you 100% there--you have to enable ZoneMinder in Apache like so:
sudo ln -s /etc/zm/apache.conf /etc/apache2/sites-available/zoneminder
sudo a2ensite zoneminder

Now ZoneMinder was reachable at http://localhost/zm and I started configuration. I added the Panasonic camera as an external source (the same one from my last post), but the camera's page in ZoneMinder had no image. Going directly to the camera worked, so I knew I had a problem somewhere on my new system.

I enabled debugging in the "Options" section of the web interface and restarted Zoneminder:
sudo /etc/init.d/zoneminder restart

And found this in the debug logs located in /tmp:
07/04/09 09:21:11.757615 zmc_m2[32546].DB1-zm_monitor.cpp/259 [monitor purpose=1]
07/04/09 09:21:11.757662 zmc_m2[32546].DB1-zm_monitor.cpp/266 [shm.size=36865516]
07/04/09 09:21:11.757723 zmc_m2[32546].ERR-zm_monitor.cpp/270 [Can't shmget, probably not enough shared memory space free: Invalid argument]

Google found me an answer in the ZoneMinder FAQ:
sudo sysctl kernel.shmmax=36869516
sudo sysctl kernel.shmall=46869516

To make this permanent, I created /etc/sysctl.d/60-shmem.conf and added:
# Needed for zoneminder camera buffer
kernel.shmall = 46869516
kernel.shmmax = 36869516
kernel.shmmni = 4096

My one camera is working great, but I'm anxiously awaiting 2 more that should arrive next week. I installed my BlueCherry video capture card and will post again when I've hooked up my other cameras.


Monday, June 22, 2009

Linux video surveillance

Since I moved my family to a more populated location, my wife and I decided that we wanted a little more security at home. Obviously, I didn't want to pay $1,000+ for a canned surveillance package that I can't configure or customize myself. I also had an inkling that there would be some open-source software that could do the job.

My googling came up with 3 programs:

Of the 3, ZoneMinder appeared the most mature and usable. Motion is probably great if you want to do a lot of custom scripting. eLViS uses Motion as a back-end and has some nice features (like a multi-camera-view panel), but hasn't been updated since 2006.

ZoneMinder has a great WiKi and forum that's quite active. It's available in the standard Debian/Ubuntu software repositories, so I installed it:
sudo apt-get update; sudo apt-get install zoneminder

The biggest dependencies are mysql and apache (yes, those are HUGE dependencies). I had to tweak the Apache config to have it listen on a different port, since I already have the VMWare Server web GUI listening on port 80. Other than that, the installation was turnkey.

The rest of the configuration depends on the cameras you choose. The ZM WiKi has pretty comprehensive support for cameras. My first test was with my webcam, a Logitech Pro 9000. It has its own nuances with the Linux kernel's USB drivers, but works OK as long as you keep it plugged in. Setting it up required installing software to convert a video stream from a UVC device to an http stream, called mjpg-streamer. The simple steps to install are:
svn co mjpg-streamer
cd mjpg-streamer
make clean all
sudo make DESTDIR=/usr install

To start up a stream, use this command:
mjpg_streamer -i " -r 640x480 -f 20" -o " -p 8080" -b

That starts a video stream that you can see with your web browser at this URL. If you want to use a webcam as a long-term monitoring device, then you'll want to put the command above in /etc/rc.local or some other startup script.

Since my test went well, I decided to take it to the next level. I purchased a Panasonic BL-C20A from the cheapest vendor I could find at PriceGrabber and it arrived within a week. I chose this one because it was about $140 and was listed in the Panasonic section of the WiKi. The default IP address on the camera is (in case you hate reading manuals). I configured it to use DHCP and WiFi, allowing me to connect it anywhere my access point provides a decent signal.

Setting it up in ZoneMinder was simple. I defined it as an external source in motion-record mode. Setting up the URL of the camera was simple, following the documentation on sources.

I'm planning on adding a ClearCam II in the coming days via a video capture card. I haven't decided what card yet, but will post with results. The camera, receiver, and capture card shouldn't cost more than $140, and should provide even better quality. A great source for ZoneMinder compatible cameras and capture cards is At your request, they also ship a live Linux CD with ZoneMinder installed with any order at not cose. This lets you try ZoneMinder without worrying about installing it, or knowing anything about Linux, for that matter. I also found this CD available for download on

As my setup becomes more elaborate, I'll post any issues I come across. If past experience is an indicator, I don't expect to be posting any time soon. HTH,


ZoneMinder UVC HowTo
An older ZoneMinder/Ubuntu HowTo

Wednesday, January 28, 2009

Invalid kernel module format

I've been working on an embedded linux appliance (actually, a continuation of my senior project), which uses initramfs root filesystem all rolled up with the kernel image, which is nice because then you only have one file to transfer around for upgrades and stuff. My latest kernel compile produced and "Invalid kernel module format" error every time I tried to load a module. Bad news, since my SATA and network drivers are compiled as modules.

I found help at these 2 sites, and between the 2 I'm sure I'll have the ammo I need to fix it up. If not, I'll be making another post shortly...