FreeCalypso > hg > freecalypso-tools
annotate loadtools/flmain.c @ 1012:11391cb6bdc0
patch from fixeria: doc change from SE K2x0 to K2xx
Since their discovery in late 2022, Sony Ericsson K200 and K220 phones
were collectively referred to as SE K2x0 in FreeCalypso documentation.
However, now that SE K205 has been discovered as yet another member
of the same family (same PCBA in different case), it makes more sense
to refer to the whole family as SE K2xx.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 23 Sep 2024 12:23:20 +0000 |
parents | f21798eb13cf |
children |
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(); |
977
511e2b85c115
fc-loadtool: implement flash lock-state command
Mychaela Falconia <falcon@freecalypso.org>
parents:
713
diff
changeset
|
99 extern int flashcmd_lock_state(); |
981
f21798eb13cf
fc-loadtool: implement flash ppb-* commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
977
diff
changeset
|
100 extern int flashcmd_ppb_program(); |
f21798eb13cf
fc-loadtool: implement flash ppb-* commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
977
diff
changeset
|
101 extern int flashcmd_ppb_program_all(); |
f21798eb13cf
fc-loadtool: implement flash ppb-* commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
977
diff
changeset
|
102 extern int flashcmd_ppb_erase_all(); |
672
57cb825b505a
fc-loadtool code: flprogbin.c refactoring in prep for e-program-bin
Mychaela Falconia <falcon@freecalypso.org>
parents:
670
diff
changeset
|
103 extern int flashcmd_progbin_wrap(); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 extern int flashcmd_program_m0(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 extern int flashcmd_program_srec(); |
711
44cdfc4fed4c
fc-loadtool: flash prot-reg command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
673
diff
changeset
|
106 extern int flashcmd_protreg(); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 extern int flashcmd_quickprog(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 extern int flashcmd_reset(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 extern int flashcmd_sectors(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 extern int flashcmd_status(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 extern int flashcmd_unlock(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 static struct cmdtab { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 char *cmd; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 int (*func)(); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 } cmdtab[] = { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 {"blankchk", flashcmd_blankchk}, |
713
cf7bd5e705ed
fc-loadtool: flash compal-imei command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
711
diff
changeset
|
118 {"compal-imei", flashcmd_compal_imei}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 {"dump2bin", flashcmd_dump2file}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 {"dump2srec", flashcmd_dump2file}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 {"erase", flashcmd_erase}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 {"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
|
123 {"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
|
124 {"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
|
125 {"e-program-srec", flashcmd_program_srec}, |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
126 {"geom", flashcmd_geom}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 {"help", flashcmd_help}, |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
128 {"id", flashcmd_id}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 {"info", flashcmd_info}, |
977
511e2b85c115
fc-loadtool: implement flash lock-state command
Mychaela Falconia <falcon@freecalypso.org>
parents:
713
diff
changeset
|
130 {"lock-state", flashcmd_lock_state}, |
981
f21798eb13cf
fc-loadtool: implement flash ppb-* commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
977
diff
changeset
|
131 {"ppb-program", flashcmd_ppb_program}, |
f21798eb13cf
fc-loadtool: implement flash ppb-* commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
977
diff
changeset
|
132 {"ppb-program-all", flashcmd_ppb_program_all}, |
f21798eb13cf
fc-loadtool: implement flash ppb-* commands
Mychaela Falconia <falcon@freecalypso.org>
parents:
977
diff
changeset
|
133 {"ppb-erase-all", flashcmd_ppb_erase_all}, |
672
57cb825b505a
fc-loadtool code: flprogbin.c refactoring in prep for e-program-bin
Mychaela Falconia <falcon@freecalypso.org>
parents:
670
diff
changeset
|
134 {"program-bin", flashcmd_progbin_wrap}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 {"program-m0", flashcmd_program_m0}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 {"program-srec", flashcmd_program_srec}, |
711
44cdfc4fed4c
fc-loadtool: flash prot-reg command implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
673
diff
changeset
|
137 {"prot-reg", flashcmd_protreg}, |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 {"quickprog", flashcmd_quickprog}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 {"reset", flashcmd_reset}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 {"sectors", flashcmd_sectors}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 {"status", flashcmd_status}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 {"unlock", flashcmd_unlock}, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 {0, 0} |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 }; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 cmd_flash(argc, argv) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 char **argv; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 int bank; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 struct cmdtab *tp; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
152 if (!flash_global_config) { |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 fprintf(stderr, "No flash configuration defined\n"); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 if (argv[0][5] == '2') { |
506
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
157 if (flash_global_config != FLASH_GLOBAL_CFG_DUAL_8M) { |
0dd2c87c1b63
fc-loadtool flash support overhaul
Mychaela Falconia <falcon@freecalypso.org>
parents:
325
diff
changeset
|
158 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
|
159 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 bank = 1; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 } else |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 bank = 0; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 for (tp = cmdtab; tp->cmd; tp++) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 if (!strcmp(tp->cmd, argv[1])) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 break; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 if (!tp->func) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 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
|
169 argv[0], argv[1]); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 return tp->func(argc, argv, bank); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 } |