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
888 stars 450 forks source link

Simplify disabling incompatible programmers on Windows #245

Open obskyr opened 2 years ago

obskyr commented 2 years ago

Background

As it stands, there are four categories of programmer that are unsupported by Flashrom on Windows. They are:

Perhaps some of these should be supported in the future! However, at the moment, they're incompatible with Windows.

The problem

In the latest stable version of Flashrom, v1.2, it sufficed to specify -Dpciutils=false, -Dconfig_linux_mtd=false, and -Dconfig_linux_spi=false. Disabling pciutils automatically disabled PCI programmers. However, when building the latest commit (b9e8b89), it requires you to manually disable each programmer – otherwise it'll error out, either saying “one or more enabled programmer requires PCI access”, or producing a mysterious compiler or linker error. Thus, the command currently required to build at all on Windows is the unwieldy:

meson \
    -Dpciutils=false \
    -Dconfig_atahpt=false \
    -Dconfig_atapromise=false \
    -Dconfig_atavia=false \
    -Dconfig_drkaiser=false \
    -Dconfig_gfxnvidia=false \
    -Dconfig_internal=false \
    -Dconfig_it8212=false \
    -Dconfig_linux_mtd=false \
    -Dconfig_linux_spi=false \
    -Dconfig_lspcon_i2c_spi=false \
    -Dconfig_mediatek_i2c_spi=false \
    -Dconfig_nic3com=false \
    -Dconfig_nicintel=false \
    -Dconfig_nicintel_eeprom=false \
    -Dconfig_nicintel_spi=false \
    -Dconfig_nicnatsemi=false \
    -Dconfig_nicrealtek=false \
    -Dconfig_ogp_spi=false \
    -Dconfig_rayer_spi=false \
    -Dconfig_realtek_mst_i2c_spi=false \
    -Dconfig_satamv=false \
    -Dconfig_satasii=false \
    --prefix="${MINGW_PREFIX}" \
    --wrap-mode=nodownload \
    --auto-features=enabled \
    --buildtype=plain \
    build

meson compile

I personally wrestled with this for days before I managed to find a combination of options that worked (creating #243 and #244, now closed, in the process). It's clear that it's not the most user-friendly build flow!

The fix

I suggest doing one of the following:

Which would you rather be implemented?

Build instructions

To build on Windows to test this, go through the following steps:

  1. Install MSYS2 on Windows.
  2. Open the “MSYS2 MinGW x64” shell.
  3. Run pacman -S git base-devel pactoys.
  4. Run pacboy -S meson cc pkg-config libftdi libusb.
  5. Clone the repo and cd into it: git clone https://github.com/flashrom/flashrom.git && cd flashrom.
  6. Run the following command to attempt to build:

    meson \
       -Dpciutils=false \
       -Dconfig_atahpt=false \
       -Dconfig_atapromise=false \
       -Dconfig_atavia=false \
       -Dconfig_drkaiser=false \
       -Dconfig_gfxnvidia=false \
       -Dconfig_internal=false \
       -Dconfig_it8212=false \
       -Dconfig_linux_mtd=false \
       -Dconfig_linux_spi=false \
       -Dconfig_lspcon_i2c_spi=false \
       -Dconfig_mediatek_i2c_spi=false \
       -Dconfig_nic3com=false \
       -Dconfig_nicintel=false \
       -Dconfig_nicintel_eeprom=false \
       -Dconfig_nicintel_spi=false \
       -Dconfig_nicnatsemi=false \
       -Dconfig_nicrealtek=false \
       -Dconfig_ogp_spi=false \
       -Dconfig_rayer_spi=false \
       -Dconfig_realtek_mst_i2c_spi=false \
       -Dconfig_satamv=false \
       -Dconfig_satasii=false \
       --prefix="${MINGW_PREFIX}" \
       --wrap-mode=nodownload \
       --auto-features=enabled \
       --buildtype=plain \
       ./build
    
    cd build && meson compile
obskyr commented 2 years ago

The presupposition that all these categories of programmer are unsupported on Windows is based on an understanding cobbled together from (potentially outdated) documentation and code-skimming, so if someone could confirm or deny that I've got the correct list, that would be nice as well!