Windows: Difference between revisions

From flashrom
Jump to navigation Jump to search
(Initial Windows/MinGW/MSYS build instructions.)
 
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This is a tutorial on how to build flashrom on Windows using MinGW/MSYS.
= Using flashrom on Windows =
 
== Requirements ==
In order to use flashrom on Windows you must either build it from source as explained below or just download a snapshot from [http://ra.openbios.org/~idwer/flashrom/mingw/ here].
If your programmer is COM or LPT-based, there is nothing more to do, because Windows has all drivers needed.
 
It isn't so easy for USB-based devices, because they needed a special libusb-win32 driver, that must be generated and installed to make it available to the flashrom executable.
Because the nature of the generation process, the driver has no digital signature and can't be installed on 64-bit Windows versions without some preparations.
 
== Obtaining libusb-win32 ==
The required installation file can be found on [http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/ the libusb-win32 project site].
Please use the same version that was used for flashrom compilation as indicated by the download path.
 
Download the file named ''libusb-win32-bin-x.y.z.t.zip'' and unpack ''/libusb-win32-bin-x.y.z.t/bin'' directory from it.
 
== Making libusb-based driver for your device ==
* Attach your USB device and click on ''Cancel'' or ''Close'' on the Driver Installation Wizard window.
 
* Run inf-wizard.exe from the unpacked ''bin'' directory. Click on ''Next''.
 
[[Image:Inf-Wizard-List.png]]
 
* Select your device from the list, click on ''Next''.
 
[[Image:Inf-Wizard-Settings.png]]
 
* Do not alter Vendor ID, Product ID and MI. You can alter Manufacturer and Device names, if you want. Click on ''Next''.
 
* Select the destination for the newly created driver and click on Save.
 
[[Image:Inf-Wizard-Done.png]]
 
* If you are using 32bit Windows version or 64bit Windows version with unsigned driver installation option enabled, click on ''Install Now...'' to install the driver.
 
* If you receive an error message instead of a successful driver installation, disable the enforced driver signing (your favorite search engine will give you details about that) and install the driver after that.
 
* Detach your device and attach it once again to finish the installation.
 
== Using flashrom ==
After installing the drivers successfully you can use flashrom without Administrator privileges.
Consult the man page about how to use it in general and the options available for your programmer.
 
= Building flashrom on Windows using MinGW/MSYS. =
 
Before you set up a MinGW/MSYS build environment, note that you may find usable Windows binaries in our [http://buildbot.flashrom.org/buildresults/?M=D buildbot archive]. However, they are usually untested and not recommended to be trusted blindly.


== Requirements ==
== Requirements ==
Line 15: Line 59:
  $ '''mingw-get update'''
  $ '''mingw-get update'''
  $ '''mingw-get install msys-wget msys-unzip'''
  $ '''mingw-get install msys-wget msys-unzip'''
* Additionally, '''pkg-config''' is needed. There are a few ways to do this. The MinGW FAQ has [http://www.mingw.org/wiki/FAQ some suggestions]: Extract the binary from GTK or use an alternative implementation. A flashrom user describes the steps for extracting pkg-config from GTK in [https://github.com/flashrom/flashrom/issues/149#issuecomment-653763669 this issue on Github].
If you are using MSYS2, '''pacman''' can also be used:
$ pacman -S mingw-w64-x86_64-pkg-config # 64-bit
$ pacman -S mingw-w64-i686-pkg-config  # 32-bit


=== libusb-win32 ===
=== libusb-win32 ===


* Download and execute [http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.3.0/libusb-win32-devel-filter-1.2.3.0.exe/download libusb-win32-devel-filter-1.2.3.0.exe].
* Download and execute [http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.6.0/libusb-win32-devel-filter-1.2.6.0.exe/download libusb-win32-devel-filter-1.2.6.0.exe].
* Download and extract [http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.4.0/libusb-win32-bin-1.2.4.0.zip/download libusb-win32-bin-1.2.4.0.zip].
* Download and extract [http://sourceforge.net/projects/libusb-win32/files/libusb-win32-releases/1.2.6.0/libusb-win32-bin-1.2.6.0.zip/download libusb-win32-bin-1.2.6.0.zip].
** Copy '''usb.h''' to '''/usr/local/include'''.
** Copy '''lusb0_usb.h''' to (the equivalent of) '''/usr/local/include'''.


=== libftdi ===
=== libftdi ===
Line 32: Line 83:
== Building flashrom ==
== Building flashrom ==


Checkout the flashrom source code from svn (e.g. using TortoiseSVN), then:
Checkout the flashrom source code (see the [[Downloads#Installation_from_source|download page]] for instructions), then:


  $ '''cd flashrom'''
  $ '''cd flashrom'''
  $ '''make'''
  $ '''make'''
= Building (cross-compiling) flashrom on Linux for Windows using MinGW. =
First you need to install MinGW (on Ubuntu it is enough to install the package mingw32).
Of course all the normal build utilities are needed like make etc. (usually contained in a package named build-essential or similar).
If you want to use libusb or libftdi you need to get the headers and static library files (*.a).
The latter can either be downloaded pre-built or need to be (cross-)compiled.
For libusb-win32 this even requires a Windows SDK which makes the whole point of cross-compiling a bit moot.
See the respective source packages for documentation on how to cross-compile them.
The headers and libraries should be organized in a Unix-like directory layout, i.e. a (sub) directory named '<tt>lib</tt>' containing the static libraries (<tt>*.a</tt>), '<tt>bin</tt>' with non-static libraries (<tt>*.dll</tt>) if need be, and '<tt>include</tt>' with the headers (<tt>*.h</tt>).
You can then compile flashrom.exe with
$ '''make CC=i686-w64-mingw32-gcc LIBS_BASE=/path_to_the_base_directory_containing_the_libraries_and_headers/'''
A relative path (originating in the flashrom directory) is allowed as LIBS_BASE's value.
The compiler to be used (given by the CC value) depends on the MinGW edition you are using.

Latest revision as of 17:13, 4 July 2020

Using flashrom on Windows

Requirements

In order to use flashrom on Windows you must either build it from source as explained below or just download a snapshot from here. If your programmer is COM or LPT-based, there is nothing more to do, because Windows has all drivers needed.

It isn't so easy for USB-based devices, because they needed a special libusb-win32 driver, that must be generated and installed to make it available to the flashrom executable. Because the nature of the generation process, the driver has no digital signature and can't be installed on 64-bit Windows versions without some preparations.

Obtaining libusb-win32

The required installation file can be found on the libusb-win32 project site. Please use the same version that was used for flashrom compilation as indicated by the download path.

Download the file named libusb-win32-bin-x.y.z.t.zip and unpack /libusb-win32-bin-x.y.z.t/bin directory from it.

Making libusb-based driver for your device

  • Attach your USB device and click on Cancel or Close on the Driver Installation Wizard window.
  • Run inf-wizard.exe from the unpacked bin directory. Click on Next.

  • Select your device from the list, click on Next.

  • Do not alter Vendor ID, Product ID and MI. You can alter Manufacturer and Device names, if you want. Click on Next.
  • Select the destination for the newly created driver and click on Save.

  • If you are using 32bit Windows version or 64bit Windows version with unsigned driver installation option enabled, click on Install Now... to install the driver.
  • If you receive an error message instead of a successful driver installation, disable the enforced driver signing (your favorite search engine will give you details about that) and install the driver after that.
  • Detach your device and attach it once again to finish the installation.

Using flashrom

After installing the drivers successfully you can use flashrom without Administrator privileges. Consult the man page about how to use it in general and the options available for your programmer.

Building flashrom on Windows using MinGW/MSYS.

Before you set up a MinGW/MSYS build environment, note that you may find usable Windows binaries in our buildbot archive. However, they are usually untested and not recommended to be trusted blindly.

Requirements

MinGW/MSYS

In order to build flashrom and various of its dependencies, we need a UNIX-like environment on Windows, which is provided by MinGW/MSYS.

  • Download the latest version (20110530 currently) of the automated MinGW installer named mingw-get-inst (double-click the installer *.exe, which will download and install all components).
    • Make sure you enable "MinGW Compiler Suite", "C++ compiler", "MSYS Basic System", and "MinGW Developer Toolkit" in the installer.
    • For simplicity it's recommended to leave the default install location of c:\MinGW unchanged.

Now open a MinGW shell via Start/Programs/MinGW/MinGW Shell and do the following:

$ mingw-get update
$ mingw-get install msys-wget msys-unzip
  • Additionally, pkg-config is needed. There are a few ways to do this. The MinGW FAQ has some suggestions: Extract the binary from GTK or use an alternative implementation. A flashrom user describes the steps for extracting pkg-config from GTK in this issue on Github.

If you are using MSYS2, pacman can also be used:

$ pacman -S mingw-w64-x86_64-pkg-config # 64-bit
$ pacman -S mingw-w64-i686-pkg-config   # 32-bit

libusb-win32

libftdi

  • Install libftdi. The easiest method is probably to use the libftdi-0.18_mingw32.zip binaries from here.
    • Extract the ZIP file into a temporary directory.
    • Copy dll/libftdi.dll to /usr/local/bin.
    • Copy lib/libftdi.a and lib/libftdi.dll.a to /usr/local/lib.
    • Copy include/ftdi.h to /usr/local/include.

Building flashrom

Checkout the flashrom source code (see the download page for instructions), then:

$ cd flashrom
$ make

Building (cross-compiling) flashrom on Linux for Windows using MinGW.

First you need to install MinGW (on Ubuntu it is enough to install the package mingw32). Of course all the normal build utilities are needed like make etc. (usually contained in a package named build-essential or similar). If you want to use libusb or libftdi you need to get the headers and static library files (*.a). The latter can either be downloaded pre-built or need to be (cross-)compiled. For libusb-win32 this even requires a Windows SDK which makes the whole point of cross-compiling a bit moot. See the respective source packages for documentation on how to cross-compile them.

The headers and libraries should be organized in a Unix-like directory layout, i.e. a (sub) directory named 'lib' containing the static libraries (*.a), 'bin' with non-static libraries (*.dll) if need be, and 'include' with the headers (*.h).

You can then compile flashrom.exe with

$ make CC=i686-w64-mingw32-gcc LIBS_BASE=/path_to_the_base_directory_containing_the_libraries_and_headers/

A relative path (originating in the flashrom directory) is allowed as LIBS_BASE's value. The compiler to be used (given by the CC value) depends on the MinGW edition you are using.