PDA

View Full Version : Flashing Your BIOS From The Linux Desktop


phoronix
05-04-2009, 10:10 AM
Phoronix: Flashing Your BIOS From The Linux Desktop

Linux hardware support has improved a great deal over the past few years, but there are still a few troubled spots. With computer motherboards, for instance, the core functionality is generally there and most consumer motherboards will "just work" with the latest desktop Linux distributions out there. Where users though can run into problems are with the ancillary features. Motherboard manufacturers usually bundle proprietary software with their products that allow monitoring of hardware sensors, flashing of the motherboard BIOS, and overclocking all from within the Windows operating system. With the exception of LM_Sensors providing some sensors support, this is a grey area for Linux. Fortunately, however, the folks working on the CoreBoot project have developed a program that will near universally allow you to flash your motherboard's BIOS from within the Linux desktop.

http://www.phoronix.com/vr.php?view=13794

sreyan
05-04-2009, 10:36 AM
A wonderful thing to bring to the attention of the community. Thanks Michael.

d2kx
05-04-2009, 10:43 AM
This is so great :)

Flashing from Windows is totally crap and dangerous, and depends on the company behind the motherboard. If this tool works reliable, this would make things easier for Linux users than for Windows users :) I'll try it out once the v1.0 release appears.

Misel
05-04-2009, 10:47 AM
This is indeed great news although many modern mainboards now have a flashing tool integrated on a static part of the BIOS.

But still ... it's good for remote BIOS flashing and updating old boxes. :)

bridgman
05-04-2009, 10:51 AM
Hmm. I'm not a big fan of flashing your BIOS while an operating system is running on top of it either. If you have any kind of power management running chances are pretty good that there are occasional calls into the BIOS happening... and if one of those calls happens while the BIOS ROM is blank, that would be a problem.

I wouldn't flash the BIOS under any OS unless I already had a recovery plan - either a disk or a shadow BIOS stored in the flash.

Chewi
05-04-2009, 10:54 AM
My BIOS can flash itself using a file from a USB stick but still, this is cool. No way I'm gonna flash mine again though. If it ain't broke, don't fix it. :D

RealNC
05-04-2009, 11:00 AM
Well, novice users usually take whatever the website tells them. And in most cases that's a Windows flash tool.

Me, I either use a boot CD to flash it (most vendors offer bootable ISOs) or (for the mobos that support it) I flash it through the BIOS itself using a USB stick. Much, much safer.

GreatWalrus
05-04-2009, 11:28 AM
Having not had to flash my bios with Linux yet, I had been wondering for quite a while how I would do it if I needed to.

This is very exciting if you ask me.

RealNC
05-04-2009, 11:34 AM
Having not had to flash my bios with Linux yet, I had been wondering for quite a while how I would do it if I needed to.

Using the method described in the post just above yours :P

GreatWalrus
05-04-2009, 12:18 PM
Using the method described in the post just above yours :P
Yes, but I said I had been wondering how I would do it. So now I know of multiple ways.

myxal
05-04-2009, 12:37 PM
Well, reading the experiences of the users here I'm quite happy my laptop manufacturer provided a bootable FreeDOS image to upgrade the BIOS. Since following that path wasn't a problem I used it.

OTOH if I was on a netbook (no optical drive) and was offered a choice between run-time Windows utility and a CD image with freedos, I'd probably explore this flashrom utility to avoid reboots.

What I want to know though - does it handle only motherboards or is it useful for CD/DVD burners/HDDs etc.? Basically, how do I "mtkflash" under Linux?

DeepDayze
05-04-2009, 04:24 PM
Something like this would be also great for flashing CD/DVD drives and HDD firmware..definitely should be worth adding such features. Definitely a must for those machines without a floppy or a CD/DVD drive

