Author: stefanct Date: Mon Jun 2 02:12:23 2014 New Revision: 1814 URL: http://flashrom.org/trac/flashrom/changeset/1814
Log: Add default arguments for the default programmer (only).
This code exists thanks to food for thought from Urja Rannikko.
Signed-off-by: Stefan Tauner stefan.tauner@alumni.tuwien.ac.at Acked-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Modified: trunk/Makefile trunk/cli_classic.c
Modified: trunk/Makefile ============================================================================== --- trunk/Makefile Mon Jun 2 01:49:03 2014 (r1813) +++ trunk/Makefile Mon Jun 2 02:12:23 2014 (r1814) @@ -52,6 +52,11 @@ # evaluated below, namely those that enable/disable the various programmers). # Compilation will fail for unspecified values. CONFIG_DEFAULT_PROGRAMMER ?= PROGRAMMER_INVALID +# The following adds a default parameter for the default programmer set above (only). +CONFIG_DEFAULT_PROGRAMMER_ARGS ?= '' +# Example: compiling with +# make CONFIG_DEFAULT_PROGRAMMER=PROGRAMMER_SERPROG CONFIG_DEFAULT_PROGRAMMER_ARGS="dev=/dev/ttyUSB0:1500000" +# would make executing './flashrom' (almost) equivialent to './flashrom -p serprog:dev=/dev/ttyUSB0:1500000'.
# If your compiler spits out excessive warnings, run make WARNERROR=no # You shouldn't have to change this flag. @@ -487,6 +492,7 @@ # Depending on the CONFIG_* variables set and verified above we set compiler flags and parameters below.
FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)' +FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER_ARGS="$(CONFIG_DEFAULT_PROGRAMMER_ARGS)"'
ifeq ($(CONFIG_INTERNAL), yes) FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
Modified: trunk/cli_classic.c ============================================================================== --- trunk/cli_classic.c Mon Jun 2 01:49:03 2014 (r1813) +++ trunk/cli_classic.c Mon Jun 2 02:12:23 2014 (r1814) @@ -396,8 +396,10 @@ if (prog == PROGRAMMER_INVALID) { if (CONFIG_DEFAULT_PROGRAMMER != PROGRAMMER_INVALID) { prog = CONFIG_DEFAULT_PROGRAMMER; - msg_pinfo("Using default programmer "%s".\n", - programmer_table[CONFIG_DEFAULT_PROGRAMMER].name); + /* We need to strdup here because we free(pparam) unconditionally later. */ + pparam = strdup(CONFIG_DEFAULT_PROGRAMMER_ARGS); + msg_pinfo("Using default programmer "%s" with arguments "%s".\n", + programmer_table[CONFIG_DEFAULT_PROGRAMMER].name, pparam); } else { msg_perr("Please select a programmer with the --programmer parameter.\n" "Previously this was not necessary because there was a default set.\n"