sabato 5 novembre 2011

Flashing a Computer BIOS (Basic Input Output System) – The hard way…

Every computer has what is called a BIOS or Basic Input Output System (this will soon be called the Unified Extensible Firmware Interface UEFI). This is a very small program stored in a chip on the motherboard, but it has a very big job.  When you press the power button on your computer the first thing it does is execute this program.  It then goes out and checks the basic circuitry needed to boot the computer.  It checks for things like a processor, memory, hard drive and any other additional devices connected to the computer that could be needed.  Once it completes its checks, also known as POST (Power On Self Test), the BIOS checks the hard drive and other block devices for boot code.  When it finds boot code it’s executed and the computer begins booting your operating system, typically Windows. The BIOS also passes certain information to the operating system.  Things like what devices it’s found, what their address is (literally, computers communicate with their parts through addresses) and other such information about the computer. So what happens when the computer can’t read the BIOS or something else happens to it that stops it from doing it’s job?  Your computer doesn’t boot, simple as that.  You won’t get anything except maybe some LEDs (Little lights). So what do you do to fix this problem? Well, the easy route is to replace the motherboard.  Motherboards are typically rather expensive, especially for laptops. Not to mention it’s just a waste to throw out a perfectly good motherboard.


Here’s where I show you how to fix your own BIOS when a motherboard replacement is cost prohibitive. Recently I had a computer sent to me for just this type of repair so I have a perfect example for you. Our example today is an Asus EEE PC 1000HE netbook.  Great computers, portable, long battery life and great for web surfing and daily tasks. So this particular machine won’t boot due to a corrupted BIOS. Lets get started.


First we’re going to need a few tools.  You’ll need a soldering iron, preferably a decent one with a variable heat range and ESD protection, but a decent 15 to 20 watt should suffice. Next get some rosin core silver bearing solder in a small diameter, I use .015? from radio shack. You’ll also need soldering wick and I highly recommend flux. There are a few electronic components you will also need.  A breadboard is a necessity for any electronics tinkerer so I recommend getting a decent sized one, even if it’s over kill for the current job. You’ll also need a 3.3v regulator in a TO220 package, two 10uf capacitors and some wire.  The wire needs to be small enough to solder to the pins of the BIOS chip, but large enough to make a decent connection in the breadboard.  Solid core CAT5 works pretty well and it’s what I use for a patch cable. Now for the important piece of the puzzle, the DLP-USB1232H module.  This module is a breadboard friendly USB to dual serial port adapter.  It comes in handy for a lot of communications projects.


Now we have the tools, lets get to work. For the sake of time I’m not going to go into details on how to disassemble a laptop.  If you’ve made it this far you’re not technologically illiterate and I assume you can take out some screws and separate a case. You only need to break it down enough to remove the palm rest. Of course I feel compelled to remind you to ensure you have removed the power adapter and battery.  Once you have the palm rest off you should be able to find the CMOS (Complimentary Metal-Oxide Semiconductor) battery. In this particular machine the battery is yellow with a wire lead plugged into the motherboard.  unplug the battery and scan just up from the connector to find the BIOS chip.  It will have a sticker on it labeled 1000HE. If you remove that sticker (which I had to do to identify the chip I’m working with) you will find some very small letters and digits on the surface of the chip. This machine uses a SST25VF040B SPI flash chip.  You need this information to find the datasheet.  You need the datasheet to get details on the pin out of the chip.


Here’s the SST25VF040B:


SST25VF040B


And here’s the pertinent information from the datasheet:


datasheet


Ignore my notes as you’ll have to make your own.  Just for a little enlightenment on the cryptic notes we’ll use pin 5 as an example.  DO BL 16 simply means “Data Out, Blue, Pin 16?. It’s my little notation to remind me that this pin provides data out, I attached the blue wire to it and the other end needs to connect to pin 16 of the DLP-USB1232H module. You can come up with your own notes that make sense to you.


Now that you know what the pins mean on the BIOS chip you’ll want to know what pins you’ll need for the DLP module. I use the following diagram to layout my circuit on the breadboard.  This will setup your programmer and give you the pin connections between the chips.


Dlp_usb1232h_spi_programmerSo we know what our circuit needs to look like, but there’s one caveat. This particular chip can’t be programmed on the motherboard.  This isn’t to say this is always the case. I’ve programmed some BIOS chips on the board with no problems.  This one didn’t work out so well however and had to be removed to be programmed.  In order to do that you will use your soldering iron, flux and soldering wick.  Take the wick and place the end of it in the flux, not too much, just enough to coat one side of the tip with a little bit of flux. Lay the soldering wick on one bank of pins and, as much as possible, lay the tip of the iron across the wick and pins.  Do not hold it for more than a few seconds.  When you’re soldering small circuits you run a high risk of heat soaking the chip which will destroy it. After a couple seconds pull the iron and wick away and let the chip cool. Move to the other bank of pins next and continue this process until the chip comes free of the board. Once you have it off you’ll have an empty lonely IC socket.


