annotate loadtools/flmain.c @ 506:0dd2c87c1b63

fc-loadtool flash support overhaul
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 28 May 2019 05:12:47 +0000
parents 545e1718f5fb
children 211be4dc6be2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This module is the main entry point for fc-loadtool flash functions
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <ctype.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdint.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <string.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <strings.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <stdlib.h>
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include "flash.h"
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13
506
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
14 extern int flash_global_config;
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
15 extern struct flash_bank_info flash_bank_info[2];
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
506
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
17 flashcmd_geom(argc, argv, bank)
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 char **argv;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 struct flash_bank_info *bi;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 if (argc > 2) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 fprintf(stderr, "error: too many arguments\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 return(-1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 }
506
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
26 if (flash_detect(bank, 0) < 0)
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
27 return(-1);
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 bi = flash_bank_info + bank;
506
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
29 if (bi->device->bank_geom[1])
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
30 printf("Device has two banks, looking at bank %d\n", bank);
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
31 else
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
32 printf("Single-bank flash device\n");
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 printf("Bank %d total size: %lx\n", bank,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 (u_long) bi->geom->total_size);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 printf("Sectors in bank %d: %u (%u regions)\n", bank,
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 bi->geom->total_sectors, bi->geom->nregions);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 printf("Command set style: %s\n", bi->ops->cmdset_name);
506
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
38 return(0);
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
39 }
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
40
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
41 flashcmd_help()
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
42 {
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
43 return loadtool_help("flash");
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
44 }
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
45
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
46 flashcmd_id(argc, argv, bank)
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
47 char **argv;
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
48 {
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
49 if (argc > 2) {
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
50 fprintf(stderr, "error: too many arguments\n");
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
51 return(-1);
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
52 }
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
53 return flash_detect(bank, 1);
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
54 }
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
55
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
56 flashcmd_info(argc, argv)
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
57 char **argv;
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
58 {
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
59 int bank, nbanks;
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
60
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
61 if (argc > 2) {
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
62 fprintf(stderr, "error: too many arguments\n");
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
63 return(-1);
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
64 }
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
65 switch (flash_global_config) {
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
66 case FLASH_GLOBAL_CFG_SINGLE_4M:
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
67 printf("Configured for a single flash bank of up to 4 MiB\n");
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
68 nbanks = 1;
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
69 break;
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
70 case FLASH_GLOBAL_CFG_SINGLE_8M:
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
71 printf("Configured for a single flash bank of up to 8 MiB\n");
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
72 nbanks = 1;
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
73 break;
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
74 case FLASH_GLOBAL_CFG_DUAL_8M:
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
75 printf("Configured for two flash banks of up to 8 MiB each\n");
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
76 nbanks = 2;
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
77 break;
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
78 default:
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
79 fprintf(stderr, "error: invalid global config\n");
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
80 return(-1);
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
81 }
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
82 for (bank = 0; bank < nbanks; bank++)
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
83 printf("Bank %d base address: %08lX\n", bank,
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
84 (u_long) flash_bank_info[bank].base_addr);
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 return(0);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 extern int flashcmd_blankchk();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 extern int flashcmd_dump2file();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 extern int flashcmd_erase();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 extern int flashcmd_erase_program_boot();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 extern int flashcmd_progbin();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 extern int flashcmd_program_m0();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 extern int flashcmd_program_srec();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 extern int flashcmd_quickprog();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 extern int flashcmd_reset();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 extern int flashcmd_sectors();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 extern int flashcmd_status();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 extern int flashcmd_unlock();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 static struct cmdtab {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 char *cmd;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 int (*func)();
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 } cmdtab[] = {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 {"blankchk", flashcmd_blankchk},
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 {"dump2bin", flashcmd_dump2file},
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 {"dump2srec", flashcmd_dump2file},
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 {"erase", flashcmd_erase},
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 {"erase-program-boot", flashcmd_erase_program_boot},
506
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
110 {"geom", flashcmd_geom},
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 {"help", flashcmd_help},
506
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
112 {"id", flashcmd_id},
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 {"info", flashcmd_info},
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 {"program-bin", flashcmd_progbin},
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 {"program-m0", flashcmd_program_m0},
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 {"program-srec", flashcmd_program_srec},
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 {"quickprog", flashcmd_quickprog},
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 {"reset", flashcmd_reset},
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 {"sectors", flashcmd_sectors},
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 {"status", flashcmd_status},
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 {"unlock", flashcmd_unlock},
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 {0, 0}
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 };
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 cmd_flash(argc, argv)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 char **argv;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 int bank;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 struct cmdtab *tp;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130
506
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
131 if (!flash_global_config) {
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 fprintf(stderr, "No flash configuration defined\n");
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 return(-1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 if (argv[0][5] == '2') {
506
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
136 if (flash_global_config != FLASH_GLOBAL_CFG_DUAL_8M) {
0dd2c87c1b63 fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents: 325
diff changeset
137 fprintf(stderr, "No second flash bank configured\n");
0
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 return(-1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 bank = 1;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 } else
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 bank = 0;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 for (tp = cmdtab; tp->cmd; tp++)
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 if (!strcmp(tp->cmd, argv[1]))
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 break;
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 if (!tp->func) {
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 fprintf(stderr, "%s %s: unknown/unimplemented subcommand\n",
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 argv[0], argv[1]);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 return(-1);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 }
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 return tp->func(argc, argv, bank);
e7502631a0f9 initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 }