Browse Source

flashrom: switch to building with meson

Added patches to fix meson compilation.

Reworked flashrom.mk to work with meson.

Several minor Makefile cleanups.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
lilik-openwrt-22.03
Rosen Penev 4 years ago
parent
commit
81618c5465
No known key found for this signature in database GPG Key ID: 36D31CFA845F0E3B
7 changed files with 134 additions and 109 deletions
  1. +4
    -10
      utils/flashrom/Makefile
  2. +78
    -81
      utils/flashrom/flashrom.mk
  3. +20
    -0
      utils/flashrom/patches/010-bitbang.patch
  4. +10
    -0
      utils/flashrom/patches/020-raw-access.patch
  5. +11
    -0
      utils/flashrom/patches/030-ppc.patch
  6. +11
    -0
      utils/flashrom/patches/040-uclibc.patch
  7. +0
    -18
      utils/flashrom/patches/900-build_internal_programmer_all_archs.patch

+ 4
- 10
utils/flashrom/Makefile View File

@ -9,30 +9,24 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=flashrom
PKG_VERSION:=1.2
PKG_RELEASE:=1
PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-v$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=https://download.flashrom.org/releases
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_DIR=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-v$(PKG_VERSION)
PKG_HASH:=e1f8d95881f5a4365dfe58776ce821dfcee0f138f75d0f44f8a3cd032d9ea42b
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-v$(PKG_VERSION)
PKG_MAINTAINER:=Álvaro Fernández Rojas <noltari@gmail.com>
PKG_LICENSE:=GPL-2.0-or-later
PKG_LICENSE_FILES:=COPYING
PKG_INSTALL:=1
PKG_BUILD_PARALLEL:=1
PKG_BUILD_DEPENDS:=meson/host
include $(INCLUDE_DIR)/package.mk
include ../../devel/meson/meson.mk
include flashrom.mk
TARGET_CFLAGS+= \
-std=gnu89
MAKE_FLAGS+= \
PREFIX="/usr"
define Package/flashrom/default
SECTION:=utils
CATEGORY:=Utilities


+ 78
- 81
utils/flashrom/flashrom.mk View File