Adarion
05-04-2009, 04:46 PM
Yeah. This is such a treat for my eyes. To finally see coreboot getting REALITY. I followed the project when it was still LinuxBios from time to time but besides a few Tyan boards nothing would work, sometimes the project seemed abandoned. But with all that embedded stuff and generally more Linux request in the world there is so much neat stuff now... LinuxBIOS for many Boards and now also to have a utility which will soon be able to do a flash job on so many BIOS media. AWESOME! I really appreciate this project.
I mean, okay, as long there could be FreeDOS used, or when you had a BIOS built in flash routine which would work system independently it wouldn't be that much of a problem but still it is a great development. I mean, not every board is Gigabyte or Asus in-bios-flasheable or not every vendor supports a DOS flashing utility. (though I would never buy anything that would be windows only)
I guess it will also be helpful on laptops or netbooks in case you don't have an internal/external floppy or such.

And imagine flashing all that other firmware... yet I had to use Windows to make my DVD region free.

markc
05-04-2009, 04:51 PM
Just wondering, how feasible is it to flash a BIOS with some ROM form of a linux kernel and initrd?

Is there a project that offers something like this?

Well it seems it is possible... http://www.hermann-uwe.de/blog/linuxbios-with-x11-server-completely-in-flash-rom

Louise
05-04-2009, 05:01 PM
Let me share a cool trick, if you often have to reprogram a flash ;)

http://www.coreboot.org/File:Pushpin_roms_2.jpg

mattmatteh
05-04-2009, 05:02 PM
If you have any kind of power management running chances are pretty good that there are occasional calls into the BIOS happening... and if one of those calls happens while the BIOS ROM is blank, that would be a problem.i didnt think any modern operating system made bios calls.
http://www.coreboot.org/FAQ#Which_different_operating_systems_will_coreboo t_boot.3F

the flashrom utility looks great, now i just need something from coreboot to replace the crappy bios i am stuck with now. (asus and gigabyte bios suck)

matt

Louise
05-04-2009, 05:13 PM
i didnt think any modern operating system made bios calls.
http://www.coreboot.org/FAQ#Which_different_operating_systems_will_coreboo t_boot.3F

the flashrom utility looks great, now i just need something from coreboot to replace the crappy bios i am stuck with now. (asus and gigabyte bios suck)

matt

I don't understand this. I have to configure how much memory I want to use for the IGP in the BIOS, and Linux really respect this. So Linux must make some sort of call to the BIOS, eventhough I have also heard that Linux doesn't use the BIOS for anything...

suokko
05-04-2009, 07:26 PM
I don't understand this. I have to configure how much memory I want to use for the IGP in the BIOS, and Linux really respect this. So Linux must make some sort of call to the BIOS, eventhough I have also heard that Linux doesn't use the BIOS for anything...

BIOS provides some system information using acpi tables that kernel reads for initialising system. BIOS also provides some basic hw access which isn't used.

cruiseoveride
05-04-2009, 11:19 PM
If I flash my bios from windows and it dies. I can swear at the motherboard manufacturer.

If I flash my bios from linux and it dies. Who do I swear at?

deanjo
05-04-2009, 11:25 PM
If I flash my bios from linux and it dies. Who do I swear at?
The guy that told you it was a good idea.:rolleyes:

energyman
05-05-2009, 02:48 AM
bridgeman has a good point. Even if I had windows installed, I would still flash with freedos.
It is so easy! systemrescuecd on usbstick. Copy flash file and flasher from mobo vendor on stick, boot from stick, choose freedos, flash.

Since a lot of driver cds from mobo vendors come with freedos this days it is a lot less risky then some 3rd party tool...

Kano
05-05-2009, 04:27 AM
If you have got Asus or Gigabyte boards they have got the flash tool inside the bios already. Only put it onto a fat partition on hd or partitioned usb stick (not superfloppy mode).

energyman
05-05-2009, 04:38 AM
yeah - except that a friend had to RMA an asus board in January after a failed flash - and not even the floppy/usb bios boot worked anymore.

Nice in theory, but fails in practice too.

energyman
05-05-2009, 05:01 AM
i didnt think any modern operating system made bios calls.
http://www.coreboot.org/FAQ#Which_different_operating_systems_will_coreboo t_boot.3F

