flashrom / flashrom

Send patches to https://review.coreboot.org: https://www.flashrom.org/Development_Guidelines#GitHub
https://review.coreboot.org/admin/repos/flashrom,general
GNU General Public License v2.0
874 stars 443 forks source link

New Windows build instructions? #242

Open obskyr opened 2 years ago

obskyr commented 2 years ago

I recently spent about a full day trying to build Flashrom on Windows! I initially attempted to follow the instructions on the wiki, but they work neither for the latest stable release (1.2) nor the latest commit (ff4c624) – instead yielding errors like Checking for libpci headers... not found. and Checking for libusb-1.0 headers... not found.. The instructions allude to using MSYS2 rather than the ancient version of MinGW recommended, but doesn't specify instructions on how.

Eventually, I managed to build Flashrom 1.2 via MSYS2 by doing the following:

  1. Install MSYS2.
  2. Run the “MSYS2 MinGW x64” shell.
  3. Run pacman -Syu to update packages.
  4. Run pacman -S binutils.
  5. MSYS2 has a Flashrom package now, so run wget https://raw.githubusercontent.com/msys2/MINGW-packages/master/mingw-w64-flashrom/PKGBUILD.
  6. Run makepkg-mingw -sCLf.
  7. Manually copy libusb-1.0.dll, libftdi1.dll, and libwinpthread-1.dll from /mingw64/bin into the build directory pkg/mingw-w64-x86_64-flashrom/mingw64/bin/flashrom.exe and delete libflashrom-1.dll.
  8. The build directory pkg/mingw-w64-x86_64-flashrom/mingw64/bin/ now contains flashrom.exe and everything needed to run it on Windows.

This was a bit of an involved process, and I'm not sure manually copying DLLs is the best way to do things, so I wouldn't be comfortable saying these are the build instructions to recommend, but… either way, I think Flashrom needs new build instructions for Windows!

mightymos commented 2 years ago

I just started with a fresh install of MSYS2. The easiest way seems to be: pacman -S pactoys pacboy -S flashrom

pacboy is just a wrapper that avoids having to specify i686, x86_64, etc. architectures. If you need to see the full package names you can run: pacman -Ss flashrom

flashrom then seemed to run with no problems on my system.

obskyr commented 2 years ago

@mightymos Oh, that's lovely! I suppose it still requires manually copying the DLLs if you intend to use the program outside of MSYS2, though – is that correct?

mightymos commented 2 years ago

@mightymos Oh, that's lovely! I suppose it still requires manually copying the DLLs if you intend to use the program outside of MSYS2, though – is that correct?

I think you'd need: libftdi1.dll libusb-1.0.dll libwinpthread-1.dll

obskyr commented 2 years ago

Yep, alright, so step #⁠7 is still relevant.

GeographicCone commented 1 year ago

For the record, this is one way to build the current snapshot on Windows (using MSys2 MinGW64 shell):

pacman -Syu
pacman -S base-devel binutils git pactoys
pacboy -S cc libusb meson pkg-config
git clone https://github.com/flashrom/flashrom.git
cd flashrom && meson setup \
  --auto-features=enabled --buildtype=plain \
  -Ddefault_programmer_name=ch341a_spi \
  -Dprogrammer=ch341a_spi,dummy -Dtests=disabled \
  --default-library=static --prefer-static \
  --prefix="${MINGW_PREFIX}" --wrap-mode=nodownload \
   build
cd build && meson compile

I'm only using flashrom with the CH341A, hence the settings. Adjust to your needs as you see fit. libwinpthread-1.dll is the only run-time dependency when built this way. Also, cc can probably be replaced with some more specific package.

Droid-MAX commented 1 year ago

try SNANDer?