empty socketNow we need to attach the chip to our patch cable that will connect it to the programmer. Use different wire colors for each connection, it helps keep things straight if something comes loose.  Again, use your own codes to tell you what goes where so it makes sense. In the end you should have something that looks like this:


Chip on ProgrammerNow it’s time to prep our computer. For this part we need Linux, not windows. If you’ve never used Linux before then you might want to do a bit of researching.  Fortunately Ubuntu linux makes this easy. They have a tool called Wubi (Windows Ubuntu Installer). Wubi will install Ubuntu in a file on your hard drive and add a boot loader that will give you the ability to select windows or linux when your computer boots. I won’t go into details here, maybe I’ll do a walk through in another post if it’s requested, but there’s plenty of Google University classes out there. (Google University is my way of saying search google, it’s a great way to learn) Once you have linux installed reboot your computer and select it in the boot menu. Once you’re in linux you will need a few things.  First you need some development tools because we’re going to be compiling our necessary programs from source code. In Ubuntu these tools can be installed by one package, build-essentials. Next you will need the source code for flashrom, and libftdi. Flashrom is the program that will do most of the work and libftdi is the library that will allow your computer to talk to the DLP-USB1232H module.


After you get all this installed, download a copy of the latest (or necessary) BIOS image from the manufacturer.  In this case we didn’t want the latest version as there were some issues with it that led to our current dilemma. Our image file for this one is going to be called 1002.ROM. Place this in a working directory (the directory you will be working out of from the command line). Flashrom is a command line based program.  Yes, be scared, we’re leaving the world of GUI (Graphical User Interface) and entering the scary world of text and data. It’s really not that scary, but many people are put off by working only on the command line. Regardless, fire up the command prompt and change directory to your working directory. Once there we need to plug in our programmer and get to work.  Flashrom has some specific command line switches to work with the DLP-USB1232H as a programmer. All this is found on flashrom’s website. The command to tell flashrom about your programmer is:


flashrom -p ft2232_spi:type=2232H,port=A


Running this by itself will cause flashrom to scan the programmer and spit out the chip it finds on the other end.  In this case it will actually find two. One will be the SST25VF040B and the other will be the SST25VF040B.REMS. Is there a difference? I have no idea, but for me I used the former, SST25VF040B. To tell flashrom what chip to use we use the command line switch “-c” like this:


flashrom -p ft2232_spi:type=2232H,port=A -c SST25VF040B


Running this alone won’t do much other than verify that yes the chip is there.  Before we start writing lets test the connection with a quick read.  To read the chip into a file run the following:


flashrom -p ft2232_spi:type=2232H,port=A -c SST25VF040B -r test.rom


This will subsequently create a file of what’s currently on the chip, not anything we really want otherwise we wouldn’t be here. If that finishes successfully you should go ahead and erase the chip just to be safe before writing.


flashrom -p ft2232_spi:type=2232H,port=A -c SST25VF040B -E


Now for the real show, lets write the BIOS we want:


flashrom -p ft2232_spi:type=2232H,port=A -c SST25VF040B -w 1002.rom


This will take a bit of time as some seemingly random alphanumeric characters populate the screen. Once it completes you will get a message that says it Verified!.  This is good, but I like to be sure. Now we’re going to do something to verify that what we wrote to the chip is still what we wanted to be there. We will use a program called md5sum to do this. First we’re going to create a baseline to check with.


md5sum 1002.rom >check.txt


This will create a file called check.txt that will contain a md5 hash of the original image we wrote to the chip. Next we need to rename the original to something else.


mv 1002.rom 1002.orig


Now we need to read the chip again and check it against the hash we created from the original file.


flashrom -p ft2232_spi:type=2232H,port=A -c SST25VF040B -r 1002.rom


md5sum -c check.txt


If this comes back as “1002.rom: Ok” then we’re good, everything went as expected. If not you need to start troubleshooting your setup and hope you didn’t fry the chip when removing it.


Unplug the programmer and desolder the chip from the patch cable. Try to clean up the pins as much as possible to make it easier to solder it back to the board. Putting a little (and I mean little, use a toothpick to paste) flux on the solder pads helps the chip stick to the board and the solder flow better while putting it back on. Remember not to heat soak the chip. Soldering the chip back on is far safer and easier than removing, but always be cautious. Once it’s back on you can test the machine to see if it works briefly. Don’t keep the machine on long since with the EEE PC the processor uses the metal plate on the palm rest as a heat sink. Plug in your power supply and hit the power button.  If you get the this:


Success!


Success! You now have a working computer again! Reassemble the rest of the machine and go on about your computing way with a new sense of pride in your machine knowing that you performed a complicated hack to save it.


Congratulations and enjoy! Please let me know if you’ve had success with this or if you have any comments, criticism or any other sort of banter you have in mind about the subject. Special thanks goes out to the developers of flashrom and the frequenters of their IRC chat room for all their help and their great project.

Nessun commento:

Posta un commento