the flashrom utility looks great, now i just need something from coreboot to replace the crappy bios i am stuck with now. (asus and gigabyte bios suck)

matt

maybe not the OS. But the hardware does. Ever heard of SMM? Look into that mess and weep.

Duo Maxwell
05-05-2009, 08:38 AM
I think I'll stick with boot floppies running freedos thank you, too big a chance of bricking...

good thing some boards now have the utility built into the bios itself to grab the flash from a usb stick.

bugmenot
05-05-2009, 10:15 AM
I also use generally the flash tool inside my bios, but flashrom is a great alternative. I flashed many board with it already, everytime without problems. It's not true though that almost every mainboard is supported. Almost every chip is supported but many mainboards need some special instruction to allow flashing, but I i asked in the IRC channel and they helped my and now everyone with my mainboard can flash out of the box. I don't think that is soo dangerous with linux, but of course there is everytime a risk. I really suggest everyone to play with it. :)

And what coreboot does is awesome, they provide a fast and stable firmware for many mainboards, but not on mine yet. AMD does also help there with code. A mainboard vendor should create a coreboot by default board I'd buy it at once. The BIOS is the last unfree part of my system. And its the most bad part of my system, too. Slow, buggy, simply bad. It seems that there is coreboot code for 780G chips, but they are not allowed to release it. I'd be so happy!

DanL
05-05-2009, 11:05 AM
If you have got Asus or Gigabyte boards they have got the flash tool inside the bios already.

My two AMD 7x0 Biostar mobos have it, and IIRC, my last MSI 690G board had it too. They all have AMI BIOS's.

deanjo
05-05-2009, 07:05 PM
My two AMD 7x0 Biostar mobos have it, and IIRC, my last MSI 690G board had it too. They all have AMI BIOS's.

Some manufacturer's even have memtest86 in the bios which I think is one hell of a great place for it. (IIRC it was DFI)

planckscnst
05-06-2009, 12:01 PM
I used it because the wiki has a list of mainboards and says it most likely supports your even if it's not on the list. There were a couple boars similar to mine. I thought, if it doesn't work, I can just clear the cmos to reset it.

It didn't work. I can't boot; I just get an incorrect beep code. Resetting the CMOS didn't work either. I'm pretty much screwed.

Saiot
05-06-2009, 12:03 PM
what does "cross-flashing" and "hot-flashing" means?

Zhick
05-06-2009, 12:42 PM
It didn't work. I can't boot; I just get an incorrect beep code. Resetting the CMOS didn't work either. I'm pretty much screwed.
That's bad.
You could look in your boards manual and look if it's got an option to emergency-restore your bios from a floppy or usb-stick.

a7v-user
05-06-2009, 01:22 PM
I tried an earlier version of Flashrom when I needed to update the bios on my ABIT UL8. I had some hardware problems earlier and wanted to see if a newer bios would work better but all non-linux would involve even more hardware surgery. I looked around for a linux version of some of windows-based bios-flashers but was a bit surprised when flashrom package in my distro(Debian).
I was a bit sceptical at first about really using it to flash my mb bios but flashrom worked perfectly. Of course that didn't magically repair my broken graphics card, my overrated excuse for a power supply or my light-duty-only motherboard but with some fresh components that motherboard has been running that new bios for quite some time now. :)

Much easier to use flashrom then to transfer files to a windows/dos partition or media and try and get a working boot media.

a7v-user
05-06-2009, 02:36 PM
what does "cross-flashing" and "hot-flashing" means?

Cross-flashing: Using the "wrong" bios file to flash your mb because you hope it will work better. Perhaps you want to use the bios from a higher quality mb with similar chipset as your mb because the other bios have better options available (Better memorysupport, more overclocking options etc.)Sometime this can actually work.
On the other hand I have a really nice dead motherboard collecting dust in my cellar thanks to cross-flashing.

