FreeCalypso > hg > freecalypso-tools
annotate loadtools/flmain.c @ 721:059649902c7f
librftab: added support for adc-cal tables
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 25 Aug 2020 07:15:02 +0000 |
parents | cf7bd5e705ed |
children | 511e2b85c115 |
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; |
508
211be4dc6be2
new flash geom command made a little nicer
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
21 unsigned rn; |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 if (argc > 2) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 fprintf(stderr, "error: too many arguments\n"); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 } |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
27 if (flash_detect(bank, 0) < 0) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
28 return(-1); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 bi = flash_bank_info + bank; |
508
211be4dc6be2
new flash geom command made a little nicer
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
30 printf("Detected flash device: %s\n", bi->device->name); |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
31 if (bi->device->bank_geom[1]) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
32 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
|
33 else |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
34 printf("Single-bank flash device\n"); |
508
211be4dc6be2
new flash geom command made a little nicer
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
35 printf("Bank %d total size: 0x%lx\n", bank, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 (u_long) bi->geom->total_size); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 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
|
38 bi->geom->total_sectors, bi->geom->nregions); |
508
211be4dc6be2
new flash geom command made a little nicer
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
39 for (rn = 0; rn < bi->geom->nregions; rn++) |
211be4dc6be2
new flash geom command made a little nicer
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
40 printf("Region %u: %u sectors of 0x%lx bytes\n", rn, |
211be4dc6be2
new flash geom command made a little nicer
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
41 bi->geom->regions[rn].nsectors, |
211be4dc6be2
new flash geom command made a little nicer
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
42 (u_long) bi->geom->regions[rn].sector_size); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 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
|
44 return(0); |
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 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
47 flashcmd_help() |
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 return loadtool_help("flash"); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
50 } |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
51 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
52 flashcmd_id(argc, argv, bank) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
53 char **argv; |
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 if (argc > 2) { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
56 fprintf(stderr, "error: too many arguments\n"); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
57 return(-1); |
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 return flash_detect(bank, 1); |
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 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
62 flashcmd_info(argc, argv) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
63 char **argv; |
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 int bank, nbanks; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
66 |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
67 if (argc > 2) { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
68 fprintf(stderr, "error: too many arguments\n"); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
69 return(-1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
70 } |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
71 switch (flash_global_config) { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
72 case FLASH_GLOBAL_CFG_SINGLE_4M: |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
73 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
|
74 nbanks = 1; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
75 break; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
76 case FLASH_GLOBAL_CFG_SINGLE_8M: |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
77 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
|
78 nbanks = 1; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
79 break; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
80 case FLASH_GLOBAL_CFG_DUAL_8M: |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
81 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
|
82 nbanks = 2; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
83 break; |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
84 default: |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
85 fprintf(stderr, "error: invalid global config\n"); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
86 return(-1); |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
87 } |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
88 for (bank = 0; bank < nbanks; bank++) |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
89 printf("Bank %d base address: %08lX\n", bank, |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
90 (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
|
91 return(0); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 extern int flashcmd_blankchk(); |
713
cf7bd5e705ed
fc-loadtool: flash compal-imei command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
711
diff
changeset
|
95 extern int flashcmd_compal_imei(); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 extern int flashcmd_dump2file(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 extern int flashcmd_erase(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 extern int flashcmd_erase_program_boot(); |
672
57cb825b505a
fc-loadtool code: flprogbin.c refactoring in prep for e-program-bin
Mychaela Falconia <falcon@freecalypso.org>
parents:
670
diff
changeset
|
99 extern int flashcmd_progbin_wrap(); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 extern int flashcmd_program_m0(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 extern int flashcmd_program_srec(); |
711
44cdfc4fed4c
fc-loadtool: flash prot-reg command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
673
diff
changeset
|
102 extern int flashcmd_protreg(); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 extern int flashcmd_quickprog(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 extern int flashcmd_reset(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 extern int flashcmd_sectors(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 extern int flashcmd_status(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 extern int flashcmd_unlock(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 static struct cmdtab { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 char *cmd; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 int (*func)(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 } cmdtab[] = { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 {"blankchk", flashcmd_blankchk}, |
713
cf7bd5e705ed
fc-loadtool: flash compal-imei command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
711
diff
changeset
|
114 {"compal-imei", flashcmd_compal_imei}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 {"dump2bin", flashcmd_dump2file}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 {"dump2srec", flashcmd_dump2file}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 {"erase", flashcmd_erase}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 {"erase-program-boot", flashcmd_erase_program_boot}, |
673
f67e5ad30324
fc-loadtool: flash e-program-bin implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
672
diff
changeset
|
119 {"e-program-bin", flashcmd_progbin_wrap}, |
670
815c3f8bcff1
fc-loadtool: flash e-program-m0 and e-program-srec implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
508
diff
changeset
|
120 {"e-program-m0", flashcmd_program_m0}, |
815c3f8bcff1
fc-loadtool: flash e-program-m0 and e-program-srec implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
508
diff
changeset
|
121 {"e-program-srec", flashcmd_program_srec}, |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
122 {"geom", flashcmd_geom}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 {"help", flashcmd_help}, |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
124 {"id", flashcmd_id}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 {"info", flashcmd_info}, |
672
57cb825b505a
fc-loadtool code: flprogbin.c refactoring in prep for e-program-bin
Mychaela Falconia <falcon@freecalypso.org>
parents:
670
diff
changeset
|
126 {"program-bin", flashcmd_progbin_wrap}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 {"program-m0", flashcmd_program_m0}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 {"program-srec", flashcmd_program_srec}, |
711
44cdfc4fed4c
fc-loadtool: flash prot-reg command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
673
diff
changeset
|
129 {"prot-reg", flashcmd_protreg}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 {"quickprog", flashcmd_quickprog}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 {"reset", flashcmd_reset}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 {"sectors", flashcmd_sectors}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 {"status", flashcmd_status}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 {"unlock", flashcmd_unlock}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 {0, 0} |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 }; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 cmd_flash(argc, argv) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 char **argv; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 int bank; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 struct cmdtab *tp; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
144 if (!flash_global_config) { |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 fprintf(stderr, "No flash configuration defined\n"); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 if (argv[0][5] == '2') { |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
149 if (flash_global_config != FLASH_GLOBAL_CFG_DUAL_8M) { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
150 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
|
151 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 bank = 1; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 } else |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 bank = 0; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 for (tp = cmdtab; tp->cmd; tp++) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 if (!strcmp(tp->cmd, argv[1])) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 break; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 if (!tp->func) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 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
|
161 argv[0], argv[1]); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 return tp->func(argc, argv, bank); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 } |