Flashing bios from linux

Обновление UEFI/BIOS в Linux

Не секрет, что производители материнских плат и ноутбуков не всегда дают возможность пользователям Linux обновить UEFI/BIOS прошивку так же ненавязчиво, как это делают пользователи Windows. Тем не менее для HP EliteBook 840G1, которым я пользуюсь, сделать это немногим сложнее.

Для этого дела понадобятся следующие артефакты:

  • FAT32 EFI System Partition (ESP)
  • WINE
  • Переменный электрический ток

FAT32 ESP

Ноутбуки линейки HP EliteBook содержат 3 режима загрузки. Узнать какой из режимов выбран можно в настройках UEFI/BIOS → System Configuration → Boot Mode . Данный раздел следует читать, если только выбран последний, бескомпромиссный режим UEFI , в остальных случаях можно проскочить.

  • Legacy
  • UEFI Hybrid with compatibility support module (CSM)
  • UEFI Native without CSM

Если вы внимательно читали топик про Linux kernel EFI Boot Stub, то вы наверняка знаете, что и как нужно сделать, для того, чтобы создать дисковый раздел. Можно использовать gdisk , parted или KDE Disk Partition для создания ESP раздела. Вот так выглядит уже готовый раздел.

Рекомендуется ESP раздел монтировать в /boot/efi , а не просто в /boot , для того чтобы можно было хранить образы ядра Linux и файлы загрузчика ОС на штатных линуксовых ФС, вместо того, чтобы все держать в FAT32 EFI System Partition.

Мы уже знаем, что UEFI/BIOS будет искать \EFI\BOOT\bootx64.efi , для чего абсолютный путь к файлу должен быть /boot/efi/EFI/Boot/Bootx64.efi , иначе все пропало и UEFI/BIOS не найдет загрузчик ОС! Обновлению системной прошивки это не помешает, но для чего же тогда нужна прошивка, если нельзя загрузить операционную систему? Очень немаловажно, что по-умолчанию GRUB-2 не копирует необходимый файл и поэтому bootx64.efi надо скопировать вручную.

Подготовка

Берем свежую прошивку с сайта HP, выбираем Linux в выпадающем списке ОС, затем BIOS, скачиваем… и обнаруживаем исполняемый файл для Windows — sp64081.exe . Нет, глаза нас не подвели.

Опытные пользователи бывают готовы к подобным сюрпризам, для чего держат Windows VM либо пользуются не-эмулятором WINE или и то и другое вместе, бо случаи бывают разные. Для распаковки файла возможностей WINE вполне достаточно. Запускаем:

Программа завершает работу с бестактной ошибкой, напоминая лишний раз о том, что нам подсунули не то, что мы ожидали.

Однако, это не должно никого волновать, так как файлы распакованы верно а сверх этого ничего и не требовалось.

Из этого списка нам понадобятся только 3 файла: L71_0137.bin , HpBiosUpdate.efi и HpBiosUpdate.s12 и теперь внимание: скопировать файлы нужно точно в указанные места.

Чтобы попасть в меню настройки UEFI/BIOS надо после включения нажать клавишу Esc или F10 а далее File → Update System BIOS .

После выбора Accept , процесс обновления стартует без прочих реверансов. Видимо зная цену своим аккумуляторам, производители обновляют прошивку только при включенном электрическом питании компьютера. 2-3 минуты, и процесс благополучно завершен.

UPDATE: По итогам здравых идей в комментариях необходимы некоторые дополнения.

  • Можно скопировать те же самые 3 файла на USB флешку, в прописанных путях и используя её обновить прошивку. Разметка файловой системы должна быть FAT32 ESP.
  • Можно обновиться из File → Update System BIOS напрямую по интернету, если подключен сетевой кабель. Обновление не будет работать через WiFi соединение.
  • Вместо WINE для распаковки архива достаточно использовать 7z e sp64081.exe .

Источник

Flash your Lenovo Ideapad laptop BIOS from Linux using UEFI capsule updates

Jul 14, 2018 · 7 min read

I’m the happy owner of a Lenovo Ideapad laptop (model 710S-13IKB). It’s comparable to the Dell XPS 13 and runs beautifully under Linux, but one detail has always been bugging me: Lenovo only provides BIOS updates for its Ideapad laptops in the form of Windows 10 executable files. System firmware updates are important, especially to mitigate newly found vulnerabilities like Meltdown and Spectre. Since I wiped Windows off my machine a long time ago, I was wondering if there was an alternative (and secure) way to flash firmware updates on it.