Hot-flashing: Hehe.. this can sound a bit edgy or crazy.
You start up the computer, load up the bios flasher, then you physically remove the bios chip from it's socket and replace it with an new chip WITH the computer still running. Then you just press Y or something similar in the bios flasher to reprogram the new chip.
Of course if your chip is soldered directly onto the motherboard you can't perform this stunt... unless you're good enough with a soldering iron to replace the soldered chip with a socket instead. (Only for the truly crazy and gifted)

Hot-swapping sounds crazily dangerous but as long as you don't break anything while removing the chips, cause electro-static shock or short circuit something it does actually work as long. Just don't drop anything like a screwdriver or a bios chip on the motherboard that is live and running. Also you have to make sure that the bios chips are compatible as the come in different shapes, use different voltages and can store different amounts of code.

The reason that hot-swapping, or bios reprogramming in general, does work is that early in the startup procedure the bios code is copied from the slow ROM memory to much faster RAM, which we have more then enough of anyway. So when we're flashing the bios eprom we're flashing something that is only read a couple of times at startup. That is also why it is vital that you don't reboot if something went wrong during the flashing process. Try flashing a second time, or if that doesn't work go back to the original bios before rebooting.


Note that you combine cross- and hot-flashing, that's how I rescued my old Asus A7V motherboard which had been permanently dead for a couple of years. I used some old P2 mb I had. First I removed the p2 mb chip, then put it back only gently so it would be easier and quicker to remove while hot-swapping. I removed the A7V chip too. Then I started the p2, loaded up dos and the bios flasher (aflash I think) with the a7v bios. I gently and quickly removed the p2 chip, put in the a7v chip and pressed Y or something to start the reprogramming. After that I shut everything down, put the chips back where they belonged, and then I started up both motherboards. I almost wept of joy when the A7V successfully booted for the first time in years. :)

Saiot
05-07-2009, 04:59 AM
@ a7v-user
thanks a lot, hoping to never need them
(sorry 4 bad english)

curaga
05-07-2009, 07:03 AM
Thanks for the explanation, was wondering about cross-flashing myself.

BTW I believe the bios-copied-to-ram doesn't happen on all motherboards, because on one the flasher app froze on the second I removed the old chip (in a menu). On a retry, this time before launching the app, FreeDOS froze, I guess because they both would use bios calls to read the file from the floppy.
And this wouldn't happen if the calls were in ram..

a7v-user
05-08-2009, 09:14 AM
Thanks for the explanation, was wondering about cross-flashing myself.

BTW I believe the bios-copied-to-ram doesn't happen on all motherboards, because on one the flasher app froze on the second I removed the old chip (in a menu). On a retry, this time before launching the app, FreeDOS froze, I guess because they both would use bios calls to read the file from the floppy.
And this wouldn't happen if the calls were in ram..

Hmm.. I think you're right.
So then this would be another reason why it would be safer to flash from linux or some other OS that doesn't use bios calls and hopefully have some mechanism in place to prevent bios calls from being made.

energyman
05-08-2009, 10:15 AM
you can not prevent bios calls. Again:
SMM

look into it. The HARDWARE does SMM calls into bios - and no matter what the OS can not prevent it. Heck, it can't even see them! You enabled dos support for usb? SMM. Keyboard? SMM. Overheat protection? SMM - and some other workarounds.

audiohacked
05-08-2009, 08:11 PM
SMM's heat protection is crap/evil, a crashing CPU can't be used for SMM since all SMM processing is done on a CPU..

flashrom is mostly safe, as safe as a FreeDOS disk or in-BIOS flasher.

energyman
05-09-2009, 12:36 AM
audiohacked, don't ridicule yourself. SMM is the way it is done. Today. And the overheat protection starts way before the CPU crashes. And overheat is not the only thing. KEyboard, even timers are done by smm mode+bios

Proof?
follow this thread:
http://marc.info/?l=linux-rt-users&m=123281464907765&w=2
http://marc.info/?l=linux-rt-users&m=123284504611486&w=2
http://marc.info/?l=linux-rt-users&m=123287647503473&w=2

or search lkml archives for 'smm'

