Pages

Friday, August 2, 2013

Update your bios with Linux

I was thinking a lot about a bios update for my HTPC lately. The hardware is a ASUS Pundit P2-M2A690G running Slackware Linux 14.0 and XBMC. The bios itself allows a bios update through a special prepared CD and some other options but that was not what I was looking for. I just wanted to download the latest bios and install it. After some research I found a pretty cool software that did the job: flashrom.

The next lines will describe how to install flashrom, create a backup from your bios and flash the bios with a newer version. I have tested the whole procedure only on my HTPC - so far. Just be careful when you update your bios follwoing my instructions - I can't and I won't give support when something goes wrong! I highly recommend to read the documentation for falshrom first. They have already a big list if you can flash your bios with flashrom and much more stuff.
The whole bios update was done via SSH while XBMC was running (everything kept working during the update and even after the update).

The first thing you need is to get a current bios ROM for your bios. So check your mainboard, bios manufacturer etc and get the latest bios version.
The second thing you need is the source for flashrom itself:

# cd /usr/src
# wget -c "http://download.flashrom.org/releases/flashrom-0.9.6.1.tar.bz2"
...


After the download has finished extract the source package and change into the newly created directory:

# tar xf flashrom-0.9.6.1.tar.bz2
# cd flashrom-0.9.6.1


Move the Makefile to Makefile.orig, run sed to change the PREFIX from /usr/local to /usr. This will install flashrom to /usr instead of /usr/local:

# mv Makefile Makefile.orig
# cat Makefile.orig | sed 's/\/usr\/local/\/usr/' > Makefile


Run make followed by make install to compile the source and to install the flashrom binary and the flashrom manpage:

# make
...
# make install
...
mkdir -p /usr/sbin
mkdir -p /usr/share/man/man8
install -m 0755 flashrom /usr/sbin
install -m 0644 flashrom.8 /usr/share/man/man8


You should have the following new files (see above make install):

/usr
 |-- sbin
 |   `-- flashrom
 `-- share
     `-- man
         `-- man8
             `-- flashrom.8


The final steps are more than easy. First final step is to create a backup of your current bios:

# flashrom -r bios.bak --programmer internal
flashrom v0.9.6.1-r1564 on Linux 3.2.29 (x86_64)
flashrom is free software, get the source code at http://www.flashrom.org

Calibrating delay loop... delay loop is unreliable, trying to continue OK.
Found chipset "AMD SB600". Enabling flash write... OK.
Found Winbond flash chip "W25X80" (1024 kB, SPI) at physical address 0xfff00000.
Reading flash... done.


The second final step is to flash your bios with the current version:

# flashrom -w M2R68L-ASUS-0710.ROM --programmer internal
flashrom v0.9.6.1-r1564 on Linux 3.2.29 (x86_64)
flashrom is free software, get the source code at http://www.flashrom.org

Calibrating delay loop... delay loop is unreliable, trying to continue OK.
Found chipset "AMD SB600". Enabling flash write... OK.
Found Winbond flash chip "W25X80" (1024 kB, SPI) at physical address 0xfff00000.
Flash image seems to be a legacy BIOS. Disabling coreboot-related checks.
Reading old flash chip contents... done.
Erasing and writing flash chip... Erase/write done.
Verifying flash... VERIFIED.


That's it. Your bios should be updated now. If you want to make sure reboot your system:

# shutdown -r now

When the bios executes it informed me that the bios has changed (what a surprise) and asked me to check the bios settings (by pressing F1) or to continue (by pressing F2). I entered the bios, selected 'Exit' followed by 'Save changes'. As hoped my system continued to boot as nothing ever has happened.

Links:

http://flashrom.org/Flashrom