And it tu r ns out there is! After months of investigation, I found an elegant and stable update procedure which doesn’t require Windows at all. It doesn’t even need the creation of a bootable USB key: everything is done from the existing Linux installation. How is that possible? Let me introduce you to an interesting new feature of the UEFI specification.

Different machines, different firmware updates

Many latop brands like Dell or Asus provide firmware files that you can put on a USB key and flash from an update application located in the BIOS menu itself. Lenovo does not. Instead, they give you two options:

  • For the higher-end ThinkPad series inherited from IBM, they provide bootable CD images that can be turned into bootable USB keys. That’s another good OS-agnostic solution.
  • For the Ideapad and Yoga series, you’re stuck with a Windows executable file. The contents of this file and the actual flashing procedure varies depending on the BIOS/Firmware brand.

If you have a modern machine with a Phoenix firmware, chances are that the Windows executable contains the update in the form of an UEFI Capsule Update.

Capsule what?

When a firmware is distributed in that form, the update program won’t flash it directly under Windows. Instead, it will delegate the task to the standard UEFI update mechanism called Capsule Update. In practice, it will ask the operating system to copy an update file to the system partition then program the UEFI to verify this update and install it after the next reboot of the machine, before the operating system starts.

This standard update system is part of the UEFI 2.5 specification released in 2015 and is also available for Linux thanks to efforts from Intel and Red Hat. To be able to use it, your Linux distribution must already boot in UEFI mode from a disk including an EFI system partition.

Читайте также:  Windows cache extension что это

Compatible models

I compiled the following list of Lenovo laptops which come with a firmware update in the form of a Capsule Update installer. If you find more (including from other brands), please mention them in the comments.

700–15ISK, 700–17ISK
710S-13ISK, 710S-13IKB
720S-15IKB, 720S Touch-15IKB
E42–80, E52–80, E53–80
300S-14ISK, 500S-14ISK, Edge 2–1580, Flex 3–1480, Flex 3–1580, Yoga 500–14ISK, Yoga 500–15ISK
720–15IKB (Type 81AG)
K21–80, K22–80, K32–80
K41–80/M41–80
XiaoXin Rui7000
Rescuer E520–15IKB
V110–14IAP, V110–15IAP
V110–15IKB, V110–15ISK
V310–14IKB, V310–15IKB, V510–14IKB, V510–15IKB
V310–14ISK, V310–15ISK
V330–15IKB, V330–15ISK
V730–13IKB, V730–13ISK
V730–15IKB

Step 1: locate and extract the firmware update file

Go to the Lenovo support website and download the latest BIOS executable file for your machine. This is actually a Windows self-extracting archive built using Inno Setup. You can extract the files in these archives using the command line tool innoextract which is available for many Linux distributions. I’m using Arch Linux so I install it using pacman :

Now let’s extract the files:

Warning: Make sure you use the latest version of innoextract which is compatible with BIOS update executable files generated by Inno Setup version 6.0.0, the version that Lenovo is currently using.

If you have a compatible model you will find a .cap file, which is the file format for UEFI Capsule Updates. Keep that file and delete the rest.

Step 2: install the UEFI Linux firmware update tools

There is a high-level tool called fwupd which allows to automatically detect, download and install updates from the Linux Vendor Firmware Service. This tool also integrates with the Gnome Software graphical user interface in order to display firmware updates next to regular software updates.

Unfortunately, there are only a handful of machines supported on that site at the time of this writing, mostly from Dell. Other vendors don’t (yet) make the effort of publishing their software updates for Linux users.

Instead of the fwupd daemon and its companion tool fwupdmgr , we’re going to use a lower-level tool called fwupdate. It’s normally installed along with fwupd, but on some Linux distributions you may have to install it separately.

On Arch Linux, fwupdate is located in: /usr/lib/fwupd/fwupdate .

We can use this tool to check if our machine provides a firmware compatible with Capsule Updates:

If nothing shows up for you, your firmware or your Linux kernel is not compatible and you can’t go any further. Otherwise, copy the GUID number of your system firmware for the next step.

Step 3: flash the firmware!

Now it’s time to prepare and schedule the update for the next system reboot, using our extracted .cap file and the GUID noted above:

Note that I manually specify the ESP path which defaults to /boot/efi . Use the appropriate path for your Linux installation.

If you see no error message, all went well. You can check that the update is pending using the following command:

Plug your laptop to a power source before rebooting or the update will be cancelled and you’ll have to repeat the last step.

Reboot. Now go to the BIOS setup menu of your machine (for Lenovo laptops, press F2 or Fn + F2 at boot time) and make sure the “Linux-Firmware-Updater” entry is moved first in the “Boot Priority Order”.

Save and exit. Now the updater will kick in, load the Capsule Update file into RAM, verify it and restart the machine again.

