Flashing a BIOS the Linux Way (tm) using flashrom

There are a gazillion HOWTOs out there for flashing a BIOS image without having to resort to ugly "boot DOS from floppy" or "run Windows *.exe file from BIOS vendor" and other ugly stuff. Unfortunately, the proposed solutions are equally ugly (e.g. creating custom CD-ROMs which contain the "floppy" with DOS/Windows flash tools).

Folks, this is so much simpler than you think:

The flashrom tool (GPL'd, written for LinuxBIOS purposes, but works perfectly fine with proprietary BIOSes, too) will easily do what you want, on a running Linux system. No floppy crap, no CD-ROM crap, no DOS/Windows crap, no rebooting crap.

Install it:

  $ apt-get install flashrom

Detect whether flashrom knows about your chipset/mainboard/BIOS chip:

  $ flashrom

Read the BIOS image into a file:

  $ flashrom -r backup.bin

Write a BIOS image (proprietary or LinuxBIOS) on the ROM chip:

  $ flashrom -wv newbios.bin

WARNING: This will overwrite your current BIOS! Make sure you know what you're doing!

For the Debian-challenged, flashrom is available in source form too, of course:

  $ svn co svn://linuxbios.org/repos/trunk/util/flashrom
  $ cd flashrom
  $ make

The list of supported chipsets, mainboards, and ROM chips is limited of course, but it's constantly expanding. Contact us on the LinuxBIOS mailing list if you want other hardware supported (or even better: if you have patches!). In many cases adding support for new hardware is pretty easy...

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

-wv does not work/ retrieved file with -r is 1024kB

flashrom -wv givesme something like "two operations read help"
flashrom -r results in a 1024kB not 512kB file, but the mainboard is in the supported ok list.
any help for me?

flashrom help

Hi, please ask on the flashrom mailing list or in the IRC channel. Make sure to mention the board vendor and name, and post the output of "flashrom -V", preferrably using the latest flashrom version (built from source, or from Debian unstable which is pretty recent).

In general: the file size _must_ match, so if your current BIOS is 1024KB, the new one you want to flash must also be 1024KB. But please check back on the mailing list or IRC for more help and information, don't flash anything if you're not sure it'll work.

Thanks, Uwe.

question about filesize

flashrom -r gives me a file of 1024 kB. Thats the correct filesize of the official msi bios. My board is in the supported list (ok). Is it safe to use flashrom, as you mentioned a correct filesize of 512kB?

I have a question ...

Hi all,
I need to update the bios because I need a the new version for install a new CPU.

When i run flashrom in my CentOS Server 5.3 I get this message:

Calibrating delay loop... OK.
No coreboot table found.
Found chipset "Intel ICH4/ICH4-L", enabling flash write... OK.
Found chip "SST SST49LF004A/B" (512 KB) at physical address 0xfff80000.
No operations were specified.

I downloaded the latest BIOS for my motherboard from the Asus site and it is called P4B533-1015.003.

My question is...
I write flashrom -wv P4B533-1015.003 or rename the file P4B533-1015.003 in P4B533-1015.003.bin and run flashrom -wv P4B533-1015.003.bin ?

flashrom

Depends, if the P4B533-1015.003 file is exactly 512KB in size it is likely a pure BIOS image (not a DOS/Windows executable or something else). Flashrom does not care about the file name itself though, you don't have to rename it.

Either way, please contact the developers on the mailing list and/or IRC (#flashrom on Freenode) for details and mention which board you use, not all of them are supported.

http://www.flashrom.org/mailman/listinfo/flashrom

Uwe.

Here goes nothing!

This is an extremely useful post, especially after trying in vain to create boot cds, boot usb keys, etc. etc. i was able to read, write and verify my new bios in literally 3 commands on my flaky Shuttle XPC SG33G5B.

Now whether my computer boots up again is another story, but, oh wait, this piece of crap barely wants to boot as it is!! But that's another story altogether...

Where is the backup stored?

Am I right in thinking step three creates a backup? If so where is this backup stored?

As you might of guessed I killed my bios, all went well and there didn't appear to be any problems so I thought I was good to go. But as I tried to reboot I noticed it had gone horribly wrong, it shutdown the OS (Fedora 9). but actually shutdown. I think this was my error, I flashed the rom with a .700 file and I think that's why it didn't work. MSI have their own flash utility and I think it turns the .700 into a usable format. The reason I didn't use MSI's utility is the instructions that I found for it were all for Windows users and they were riddled with .EXE's (I realize/remember now that Dos also uses .EXE right? D'oh!)

I've tired using the flash recovery methods (AMIBOOT) but I can't use the flash utility, and I cannot find the same version of bios.

I'm guessing the backup is stored in ram so when the PC powers down you lose it? But I like to clutch at straws?

flashrom backups

No, if you did "flashrom -r backup.bin" it should have created a file called backup.bin containing your original BIOS in the current directory. That's not stored in RAM but rather on your disk, so it should survive a reboot.

Please contact the coreboot@coreboot.org mailing list or join the #coreboot IRC channel on Freenode, I hope we can help restore your system.

reset?

Seems like my MSI GX610 laptop bios are not supported... :(
I can't even read the bios... it keeps returning in console
reset
reset
reset
..
...

Reading the ROM contents

That's strange, never seen that.

Did you try "flashrom -r foo.bin" as root? Did you use the latest flashrom version? Try to boot with "nopat" on the Linux kernel command line. You might also have to use a kernel which does not use CONFIG_STRICT_DEVMEM...

flashrom

:(
Got a killed motherboard GA-8IE (Gigabyte Intel 845) with soldered 49LF002A.
Flashing reported as unsuccessful,
flashing back original BIOS either unsuccessful,
comparing 1st time read bios and 2nd time show 00-filled tail of eprom (about 30%).
Seems like bootblock (BIOS restoration from floppy) is overwritten.

I get similar output as in

I get similar output as in the first comment:

./flashrom
Calibrating delay loop... ok
No LinuxBIOS table found.
Found chipset "VT82C686": Enabling flash write... OK.
M29F002B found at physical address: 0xfffc0000
Flash part is M29F002B (256 KB)
OK, only ENABLING flash write, but NOT FLASHING.

and I have the same question: can I flash or not? There's someone that have tried it?

flashrom

Yep, looks good, it should work. Do make a backup of your original BIOS, of course, and first try to reflash the backup BIOS (just to see whether errors appear, but I doubt it).

If you want to be really, really safe you can get a second ROM chip and flash the backup image on that one...

HTH, Uwe.

Thanks for the info Uwe. In

Thanks for the info Uwe.
In running the flashrom test I get:

Calibrating delay loop... ok
No LinuxBIOS table found.
Found chipset "ICH6-M": Enabling flash write... OK.
Pm49FL004 found at physical address: 0xfff80000
Flash part is Pm49FL004 (512 KB)
OK, only ENABLING flash write, but NOT FLASHING.

What does that last part mean? Can I flash or not?

flashrom

Yep, should work (see above).

Uwe.

cool thanks, i was looking

cool thanks, i was looking for something like this!

flashrom in IBM/Lenovo Thinkpads?

Hi Uwe,

your article sounds very interesting to me, and I wanted to try your nice tool. I have two IBM/Lenovo Thinkpads here (X31 and Z61m) and both give an output like this, when running flashrom:
# flashrom
Calibrating delay loop... ok
No LinuxBIOS table found.
Found chipset "ICH4-M": Enabling flash write... OK.
No EEPROM/flash device found.

s/4-M/7M/ for the Z61m ;)

Is there any chance to get flashrom working on these, or are the laptop-boards/bioses just too complicated/different for this?

Regards
Evgeni

flashrom

Hi,

those messages mean that the chipsets are supported, but the ROM chips are unknown to flashrom / unsupported.

I would rather not try this on a laptop if you're not able and willing to open it up and replace the ROM chip in case you screw up the flashing. Yes, laptops are pretty ugly in this respect. Many will probably have a soldered-on ROM chip, so you cannot easily remove it and insert another one. Also, on most laptops it's probably quite hard to even get to the BIOS chip. You'll probably have to completely disassemble the laptop...

Anyway, if you know exactly which ROM chip is in the laptop (vendor and part name, e.g. Atmel AT29C040A or SST 49LF040B etc), then we could look up the respective datasheets and add support for them.

Flashrom is not written by me, btw (I only contributed a bit of code).

HTH, Uwe.

it seems to work now!

As of your today's upload (r2769), flashrom seems to support my X31 ThinkPad (not tested with the Z61m yet):

# flashrom -r bios.bak
Calibrating delay loop... ok
No LinuxBIOS table found.
Found chipset "ICH4-M": Enabling flash write... OK.
M50FW080 found at physical address: 0xfff00000
Flash part is M50FW080 (1024 KB)
Reading Flash...done

Should writing back be safe?

Regards
Evgeni

Flashrom writes

It could be, but it doesn't have to be, unfortunately.

Your mainboard might require a special "init" sequence to allow ROM writes, which is likely not documented anywhere and flashrom probably doesn't know about.

I'd only try writing if you have a means of recovery in case things go bad; an example is if your BIOS is in a socket so you can remove it, flash it externally (in another board or using an external programmer) and then re-insert it. On a laptop that's probably not easily possible...

If you really want to find out, try re-flashing the exact same image you just read from the chip. In theory, even if the write fails your board should not be bricked. Use "flashrom -wv bios.bak" in that case (-v for "verify") and flashrom will tell you if the write worked. If that worked fine, you could try to flash a different BIOS image and see if that works, too.

ALL OF THIS MAY BRICK YOUR MAINBOARD! USE AT YOUR OWN RISK! YOU HAVE BEEN WARNED!

(just in case :-)

HTH, Uwe.

flashrom facepalm?

I have a huge problem on my hands and I need some help from you. I used flashrom to detect my chipset and this is what it gave me

╔═[15:09]═[inxs @ arch]
╚═══===═══[~]>> sudo flashrom
flashrom v0.9.1-r710
No coreboot table found.
Found chipset "Intel ICH2-M", enabling flash write... OK.
This chipset supports the following protocols: Non-SPI.
Calibrating delay loop... OK.
Found chip "SST SST49LF004A/B" (512 KB, FWH) at physical address 0xfff80000.
No operations were specified.

Then I went ahead and created a backup of my current BIOS. That went well and I had my backup. However the exe BIOS I downloaded from Dell fro my laptop didn't have any file that matched the size of my current BIOS. I did a -v on each file and for all it gave me a "size doesn't match"

Finally I thought I should at least try to see if flashrom will flash my BIOS with the backup that I created. Then flashrom gave me this and now I am not sure if I can reboot or not.

╔═[14:58]═[inxs @ arch]
╚═══===═══[~]>> sudo flashrom -w backupBios.bin
Password:
flashrom v0.9.1-r710
No coreboot table found.
Found chipset "Intel ICH2-M", enabling flash write... OK.
This chipset supports the following protocols: Non-SPI.
Calibrating delay loop... OK.
Found chip "SST SST49LF004A/B" (512 KB, FWH) at physical address 0xfff80000.
Flash image seems to be a legacy BIOS. Disabling checks.
Writing flash chip... Block lock clearing failed, not erasing block at 0x000000
ERASE FAILED!
ERASE FAILED!
FAILED!
Your flash chip is in an unknown state.
Get help on IRC at irc.freenode.net channel #flashrom or
mail flashrom@flashrom.org
------------------------------------------------------------
DO NOT REBOOT OR POWEROFF!

Should I reboot?? I know this blog is almost 3 years old, but I am really hoping that you could help me out. If you need more information then please email. Also, I started a thread on the Arch linux forums which might help you in gleaning some info that you might require.

http://bbs.archlinux.org/viewtopic.php?id=98538

Thanks in advance.

at first, rev 710 is *old*,

at first, rev 710 is *old*, please upgrade, and retry posting somewhere preferably some pastebin with expiry set to never flashrom -V (after upgrade)
this should give some info about how current flashrom detects your hardware.

Also, in some cases its easier to step in #flashrom on freenode, usually on evenings and afternoons (for european timezones) somebody is there more or less alive.