@ -3,100 +3,97 @@
define DefaultProgrammer
MAKE_FLAGS += CONFIG_DEFAULT_PROGRAMMER=PROGRAMMER_$(1)
endef
define DefineConfig
ifeq ($(2),yes)
MAKE_FLAGS += NEED_$(1)=$(2)
endif
endef
define DefineProgrammer
# Selecting invalid programmers will fail
# Only disable unwanted programmers and keep the default ones
ifeq ($(2),no)
MAKE_FLAGS += CONFIG_$(1)=$(2)
endif
endef
ifeq ($(BUILD_VARIANT),full)
$(eval $(call DefaultProgrammer,LINUX_SPI))
FLASHROM_BASIC := yes
FLASHROM_FTDI := yes
FLASHROM_PCI := yes
FLASHROM_RAW := yes
FLASHROM_SERIAL := yes
FLASHROM_USB := yes
FLASHROM_BASIC := true
FLASHROM_FTDI := true
FLASHROM_PCI := true
FLASHROM_RAW := $(if $(findstring x86,$(CONFIG_ARCH)),true,false)
FLASHROM_SERIAL := true
FLASHROM_USB := true
endif
ifeq ($(BUILD_VARIANT),pci)
$(eval $(call DefaultProgrammer,INTERNAL))
FLASHROM_BASIC := yes
FLASHROM_FTDI := no
FLASHROM_PCI := yes
FLASHROM_RAW := yes
FLASHROM_SERIAL := no
FLASHROM_USB := no
FLASHROM_BASIC := true
FLASHROM_FTDI := false
FLASHROM_PCI := true
FLASHROM_RAW := $(if $(findstring x86,$(CONFIG_ARCH)),true,false)
FLASHROM_SERIAL := false
FLASHROM_USB := false
endif
ifeq ($(BUILD_VARIANT),spi)
$(eval $(call DefaultProgrammer,LINUX_SPI))
FLASHROM_BASIC := yes
FLASHROM_FTDI := no
FLASHROM_PCI := no
FLASHROM_RAW := no
FLASHROM_SERIAL := no
FLASHROM_USB := no
FLASHROM_BASIC := true
FLASHROM_FTDI := false
FLASHROM_PCI := false
FLASHROM_RAW := false
FLASHROM_SERIAL := false
FLASHROM_USB := false
endif
ifeq ($(BUILD_VARIANT),usb)
$(eval $(call DefaultProgrammer,SERPROG))
FLASHROM_BASIC := yes
FLASHROM_FTDI := yes
FLASHROM_PCI := no
FLASHROM_RAW := no
FLASHROM_SERIAL := yes
FLASHROM_USB := yes
FLASHROM_BASIC := true
FLASHROM_FTDI := true
FLASHROM_PCI := false
FLASHROM_RAW := false
FLASHROM_SERIAL := true
FLASHROM_USB := true
endif
# Misc
$(eval $(call DefineProgrammer,LINUX_SPI,$(FLASHROM_BASIC)))
#$(eval $(call DefineProgrammer,MSTARDDC_SPI,$(FLASHROM_BASIC)))
$(eval $(call DefineProgrammer,DUMMY,$(FLASHROM_BASIC)))
# FTDI
$(eval $(call DefineConfig,LIBFTDI,$(FLASHROM_FTDI)))
$(eval $(call DefineProgrammer,FT2232_SPI,$(FLASHROM_FTDI)))
$(eval $(call DefineProgrammer,USBBLASTER_SPI,$(FLASHROM_FTDI)))
# RAW
$(eval $(call DefineConfig,RAW_ACCESS,$(FLASHROM_RAW)))
$(eval $(call DefineProgrammer,RAYER_SPI,$(FLASHROM_RAW)))
MESON_ARGS += \
-Dconfig_dummy=$(FLASHROM_BASIC) \
-Dconfig_linux_mtd=$(FLASHROM_BASIC) \
-Dconfig_linux_spi=$(FLASHROM_BASIC) \
-Dconfig_mstarddc_spi=$(FLASHROM_BASIC) \
\
-Dconfig_ft2232_spi=$(FLASHROM_FTDI) \
-Dconfig_usbblaster_spi=$(FLASHROM_FTDI) \
\
-Dpciutils=$(FLASHROM_PCI) \
-Dconfig_atavia=$(FLASHROM_PCI) \
-Dconfig_drkaiser=$(FLASHROM_PCI) \
-Dconfig_gfxnvidia=$(FLASHROM_PCI) \
-Dconfig_internal=$(FLASHROM_PCI) \
-Dconfig_it8212=$(FLASHROM_PCI) \
-Dconfig_nicintel=$(FLASHROM_PCI) \
-Dconfig_nicintel_spi=$(FLASHROM_PCI) \
-Dconfig_nicintel_eeprom=$(FLASHROM_PCI) \
-Dconfig_ogp_spi=$(FLASHROM_PCI) \
-Dconfig_satasii=$(FLASHROM_PCI) \
\
-Dconfig_bitbang_spi=$(FLASHROM_RAW) \
-Dconfig_rayer_spi=$(FLASHROM_RAW) \
\
-Dconfig_buspirate_spi=$(FLASHROM_SERIAL) \
-Dconfig_pony_spi=$(FLASHROM_SERIAL) \
-Dconfig_serprog=$(FLASHROM_SERIAL) \
\
-Dusb=$(FLASHROM_USB) \
-Dconfig_ch341a_spi=$(FLASHROM_USB) \
-Dconfig_dediprog=$(FLASHROM_USB) \
-Dconfig_developerbox_spi=$(FLASHROM_USB) \
-Dconfig_digilent_spi=$(FLASHROM_USB) \
-Dconfig_pickit2_spi=$(FLASHROM_USB) \
-Dconfig_stlinkv3_spi=$(FLASHROM_USB)
# PCI
$(eval $(call DefineConfig,LIBPCI,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,INTERNAL,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,NIC3COM,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,GFXNVIDIA,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,SATASII,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,ATAHPT,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,ATAPROMISE,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,ATAVIA,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,IT8212,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,DRKAISER,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,NICREALTEK,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,NICNATSEMI,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,NICINTEL,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,NICINTEL_SPI,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,NICINTEL_EEPROM,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,OGP_SPI,$(FLASHROM_PCI)))
$(eval $(call DefineProgrammer,SATAMV,$(FLASHROM_PCI)))
# Serial
$(eval $(call DefineConfig,SERIAL,$(FLASHROM_SERIAL)))
$(eval $(call DefineProgrammer,SERPROG,$(FLASHROM_SERIAL)))
$(eval $(call DefineProgrammer,PONY_SPI,$(FLASHROM_SERIAL)))
$(eval $(call DefineProgrammer,BUSPIRATE_SPI,$(FLASHROM_SERIAL)))
# USB1
$(eval $(call DefineConfig,LIBUSB1,$(FLASHROM_USB)))
$(eval $(call DefineProgrammer,CH341A_SPI,$(FLASHROM_USB)))
$(eval $(call DefineProgrammer,DEDIPROG,$(FLASHROM_USB)))
$(eval $(call DefineProgrammer,DEVELOPERBOX_SPI,$(FLASHROM_USB)))
$(eval $(call DefineProgrammer,DIGILENT_SPI,$(FLASHROM_USB)))
$(eval $(call DefineProgrammer,PICKIT2_SPI,$(FLASHROM_USB)))
$(eval $(call DefineProgrammer,STLINKV3_SPI,$(FLASHROM_USB)))
ifeq ($(findstring i386,$(CONFIG_ARCH))$(findstring x86,$(CONFIG_ARCH)),)
MESON_ARGS += \
-Dconfig_atahpt=false \
-Dconfig_atapromise=false \
-Dconfig_internal_dmi=true \
-Dconfig_nic3com=false \
-Dconfig_nicnatsemi=false \
-Dconfig_nicrealtek=false \
-Dconfig_satamv=false
else
MESON_ARGS += \
-Dconfig_atahpt=$(FLASHROM_PCI) \
-Dconfig_atapromise=$(FLASHROM_PCI) \
-Dconfig_internal_dmi=$(if $(FLASHROM_PCI),false,true)
-Dconfig_nic3com=$(FLASHROM_PCI) \
-Dconfig_nicnatsemi=$(FLASHROM_PCI) \
-Dconfig_nicrealtek=$(FLASHROM_PCI) \
-Dconfig_satamv=$(FLASHROM_PCI)
endif

