Difference between revisions of "Flashing BIOS from Linux"

From ArchWiki
Jump to navigation Jump to search
m (Fix style)
(→‎Pre-built images: fix a link that is blocked in Russia)
 
(49 intermediate revisions by 29 users not shown)
Line 5: Line 5:
 
{{Warning|Flashing motherboard BIOS is a dangerous activity that can render your motherboard inoperable! While the author of this article has successfully run this procedure many times, your mileage may vary. Be careful! You may want to consider updating [[microcode]] instead if it is supported by your system.}}
 
{{Warning|Flashing motherboard BIOS is a dangerous activity that can render your motherboard inoperable! While the author of this article has successfully run this procedure many times, your mileage may vary. Be careful! You may want to consider updating [[microcode]] instead if it is supported by your system.}}
  
== Introduction ==
+
{{Note|
There are a few ways that you can use to flash the system BIOS under Linux.
+
* HP users may download Windows BIOS updater from HP website, extract *.exe file and locate ISO image for burning to a CD. Using CD, upgrade is possible from BIOS menu using 'Firmware Upgrade' without using below tools. See [https://h30434.www3.hp.com/t5/Notebook-Operating-System-and-Recovery/How-to-update-BIOS-on-Linux/td-p/4869835 this] thread for details.
 +
* For users with Dell computers, Dell recommends Linux users flash their BIOS following information located [https://www.dell.com/support/article/us/en/19/sln171755/updating-the-dell-bios-in-linux-and-ubuntu-environments here] (in short, put the .EXE on a USB stick and use the F12 boot menu to access the firmware's flash utility).
 +
}}
 +
 
 +
== fwupd ==
 +
 
 +
fwupd is a simple daemon to allow session software to update device firmware on your local machine.
 +
 
 +
Large vendors including Dell and Logitech use this way to distribute firmware updates to Linux.
 +
 
 +
fwupd only supports flashing BIOS updates in UEFI mode.
 +
 
 +
See [[fwupd]] for further information about installation and usage.
  
 
== BiosDisk ==
 
== BiosDisk ==
[http://linux.dell.com/git/biosdisk.git BiosDisk] BiosDisk simplifies the process of flashing your system BIOS under Linux
 
  
=== Installation ===
+
[https://github.com/dell/biosdisk BiosDisk] simplifies the process of flashing your system BIOS under Linux.
[[Install]] the {{AUR|biosdisk-git}}.
 
  
=== Usage ===
+
{{Note|This is only supported on systems when booted in "Legacy mode". In UEFI mode you will need to use a different method.}}
To use the biosdisk utility to create a BIOS flash image, first download the latest raw BIOS image for your system from your manufacturer's website. Make sure however, that you always get the BIOS executable and NOT the Windows executable. You then have one of several options: create a floppy, create a dd floppy image, create a user-installable distribution-specific package (e.g. RPM), or actually install the image for your bootloader.
 
  
* The mkfloppy action will create the biosdisk image and write it directly to a floppy disk. Usage is the following:
+
=== Installation ===
  
    biosdisk mkfloppy [-o option] [-d device] [-k baseimage] /path/to/.exe
+
[[Install]] the {{AUR|biosdisk-git}} package.
  
* The mkimage action will create a floppy image on the user's hard drive. Usage is the following:
+
=== Usage ===
  
    biosdisk mkimage [-o option] [-i destination] [-k baseimage] /path/to/.exe
+
To use the biosdisk utility to create a BIOS flash image, first download the latest raw BIOS image for your system from your manufacturer's website. Make sure however, that you always get the BIOS executable and NOT the Windows executable. You then have one of two options: create a ISO or install the image for your bootloader.
  
* The mkpkg action will create the floppy image, and use it to create a user-installable package specific to the distribution (example: RPM). When the package is installed, it will use the distribution's built-in tools to update the system's bootloader so that the user can boot to the image from the hard drive to flash the BIOS, without needing a floppy drive. Currently only Red Hat/Fedora RPM packages are supported. Usage is as follows:
+
* The mkimage action will create a ISO image on the user's hard drive. Usage is the following:
  
    biosdisk mkpkg [-o option] [--install] [--distro=] [--name=] [--version=] [--release=] /path/to/{.exe | .img}
+
# biosdisk mkimage [-o option] [-i destination] /path/to/.exe  
  
 
* The install action will create the biosdisk image, copy the image file to /boot, and then update the bootloader with an entry for the image. Then all the user has to do is boot the system and select the image to flash the BIOS; this will load the biosdisk image directly from the hard drive and flash the BIOS.
 
* The install action will create the biosdisk image, copy the image file to /boot, and then update the bootloader with an entry for the image. Then all the user has to do is boot the system and select the image to flash the BIOS; this will load the biosdisk image directly from the hard drive and flash the BIOS.
  
    biosdisk install [-o option] [--name=] /path/to/{.exe | .img}
+
# biosdisk install [-o option] [--name=] /path/to/.exe
  
 
== Flashrom ==
 
== Flashrom ==
[http://www.flashrom.org/Flashrom Flashrom]is a utility for identifying, reading, writing, verifying and erasing flash chips. It is designed to flash BIOS/EFI/coreboot/firmware/optionROM images on mainboards, network/graphics/storage controller cards, and various programmer devices.
+
 
 +
[http://www.flashrom.org/Flashrom Flashrom] is a utility for identifying, reading, writing, verifying and erasing flash chips. It is designed to flash BIOS/EFI/coreboot/firmware/optionROM images on mainboards, network/graphics/storage controller cards, and various programmer devices.
 +
 
 +
{{Warning|If you have a laptop/notebook/netbook, please do NOT try flashrom because interactions with the EC on these machines might crash your machine during flashing. flashrom tries to detect if a machine is a laptop, but not all laptops follow the standard, so this is not 100% reliable.[https://www.flashrom.org/Board_Testing_HOWTO]}}
  
 
=== Installation ===
 
=== Installation ===
  
[[pacman|Install]] the {{pkg|flashrom}} or {{AUR|flashrom-svn}}.
+
[[Install]] the {{pkg|flashrom}} or {{AUR|flashrom-git}} package.
  
 
=== Usage ===
 
=== Usage ===
 +
 
Find out if your motherboard and chipset (internal) is supported by flashrom at this website. [http://www.flashrom.org/Supported_hardware Supported Hardware]
 
Find out if your motherboard and chipset (internal) is supported by flashrom at this website. [http://www.flashrom.org/Supported_hardware Supported Hardware]
 
You can also find out if your hardware is supported by issuing the following command
 
You can also find out if your hardware is supported by issuing the following command
 +
 
  # flashrom --programmer internal
 
  # flashrom --programmer internal
  
 
The above command will tell you your motherboard and chipset. You can then find out if yours is supported by issuing this command:
 
The above command will tell you your motherboard and chipset. You can then find out if yours is supported by issuing this command:
 +
 
  # flashrom --programmer internal -L | grep CHIPNAMEfrompreviouscommand
 
  # flashrom --programmer internal -L | grep CHIPNAMEfrompreviouscommand
  
On modern mainboards you probably get more than one rom chip listed. You have to select the chipname you get from the upper command. Them you use the {{ic|-c}} option to select which rom is affected by the command
+
On modern mainboards you probably get more than one rom chip listed. You have to select the chipname you get from the upper command. Then you use the {{ic|-c}} option to select which rom is affected by the command
 +
 
 
  # flashrom --programmer internal -c "CHIPNAME" -r backup_CHIPNAME.bin
 
  # flashrom --programmer internal -c "CHIPNAME" -r backup_CHIPNAME.bin
  
 
Write and verify the new BIOS image (proprietary or Coreboot) on the ROM chip:
 
Write and verify the new BIOS image (proprietary or Coreboot) on the ROM chip:
 +
 
  # flashrom --programmer internal internal -c "CHIPNAME" -w newbios.bin
 
  # flashrom --programmer internal internal -c "CHIPNAME" -w newbios.bin
  
 
If you want to flash other flash chips on your mainboard, you will find all options with
 
If you want to flash other flash chips on your mainboard, you will find all options with
 +
 
  # flashrom
 
  # flashrom
 +
 +
{{Note|1=With Linux kernel versions greater than 4.4, {{ic|CONFIG_IO_STRICT_DEVMEM}} a new kernel security measure can make flashrom stop working, in that case you can try adding {{ic|1=iomem=relaxed}} to your kernel parameters. [https://www.flashrom.org/FAQ FAQ].}}
  
 
== FreeDOS ==
 
== FreeDOS ==
 +
 
[http://www.freedos.org/ FreeDOS] a free DOS-compatible operating system, is up to the challenge, no need for proprietary DOS versions. So, all you need is a bootable floppy disk image with FreeDOS kernel on it.
 
[http://www.freedos.org/ FreeDOS] a free DOS-compatible operating system, is up to the challenge, no need for proprietary DOS versions. So, all you need is a bootable floppy disk image with FreeDOS kernel on it.
  
 
=== Unetbootin ===
 
=== Unetbootin ===
By far the easiest way to make a bootable FreeDOS USB Stick is using {{pkg|unetbootin}}, available in the [[Official repositories]].
 
  
You should format a pendrive with FAT16 and flag it as "boot" (you may do this through a GUI with {{Pkg|gparted}}, {{AUR|qtparted}}{{Broken package link|{{aur-mirror|qtparted}}}} or {{Pkg|partitionmanager}}). Then, after mounting the flash drive, select under distribution '''FreeDOS''' and your mounted stick. The app will automatically download the image for you and copy it to the drive. Finally, you may copy everything you want to flash there (BIOS, firmwares, etc).
+
By far the easiest way to make a bootable FreeDOS USB Stick is using {{AUR|unetbootin}}.
 +
 
 +
You should format a pendrive with FAT16 and flag it as "boot" (you may do this through a GUI with {{Pkg|gparted}} or {{Pkg|partitionmanager}}). Then, after mounting the flash drive, select under distribution '''FreeDOS''' and your mounted stick. The app will automatically download the image for you and copy it to the drive. Finally, you may copy everything you want to flash there (BIOS, firmwares, etc).
  
 
{{Warning|Unetbootin may not function properly on some Lenovo systems. It may be necessary to create the bootable stick on a different device. See [http://reboot.pro/topic/9849-blinking-cursor-at-boot/ here].}}
 
{{Warning|Unetbootin may not function properly on some Lenovo systems. It may be necessary to create the bootable stick on a different device. See [http://reboot.pro/topic/9849-blinking-cursor-at-boot/ here].}}
  
=== Gentoo ===
+
=== dosemu ===
Check out [https://wiki.gentoo.org/wiki/BIOS_Update#FreeDOS_environment FreeDOS Flash Drive] on the Gentoo Wiki if you want to create a bootable FreeDOS Flash drive.
+
 
 +
The problem with the official FreeDOS images is the lack of extra space for holding firmware and BIOS update files and programs. The easiest way to create a DOS, bootable FAT drive of arbitrary size under Linux is to [https://wiki.gentoo.org/wiki/Bootable_DOS_USB_stick mount a FAT drive under dosemu then make it bootable with the FreeDOS sys command.]
 +
 
 +
For an alternative method, see [[gentoo:BIOS Update#FreeDOS environment|FreeDOS Flash Drive]], also on the Gentoo Wiki.
 +
 
 +
=== Pre-built images ===
 +
 
 +
Yet another simple solution: [http://myhq.it/sites/myhq.it/files/FreeDOS-1.1-memstick-2-2048M.img.bz2 FreeDOS pre-built bootable USB flash drive image by Christian Taube]. Instructions can be found [https://web.archive.org/web/20160224081331/http://www.chtaube.eu/computers/freedos/bootable-usb/ here].
 +
 
 +
=== Using a FreeDOS-provided Disk Image + USB stick on Linux ===
  
=== Prebuilt images ===
+
As of writing (2017-07-11), {{AUR|unetbootin}} doesn't support versions of FreeDOS more recent than 1.0 (current version is 1.2). The following procedure worked to upgrade an Inspiron 17-3737 to the A09 BIOS. (Dell offers this as a possibility [http://www.dell.com/support/article/ca/en/cabsdt1/SLN171755/updating-the-dell-bios-in-linux-and-ubuntu-environments?lang=EN#Creating%20a%20USB%20Bootable%20Storage%20Device on their site])
  
Yet another simple solution: [http://chtaube.eu/computers/freedos/bootable-usb/ FreeDOS prebuilt bootable USB flash drive image by Christian Taube]
+
Some notes before starting:
 +
 
 +
* You can check your current BIOS version with {{pkg|dmidecode}}. You might already be at the latest version.
 +
* Ensure that your hardware vendor has verified this method works (use of FreeDOS to run BIOS update {{ic|.exe}})
 +
* Laptop users should not attempt this without AC power
 +
* This is dangerous, and you assume all risk for following this procedure.
 +
 
 +
Procedure:
 +
 
 +
# Grab the latest USB installer from the [http://www.freedos.org/download/ FreeDOS Download Page]
 +
#* author note: used the "Full" version on suspicion that it might include more drivers, etc (pure speculation)
 +
# Extract the archive, you get a ''.img'' file
 +
# Determine which of {{ic|/dev/sdX}} is your USB stick (use {{ic|fdisk -l}})
 +
# Write the image directly to the block device:
 +
#* {{ic|1=dd if=FD12FULL.img of=/dev/sdX status=progress}} (where {{ic|X}} is the letter representing your USB stick as a block device, don't write the image to a partition)
 +
# Double-check that the image copying worked:
 +
#* {{ic|fdisk -l}} (you should see a single partition on a DOS disk with the bootable ("boot") flag set)
 +
# Mount the partition, and copy over the ''.exe'' used to update your firmware
 +
#* Stay on the safe side and limit the filename to 8 characters (without extension), upper case
 +
#* Ensure that you verified any checksums provided by your hardware vendor
 +
# Unmount and reboot. Do whatever is needed to boot from the USB drive
 +
 
 +
Now you will find yourself in the FreeDOS live installation environment.
 +
 
 +
# Select your language
 +
# You will be prompted to install FreeDOS
 +
#* Select "No - Return to DOS"
 +
# You should see a prompt ({{ic|C:\>}})
 +
# Run {{ic|dir /w}} and verify that your firmware upgrade tool is present
 +
# Run the executable
 +
#* author note: in the case of the Dell tool, the machine displayed a spash screen and then rebooted. Upon reboot, it started the firmware upgrade automatically, and ran for about 2 minutes with the fan at full speed)
 +
# Once the process specific to your vendor completes, optionally verify through the BIOS setup screen, as well as by running {{pkg|dmidecode}} when you're back in linux
 +
 
 +
=== Using a FreeDOS-provided Disk Image + USB stick with Windows ===
 +
 
 +
The author for this procedure encountered several issues related to mounting the FAT partition type of the USB using the previous method on Linux with dd. This procedure seeks to outline a method to flash the BIOS with FreeDOS, a USB stick and Ruckus on Windows 7/8/8.1/10. This procedure was performed on 4 JULY 2019 on a Dell Inspiron 5547 Laptop to upgrade from BIOS A10 to A12.
 +
 
 +
Prerequisites:
 +
* Download and install Rufus for Windows. This can be either the full installation or the portable version.
 +
* Download the latest Full USB installer for FreeDOS (v1.2 as of the time of writing).
 +
* Download the latest BIOS update from the vendors' website
 +
* It is assumed that ''dmidecode'' is installed on the system
 +
 
 +
Procedure:
 +
# Extract the contents of the ''FD12FULL.zip'' archive, noting the ''.img'' file
 +
# Insert a flash drive and flash the ''FD12FULL.img'' file using Rufus, leaving all default options
 +
#* Detailed use of Rufus is not covered in this guide. Refer to Rufus' manual or documentation for detailed usage
 +
# Once flashed with Rufus, rename the BIOS file with 8 uppercase characters (not including the extension) and copy it over to the flash drive
 +
# Eject the flash drive and plug it into the laptop.
 +
# Perform whatever steps are necessary to boot from the USB with LEGACY BOOT
 +
#* Author note: For my Dell Laptop, I press F12 for boot options and select 'USB Storage Device' under 'Legacy Options'. I have explicitly enabled legacy boot from within my BIOS, but this option may not be present if the system is only configured to boot with UEFI
 +
# You will be presented with the FreeDOS Installation environment
 +
#* Select preferred language
 +
#* Select 'No - Return to DOS' on the next screen
 +
#* Type ''dir'' to view the contents of the USB flash drive
 +
#* To execute the BIOS upgrade file, simply type the filename and press enter
 +
#* Note: My upgrade took <2 minutes with the fans at full speed. The system reboot 3 times total.
 +
# Once the upgrade completes and the system boots back into the OS, issue ''sudo dmidecode | grep -E 'BIOS|Version' '' and validate the BIOS version has been upgraded
  
 
=== Images that are too large for a floppy ===
 
=== Images that are too large for a floppy ===
 +
 
If your flash image is too large for a floppy, go to the [http://www.fdos.org/bootdisks/ FreeDos bootdisk website], and download the 10Mb hard-disk image.  This image is a full disk image, including partitions, so adding your flash utility will be a little trickier:
 
If your flash image is too large for a floppy, go to the [http://www.fdos.org/bootdisks/ FreeDos bootdisk website], and download the 10Mb hard-disk image.  This image is a full disk image, including partitions, so adding your flash utility will be a little trickier:
  
First find the first partition (at time of writing, the first partition starts at block 63; this means that the partitions starts at offset <tt>512 * 63 = 32256</tt>).
+
First find the first partition (at time of writing, the first partition starts at block 63; this means that the partitions starts at offset {{ic|1=512 * 63 = 32256}}).
 
You can either use:
 
You can either use:
# file -sk ''<image-file>'' | sed -r 's/.*startsector ([0-9]+).*/\1/'
+
 
'''63'''
+
{{hc|# file -sk ''<image-file>'' {{!}} sed -r 's/.*startsector ([0-9]+).*/\1/'|
 +
'''63'''
 +
}}
  
 
Or:
 
Or:
  
# fdisk -l ''<image-file>''
+
{{hc|# fdisk -l ''<image-file>''|2=
+
Units = sectors of 1 * '''512''' = 512 bytes
+
Units = sectors of 1 * '''512''' = 512 bytes
+
      Device  Boot  Start    End  Blocks  Id  System
+
      Device  Boot  Start    End  Blocks  Id  System
              *        '''63'''  19151  9544+  1  FAT12
+
              *        '''63'''  19151  9544+  1  FAT12
 +
}}
  
 
Now you can mount the image:
 
Now you can mount the image:
Line 104: Line 196:
 
=== Usage ===
 
=== Usage ===
  
The OEM Bootdisk version is recommended, as it only includes {{ic|kernel}} and {{ic|command.com}} thus leaving more space for the flash utility and new BIOS image. Download and decompress the FreeDOS image:
+
The OEM Bootdisk version is recommended, as it only includes {{ic|kernel}} and {{ic|command.com}} thus leaving more space for the flash utility and new BIOS image. Download the [http://www.fdos.org/bootdisks/autogen/FDOEM.144.gz FreeDOS image] and [[decompress]] it.
 
 
$ wget http://www.fdos.org/bootdisks/autogen/FDOEM.144.gz
 
$ gunzip FDOEM.144.gz
 
  
 
Copy your BIOS flash utility and new BIOS image to the mounted floppy disk image. Load the necessary modules:
 
Copy your BIOS flash utility and new BIOS image to the mounted floppy disk image. Load the necessary modules:
Line 121: Line 210:
 
If the mount went without errors, copy the BIOS flash utility and new BIOS image to the mounted floppy disk image. You will probably have to unzip the archive you downloaded from your motherboard vendor site, to get to those two files. For example:
 
If the mount went without errors, copy the BIOS flash utility and new BIOS image to the mounted floppy disk image. You will probably have to unzip the archive you downloaded from your motherboard vendor site, to get to those two files. For example:
  
# unzip 775Dual-VSTA\(2.60\).zip
+
{{hc|# unzip 775Dual-VSTA\(2.60\).zip|
Archive: 775Dual-VSTA(2.60).zip
+
Archive: 775Dual-VSTA(2.60).zip
  inflating: 75DVSTA2.60
+
inflating: 75DVSTA2.60
  inflating: ASRflash.exe
+
inflating: ASRflash.exe
 +
}}
 +
 
 
  # cp 75DVSTA2.60 ASRflash.exe /tmp/floppy
 
  # cp 75DVSTA2.60 ASRflash.exe /tmp/floppy
  
 
Check that the two files were not too big for the floppy:
 
Check that the two files were not too big for the floppy:
  
Filesystem          1K-blocks      Used Available Use% Mounted on
+
{{bc|
 +
Filesystem          1K-blocks      Used Available Use% Mounted on
 
  /tmp/FDOEM.144
 
  /tmp/FDOEM.144
 
                           1424      990      434  70% /tmp/floppy
 
                           1424      990      434  70% /tmp/floppy
 +
}}
 +
 
Unmount the floppy disk image:
 
Unmount the floppy disk image:
  
  umount /tmp/floppy
+
  # umount /tmp/floppy
  
 
The next step is to burn the floppy image to a CD/DVD-RW media, but in a way that it can be booted afterwards. First create a bootable CD image, and then burn it.
 
The next step is to burn the floppy image to a CD/DVD-RW media, but in a way that it can be booted afterwards. First create a bootable CD image, and then burn it.
  
  genisoimage -o bootcd.iso -b FDOEM.144 FDOEM.144
+
  # genisoimage -o bootcd.iso -b FDOEM.144 FDOEM.144
  wodim -v bootcd.iso
+
  # wodim -v bootcd.iso
  
 
You may alternatively add your image to the [[GRUB]] menu. Install [[syslinux]] and copy {{ic|memdisk}} and your image to {{ic|/boot}}:
 
You may alternatively add your image to the [[GRUB]] menu. Install [[syslinux]] and copy {{ic|memdisk}} and your image to {{ic|/boot}}:
  
  cp /usr/lib/syslinux/memdisk /boot
+
# cp /usr/lib/syslinux/memdisk /boot
  cp FDOEM.144 /boot/flashbios.img
+
# cp FDOEM.144 /boot/flashbios.img
  
 
Now add an entry to {{ic|/boot/grub/menu.lst}}:
 
Now add an entry to {{ic|/boot/grub/menu.lst}}:
 
    
 
    
  title Flash BIOS
+
{{hc|/boot/grub/menu.lst|
  kernel /memdisk
+
title Flash BIOS
  initrd /flashbios.img
+
kernel /memdisk
 +
initrd /flashbios.img
 +
}}
  
 
Or for GRUB2 in {{ic|/boot/grub/grub.cfg}}:
 
Or for GRUB2 in {{ic|/boot/grub/grub.cfg}}:
  
  menuentry "Flash BIOS" {
+
{{hc|/boot/grub/grub.cfg|<nowiki>
  linux16 /boot/memdisk
+
menuentry "Flash BIOS" {
  initrd16 /boot/flashbios.img
+
linux16 /boot/memdisk
  }
+
initrd16 /boot/flashbios.img
 +
}
 +
</nowiki>}}
  
 
Or for syslinux in {{ic|/boot/syslinux/syslinux.cfg}}:
 
Or for syslinux in {{ic|/boot/syslinux/syslinux.cfg}}:
  
LABEL flashbios
+
{{hc|/boot/syslinux/syslinux.cfg|
MENU LABEL Flash BIOS
+
LABEL flashbios
LINUX ../memdisk
+
MENU LABEL Flash BIOS
INITRD ../fdboot.img
+
LINUX ../memdisk
 +
INITRD ../fdboot.img
 +
}}
  
 
Finally reboot your machine, making sure the CD drive is first in the boot sequence, and run the BIOS upgrade procedure when the CD boots. If using the GRUB method, choose the new entry on the list, and it should boot into FreeDOS.
 
Finally reboot your machine, making sure the CD drive is first in the boot sequence, and run the BIOS upgrade procedure when the CD boots. If using the GRUB method, choose the new entry on the list, and it should boot into FreeDOS.
  
== Geteltorito.pl ==
+
== Bootable optical disk emulation ==
This perl script will extract the El Torito boot image. It has worked on Lenovo laptops like X220 X230, and W540. It may work for other vendors as well.
+
 
 +
The script Geteltorito.pl will extract the [[wikipedia:El Torito (CD-ROM standard)|El Torito]] boot image. It has worked with Lenovo laptops like the X1 Carbon, X220, X230, X260, W540, T450 and T450s. It may work for other vendors as well.
  
 
=== Installation ===
 
=== Installation ===
Install the {{AUR|geteltorito}}.
+
 
 +
Install the {{AUR|geteltorito}} package.
  
 
=== Usage ===
 
=== Usage ===
Line 178: Line 280:
 
Get the bios update iso from the vendor support site. Run the ''geteltorito'' image extraction:
 
Get the bios update iso from the vendor support site. Run the ''geteltorito'' image extraction:
  
  # geteltorito.pl -o <image>.img <image>.iso
+
  $ geteltorito.pl -o <image>.img <image>.iso
  
 
Copy the image to the usb thumbdrive:
 
Copy the image to the usb thumbdrive:
Line 185: Line 287:
  
 
Reboot and boot from the USB drive, follow vendor directions.
 
Reboot and boot from the USB drive, follow vendor directions.
 +
 +
{{Note|If you get the message "Secure Flash Authentication failed!", it means that some security check did not allow the flash to happen. It can help to go to the BIOS options page "Security" > "UEFI BIOS Update Option" and disable "Secure RollBack Prevention" and enable "Flash BIOS Updating by End-Users". You can set them to what you want after flashing.}}

Latest revision as of 04:13, 8 November 2019

This article aims on providing information on flashing your system BIOS under Linux. Most manufacturers provide a Windows executable or a BIOS executable that can only be run under Windows. However, there are a few utilities, that allow you to upgrade your system BIOS under Linux.

Warning: Flashing motherboard BIOS is a dangerous activity that can render your motherboard inoperable! While the author of this article has successfully run this procedure many times, your mileage may vary. Be careful! You may want to consider updating microcode instead if it is supported by your system.
Note:
  • HP users may download Windows BIOS updater from HP website, extract *.exe file and locate ISO image for burning to a CD. Using CD, upgrade is possible from BIOS menu using 'Firmware Upgrade' without using below tools. See this thread for details.
  • For users with Dell computers, Dell recommends Linux users flash their BIOS following information located here (in short, put the .EXE on a USB stick and use the F12 boot menu to access the firmware's flash utility).

fwupd

fwupd is a simple daemon to allow session software to update device firmware on your local machine.

Large vendors including Dell and Logitech use this way to distribute firmware updates to Linux.

fwupd only supports flashing BIOS updates in UEFI mode.

See fwupd for further information about installation and usage.

BiosDisk

BiosDisk simplifies the process of flashing your system BIOS under Linux.

Note: This is only supported on systems when booted in "Legacy mode". In UEFI mode you will need to use a different method.

Installation

Install the biosdisk-gitAUR package.

Usage

To use the biosdisk utility to create a BIOS flash image, first download the latest raw BIOS image for your system from your manufacturer's website. Make sure however, that you always get the BIOS executable and NOT the Windows executable. You then have one of two options: create a ISO or install the image for your bootloader.

  • The mkimage action will create a ISO image on the user's hard drive. Usage is the following:
# biosdisk mkimage [-o option] [-i destination] /path/to/.exe 
  • The install action will create the biosdisk image, copy the image file to /boot, and then update the bootloader with an entry for the image. Then all the user has to do is boot the system and select the image to flash the BIOS; this will load the biosdisk image directly from the hard drive and flash the BIOS.
# biosdisk install [-o option] [--name=] /path/to/.exe

Flashrom

Flashrom is a utility for identifying, reading, writing, verifying and erasing flash chips. It is designed to flash BIOS/EFI/coreboot/firmware/optionROM images on mainboards, network/graphics/storage controller cards, and various programmer devices.

Warning: If you have a laptop/notebook/netbook, please do NOT try flashrom because interactions with the EC on these machines might crash your machine during flashing. flashrom tries to detect if a machine is a laptop, but not all laptops follow the standard, so this is not 100% reliable.[1]

Installation

Install the flashrom or flashrom-gitAUR package.

Usage

Find out if your motherboard and chipset (internal) is supported by flashrom at this website. Supported Hardware You can also find out if your hardware is supported by issuing the following command

# flashrom --programmer internal

The above command will tell you your motherboard and chipset. You can then find out if yours is supported by issuing this command:

# flashrom --programmer internal -L | grep CHIPNAMEfrompreviouscommand

On modern mainboards you probably get more than one rom chip listed. You have to select the chipname you get from the upper command. Then you use the -c option to select which rom is affected by the command

# flashrom --programmer internal -c "CHIPNAME" -r backup_CHIPNAME.bin

Write and verify the new BIOS image (proprietary or Coreboot) on the ROM chip:

# flashrom --programmer internal internal -c "CHIPNAME" -w newbios.bin

If you want to flash other flash chips on your mainboard, you will find all options with

# flashrom
Note: With Linux kernel versions greater than 4.4, CONFIG_IO_STRICT_DEVMEM a new kernel security measure can make flashrom stop working, in that case you can try adding iomem=relaxed to your kernel parameters. FAQ.

FreeDOS

FreeDOS a free DOS-compatible operating system, is up to the challenge, no need for proprietary DOS versions. So, all you need is a bootable floppy disk image with FreeDOS kernel on it.

Unetbootin

By far the easiest way to make a bootable FreeDOS USB Stick is using unetbootinAUR.

You should format a pendrive with FAT16 and flag it as "boot" (you may do this through a GUI with gparted or partitionmanager). Then, after mounting the flash drive, select under distribution FreeDOS and your mounted stick. The app will automatically download the image for you and copy it to the drive. Finally, you may copy everything you want to flash there (BIOS, firmwares, etc).

Warning: Unetbootin may not function properly on some Lenovo systems. It may be necessary to create the bootable stick on a different device. See here.

dosemu

The problem with the official FreeDOS images is the lack of extra space for holding firmware and BIOS update files and programs. The easiest way to create a DOS, bootable FAT drive of arbitrary size under Linux is to mount a FAT drive under dosemu then make it bootable with the FreeDOS sys command.

For an alternative method, see FreeDOS Flash Drive, also on the Gentoo Wiki.

Pre-built images

Yet another simple solution: FreeDOS pre-built bootable USB flash drive image by Christian Taube. Instructions can be found here.

Using a FreeDOS-provided Disk Image + USB stick on Linux

As of writing (2017-07-11), unetbootinAUR doesn't support versions of FreeDOS more recent than 1.0 (current version is 1.2). The following procedure worked to upgrade an Inspiron 17-3737 to the A09 BIOS. (Dell offers this as a possibility on their site)

Some notes before starting:

  • You can check your current BIOS version with dmidecode. You might already be at the latest version.
  • Ensure that your hardware vendor has verified this method works (use of FreeDOS to run BIOS update .exe)
  • Laptop users should not attempt this without AC power
  • This is dangerous, and you assume all risk for following this procedure.

Procedure:

  1. Grab the latest USB installer from the FreeDOS Download Page
    • author note: used the "Full" version on suspicion that it might include more drivers, etc (pure speculation)
  2. Extract the archive, you get a .img file
  3. Determine which of /dev/sdX is your USB stick (use fdisk -l)
  4. Write the image directly to the block device:
    • dd if=FD12FULL.img of=/dev/sdX status=progress (where X is the letter representing your USB stick as a block device, don't write the image to a partition)
  5. Double-check that the image copying worked:
    • fdisk -l (you should see a single partition on a DOS disk with the bootable ("boot") flag set)
  6. Mount the partition, and copy over the .exe used to update your firmware
    • Stay on the safe side and limit the filename to 8 characters (without extension), upper case
    • Ensure that you verified any checksums provided by your hardware vendor
  7. Unmount and reboot. Do whatever is needed to boot from the USB drive

Now you will find yourself in the FreeDOS live installation environment.

  1. Select your language
  2. You will be prompted to install FreeDOS
    • Select "No - Return to DOS"
  3. You should see a prompt (C:\>)
  4. Run dir /w and verify that your firmware upgrade tool is present
  5. Run the executable
    • author note: in the case of the Dell tool, the machine displayed a spash screen and then rebooted. Upon reboot, it started the firmware upgrade automatically, and ran for about 2 minutes with the fan at full speed)
  6. Once the process specific to your vendor completes, optionally verify through the BIOS setup screen, as well as by running dmidecode when you're back in linux

Using a FreeDOS-provided Disk Image + USB stick with Windows

The author for this procedure encountered several issues related to mounting the FAT partition type of the USB using the previous method on Linux with dd. This procedure seeks to outline a method to flash the BIOS with FreeDOS, a USB stick and Ruckus on Windows 7/8/8.1/10. This procedure was performed on 4 JULY 2019 on a Dell Inspiron 5547 Laptop to upgrade from BIOS A10 to A12.

Prerequisites:

  • Download and install Rufus for Windows. This can be either the full installation or the portable version.
  • Download the latest Full USB installer for FreeDOS (v1.2 as of the time of writing).
  • Download the latest BIOS update from the vendors' website
  • It is assumed that dmidecode is installed on the system

Procedure:

  1. Extract the contents of the FD12FULL.zip archive, noting the .img file
  2. Insert a flash drive and flash the FD12FULL.img file using Rufus, leaving all default options
    • Detailed use of Rufus is not covered in this guide. Refer to Rufus' manual or documentation for detailed usage
  3. Once flashed with Rufus, rename the BIOS file with 8 uppercase characters (not including the extension) and copy it over to the flash drive
  4. Eject the flash drive and plug it into the laptop.
  5. Perform whatever steps are necessary to boot from the USB with LEGACY BOOT
    • Author note: For my Dell Laptop, I press F12 for boot options and select 'USB Storage Device' under 'Legacy Options'. I have explicitly enabled legacy boot from within my BIOS, but this option may not be present if the system is only configured to boot with UEFI
  6. You will be presented with the FreeDOS Installation environment
    • Select preferred language
    • Select 'No - Return to DOS' on the next screen
    • Type dir to view the contents of the USB flash drive
    • To execute the BIOS upgrade file, simply type the filename and press enter
    • Note: My upgrade took <2 minutes with the fans at full speed. The system reboot 3 times total.
  7. Once the upgrade completes and the system boots back into the OS, issue sudo dmidecode | grep -E 'BIOS|Version' and validate the BIOS version has been upgraded

Images that are too large for a floppy

If your flash image is too large for a floppy, go to the FreeDos bootdisk website, and download the 10Mb hard-disk image. This image is a full disk image, including partitions, so adding your flash utility will be a little trickier:

First find the first partition (at time of writing, the first partition starts at block 63; this means that the partitions starts at offset 512 * 63 = 32256). You can either use:

# file -sk <image-file> | sed -r 's/.*startsector ([0-9]+).*/\1/'
63

Or:

# fdisk -l <image-file>
…
Units = sectors of 1 * 512 = 512 bytes
…
      Device  Boot  Start    End  Blocks  Id  System
              *        63  19151   9544+   1  FAT12

Now you can mount the image:

# mount -oloop,offset=$((63 * 512)) <image-file> /mnt

Then you can copy your flash utility onto the filesystem as normal. Once you're done:

# umount /mnt

The image can now be copied to a USB stick for booting, or booted as a memdisk as per normal instructions.

Usage

The OEM Bootdisk version is recommended, as it only includes kernel and command.com thus leaving more space for the flash utility and new BIOS image. Download the FreeDOS image and decompress it.

Copy your BIOS flash utility and new BIOS image to the mounted floppy disk image. Load the necessary modules:

# modprobe vfat
# modprobe loop

/proc/fileystems shows if the needed file systems are supported. "loop mount" the floppy disk image to a temporary path:

$ mkdir /tmp/floppy
$ mount -t vfat -o loop FDOEM.144 /tmp/floppy

If the mount went without errors, copy the BIOS flash utility and new BIOS image to the mounted floppy disk image. You will probably have to unzip the archive you downloaded from your motherboard vendor site, to get to those two files. For example:

# unzip 775Dual-VSTA\(2.60\).zip
Archive: 775Dual-VSTA(2.60).zip
 inflating: 75DVSTA2.60
 inflating: ASRflash.exe
# cp 75DVSTA2.60 ASRflash.exe /tmp/floppy

Check that the two files were not too big for the floppy:

Filesystem           1K-blocks      Used Available Use% Mounted on
 /tmp/FDOEM.144
                          1424       990       434  70% /tmp/floppy

Unmount the floppy disk image:

# umount /tmp/floppy

The next step is to burn the floppy image to a CD/DVD-RW media, but in a way that it can be booted afterwards. First create a bootable CD image, and then burn it.

# genisoimage -o bootcd.iso -b FDOEM.144 FDOEM.144
# wodim -v bootcd.iso

You may alternatively add your image to the GRUB menu. Install syslinux and copy memdisk and your image to /boot:

# cp /usr/lib/syslinux/memdisk /boot
# cp FDOEM.144 /boot/flashbios.img

Now add an entry to /boot/grub/menu.lst:

/boot/grub/menu.lst
title Flash BIOS
kernel /memdisk
initrd /flashbios.img

Or for GRUB2 in /boot/grub/grub.cfg:

/boot/grub/grub.cfg
menuentry "Flash BIOS" {
 linux16 /boot/memdisk
 initrd16 /boot/flashbios.img
}

Or for syslinux in /boot/syslinux/syslinux.cfg:

/boot/syslinux/syslinux.cfg
LABEL flashbios
	MENU LABEL Flash BIOS
	LINUX ../memdisk
	INITRD ../fdboot.img

Finally reboot your machine, making sure the CD drive is first in the boot sequence, and run the BIOS upgrade procedure when the CD boots. If using the GRUB method, choose the new entry on the list, and it should boot into FreeDOS.

Bootable optical disk emulation

The script Geteltorito.pl will extract the El Torito boot image. It has worked with Lenovo laptops like the X1 Carbon, X220, X230, X260, W540, T450 and T450s. It may work for other vendors as well.

Installation

Install the geteltoritoAUR package.

Usage

Get the bios update iso from the vendor support site. Run the geteltorito image extraction:

$ geteltorito.pl -o <image>.img <image>.iso

Copy the image to the usb thumbdrive:

# dd if=<image>.img of=<destination> bs=512K

Reboot and boot from the USB drive, follow vendor directions.

Note: If you get the message "Secure Flash Authentication failed!", it means that some security check did not allow the flash to happen. It can help to go to the BIOS options page "Security" > "UEFI BIOS Update Option" and disable "Secure RollBack Prevention" and enable "Flash BIOS Updating by End-Users". You can set them to what you want after flashing.