audiohacked
05-10-2009, 03:14 AM
"about the smm stuff: SMM is only needed if the hardware is crap or the BIOS is crap or the OS is crap. With AMD hardware, a decent BIOS (or coreboot) and Linux, you don't need SMM. If there is some SMM active, complain to your vendor." ~ coreboot dev

"And if SMM is used for overheat protection, the BIOS writer needs to get his brain replaced. By definition, a crashing CPU will cause SMM overheat protection to fail." ~ coreboot dev

Good Hardware will have will have a dedicated chip, or the processor's internals will have the hardware for Thermal Protection. The proper way to do thermal protection, is in pure hardware.

energyman
05-10-2009, 03:42 AM
you didn't even read the links. Did you?

audiohacked
05-10-2009, 10:10 AM
you didn't even read the links. Did you?

I did. One RTAI is not a good reference, and the P4 needs a ton of thermal protection because it will literaly burn/melt itself. Other processors from both Intel and AMD use a hardware limit to keep the processor from killing itself, the software limit (SMM) is used to down/up clock the CPU to further control Thermals. SMM is a bad idea still because you can disable it, or it can fail to run. You should know that software can not be trusted, and can/will fail without reason.

Laptops use an Embedded Controller for various functions in addition to replacing the SMM Thermal Protection with a hardware-based Thermal Controller.

PS. I do hardware design and work on Coreboot, so I actually understand how and what goes on with hardware and Firmware.

deanjo
05-10-2009, 10:25 AM
Other processors from both Intel and AMD use a hardware limit to keep the processor from killing itself, the software limit (SMM) is used to down/up clock the CPU to further control Thermals.

Not all AMD procs had such thermal protection either. It wasn't until later Athlon XP revisions that (barton core IIRC) that you finally couldn't burn up a CPU in seconds with a misplaced heatsink.

audiohacked
05-10-2009, 10:33 AM
Not all AMD procs had such thermal protection either. It wasn't until later Athlon XP revisions that (barton core IIRC) that you finally couldn't burn up a CPU in seconds with a misplaced heatsink.

Yes, at that time it was common practice to include a thermal diode in IC's and Intel's P2/Celeron and AMD's Athlon XP/MP started to include a thermal diode and fuse.

libv
05-26-2009, 05:34 AM
Hmm. I'm not a big fan of flashing your BIOS while an operating system is running on top of it either. If you have any kind of power management running chances are pretty good that there are occasional calls into the BIOS happening... and if one of those calls happens while the BIOS ROM is blank, that would be a problem.

I wouldn't flash the BIOS under any OS unless I already had a recovery plan - either a disk or a shadow BIOS stored in the flash.

BS.

The bios image in the flash is read out at boot, parts of it are executed in situ, parts of it are copied/extracted to ram and then executed, and the parts that are needed later are kept around in C,D,E and F segments, with the necessary hooks installed in the interrupt vectors and the EBDA. So whatever you need at runtime no longer depends on the contents of the flashchip.

Stop spreading useless FUD about real free software.

Backup plan when it fails under linux: make sure you don't reboot or power-off and contact the developers right away (on irc or on email).

If you do mess up and have a socketed bios, you can find someone to flash your bios for you or you can buy a new pre-flashed chip off of ebay for an arm and a leg.

It is clear where you stand against BIOSes and all that surrounds them, and it is clear why. Equally it is clear where i stand, and why i stand there: because i have been dealing with them all my time as a free software developer and only found them to be: buggy/hard to fix, and forcing solutions which are not as good as they can be, which are full of workarounds. Don't dare claim anything else.

energyman
05-26-2009, 05:42 AM
sure, flashing under a 'normal' os is perfectly fine and safe. Tell that my friend who killed a board that way. Flashing in windows.

cruiseoveride
05-26-2009, 09:39 AM
@libv. As much as we all hate ATi and everything to do with it. Don't make it personal. State the facts and leave it at that.

libv
05-26-2009, 11:28 AM
@libv. As much as we all hate ATi and everything to do with it. Don't make it personal. State the facts and leave it at that.

I wish everyone would state facts and the truth all the time; guess why this becomes personal.