blob: 9b9b45164b95c2959a54ba6a92d45073d8931f69 [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>
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +000026#include <sys/stat.h>
27#include <string.h>
28#include <stdlib.h>
29#include <getopt.h>
30#include "flash.h"
31#include "flashchips.h"
Carl-Daniel Hailfinger5b997c32010-07-27 22:41:39 +000032#include "programmer.h"
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +000033
Carl-Daniel Hailfingerad3cc552010-07-03 11:02:10 +000034static void cli_classic_usage(const char *name)
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +000035{
Uwe Hermann2db77a02010-06-04 17:07:39 +000036 printf("Usage: flashrom [-n] [-V] [-f] [-h|-R|-L|"
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +000037#if CONFIG_PRINT_WIKI == 1
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +000038 "-z|"
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +000039#endif
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +000040 "-E|-r <file>|-w <file>|-v <file>]\n"
41 " [-c <chipname>] [-m [<vendor>:]<part>] [-l <file>]\n"
Uwe Hermann2db77a02010-06-04 17:07:39 +000042 " [-i <image>] [-p <programmername>[:<parameters>]]\n\n");
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +000043
44 printf("Please note that the command line interface for flashrom has "
45 "changed between\n"
46 "0.9.1 and 0.9.2 and will change again before flashrom 1.0.\n"
47 "Do not use flashrom in scripts or other automated tools "
48 "without checking\n"
49 "that your flashrom version won't interpret options in a "
50 "different way.\n\n");
51
52 printf(" -h | --help print this help text\n"
53 " -R | --version print version (release)\n"
54 " -r | --read <file> read flash and save to "
55 "<file>\n"
56 " -w | --write <file> write <file> to flash\n"
57 " -v | --verify <file> verify flash against "
58 "<file>\n"
59 " -E | --erase erase flash device\n"
60 " -V | --verbose more verbose output\n"
61 " -c | --chip <chipname> probe only for specified "
62 "flash chip\n"
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +000063#if CONFIG_INTERNAL == 1
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +000064 /* FIXME: --mainboard should be a programmer parameter */
65 " -m | --mainboard <[vendor:]part> override mainboard "
66 "detection\n"
67#endif
68 " -f | --force force specific operations "
69 "(see man page)\n"
70 " -n | --noverify don't auto-verify\n"
71 " -l | --layout <file> read ROM layout from "
72 "<file>\n"
73 " -i | --image <name> only flash image <name> "
74 "from flash layout\n"
75 " -L | --list-supported print supported devices\n"
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +000076#if CONFIG_PRINT_WIKI == 1
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +000077 " -z | --list-supported-wiki print supported devices "
78 "in wiki syntax\n"
79#endif
80 " -p | --programmer <name>[:<param>] specify the programmer "
Carl-Daniel Hailfingera73fb492010-10-06 23:48:34 +000081 "device\n");
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +000082
Carl-Daniel Hailfingera73fb492010-10-06 23:48:34 +000083 list_programmers_linebreak(37, 80, 1);
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +000084 printf("\nYou can specify one of -h, -R, -L, "
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +000085#if CONFIG_PRINT_WIKI == 1
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +000086 "-z, "
87#endif
88 "-E, -r, -w, -v or no operation.\n"
89 "If no operation is specified, flashrom will only probe for "
90 "flash chips.\n\n");
91}
92
Carl-Daniel Hailfingerad3cc552010-07-03 11:02:10 +000093static void cli_classic_abort_usage(void)
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +000094{
Uwe Hermann2db77a02010-06-04 17:07:39 +000095 printf("Please run \"flashrom --help\" for usage info.\n");
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +000096 exit(1);
97}
98
99int cli_classic(int argc, char *argv[])
100{
101 unsigned long size;
102 /* Probe for up to three flash chips. */
103 struct flashchip *flash, *flashes[3];
104 const char *name;
105 int namelen;
106 int opt;
107 int option_index = 0;
108 int force = 0;
109 int read_it = 0, write_it = 0, erase_it = 0, verify_it = 0;
110 int dont_verify_it = 0, list_supported = 0;
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000111#if CONFIG_PRINT_WIKI == 1
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000112 int list_supported_wiki = 0;
113#endif
114 int operation_specified = 0;
115 int i;
116
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000117 const char *optstring = "r:Rw:v:nVEfc:m:l:i:p:Lzh";
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000118 static struct option long_options[] = {
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000119 {"read", 1, 0, 'r'},
120 {"write", 1, 0, 'w'},
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000121 {"erase", 0, 0, 'E'},
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000122 {"verify", 1, 0, 'v'},
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000123 {"noverify", 0, 0, 'n'},
124 {"chip", 1, 0, 'c'},
125 {"mainboard", 1, 0, 'm'},
126 {"verbose", 0, 0, 'V'},
127 {"force", 0, 0, 'f'},
128 {"layout", 1, 0, 'l'},
129 {"image", 1, 0, 'i'},
130 {"list-supported", 0, 0, 'L'},
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000131 {"list-supported-wiki", 0, 0, 'z'},
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000132 {"programmer", 1, 0, 'p'},
133 {"help", 0, 0, 'h'},
134 {"version", 0, 0, 'R'},
135 {0, 0, 0, 0}
136 };
137
138 char *filename = NULL;
139
140 char *tempstr = NULL;
Carl-Daniel Hailfingerad3cc552010-07-03 11:02:10 +0000141 char *pparam = NULL;
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000142
143 print_version();
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000144 print_banner();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000145
146 if (selfcheck())
147 exit(1);
148
149 setbuf(stdout, NULL);
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000150 /* FIXME: Delay all operation_specified checks until after command
151 * line parsing to allow --help overriding everything else.
152 */
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000153 while ((opt = getopt_long(argc, argv, optstring,
154 long_options, &option_index)) != EOF) {
155 switch (opt) {
156 case 'r':
157 if (++operation_specified > 1) {
158 fprintf(stderr, "More than one operation "
159 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000160 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000161 }
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000162 filename = strdup(optarg);
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000163 read_it = 1;
164 break;
165 case 'w':
166 if (++operation_specified > 1) {
167 fprintf(stderr, "More than one operation "
168 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000169 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000170 }
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000171 filename = strdup(optarg);
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000172 write_it = 1;
173 break;
174 case 'v':
175 //FIXME: gracefully handle superfluous -v
176 if (++operation_specified > 1) {
177 fprintf(stderr, "More than one operation "
178 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000179 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000180 }
181 if (dont_verify_it) {
182 fprintf(stderr, "--verify and --noverify are"
183 "mutually exclusive. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000184 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000185 }
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000186 filename = strdup(optarg);
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000187 verify_it = 1;
188 break;
189 case 'n':
190 if (verify_it) {
191 fprintf(stderr, "--verify and --noverify are"
192 "mutually exclusive. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000193 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000194 }
195 dont_verify_it = 1;
196 break;
197 case 'c':
198 chip_to_probe = strdup(optarg);
199 break;
200 case 'V':
Sean Nelson51e97d72010-01-07 20:09:33 +0000201 verbose++;
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000202 break;
203 case 'E':
204 if (++operation_specified > 1) {
205 fprintf(stderr, "More than one operation "
206 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000207 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000208 }
209 erase_it = 1;
210 break;
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000211 case 'm':
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000212#if CONFIG_INTERNAL == 1
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000213 tempstr = strdup(optarg);
214 lb_vendor_dev_from_string(tempstr);
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000215#else
216 fprintf(stderr, "Error: Internal programmer support "
217 "was not compiled in and --mainboard only\n"
218 "applies to the internal programmer. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000219 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000220#endif
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000221 break;
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000222 case 'f':
223 force = 1;
224 break;
225 case 'l':
226 tempstr = strdup(optarg);
227 if (read_romlayout(tempstr))
Uwe Hermann2db77a02010-06-04 17:07:39 +0000228 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000229 break;
230 case 'i':
231 tempstr = strdup(optarg);
232 find_romentry(tempstr);
233 break;
234 case 'L':
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000235 if (++operation_specified > 1) {
236 fprintf(stderr, "More than one operation "
237 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000238 cli_classic_abort_usage();
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000239 }
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000240 list_supported = 1;
241 break;
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000242 case 'z':
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000243#if CONFIG_PRINT_WIKI == 1
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000244 if (++operation_specified > 1) {
245 fprintf(stderr, "More than one operation "
246 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000247 cli_classic_abort_usage();
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000248 }
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000249 list_supported_wiki = 1;
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000250#else
251 fprintf(stderr, "Error: Wiki output was not compiled "
252 "in. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000253 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000254#endif
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000255 break;
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000256 case 'p':
257 for (programmer = 0; programmer < PROGRAMMER_INVALID; programmer++) {
258 name = programmer_table[programmer].name;
259 namelen = strlen(name);
260 if (strncmp(optarg, name, namelen) == 0) {
261 switch (optarg[namelen]) {
262 case ':':
Carl-Daniel Hailfingerad3cc552010-07-03 11:02:10 +0000263 pparam = strdup(optarg + namelen + 1);
264 if (!strlen(pparam)) {
265 free(pparam);
266 pparam = NULL;
Carl-Daniel Hailfinger27023762010-04-28 15:22:14 +0000267 }
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000268 break;
269 case '\0':
270 break;
271 default:
272 /* The continue refers to the
273 * for loop. It is here to be
274 * able to differentiate between
275 * foo and foobar.
276 */
277 continue;
278 }
279 break;
280 }
281 }
282 if (programmer == PROGRAMMER_INVALID) {
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000283 fprintf(stderr, "Error: Unknown programmer "
284 "%s.\n", optarg);
Uwe Hermann2db77a02010-06-04 17:07:39 +0000285 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000286 }
287 break;
288 case 'R':
289 /* print_version() is always called during startup. */
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000290 if (++operation_specified > 1) {
291 fprintf(stderr, "More than one operation "
292 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000293 cli_classic_abort_usage();
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000294 }
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000295 exit(0);
296 break;
297 case 'h':
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000298 if (++operation_specified > 1) {
299 fprintf(stderr, "More than one operation "
300 "specified. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000301 cli_classic_abort_usage();
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000302 }
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000303 cli_classic_usage(argv[0]);
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000304 exit(0);
305 break;
306 default:
Uwe Hermann2db77a02010-06-04 17:07:39 +0000307 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000308 break;
309 }
310 }
311
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000312 /* FIXME: Print the actions flashrom will take. */
313
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000314 if (list_supported) {
315 print_supported();
316 exit(0);
317 }
318
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000319#if CONFIG_PRINT_WIKI == 1
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000320 if (list_supported_wiki) {
321 print_supported_wiki();
322 exit(0);
323 }
324#endif
325
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000326 if (optind < argc) {
327 fprintf(stderr, "Error: Extra parameter found.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000328 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000329 }
330
Carl-Daniel Hailfinger71127722010-05-31 15:27:27 +0000331#if CONFIG_INTERNAL == 1
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000332 if ((programmer != PROGRAMMER_INTERNAL) && (lb_part || lb_vendor)) {
333 fprintf(stderr, "Error: --mainboard requires the internal "
334 "programmer. Aborting.\n");
Uwe Hermann2db77a02010-06-04 17:07:39 +0000335 cli_classic_abort_usage();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000336 }
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000337#endif
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000338
Carl-Daniel Hailfinger27023762010-04-28 15:22:14 +0000339 if (chip_to_probe) {
340 for (flash = flashchips; flash && flash->name; flash++)
341 if (!strcmp(flash->name, chip_to_probe))
342 break;
343 if (!flash || !flash->name) {
344 fprintf(stderr, "Error: Unknown chip '%s' specified.\n",
345 chip_to_probe);
346 printf("Run flashrom -L to view the hardware supported "
347 "in this flashrom version.\n");
348 exit(1);
349 }
350 /* Clean up after the check. */
351 flash = NULL;
352 }
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000353
Carl-Daniel Hailfinger49884202010-05-22 07:10:46 +0000354 /* FIXME: Delay calibration should happen in programmer code. */
355 myusec_calibrate_delay();
356
Carl-Daniel Hailfingerad3cc552010-07-03 11:02:10 +0000357 if (programmer_init(pparam)) {
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000358 fprintf(stderr, "Error: Programmer initialization failed.\n");
359 exit(1);
360 }
361
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000362 /* FIXME: Delay calibration should happen in programmer code. */
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000363 for (i = 0; i < ARRAY_SIZE(flashes); i++) {
364 flashes[i] =
365 probe_flash(i ? flashes[i - 1] + 1 : flashchips, 0);
366 if (!flashes[i])
367 for (i++; i < ARRAY_SIZE(flashes); i++)
368 flashes[i] = NULL;
369 }
370
371 if (flashes[1]) {
372 printf("Multiple flash chips were detected:");
373 for (i = 0; i < ARRAY_SIZE(flashes) && flashes[i]; i++)
374 printf(" %s", flashes[i]->name);
375 printf("\nPlease specify which chip to use with the -c <chipname> option.\n");
376 programmer_shutdown();
377 exit(1);
378 } else if (!flashes[0]) {
379 printf("No EEPROM/flash device found.\n");
380 if (!force || !chip_to_probe) {
Carl-Daniel Hailfinger27023762010-04-28 15:22:14 +0000381 printf("Note: flashrom can never write if the flash chip isn't found automatically.\n");
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000382 }
383 if (force && read_it && chip_to_probe) {
Carl-Daniel Hailfinger27023762010-04-28 15:22:14 +0000384 printf("Force read (-f -r -c) requested, pretending the chip is there:\n");
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000385 flashes[0] = probe_flash(flashchips, 1);
386 if (!flashes[0]) {
Carl-Daniel Hailfinger27023762010-04-28 15:22:14 +0000387 printf("Probing for flash chip '%s' failed.\n", chip_to_probe);
388 programmer_shutdown();
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000389 exit(1);
390 }
391 printf("Please note that forced reads most likely contain garbage.\n");
Carl-Daniel Hailfinger1748c572010-07-13 23:56:13 +0000392 return read_flash_to_file(flashes[0], filename);
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000393 }
394 // FIXME: flash writes stay enabled!
395 programmer_shutdown();
396 exit(1);
397 }
398
399 flash = flashes[0];
400
401 check_chip_supported(flash);
402
403 size = flash->total_size * 1024;
404 if (check_max_decode((buses_supported & flash->bustype), size) &&
405 (!force)) {
406 fprintf(stderr, "Chip is too big for this programmer "
407 "(-V gives details). Use --force to override.\n");
408 programmer_shutdown();
409 return 1;
410 }
411
412 if (!(read_it | write_it | verify_it | erase_it)) {
413 printf("No operations were specified.\n");
414 // FIXME: flash writes stay enabled!
415 programmer_shutdown();
Carl-Daniel Hailfinger8841d3e2010-05-15 15:04:37 +0000416 exit(0);
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000417 }
418
419 if (!filename && !erase_it) {
420 printf("Error: No filename specified.\n");
421 // FIXME: flash writes stay enabled!
422 programmer_shutdown();
423 exit(1);
424 }
425
426 /* Always verify write operations unless -n is used. */
427 if (write_it && !dont_verify_it)
428 verify_it = 1;
429
Carl-Daniel Hailfinger9ad42552010-09-15 10:20:16 +0000430 /* FIXME: We should issue an unconditional chip reset here. This can be
431 * done once we have a .reset function in struct flashchip.
432 * Give the chip time to settle.
433 */
434 programmer_delay(100000);
Carl-Daniel Hailfingera84835a2010-01-07 03:24:05 +0000435 return doit(flash, force, filename, read_it, write_it, erase_it, verify_it);
436}