diff options
author | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2012-09-25 21:24:55 +0000 |
---|---|---|
committer | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2012-09-25 21:24:55 +0000 |
commit | fd0d41353777804d890caf150c749da928da4d79 (patch) | |
tree | 9278307eb81e760066cbe758f227edffa5a790b6 | |
parent | 98feaa5c2cd4f6b217ac0dbf57d1b5254bbdcd81 (diff) | |
download | flashrom-fd0d41353777804d890caf150c749da928da4d79.tar.gz flashrom-fd0d41353777804d890caf150c749da928da4d79.tar.bz2 flashrom-fd0d41353777804d890caf150c749da928da4d79.zip |
Introduce a compile time option to select a default programmer
Heavily influenced by a discussion with (and based on code from) Peter Stuge.
Please read the comment in the Makefile before using this option.
Corresponding to flashrom svn r1607.
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Peter Stuge <peter@stuge.se>
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | cli_classic.c | 16 |
2 files changed, 25 insertions, 5 deletions
@@ -39,6 +39,18 @@ CFLAGS ?= -Os -Wall -Wshadow EXPORTDIR ?= . AR ?= ar RANLIB ?= ranlib +# The following parameter changes the default programmer that will be used if there is no -p/--programmer +# argument given when running flashrom. The predefined setting does not enable any default so that every +# user has to declare the programmer he wants to use on every run. The rationale for this to be not set +# (to e.g. the internal programmer) is that forgetting to specify this when working with another programmer +# easily puts the system attached to the default programmer at risk (e.g. you want to flash coreboot to another +# system attached to an external programmer while the default programmer is set to the internal programmer, and +# you forget to use the -p parameter. This would (try to) overwrite the existing firmware of the computer +# running flashrom). Please do not enable this without thinking about the possible consequences. Possible +# values are those specified in enum programmer in programmer.h (which depend on other CONFIG_* options +# evaluated below, namely those that enable/disable the various programmers). +# Compilation will fail for unspecified values. +CONFIG_DEFAULT_PROGRAMMER ?= PROGRAMMER_INVALID # If your compiler spits out excessive warnings, run make WARNERROR=no # You shouldn't have to change this flag. @@ -399,6 +411,8 @@ endif ############################################################################### # Programmer drivers and programmer support infrastructure. +FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)' + ifeq ($(CONFIG_INTERNAL), yes) FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1' PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o dmi.o internal.o diff --git a/cli_classic.c b/cli_classic.c index 58696adf9..4ae375cfa 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -402,11 +402,17 @@ int main(int argc, char *argv[]) } if (prog == PROGRAMMER_INVALID) { - msg_perr("Please select a programmer with the --programmer parameter.\n" - "Valid choices are:\n"); - list_programmers_linebreak(0, 80, 0); - ret = 1; - goto out; + if (CONFIG_DEFAULT_PROGRAMMER != PROGRAMMER_INVALID) { + prog = CONFIG_DEFAULT_PROGRAMMER; + msg_pinfo("Using default programmer \"%s\".\n", + programmer_table[CONFIG_DEFAULT_PROGRAMMER].name); + } else { + msg_perr("Please select a programmer with the --programmer parameter.\n" + "Valid choices are:\n"); + list_programmers_linebreak(0, 80, 0); + ret = 1; + goto out; + } } /* FIXME: Delay calibration should happen in programmer code. */ |