Hold your breath during the actual flashing procedure.

Success! Your machine has just been updated to its latest firmware.

Step 4: reconfigure the BIOS to boot Linux again

Now the system won’t boot. Don’t panic, it’s just because the BIOS settings have been reset to the factory defaults. You need to configure a few things to put Linux back in charge. At boot, enter the BIOS menu by pressing Fn + F2.

In the “Configuration” tab, put the “SATA Controller Mode” back to AHCI because Linux can’t boot in RAID mode. You can also enable “Intel Virtual Technology” if you’re using KVM (it’s used by virtualization and emulation software).

Next, in the “Security” tab disable “Secure Boot”. Only Windows and a few Linux distributions provide a suitably signed boot loader.

In the “Boot” tab, you’ll notice that the Linux boot loader entry is gone as well, but that shouldn’t be a problem because most systems will attempt to detect previously installed UEFI boot loaders automatically from the disks. Save and exit and your machine should boot back into your Linux installation. If it doesn’t, you can always use a bootable Linux USB stick for the next step.

Step 5: restore the UEFI boot entry

If you want to add back the Linux option in your UEFI boot menu, the simplest way is to reinstall your boot loader. Check the documentation of your Linux distribution to find the correct procedure, which usually consists of a single command line. Many distributions install GRUB2 by default; I prefer using systemd-boot for simplicity.

Everything is back to normal.

I’m excited to see that there are now better options to safely and quickly update our machine firmwares from Linux. I’m waiting for more manufacturers to publish their updates on the Linux Vendor Firmware Service or for a community effort to appear. In the meantime, you can always use this procedure to download, extract and install the update files yourself, if you own a compatible system. Happy flashing!

Источник

Flashing BIOS from Linux

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.

Contents

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.

Читайте также:  Браузер для linux pale moon

Installation

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:
  • 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.

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.

Installation

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

The above command will tell you your motherboard and chipset. You can then find out if yours is supported by issuing this 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 -c option to select which rom is affected by the command

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

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

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 unetbootin AUR .

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).

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 and then make it bootable with the FreeDOS sys command.

Pre-built images

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

As of writing (2017-07-11), unetbootin AUR does not 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.
  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, do not 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 are 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.

  • 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
  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 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:

Now you can mount the image:

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

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:

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

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:

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

Unmount the floppy disk image:

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.

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

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

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

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

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, X200, X220, X230, X260, X395, W540, T450, T450s and P50. It may work for other vendors as well.

Installation

Usage

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

Copy the image to the usb thumbdrive:

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

Using a Windows PE

If your manufacturer only provides an exe file and you were not successful following the prior advice , you can update your bios creating a Windows PE flash drive and from there flash the bios update as normally.

Usage

Download a ISO Windows PE to create a bootable drive.

Boot the usb and go to your manufacturer website and download the respective update, and execute normally.

HP Users

Some HP BIOS, especially the ones available in their business lines — ProDesk 600, EliteDesk 800, Thin Clients (T620, T730 etc) — have an option to update the BIOS from within the BIOS. This option is usually available under the File Menu and is called «Flash System ROM». There are 2 different directory structures that seem to work. Your BIOS may or may not work with either directory structure.

  1. Placing the BIOS *.bin file in the root of the FAT32 formatted USB drive without any other directories. You do not need any other files.
  2. Using the directory structure as described here

If neither of the above directory structures seem to work, then either use the FreeDOS method if HP provides the relevant DOS executables for your BIOS version or get a Windows machine to first create a HP BIOS Flash Recovery USB and then use that USB to flash the BIOS using the same Flash System ROM option.

  1. Download the BIOS executable from HP’s support website using your serial number and indicating Windows as the OS .
  2. The exe file is an archive and can then be extracted using 7z
    • 7z e .exe
  3. Create the appropriate directory structure in the USB as described above. If one does not work, try the other
  4. Unmount the USB
  5. Attach it to the computer whose BIOS needs to be upgraded (if using a different computer to create the USB drive)
  6. Reboot the computer and get into the BIOS using the assigned key (F10 for eg.) for your BIOS.
  7. Once in the BIOS, find and select the «Flash System ROM» option. It may provide you with 3 options to flash from
    • USB
    • Hard disk
    • Network
  8. Select the appropriate option (in this case USB) and it will pop up another text box which will have the file name of the BIN file that you put in the root of the USB drive.
  9. Hit Enter and it should indicate that current version of the BIOS and new one being upgraded to.
  10. Follow the screen prompts to upgrade the BIOS and finally reboot.

Источник

Читайте также:  Windows restarting error message
Оцените статью