summaryrefslogtreecommitdiff
path: root/config/module/flashprog
diff options
context:
space:
mode:
Diffstat (limited to 'config/module/flashprog')
-rw-r--r--config/module/flashprog/default/patches/0001-Workaround-for-MX25-chips.patch91
-rw-r--r--config/module/flashprog/default/patches/0002-lbmk-hack-add-config-Makefile-options.patch48
-rw-r--r--config/module/flashprog/default/patches/0003-force-WARNERROR-no.patch113
-rw-r--r--config/module/flashprog/default/target.cfg12
4 files changed, 264 insertions, 0 deletions
diff --git a/config/module/flashprog/default/patches/0001-Workaround-for-MX25-chips.patch b/config/module/flashprog/default/patches/0001-Workaround-for-MX25-chips.patch
new file mode 100644
index 00000000..77c05577
--- /dev/null
+++ b/config/module/flashprog/default/patches/0001-Workaround-for-MX25-chips.patch
@@ -0,0 +1,91 @@
+From f57f12e4aac690ebbfda40d92d1d0c5ff2b74c0a Mon Sep 17 00:00:00 2001
+From: consts <grudnevkv@gmail.com>
+Date: Fri, 2 Mar 2018 07:03:37 +0000
+Subject: [PATCH 1/2] Workaround for MX25 chips
+
+TEST: In-system programming a ThinkPad X200 using a clip and
+pico-serprog works now. It just doesn't without this hack.
+
+Chip: MX25L6405D
+
+Tested-by: Riku Viitanen <riku.viitanen@protonmail.com>
+Change-Id: I43a306b67862b59c1dcd02729e189f3bf73f481b
+---
+ cli_classic.c | 5 +++++
+ include/programmer.h | 1 +
+ spi.c | 11 ++++++++++-
+ 3 files changed, 16 insertions(+), 1 deletion(-)
+
+diff --git a/cli_classic.c b/cli_classic.c
+index a49e0458..0b85a80e 100644
+--- a/cli_classic.c
++++ b/cli_classic.c
+@@ -68,6 +68,7 @@ static void cli_classic_usage(const char *name)
+ " -o | --output <logfile> log output to <logfile>\n"
+ " --flash-contents <ref-file> assume flash contents to be <ref-file>\n"
+ " -L | --list-supported print supported devices\n"
++ " -m | --workaround-mx keep flash busy before sending command\n"
+ #if CONFIG_PRINT_WIKI == 1
+ " -z | --list-supported-wiki print supported devices in wiki syntax\n"
+ #endif
+@@ -231,6 +232,7 @@ int flashprog_classic_main(int argc, char *argv[])
+ {"version", 0, NULL, 'R'},
+ {"output", 1, NULL, 'o'},
+ {"progress", 0, NULL, OPTION_PROGRESS},
++ {"workaround-mx", 0, NULL, 'm'},
+ {NULL, 0, NULL, 0},
+ };
+
+@@ -357,6 +359,9 @@ int flashprog_classic_main(int argc, char *argv[])
+ cli_classic_usage(argv[0]);
+ exit(0);
+ break;
++ case 'm': /* --workaround-mx */
++ workaround_mx = 1;
++ break;
+ case OPTION_PROGRESS:
+ show_progress = true;
+ break;
+diff --git a/include/programmer.h b/include/programmer.h
+index 11d15a84..3b33d5ae 100644
+--- a/include/programmer.h
++++ b/include/programmer.h
+@@ -372,6 +372,7 @@ enum ich_chipset {
+ CHIPSET_LUNAR_LAKE,
+ CHIPSET_ARROW_LAKE,
+ };
++extern int workaround_mx; /* workaround for MX25* chips, makes flash operations more reliable, less failures */
+
+ /* ichspi.c */
+ #if CONFIG_INTERNAL == 1
+diff --git a/spi.c b/spi.c
+index 748ef994..9bbdee9a 100644
+--- a/spi.c
++++ b/spi.c
+@@ -27,13 +27,22 @@
+ #include "spi_command.h"
+ #include "spi.h"
+
++int workaround_mx; /* Make operations with MX25* chips more reliable */
++
+ int spi_send_command(const struct flashctx *flash, unsigned int writecnt,
+ unsigned int readcnt, const unsigned char *writearr,
+ unsigned char *readarr)
+ {
+- if (spi_current_io_mode(flash) != SINGLE_IO_1_1_1)
++ if (spi_current_io_mode(flash) != SINGLE_IO_1_1_1) {
+ return default_spi_send_command(flash, writecnt, readcnt, writearr, readarr);
++ } else if (workaround_mx) {
++ const unsigned char cmd[JEDEC_READ_OUTSIZE] = {JEDEC_READ, 0, 0, 0};
++ unsigned char buf[256];
++ /* keep flash busy for some time, keep CS warm before sending actual command */
++ flash->mst.spi->command(flash, sizeof(cmd), sizeof(buf), cmd, buf);
++ }
+
++ /* actual command */
+ return flash->mst.spi->command(flash, writecnt, readcnt, writearr,
+ readarr);
+ }
+--
+2.47.3
+
diff --git a/config/module/flashprog/default/patches/0002-lbmk-hack-add-config-Makefile-options.patch b/config/module/flashprog/default/patches/0002-lbmk-hack-add-config-Makefile-options.patch
new file mode 100644
index 00000000..15fc0916
--- /dev/null
+++ b/config/module/flashprog/default/patches/0002-lbmk-hack-add-config-Makefile-options.patch
@@ -0,0 +1,48 @@
+From 10b23a84799c7b81a8b0b974529e67cc3f22429d Mon Sep 17 00:00:00 2001
+From: Leah Rowe <leah@libreboot.org>
+Date: Thu, 22 May 2025 11:25:42 +0100
+Subject: [PATCH 2/2] lbmk hack: add config Makefile options
+
+this prevents a build error when running the
+-u, -m, -s, -l and -n options in lbmk without
+argument.
+
+this makes no functional changes to flashprog.
+
+Signed-off-by: Leah Rowe <leah@libreboot.org>
+---
+ Makefile | 18 +++++++++++++++++-
+ 1 file changed, 17 insertions(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index 2d94afea..e514e300 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1116,7 +1116,23 @@ libpayload: clean
+ gitconfig:
+ ./util/getrevision.sh -c 2>/dev/null && ./util/git-hooks/install.sh
+
+-.PHONY: all install clean distclean config branch tag versioninfo _export export tarball libpayload gitconfig
++oldconfig:
++ :
++
++menuconfig:
++ :
++
++savedefconfig:
++ :
++
++olddefconfig:
++ :
++
++nconfig:
++ :
++
++
++.PHONY: all install clean distclean config branch tag versioninfo _export export tarball libpayload gitconfig oldconfig menuconfig savedefconfig olddefconfig nconfig
+
+ # Disable implicit suffixes and built-in rules (for performance and profit)
+ .SUFFIXES:
+--
+2.47.3
+
diff --git a/config/module/flashprog/default/patches/0003-force-WARNERROR-no.patch b/config/module/flashprog/default/patches/0003-force-WARNERROR-no.patch
new file mode 100644
index 00000000..634cc5af
--- /dev/null
+++ b/config/module/flashprog/default/patches/0003-force-WARNERROR-no.patch
@@ -0,0 +1,113 @@
+From 5f79b0def288d97534ebb4b477152d13b00cedb5 Mon Sep 17 00:00:00 2001
+From: Leah Rowe <leah@libreboot.org>
+Date: Mon, 21 Sep 2026 11:59:02 +0100
+Subject: [PATCH 1/1] force WARNERROR=no
+
+the variable itself is kept, in case upstream
+adds anything else that uses it in the future.
+
+Signed-off-by: Leah Rowe <leah@libreboot.org>
+---
+ Makefile | 9 ++-------
+ Makefile.include | 4 ++--
+ README.md | 4 +---
+ meson.build | 2 +-
+ util/ich_descriptors_tool/Makefile | 9 ++-------
+ 5 files changed, 8 insertions(+), 20 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index e514e300..05cee5ff 100644
+--- a/Makefile
++++ b/Makefile
+@@ -57,13 +57,8 @@ override CPPFLAGS := $(CPPFLAGS)
+ override CFLAGS := $(CFLAGS)
+ override LDFLAGS := $(LDFLAGS)
+
+-# If your compiler spits out excessive warnings, run make WARNERROR=no
+-# You shouldn't have to change this flag.
+-WARNERROR ?= yes
+-
+-ifeq ($(WARNERROR), yes)
+-override CFLAGS += -Werror
+-endif
++# lbmk forces removal of werror
++WARNERROR = no
+
+ ifdef LIBS_BASE
+ PKG_CONFIG_LIBDIR ?= $(LIBS_BASE)/lib/pkgconfig
+diff --git a/Makefile.include b/Makefile.include
+index 1bca4f3a..18c1e55b 100644
+--- a/Makefile.include
++++ b/Makefile.include
+@@ -46,11 +46,11 @@ $(strip $(call debug_shell, $(CC) -E $1 | tail -n 1 | tr -d '"'))
+ endef
+
+ define c_compile_test # $1: files to compile, $2: cflags
+-$(call debug_shell, $(CC) -c -Wall -Werror $2 $1 -o /dev/null && echo yes || echo no)
++$(call debug_shell, $(CC) -c -Wall $2 $1 -o /dev/null && echo yes || echo no)
+ endef
+
+ define c_link_test # $1: file to compile and link, $2: cflags, $3: ldflags
+-$(call debug_shell, $(CC) -Wall -Werror $2 $1 $3 -o /dev/null && echo yes || echo no)
++$(call debug_shell, $(CC) -Wall $2 $1 $3 -o /dev/null && echo yes || echo no)
+ endef
+
+ define find_dependency
+diff --git a/README.md b/README.md
+index 2051810c..f6a11a14 100644
+--- a/README.md
++++ b/README.md
+@@ -180,9 +180,7 @@ Processor architecture dependent features:
+
+ Compiler quirks:
+
+-If you are using clang and if you want to enable only one driver, you may hit an
+-overzealous compiler warning from clang. Compile with "make WARNERROR=no" to
+-force it to continue and enjoy.
++Libreboot modifies flashprog to always set WARNERROR=no
+
+ Installation
+ ------------
+diff --git a/meson.build b/meson.build
+index 39ae0c47..dc665c46 100644
+--- a/meson.build
++++ b/meson.build
+@@ -5,7 +5,7 @@ project('flashprogutils', 'c',
+ default_options : [
+ 'warning_level=2',
+ 'c_std=c99',
+- 'werror=true',
++ 'werror=false',
+ 'optimization=s',
+ 'debug=false',
+ ],
+diff --git a/util/ich_descriptors_tool/Makefile b/util/ich_descriptors_tool/Makefile
+index 14e6d2fe..7f6e9479 100644
+--- a/util/ich_descriptors_tool/Makefile
++++ b/util/ich_descriptors_tool/Makefile
+@@ -12,9 +12,8 @@ DEPPATH = .dep
+ OBJATH = .obj
+ SHAREDSRC = ich_descriptors.c
+ SHAREDSRCDIR = ../..
+-# If your compiler spits out excessive warnings, run make WARNERROR=no
+-# You shouldn't have to change this flag.
+-WARNERROR ?= yes
++# libreboot forces WARNERROR=no
++WARNERROR = no
+
+ SRC = $(wildcard *.c)
+
+@@ -45,10 +44,6 @@ EXEC_SUFFIX := .exe
+ FLASHPROG_CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
+ endif
+
+-ifeq ($(WARNERROR), yes)
+-CFLAGS += -Werror
+-endif
+-
+
+ FLASHPROG_CFLAGS += -MMD -MP -MF $(DEPPATH)/$(@F).d
+ # enables functions that populate the descriptor structs from plain binary dumps
+--
+2.47.3
+
diff --git a/config/module/flashprog/default/target.cfg b/config/module/flashprog/default/target.cfg
new file mode 100644
index 00000000..57860839
--- /dev/null
+++ b/config/module/flashprog/default/target.cfg
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+url="https://review.sourcearcade.org/flashprog"
+bkup_url="https://github.com/SourceArcade/flashprog.git"
+
+rev="ffcf92fbfd04a3ac1a5d882bcd5c4b78255af495"
+
+tree="default"
+
+makeargs="WARNERROR=no"
+
+noconfig="y"