+ 20
- 0
utils/flashrom/patches/010-bitbang.patch View File

@ -0,0 +1,20 @@
--- a/meson.build
+++ b/meson.build
@@ -33,6 +33,7 @@ add_project_arguments('-DFLASHROM_VERSION="' + meson.project_version() + '"', la
config_atahpt = get_option('config_atahpt')
config_atapromise = get_option('config_atapromise')
config_atavia = get_option('config_atavia')
+config_bitbang_spi = get_option('config_bitbang_spi')
config_buspirate_spi = get_option('config_buspirate_spi')
config_ch341a_spi = get_option('config_ch341a_spi')
config_dediprog = get_option('config_dediprog')
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -4,6 +4,7 @@ option('usb', type : 'boolean', value : true, description : 'use libusb1')
option('config_atahpt', type : 'boolean', value : false, description : 'Highpoint (HPT) ATA/RAID controllers')
option('config_atapromise', type : 'boolean', value : false, description : 'Promise ATA controller')
option('config_atavia', type : 'boolean', value : true, description : 'VIA VT6421A LPC memory')
+option('config_bitbang_spi', type : 'boolean', value : true, description : 'Bitbang')
option('config_buspirate_spi', type : 'boolean', value : true, description : 'Bus Pirate SPI')
option('config_ch341a_spi', type : 'boolean', value : true, description : 'Winchiphead CH341A')
option('config_dediprog', type : 'boolean', value : true, description : 'Dediprog SF100')

+ 10
- 0
utils/flashrom/patches/020-raw-access.patch View File

@ -0,0 +1,10 @@
--- a/meson.build
+++ b/meson.build
@@ -263,6 +263,7 @@ endif
if config_satasii
srcs += 'satasii.c'
cargs += '-DCONFIG_SATASII=1'
+ need_raw_access = true
endif
if config_serprog
srcs += 'serprog.c'

+ 11
- 0
utils/flashrom/patches/030-ppc.patch View File

@ -0,0 +1,11 @@
--- a/hwaccess.c
+++ b/hwaccess.c
@@ -71,7 +71,7 @@ static inline void sync_primitive(void)
* See also https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/memory-barriers.txt
*/
#if IS_PPC // cf. http://lxr.free-electrons.com/source/arch/powerpc/include/asm/barrier.h
- asm("eieio" : : : "memory");
+ __asm__ ("eieio" : : : "memory");
#elif IS_SPARC
#if defined(__sparc_v9__) || defined(__sparcv9)
/* Sparc V9 CPUs support three different memory orderings that range from x86-like TSO to PowerPC-like

+ 11
- 0
utils/flashrom/patches/040-uclibc.patch View File

@ -0,0 +1,11 @@
--- a/meson.build
+++ b/meson.build
@@ -25,7 +25,7 @@ conf = configuration_data()
cc = meson.get_compiler('c')
add_project_arguments(cc.get_supported_arguments(warning_flags), language : 'c')
add_project_arguments('-D_DEFAULT_SOURCE', language : 'c')
-add_project_arguments('-D_POSIX_C_SOURCE', language : 'c') # required for fileno
+add_project_arguments('-D_POSIX_C_SOURCE=200809L', language : 'c') # required for fileno, nanosleep, and strndup
add_project_arguments('-D_BSD_SOURCE', language : 'c') # required for glibc < v2.19
add_project_arguments('-DFLASHROM_VERSION="' + meson.project_version() + '"', language : 'c')

+ 0
- 18
utils/flashrom/patches/900-build_internal_programmer_all_archs.patch View File

@ -1,18 +0,0 @@
--- a/Makefile
+++ b/Makefile
@@ -424,15 +424,6 @@ endif
override ARCH := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E archtest.c 2>/dev/null | grep -v '^\#' | grep '"' | cut -f 2 -d'"'))
override ENDIAN := $(strip $(call debug_shell,$(CC) $(CPPFLAGS) -E endiantest.c 2>/dev/null | grep -v '^\#'))
-# Disable the internal programmer on unsupported architectures (everything but x86 and mipsel)
-ifneq ($(ARCH)-little, $(filter $(ARCH),x86 mips)-$(ENDIAN))
-ifeq ($(CONFIG_INTERNAL), yes)
-UNSUPPORTED_FEATURES += CONFIG_INTERNAL=yes
-else
-override CONFIG_INTERNAL = no
-endif
-endif
-
# PCI port I/O support is unimplemented on PPC/MIPS/SPARC and unavailable on ARM.
# Right now this means the drivers below only work on x86.
ifneq ($(ARCH), x86)

Loading…
Cancel
Save