Linux - flashing a motherboard BIOS

Every once in a while, the need arises to upgrade the BIOS on a motherboard to a new version. This involves a visit to the website of the motherboard manufacturer to pick up a new bios image.

A tool is needed to install "flash" the image into the chip on the motherboard that holds the BIOS. Typically you are instructed to run some command from windows or to prepare a bootable DOS floppy. Either of these options (never mind that almost no systems these days have floppies) are problematic at best for a person running linux.

WARNING Flashing a new bios is risky. If things don't go right, you may end up with a dead motherboard (and a new appreciation for the role of the BIOS in the world of computing). I will describe what has worked for me, but you should be aware of the risks and realize that your hardware may be different and incompatible with the instructions I am giving here.

Flashrom

There is a wonderful tool called flashrom that runs under linux. All I had to do to install it on my fedora system was:
yum install flashrom
After this, I used the following commands:
su
flashrom
flashrom -r oldbios.bin
flashrom -w newbios.bin
The first two flashrom commands should be safe on any system. The first simply probes for hardware and reports what it finds. The second (flashrom -r) command reads the current bios image and deposits it in a file. The last (flashrom -w) command is the risky one - it writes a new image into the flash chip.

You won't really know that everything is OK until you have successfully rebooted your system. Since linux does not use the BIOS when it is running, you could flash a new bios, run for weeks, and then discover when you rebooted that your system could not reboot. So, I held my breath when I rebooted and everything was fine. But I had two facts to bolster my confidence. One is that my motherboard was listed on the flashrom website as working. The other is that the first two flashrom commands had produced reasonable results and read out a bios image that matched (in size at least) the new bios image I had downloaded.

Using flashrom was simple, quick, and easy.

But flashing changed my MAC address

It took a while to figure out this had happened. The symptoms were that my network was not set up right and did not work. Probing a little further I found out that my network adapter was now recognized as eth1 rather than eth0. A peek at /etc/udev/rules.d/70-persistent-net.rules showed the old and new MAC addresses, and editing this file and rebooting made the new MAC address be eth0, but more was required. The file /etc/sysconfig/network-scripts/ifcfg-eth0 needed to be edited and the new MAC address inserted. After this service network restart almost gets things going.

Along the way I did

yum erase NetworkManager
This is always my kneejerk response when any networking problem pops up, but may be what is causing the next round of troubles.
In /var/log/messages I see the following error multiple times:
 RTNETLINK answers: File exists
Also, and in particular, the "route" command shows that no default route is set, which is the root of my trouble no doubt. DNS is working because I can talk to a DNS server on my local LAN. I can set the default route by hand via:
route add default gw 199.104.105.1
But this will just get me along while I research the problem. The quick answer for now is:
yum install NetworkManager
service network restart
The upshot of all of this, as far as I can sort it out, is that whatever script the service network restart command is running is still trying to talk to network manager. Somewhere in that process it is doing whatever it does to try to configure the default route and the utterly misleading message about "File exists" comes forth.

Bootable CDroms

If for some reason flashrom will not work for you, you can put FreeDOS onto a bootable CDROM, and use it to run the vendor supplied flashing utility. There are many tutorials online that can be found via a google search for something like "linux bootable cd for bios flashing". You get the rom image you want to flash (and the flashing utility) from your motherboard vendor. These typically come as zip files that you unzip to get flasher.exe and newbios.rom You also need a floppy image (like FDOEM.144), but others have used a larger iso image of a bootable cd, which is probably even better.
mkdir floppy
mount -t vfat -o loop fdoem.144 floppy
cp flasher.exe floppy
cp newbios.rom floppy
umount floppy
mkisofs -o bootcd.iso -b fdoem.144 fdoem.144
cdrecord -v bootcd.iso
I did not actually follow through with this, because flashrom did the job for me.
Have any comments? Questions? Drop me a line!

Adventures in Computing / [email protected]