CMOS.TXT - Freeware to restore damaged CMOS Last updated 2008-09-21 by Roedy Green The most important fact you will want to know about this package is how to turn it off. If the CHKCMOS.BAT has been installed in AUTOEXEC.BAT, you must delete the files C:\CMP\CMOS.SAV and C:\CMP\BOOT.SAV B_E_F_O_R_E making any changes to CMOS or to the partitions. Otherwise, CHKCMOS will put CMOS back the way it was and BOOTREST will put back the partition table. This is deliberate to protect you from naive users from experimenting with the CMOS settings. You may have installed CHGCMOS.BAT and CHGBOOT.BAT files to do this deleting for you. You can do this by running the CHGCMOS.BAT program before you make any delibarate CMOS changes. The second most important fact is you must use CMOSSAVE BEFORE you have trouble. If you have not done so, CMOSREST won't do you a lick if good once your CMOS is corrupted. The third most important fact is you must REDO you CMOSSAVE any time you change your CMOS, e.g. upgrade your disk. You also need to redo your BOOTSAVE at the same time. GETTING THE LATEST VERSION ************************** You can find the latest CMP utilities via my home page at: http://mindprod.com/downloads#CMOS PURPOSE ******* 1. Naive users sometimes fiddle with CMOS settings. We need a fast way to put the scores of subtle CMOS configuration settings back the way they were. 2. Power surges can corrupt CMOS. We need a way for a naive user to quickly restore all the CMOS settings. 3. If the battery fails, the contents will be lost. We need a way to restore a known working CMOS configuration. 4. You may want to alter some obscure CMOS setting and you don't have a program to set it. 5. CMOSRest can also be used to toggle between two CMOS configurations, for example with and without a removable hard drive installed. If you had removable hard disks, you could rapidly switch between the various disks. 6. CMOSChk can detect subtle corruption to CMOS, as might be caused by a rogue program or a virus, something that might slow your machine or make it unreliable. 7. CMOSSave can create a backup of your CMOS on floppy. This way you may safely experiment with CMOS settings. You can always get back to where you started by using CMOSRest to restore the original settings. Any time you fiddle with the computer innards, you might accidentally disconnect the battery, losing CMOS. CMOSSAVE lets you put it back the way it was. 8. Testing your machine for year Y2K 2000 compliance, to make sure the BIOS will kick the date over properly in the year 2000. Not so important anymore. 9. If you build machines for a living, you can rapidly clone the CMOS settings of one template machine in a dozen others. WHAT IS CMOS ************ Your computer has three kinds of memory, RAM, CMOS and hard disk. When the power turns off, your computer forgets everything in RAM. Your much slower hard disk retains its magnetic memory. When the power is off, your tiny CMOS memory is kept alive by battery backup (ideally a lithium battery, sometimes a rechargeable nicad battery, or worst of all a pack of ordinary alkaline batteries.) In the CMOS is recorded basic facts about your configuration -- the size and geometry of your hard disk, how many floppy drives you have and what type, how much RAM you have, how many wait states need to be added to slow down the CPU enough to work with your RAM, etc. etc. The data in CMOS RAM can only be examined or changed with a special program such as CMOSSAVE. It is not a file. If you are curious about how CMOSSAVE does the access, have a look at the notes in the source code in CMOS.ASM. When the battery dies, or does when a recharegeable battery not get sufficient on time to recharge, the CMOS fails, and it forgets all it knows about your configuration. CMOSSAVE is designed to restore this lost information by storing copies of it on floppy and/or hard disk. SYNTAX ****** There are three utilities in the CMOS suite: CMOSSAVE.COM A:Myfile.Sav IF ERRORLEVEL 1 GO TO Trouble - saves a copy of CMOS in a file on hard disk or floppy. CMOSREST.COM A:MyFile.Sav IF ERRORLEVEL 1 GO TO Trouble - restores CMOS from a file on hard disk or floppy. CMOSCHK.COM A:MyFile.Sav /Q IF ERRORLEVEL 1 GO TO FixIt - checks that CMOS has not been fiddled with since the last CMOSSAVE. Compares CMOS with a file on hard disk or floppy. - /Q suppresses unnecessary banner messages. HINTS ON USE ************ There are three ways you can use the suite: (1) manually, (2) automatically (3) with a rescue diskette. 1. Manually. Prepare a bootable floppy with the command: Format A: /S /V /U /F:1.44MB Unfortunatly Windows NT W2K and XP can no longer create a bootable DOS floppy. Borrow a DOS bootable disk from someone with FORMAT on it, and duplicate it or boot from it to create another bootable dos floppy, or get a friend to create you a bootable DOS floppy with W98 or WindowsME.) Install CMOSSAVE.com and CMOSREST.com on your hard disk into C:\CMP You can create such a directory with: MD C:\CMP This directory need not be on the path, but if it is not, you will have to type C:\CMP\CMOSSAVE instead of just CMOSSAVE. Backup your CMOS to the bootable floppy with: CMOSSAVE.com A:\CMOS.SAV COPY C:\CMP\CMOS*.com A: If ever your cmos becomes corrupted, correct it by booting from floppy and typing: CMOSREST.com A:\CMOS.SAV Then reboot. In this case you don't bother with CMOSCHK.com at all. 2. With a rescue diskette. Prepare a bootable DOS floppy with an autoexec.bat that invokes the following commands to correct most CMOS and hard disk problems: CMOSREST A:\CMOS.SAV BOOTREST A:\BOOT.SAV CHKDSK C:/F SYS C: COPY A:\COMMAND.COM C:\ COPY A:\COMMAND.COM C:\DOS (BootRest.com freeware is separately available. It is part of the package we send when you register or you can get it from my website.) You need to make a separate rescue disk for each machine unless the machines are absolutely identical including hard disk size. 3. Automatically. This won't work in NT, W2K or XP since those operating systems block CMOSREST.COM from working. Insert the line: CALL C:\CMP\CHKCMOS.BAT in your autoexec.bat. This bat file uses CMOSCHK.com to compare the contents of CMOS with what it should be. If there is a mismatch, it will invoke CMOSREST.com to put it back. then REBOOT.com to try again. Note this method will not be able to recover if the CMOS is badly damaged. You will have to revert to method 1 or 2. Note that CHKCMOS.BAT needs to be configured with a text editor before use. Need.com and Reboot.com are freeware available separately. NOTE THE NAMES: CHKCMOS.BAT but CMOSCHK.com!!! BELT AND SUSPENDERS ******************* Do a CMOSSAVE both to hard disk and to floppy. The hard disk copy can be used for quick restores with the following two lines added to your AUTOEXEC.BAT file. Use a text editor to add these lines. CMOSCHK.COM C:\CMP\CMOS.Sav IF ERRORLEVEL 1 CMOSREST.COM C:\CMP\CMOS.Sav At that point you must reboot before the restored cmos settings take effect. See CHKCMOS.BAT for a realistic way to handle this. You will will have to tune that BAT file a little to suit your machine, either by replacing the %XXX% or inserting SET commands. Sometimes CMOS will be so badly damaged the hard disk parameters will be corrupt and your hard disk will stop working. In that case you will have to revert to using the floppy copy. Whenever you change your CMOS setting deliberately, you need to redo the CMOSSAV.COM. However USE A NEW FILENAME, so that you can easily revert to the old version if your new settings do not pan out. If you are just making a minor change, you can simply delete the existing *.SAV files, and CHKCMOS.BAT will recreate them. If you fail to do this, CHKCMOS.BAT will presume the changes were unintentional and will undo them. To someone unfamiliar with CMOSSAVE, having his deliberate CMOS changes undone can be very disconcerting. HOW IT WORKS ************ CMOSSAVE.COM simply copies the 128 byte contents of the CMOS bytes to a file. CMOSREST.COM copies them back. CMOSCHK compares them with the file contents. If they are not equal it sets ERRORLEVEL 1. Modern computers have larger CMOS memories than 128 bytes, but you access them via proprietary ways, which CMOSSAVE does not know. So CMOSSAVE just saves the first 128 bytes, which are accesses in a uniform way on all PCs. CMOSREST does not touch bytes 0 to 09 and 32h because these are volatile -- they contain the date and time. Similarly CMOSCHK, does not panic if any of these volatile bytes differ. However, CMOSSAVE saves all 128 bytes, so that you can browse the generated file with a hex editor to learn more about how CMOS works. You need some sort of hex viewer to see the contents of the CMOS.SAV file. I use a free one called Hexview I got from www.sprynet.com/sprynet/funduc. There is one built into QDOS. The old DOS version of the Norton utilities DE (DiskEdit) had a hex viewer. The hex list of bytes is not that meaningful if you are not a computer programmer. Daring users could even patch the CMOS.SAV file with a hex editor and restore to get special effects, e.g. to switch between two different CMOS configurations e.g. one with and one without some hard disk. Don't attempt to edit the file with a non-hex viewer such as NotePad, WordPad, Write or Word For Windows. If you do, you will scramble the file beyond recognition. Because CMOSSave also saves the extended CMOS bytes, CMOSRest will restore the esoteric options like shadow RAM, wait states, processor clock speed, HMA enable etc. It works on ISA, EISA and PCI machines. These is no need to calculate checksums, since the checksum is saved and restored just like any other CMOS byte. I have included a sample file called CHKCMOS.BAT. You can insert a CALL to it in your AUTOEXEC.BAT. It uses all three utilities in a fairly sophisticated way. Using CHKCMOS.BAT requires fairly good knowledge of BAT files to customize it for your needs. Don't worry if this technique is beyond your current skill. Just use the the simpler manual floppy disk method described above. You might wonder why CMOSSave saves only 128 bytes of CMOS even though some modern computers have many times that amount. The problem is the way you get at the rest of it is proprietary. The vendors won't disclose how you get at it. It is possible to disassemble the ROM BIOS to figure it out in an individual case, but that won't work on other machines. So it is usually not worth the bother unless you wanted a special version of CMOSSAVE for thousands of identical machines. HOW CMOS IS USED **************** CMOS is battery backed RAM that stores configuration information when the power is off. It is on my top ten worst ideas list of all time. The problem is, CMOS is far too easily corrupted, by programs, power or naive users experimenting. See CMOS.OFS for a detailed list of what each byte in the CMOS is used for. This is usually of interests to technophiles only. TROUBLESHOOTING *************** CMOSSAVE is compatible with every machine I have so far encountered. There are a few that have additional proprietary CMOS that CMOSSAVE does not see, but CMOSSAVE saves the crucial areas. Because different vendors use CMOS in different ways, CMOSCHK can give false alarms when bits of CMOS change legitimately. What is considered volatile and what is not, might vary for different motherboards. If you have trouble restoring, DO NOT DESPAIR. All is recorded. A variant of the CMOSREST program could get you back. All you need do in make a slight modification to the assembler source VOLATILE routine that decides which bytes to consider volatile. Even a very junior MASM programmer could make that modification for you if you have registered and have the assembler source. If you do a CMOSSAVE from the DOS prompt and from true DOS there may be some subtle differences, and CMOSCHK may complain about them. This is nothing to worry about since when you restore, those bits in the CMOS will be automatically corrected the next time you boot to either DOS or Windows. It is quite safe to save from the DOS prompt with CMOSSAVE, check with CMOSCHK from autoexec.bat or other bat file, and do your restore with CMOSREST from true DOS. Sometimes your CMOS will be so wrecked you cannot even get your machine limping enough to run CMOSREST from floppy. In that case you must clear CMOS. Do this on AMI BIOSes by holding down the INS key, powering off, powering on, then releasing the INS key. In the worst case, remove the battery and let the capacitance on the board drain overnight to clear it. On some CMOSes you can clear CMOS by selecting universal default settings from the normal CMOS setting menu. You can then get a bare bones CMOS configured -- that just has the floppies right. Nothing else much matters. From there you can run CMOSREST.COM. The SSTOR disk formatting utility from Storage Dimensions makes it look as though it had modified CMOS. If you boot without the SSTOR driver, CMOS will appear to have changed because SSTOR is not doing its standard trickery. The NCR CMOSDR6X program interferes with CMOSSAVE and CMOSREST. Make sure you do your CMOSSAVE CMOSREST work before loading this program. The TURBO setting is part of CMOS. If you accidentally turn turbo mode off, CMOS will appear to be changed, and CMOSCHK will complain. To clear the problem, set turbo back on and allow the CMOSCHK to restore CMOS. This way CMOSCHK will remind you if you have accidentally turned off turbo mode. This feature can be turned off by making the byte where your turbo info is stored volatile. If you want this feature, just send the CMOSCHK listing that complains about CMOS being changed when you register. *************************************************************** *************************************************************** I repeat: CMOSREST won't do you a lick of good unless you run CMOSSAVE BEFORE you have trouble. Make sure you have copies of CMOS.SAV both on hard disk and on floppy. *************************************************************** *************************************************************** There is a companion program called BOOTSAVE that works in a similar way to protects your boot track from damage by rogue programs or viruses. Again, you must use it BEFORE you have trouble. When you register, I will send you a copy of BOOTSAVE, and REBOOT, which are useful adjuncts to CMOSSAVE. These should be available on the same site you found CMOSSAVE. CMOSREST does not take effect until you REBOOT!! VERIFICATION FIRE DRILL *********************** CMOSSave and CMOSTRest have internal checks to warn you if they are not functioning. However, you can assure yourself they are working properly by using CMOSSave, then changing some minor setting in CMOS (e.g. to add an extra unneeded wait state), then use CMOSChk to detect the "damage" then CMOSRest to restore the CMOS back the way it was. If all is working correctly, the minor change should be undone. FALSE ALARM CMOSCHK CORRUPTION MESSAGES *************************************** Some non-standard BIOSes have additional volatile portions that CMOSCHK does not know about. It will report false corruptions. There are three ways you can handle the problem: 1. Send me a screen print of what CMOSCHK is saying. I will send you a custom version with those false mismatches considered as volatile bytes. You must register if you want this service. 2. Modify the "VolatileList" line in CMOS.ASM yourself to include the extra offsets your BIOS is treating as volatile. Then reassemble. CmosChk.com will give you a list of offsets where it thinks there are mismatches. It is up to you to determine which ones you think are false alarms. 3. Simply avoid using CMOSChk. Just use CMOSSAVE and CMOSREST. Most of the time damaged CMOS is fairly obvious. WHAT IF YOU HAVE ALREADY CRASHED? ********************************* CMOSSAVE is prophylaxis, not a cure. You have to use it BEFORE you have trouble. (Hmm. Is there is an echo in here?) However, what can you do if your CMOS is wrecked and you have no CMOS.SAV backup of it? You had best get an expert to help you set the CMOS back to defaults and guess the fine tuning for the parameters. The dealer who sold you the machine is the best person to help. He may be able to contact the disk manufacturer to find out how many heads and cylinders it has. He may be able to find hints in the motherboard manual. If your machine has an EXACT TWIN, you may still be in luck. You can make a backup of the CMOS on that machine, then restore it into the ruined one. Don't try this unless the machines are ABSOLUTELY identical. There is a good chance you will destroy your hard disk data if you transplant a CMOS from a different sized disk. You can manually set CMOS back if you hit the magic keys during hard boot, often DEL, F2, or Ctrl-Alt-Esc. Sometimes you need a diskette to set up CMOS. Check the manual that came with your motherboard, or check with the company that sold it to you. Usually there is a way to set CMOS settings to default. In a pinch you can do it by removing the battery for a day or two. WINDOWS 95/98/ME **************** CMOSSAVE is a DOS program that gets its data from the command line. The most common mistake is to try to run CMOSSAVE directly from Windows 95 Explorer, rather than by first starting a DOS box or setting up the CMOSSAVE command line in the properties for the icon. Windows 95 still has a C:\autoexec.bat just as under DOS. Alternatively go into a DOS box and use the CMOSSSAVE utilities just as you would under DOS to add the call to CHKCMOS.BAT or to directly invoke CHKCMOS.COM. still use CMOSSAVE and CMOSREST just as under previous versions of DOS and Windows. Putting cmoschk.com in your autoexec just helps you detect cmos corruption the instant it occurs. Windows 95 users often have no understanding of the DOS CD, MD and path commands, how to edit autoexec.bat or even how to run a DOS program. If you are one of this new breed, your best bet is to get help from someone who is familiar with DOS, since if CMOS is corrupt you will need to revert to DOS to get Windows going again. You can run the utilities either in autoexec.bat, in DOS or 4DOS box, in a BAT file, or by creating a shortcut, complete with parameters on the command line. However, here is a crude, but fool-proof recipe to use cmossave manually under Windows 95. Copy the files cmossave.com, cmoschk.com and cmosrest.com to a freshly formatted floppy in your A: drive. In Win 95, select Start, Programs, MS DOS Prompt to get you to the Win 95 DOS box. Type: c: sys a: a: cmossave cmos.sav exit If later suspect your CMOS is corrupted boot from that floppy. Then type: A: cmoschk cmos.sav If it turns out it is indeed corrupt, then type cmosrest cmos.sav Then remove the floppy and reboot by hitting either Ctrl-Alt-Del, the reset button, or if all else fails, power off/power on. WINDOWS NT/2000/XP/VISTA ************************ Windows NT interferes with CMOSREST, though it will allow CMOSSAVE and CMOSCHK to run properly. The restore appears to work, but when you exit the DOS box, NT undoes the restore. Should you need to restore, you will have to boot from a DOS floppy or dual boot to Windows to run CMOSREST. It would be wise to have a copy of your CMOS.SAV file and cmosrest.com on that bootable floppy or CD. Y2K Year 2000 Compliance ************************ Some older machines will not work properly in the year 2000 because the BIOS will not handle dates past 1999. You would probably want to know if your machine will have this problem. Unfortunately, if you perform an experiment by setting the date to 2000 Jan 01, some BIOSes forget EVERYTHING. If you make a backup first with CMOSSAVE, you can easily restore CMOS to its orginal settings. If you are testing a number of machines, make sure you erase the CMOS.SAV file on floppy between tests. You don't want to accidentally restore the CMOS.SAV file from one machine into another (unless they were absolutely identical, including hard disk size.) XT COMPUTERS ************ You will find that XT computers don't HAVE a CMOS, so CMOSSAVE will not do you much good. You can configure XT floppies using DOS's DRIVPARM. Back in the good old days of the XT you had to use proprietary methods to format hard disks and tell DOS how big they are. Typically you fired them up with debug g=c800:5 and talked with a proprietary ram-based low level formatting program. Then you later used DOS format. HDSNIFF goes into this in much more detail. Briefly: Brand Debug Init Step byte code interpreted as step pulse rate ÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍ ÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ Adaptec g=c800:ccc 3=13 æs, 2=30 æs, 5=70 æs, 4=200 æs, 0=3 ms DTC5150CRH g=c800:5 2=12 æs, 5=70 æs, 4=200 æs, 0,1,6,7=3 ms DTC5150XL g=c800:5 0=5,10,20,30,40,50,60,70 æs (cannot tell which!) IBM/Xebec 5=70 æs, 4=200 æs, 0,6,7=3 ms Omti g=c800:6 1=10 æs, 2=25 æs, 3=40 æs, 5=70 æs, 4=200 æs, 0,6,7=3 ms WD-old g=c800:5 5=70 æs, 4=200 æs, 0,6,7=3 ms WD1002-WX1 g=c800:5 3,7=10.5 æs, 2=22.5 æs, 6=28.5 æs, 1=46.5 æs, 5=70.5 æs, 4=202.5 æs, 0=3.1 ms WD10025WX2 g=c800:5 3,7=18 æs, 6=30 æs, 1=45 æs, 2=60 æs, 5=75 æs, 4=210 æs, 0=3ms WD1002-27X g=c800:5 3,7=8 æs, 1,2,4,5,6=24 æs, 0=3 ms WD1004-WX1 g=c800:5 3,7=12 æs, 6=27 æs, 1=51 æs, 2=63 æs, 5=75 æs, 4=207 æs, 0=3 ms WD1004-27X g=c800:5 3,7=8 æs, 1,2,4,5,6=24 æs, 0=3 ms WD1004A27X g=c800:5 3,7=11 æs, 1,2,4,5,6=24 æs, 0=3.3 ms WD-XT-GEN1 g=c800:5 3,7=18 æs, 6=30 æs, 1=45 æs, 2=60 æs, 5=75 æs, 4=210 æs, 0=3ms WD-XT-GEN2 g=c800:5 3,7=18 æs, 6=30 æs, 1=45 æs, 2=60 æs, 5=75 æs, 4=210 æs, 0=3ms REPEATED FAILURES ***************** What happens if your machine routinely loses CMOS. What are the causes: 1. a poor battery. Replace it with a lithium battery. (You will need the motherboard manual, because sometimes you need to change a jumper when you do this. If you have a nicad rechargeable battery, leave the machine on all the time to give it time to recharge. 2. a roque program. A program going nuts can accidentally write garbage into CMOS. I have found this is less likely to happen with Windows 95. Author ****** Roedy Green of Canadian Mind Products wrote this suite. CMOSSAVE, CMOSREST and CMOSCHK are copyrighted but may be freely used for any purpose except military with the exception of U.N. Sanctioned Peacekeeping Missions. If you pass the files on, PLEASE PASS ON THIS DOCUMENTATION TOO. Please report bugs and problems. Harvey Fishman wrote a pair of programs similar to CMOSSAVE and CMOSREST, but to the best of my knowledge, never released them. WARRANTY and SUPPORT ******************** This is a free program, so there is no guarantee. Howevever, I wil fix any bugs. Keep in mind, CMOSSAVE won't do you any good unless you have used it BEFORE you have trouble. I have no magic to bail you out after the fact. Pleading with me won't help. Happily, so long as you have done a CMOSSAVE, and have not overwritten it, almost any problem can be recitified even if CMOSREST or CMOSCHK should fail. Freeware Status **************** CMOSSAVE CMOSREST and CMOSCHK are freeware. Roedy Green Canadian Mind Products #101 - 2536 Wark Street Victoria, BC Canada V8T 4G8 Tel: (250) 361-9093 mailto:roedyg@mindprod.com http://mindprod.com Big companies such as Sony, NCR and Chemineer use cmossave to protect all their machines and to clone CMOS settings across machines. -30-