blob: d78c5755c1ccd4163ce3bb5e1b3ad7912579072e [file] [log] [blame]
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +00001/*
2 * This file is part of the flashrom project.
3 *
4 * Copyright (C) 2000 Silicon Integrated System Corporation
5 * Copyright (C) 2004 Tyan Corp <yhlu@tyan.com>
6 * Copyright (C) 2005-2008 coresystems GmbH
7 * Copyright (C) 2008,2009,2010 Carl-Daniel Hailfinger
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
Carl-Daniel Hailfinger831e8f42010-05-30 22:24:40 +000024#include <stdio.h>
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +000025#include <fcntl.h>
26#include <sys/types.h>
27#include <sys/stat.h>
28#include <string.h>
29#include <stdlib.h>
30#include <getopt.h>
31#include "flash.h"
32#include "flashchips.h"
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +000033#include "programmer.h"
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +000034
Carl-Daniel Hailfingerad3cc552010-07-03 11:02:10 +000035static void cli_classic_usage(const char *name)
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +000036{
37 const char *pname;
38 int pnamelen;
39 int remaining = 0;
40 enum programmer p;
41
Uwe Hermann2db77a02010-06-04 17:07:39 +000042 printf("Usage: flashrom [-n] [-V] [-f] [-h|-R|-L|"
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +000043#if CONFIG_PRINT_WIKI == 1
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +000044 "-z|"
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +000045#endif
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +000046 "-E|-r <file>|-w <file>|-v <file>]\n"
47 " [-c <chipname>] [-m [<vendor>:]<part>] [-l <file>]\n"
Uwe Hermann2db77a02010-06-04 17:07:39 +000048 " [-i <image>] [-p <programmername>[:<parameters>]]\n\n");
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +000049
50 printf("Please note that the command line interface for flashrom has "
51 "changed between\n"
52 "0.9.1 and 0.9.2 and will change again before flashrom 1.0.\n"
53 "Do not use flashrom in scripts or other automated tools "
54 "without checking\n"
55 "that your flashrom version won't interpret options in a "
56 "different way.\n\n");
57
58 printf(" -h | --help print this help text\n"
59 " -R | --version print version (release)\n"
60 " -r | --read <file> read flash and save to "
61 "<file>\n"
62 " -w | --write <file> write <file> to flash\n"
63 " -v | --verify <file> verify flash against "
64 "<file>\n"
65 " -E | --erase erase flash device\n"
66 " -V | --verbose more verbose output\n"
67 " -c | --chip <chipname> probe only for specified "
68 "flash chip\n"
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +000069#if CONFIG_INTERNAL == 1
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +000070 /* FIXME: --mainboard should be a programmer parameter */
71 " -m | --mainboard <[vendor:]part> override mainboard "
72 "detection\n"
73#endif
74 " -f | --force force specific operations "
75 "(see man page)\n"
76 " -n | --noverify don't auto-verify\n"
77 " -l | --layout <file> read ROM layout from "
78 "<file>\n"
79 " -i | --image <name> only flash image <name> "
80 "from flash layout\n"
81 " -L | --list-supported print supported devices\n"
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +000082#if CONFIG_PRINT_WIKI == 1
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +000083 " -z | --list-supported-wiki print supported devices "
84 "in wiki syntax\n"
85#endif
86 " -p | --programmer <name>[:<param>] specify the programmer "
87 "device");
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +000088
89 for (p = 0; p < PROGRAMMER_INVALID; p++) {
90 pname = programmer_table[p].name;
91 pnamelen = strlen(pname);
92 if (remaining - pnamelen - 2 < 0) {
93 printf("\n ");
94 remaining = 43;
95 } else {
96 printf(" ");
97 remaining--;
98 }
99 if (p == 0) {
100 printf("(");
101 remaining--;
102 }
103 printf("%s", pname);
104 remaining -= pnamelen;
105 if (p < PROGRAMMER_INVALID - 1) {
106 printf(",");
107 remaining--;
108 } else {
109 printf(")\n");
110 }
111 }
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000112
113 printf("\nYou can specify one of -h, -R, -L, "
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000114#if CONFIG_PRINT_WIKI == 1
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000115 "-z, "
116#endif
117 "-E, -r, -w, -v or no operation.\n"
118 "If no operation is specified, flashrom will only probe for "
119 "flash chips.\n\n");
120}
121
Carl-Daniel Hailfingerad3cc552010-07-03 11:02:10 +0000122static void cli_classic_abort_usage(void)
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000123{
Uwe Hermann2db77a02010-06-04 17:07:39 +0000124 printf("Please run \"flashrom --help\" for usage info.\n");
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000125 exit(1);
126}
127
128int cli_classic(int argc, char *argv[])
129{
130 unsigned long size;
131 /* Probe for up to three flash chips. */
132 struct flashchip *flash, *flashes[3];
133 const char *name;
134 int namelen;
135 int opt;
136 int option_index = 0;
137 int force = 0;
138 int read_it = 0, write_it = 0, erase_it = 0, verify_it = 0;
139 int dont_verify_it = 0, list_supported = 0;
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000140#if CONFIG_PRINT_WIKI == 1
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000141 int list_supported_wiki = 0;
142#endif
143 int operation_specified = 0;
144 int i;
145
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000146 const char *optstring = "r:Rw:v:nVEfc:m:l:i:p:Lzh";
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000147 static struct option long_options[] = {
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000148 {"read", 1, 0, 'r'},
149 {"write", 1, 0, 'w'},
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000150 {"erase", 0, 0, 'E'},
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000151 {"verify", 1, 0, 'v'},
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000152 {"noverify", 0, 0, 'n'},
153 {"chip", 1, 0, 'c'},
154 {"mainboard", 1, 0, 'm'},
155 {"verbose", 0, 0, 'V'},
156 {"force", 0, 0, 'f'},
157 {"layout", 1, 0, 'l'},
158 {"image", 1, 0, 'i'},
159 {"list-supported", 0, 0, 'L'},
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000160 {"list-supported-wiki", 0, 0, 'z'},
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000161 {"programmer", 1, 0, 'p'},
162 {"help", 0, 0, 'h'},
163 {"version", 0, 0, 'R'},
164 {0, 0, 0, 0}
165 };
166
167 char *filename = NULL;
168
169 char *tempstr = NULL;
Carl-Daniel Hailfingerad3cc552010-07-03 11:02:10 +0000170 char *pparam = NULL;
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000171
172 print_version();
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000173 print_banner();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000174
175 if (selfcheck())
176 exit(1);
177
178 setbuf(stdout, NULL);
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000179 /* FIXME: Delay all operation_specified checks until after command
180 * line parsing to allow --help overriding everything else.
181 */
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000182 while ((opt = getopt_long(argc, argv, optstring,
183 long_options, &option_index)) != EOF) {
184 switch (opt) {
185 case 'r':
186 if (++operation_specified > 1) {
187 fprintf(stderr, "More than one operation "
188 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000189 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000190 }
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000191 filename = strdup(optarg);
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000192 read_it = 1;
193 break;
194 case 'w':
195 if (++operation_specified > 1) {
196 fprintf(stderr, "More than one operation "
197 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000198 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000199 }
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000200 filename = strdup(optarg);
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000201 write_it = 1;
202 break;
203 case 'v':
204 //FIXME: gracefully handle superfluous -v
205 if (++operation_specified > 1) {
206 fprintf(stderr, "More than one operation "
207 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000208 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000209 }
210 if (dont_verify_it) {
211 fprintf(stderr, "--verify and --noverify are"
212 "mutually exclusive. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000213 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000214 }
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000215 filename = strdup(optarg);
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000216 verify_it = 1;
217 break;
218 case 'n':
219 if (verify_it) {
220 fprintf(stderr, "--verify and --noverify are"
221 "mutually exclusive. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000222 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000223 }
224 dont_verify_it = 1;
225 break;
226 case 'c':
227 chip_to_probe = strdup(optarg);
228 break;
229 case 'V':
Sean Nelson51e97d72010-01-07 20:09:33 +0000230 verbose++;
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000231 break;
232 case 'E':
233 if (++operation_specified > 1) {
234 fprintf(stderr, "More than one operation "
235 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000236 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000237 }
238 erase_it = 1;
239 break;
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000240 case 'm':
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000241#if CONFIG_INTERNAL == 1
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000242 tempstr = strdup(optarg);
243 lb_vendor_dev_from_string(tempstr);
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000244#else
245 fprintf(stderr, "Error: Internal programmer support "
246 "was not compiled in and --mainboard only\n"
247 "applies to the internal programmer. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000248 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000249#endif
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000250 break;
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000251 case 'f':
252 force = 1;
253 break;
254 case 'l':
255 tempstr = strdup(optarg);
256 if (read_romlayout(tempstr))
Uwe Hermann2db77a02010-06-04 17:07:39 +0000257 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000258 break;
259 case 'i':
260 tempstr = strdup(optarg);
261 find_romentry(tempstr);
262 break;
263 case 'L':
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000264 if (++operation_specified > 1) {
265 fprintf(stderr, "More than one operation "
266 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000267 cli_classic_abort_usage();
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000268 }
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000269 list_supported = 1;
270 break;
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000271 case 'z':
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000272#if CONFIG_PRINT_WIKI == 1
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000273 if (++operation_specified > 1) {
274 fprintf(stderr, "More than one operation "
275 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000276 cli_classic_abort_usage();
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000277 }
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000278 list_supported_wiki = 1;
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000279#else
280 fprintf(stderr, "Error: Wiki output was not compiled "
281 "in. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000282 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000283#endif
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000284 break;
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000285 case 'p':
286 for (programmer = 0; programmer < PROGRAMMER_INVALID; programmer++) {
287 name = programmer_table[programmer].name;
288 namelen = strlen(name);
289 if (strncmp(optarg, name, namelen) == 0) {
290 switch (optarg[namelen]) {
291 case ':':
Carl-Daniel Hailfingerad3cc552010-07-03 11:02:10 +0000292 pparam = strdup(optarg + namelen + 1);
293 if (!strlen(pparam)) {
294 free(pparam);
295 pparam = NULL;
Carl-Daniel Hailfinger27023762010-04-28 15:22:14 +0000296 }
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000297 break;
298 case '\0':
299 break;
300 default:
301 /* The continue refers to the
302 * for loop. It is here to be
303 * able to differentiate between
304 * foo and foobar.
305 */
306 continue;
307 }
308 break;
309 }
310 }
311 if (programmer == PROGRAMMER_INVALID) {
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000312 fprintf(stderr, "Error: Unknown programmer "
313 "%s.\n", optarg);
Uwe Hermann2db77a02010-06-04 17:07:39 +0000314 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000315 }
316 break;
317 case 'R':
318 /* print_version() is always called during startup. */
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000319 if (++operation_specified > 1) {
320 fprintf(stderr, "More than one operation "
321 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000322 cli_classic_abort_usage();
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000323 }
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000324 exit(0);
325 break;
326 case 'h':
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000327 if (++operation_specified > 1) {
328 fprintf(stderr, "More than one operation "
329 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000330 cli_classic_abort_usage();
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000331 }
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000332 cli_classic_usage(argv[0]);
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000333 exit(0);
334 break;
335 default:
Uwe Hermann2db77a02010-06-04 17:07:39 +0000336 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000337 break;
338 }
339 }
340
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000341 /* FIXME: Print the actions flashrom will take. */
342
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000343 if (list_supported) {
344 print_supported();
345 exit(0);
346 }
347
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000348#if CONFIG_PRINT_WIKI == 1
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000349 if (list_supported_wiki) {
350 print_supported_wiki();
351 exit(0);
352 }
353#endif
354
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000355 if (optind < argc) {
356 fprintf(stderr, "Error: Extra parameter found.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000357 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000358 }
359
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000360#if CONFIG_INTERNAL == 1
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000361 if ((programmer != PROGRAMMER_INTERNAL) && (lb_part || lb_vendor)) {
362 fprintf(stderr, "Error: --mainboard requires the internal "
363 "programmer. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000364 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000365 }
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000366#endif
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000367
Carl-Daniel Hailfinger27023762010-04-28 15:22:14 +0000368 if (chip_to_probe) {
369 for (flash = flashchips; flash && flash->name; flash++)
370 if (!strcmp(flash->name, chip_to_probe))
371 break;
372 if (!flash || !flash->name) {
373 fprintf(stderr, "Error: Unknown chip '%s' specified.\n",
374 chip_to_probe);
375 printf("Run flashrom -L to view the hardware supported "
376 "in this flashrom version.\n");
377 exit(1);
378 }
379 /* Clean up after the check. */
380 flash = NULL;
381 }
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000382
Carl-Daniel Hailfinger49884202010-05-22 07:10:46 +0000383 /* FIXME: Delay calibration should happen in programmer code. */
384 myusec_calibrate_delay();
385
Carl-Daniel Hailfingerad3cc552010-07-03 11:02:10 +0000386 if (programmer_init(pparam)) {
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000387 fprintf(stderr, "Error: Programmer initialization failed.\n");
388 exit(1);
389 }
390
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000391 /* FIXME: Delay calibration should happen in programmer code. */
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000392 for (i = 0; i < ARRAY_SIZE(flashes); i++) {
393 flashes[i] =
394 probe_flash(i ? flashes[i - 1] + 1 : flashchips, 0);
395 if (!flashes[i])
396 for (i++; i < ARRAY_SIZE(flashes); i++)
397 flashes[i] = NULL;
398 }
399
400 if (flashes[1]) {
401 printf("Multiple flash chips were detected:");
402 for (i = 0; i < ARRAY_SIZE(flashes) && flashes[i]; i++)
403 printf(" %s", flashes[i]->name);
404 printf("\nPlease specify which chip to use with the -c <chipname> option.\n");
405 programmer_shutdown();
406 exit(1);
407 } else if (!flashes[0]) {
408 printf("No EEPROM/flash device found.\n");
409 if (!force || !chip_to_probe) {
Carl-Daniel Hailfinger27023762010-04-28 15:22:14 +0000410 printf("Note: flashrom can never write if the flash chip isn't found automatically.\n");
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000411 }
412 if (force && read_it && chip_to_probe) {
Carl-Daniel Hailfinger27023762010-04-28 15:22:14 +0000413 printf("Force read (-f -r -c) requested, pretending the chip is there:\n");
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000414 flashes[0] = probe_flash(flashchips, 1);
415 if (!flashes[0]) {
Carl-Daniel Hailfinger27023762010-04-28 15:22:14 +0000416 printf("Probing for flash chip '%s' failed.\n", chip_to_probe);
417 programmer_shutdown();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000418 exit(1);
419 }
420 printf("Please note that forced reads most likely contain garbage.\n");
Carl-Daniel Hailfinger1748c572010-07-13 23:56:13 +0000421 return read_flash_to_file(flashes[0], filename);
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000422 }
423 // FIXME: flash writes stay enabled!
424 programmer_shutdown();
425 exit(1);
426 }
427
428 flash = flashes[0];
429
430 check_chip_supported(flash);
431
432 size = flash->total_size * 1024;
433 if (check_max_decode((buses_supported & flash->bustype), size) &&
434 (!force)) {
435 fprintf(stderr, "Chip is too big for this programmer "
436 "(-V gives details). Use --force to override.\n");
437 programmer_shutdown();
438 return 1;
439 }
440
441 if (!(read_it | write_it | verify_it | erase_it)) {
442 printf("No operations were specified.\n");
443 // FIXME: flash writes stay enabled!
444 programmer_shutdown();
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000445 exit(0);
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000446 }
447
448 if (!filename && !erase_it) {
449 printf("Error: No filename specified.\n");
450 // FIXME: flash writes stay enabled!
451 programmer_shutdown();
452 exit(1);
453 }
454
455 /* Always verify write operations unless -n is used. */
456 if (write_it && !dont_verify_it)
457 verify_it = 1;
458
459 return doit(flash, force, filename, read_it, write_it, erase_it, verify_it);
460}