FreeCalypso > hg > freecalypso-sw
annotate loadtools/ltflash.c @ 216:0eb85790c0ed
gsm-fw/services/ffs: reclaim.c compiles
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Mon, 06 Jan 2014 07:23:36 +0000 |
parents | cd12d1049f91 |
children | f027c6fbe37e |
rev | line source |
---|---|
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * In this module we are going to implement the flash operation commands |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * of fc-loadtool. |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <sys/types.h> |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdio.h> |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <stdint.h> |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <string.h> |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include <strings.h> |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include <stdlib.h> |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "flash.h" |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 |
96
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
14 /* K5A32xx device description */ |
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
15 |
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
16 static struct flash_region_desc k5a32xx_topboot_regions[] = { |
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
17 /* 4 MiB total, 64 KiB sectors except for the boot block of 8x 8 KiB */ |
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
18 {0x10000, 63}, |
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
19 {0x2000, 8}, |
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
20 {0, 0} /* array terminator */ |
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
21 }; |
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
22 |
203
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
23 static struct flash_idcheck k5a32xx_topboot_idcheck[2] = { |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
24 {0x00, 0x00EC}, |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
25 {0x02, 0x22A0} |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
26 }; |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
27 |
96
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
28 static struct flash_bank_desc k5a32xx_topboot_bankdesc = { |
203
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
29 k5a32xx_topboot_regions, 0xFFF00000, k5a32xx_topboot_idcheck, 2 |
96
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
30 }; |
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
31 |
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 /* S{29,71}PL129N device description */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 static struct flash_region_desc pl129n_ce1_regions[] = { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 /* 4 sectors of 64 KiB each at the beginning, then 256 KiB sectors */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 {0x10000, 4}, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 {0x40000, 31}, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 {0, 0} /* array terminator */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 }; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 static struct flash_region_desc pl129n_ce2_regions[] = { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 /* the other way around now */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 {0x40000, 31}, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 {0x10000, 4}, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 {0, 0} /* array terminator */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 }; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 |
203
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
48 static struct flash_idcheck pl129n_idcheck[4] = { |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
49 {0x00, 0x0001}, |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
50 {0x02, 0x227E}, |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
51 {0x1C, 0x2221}, |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
52 {0x1E, 0x2200} |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
53 }; |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
54 |
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 static struct flash_bank_desc pl129n_banks[2] = { |
203
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
56 {pl129n_ce1_regions, 0xFFFC0000, pl129n_idcheck, 4}, |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
57 {pl129n_ce2_regions, 0xFFFC0000, pl129n_idcheck, 4} |
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 }; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 /* list of supported flash devices */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 struct flash_device_desc flash_device_list[] = { |
96
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
63 {"k5a32xx_t", &k5a32xx_topboot_bankdesc, 1}, |
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 {"pl129n", pl129n_banks, 2}, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 {0, 0, 0} /* array terminator */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 }; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 /* the following variables describe our selected flash device */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 struct flash_device_desc *selected_flash_device; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 struct flash_bank_info flash_bank_info[2]; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 /* called from hwparam.c config file parser */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 void |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 set_flash_device(arg, filename_for_errs, lineno_for_errs) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 char *arg; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 char *filename_for_errs; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 int lineno_for_errs; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 char *cp, *np, *ep; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 struct flash_device_desc *tp; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 int bank; |
56
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
83 struct flash_bank_info *bi; |
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 if (selected_flash_device) { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 fprintf(stderr, "%s line %d: duplicate flash setting\n", |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 filename_for_errs, lineno_for_errs); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 exit(1); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 for (cp = arg; isspace(*cp); cp++) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 ; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 if (!*cp || *cp == '#') { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 too_few_arg: fprintf(stderr, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 "%s line %d: flash setting: too few arguments\n", |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 filename_for_errs, lineno_for_errs); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 exit(1); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 for (np = cp; *cp && !isspace(*cp); cp++) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 ; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 if (*cp) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 *cp++ = '\0'; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 for (tp = flash_device_list; tp->name; tp++) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 if (!strcmp(tp->name, np)) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 break; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 if (!tp->name) { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 fprintf(stderr, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 "%s line %d: unknown flash device \"%s\"\n", |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 filename_for_errs, lineno_for_errs, np); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 exit(1); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
110 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 selected_flash_device = tp; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 /* now initialize flash_bank_info */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 for (bank = 0; bank < selected_flash_device->nbanks; bank++) { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 while (isspace(*cp)) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 cp++; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 if (!*cp || *cp == '#') |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 goto too_few_arg; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 for (np = cp; *cp && !isspace(*cp); cp++) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 ; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 if (*cp) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 *cp++ = '\0'; |
56
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
123 bi = flash_bank_info + bank; |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
124 bi->base_addr = strtoul(np, &ep, 16); |
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 if (*ep) { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 fprintf(stderr, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 "%s line %d: syntax error (base addr expected after flash device type)\n", |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 filename_for_errs, lineno_for_errs); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 exit(1); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 /* the rest comes from the flash device type */ |
56
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
132 bi->bank_desc = selected_flash_device->bank_desc + bank; |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
133 compute_flash_totsize_nsecs(bank); |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
134 if (count_ones(bi->total_size) != 1) { |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
135 fprintf(stderr, |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
136 "fc-loadtool internal bug: flash bank %d size for %s is not a power of 2\n", |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
137 bank, selected_flash_device->name); |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
138 exit(1); |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
139 } |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
140 if (bi->base_addr & (bi->total_size - 1)) { |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
141 fprintf(stderr, |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
142 "%s line %d: flash bank %d base addr is not aligned to the bank size (0x%lx)\n", |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
143 filename_for_errs, lineno_for_errs, bank, |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
144 (u_long) bi->total_size); |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
145 exit(1); |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
146 } |
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
148 while (isspace(*cp)) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 cp++; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 if (*cp && *cp != '#') { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
151 fprintf(stderr, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 "%s line %d: flash setting: too many arguments\n", |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 filename_for_errs, lineno_for_errs); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
154 exit(1); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
155 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 } |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
157 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
158 flashcmd_blankchk(argc, argv, bank) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
159 char **argv; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
160 { |
60
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
161 struct flash_bank_info *bi; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
162 u_long offset, len; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
163 char *strtoul_endp; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
164 char *targv[4], targ_start[10], targ_len[10]; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
165 |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
166 if (argc != 4) { |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
167 inv: fprintf(stderr, "usage: %s %s hex-start-offset hex-length\n", |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
168 argv[0], argv[1]); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
169 return(-1); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
170 } |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
171 offset = strtoul(argv[2], &strtoul_endp, 16); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
172 if (*strtoul_endp) |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
173 goto inv; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
174 bi = flash_bank_info + bank; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
175 if (offset >= bi->total_size) { |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
176 fprintf(stderr, |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
177 "error: specified offset exceeds flash bank size (0x%lx)\n", |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
178 (u_long) bi->total_size); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
179 return(-1); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
180 } |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
181 len = strtoul(argv[3], &strtoul_endp, 16); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
182 if (*strtoul_endp) |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
183 goto inv; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
184 if (len > bi->total_size - offset) { |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
185 fprintf(stderr, |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
186 "error: specified offset+length exceed flash bank size (0x%lx)\n", |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
187 (u_long) bi->total_size); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
188 return(-1); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
189 } |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
190 sprintf(targ_start, "%lx", (u_long) bi->base_addr + offset); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
191 sprintf(targ_len, "%lx", len); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
192 targv[0] = "blankchk"; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
193 targv[1] = targ_start; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
194 targv[2] = targ_len; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
195 targv[3] = 0; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
196 tpinterf_make_cmd(targv); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
197 if (tpinterf_send_cmd() < 0) |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
198 return(-1); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
199 return tpinterf_pass_output(10); /* 10 s timeout */ |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
200 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
201 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
202 flashcmd_dump2file(argc, argv, bank) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
203 char **argv; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
204 { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
205 struct flash_bank_info *bi; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
206 u_long offset, dumplen, maxlen; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
207 char *strtoul_endp; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
208 int format; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
209 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
210 if (argc < 3 || argc > 5) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
211 inv: fprintf(stderr, "usage: %s %s outfile [offset [length]]\n", |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
212 argv[0], argv[1]); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
213 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
214 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
215 bi = flash_bank_info + bank; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
216 if (argc >= 4) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
217 offset = strtoul(argv[3], &strtoul_endp, 16); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
218 if (*strtoul_endp) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
219 goto inv; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
220 if (offset >= bi->total_size) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
221 fprintf(stderr, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
222 "error: specified offset exceeds flash bank size (0x%lx)\n", |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
223 (u_long) bi->total_size); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
224 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
225 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
226 } else |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
227 offset = 0; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
228 maxlen = bi->total_size - offset; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
229 if (argc >= 5) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
230 dumplen = strtoul(argv[4], &strtoul_endp, 16); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
231 if (*strtoul_endp) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
232 goto inv; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
233 if (dumplen > maxlen) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
234 fprintf(stderr, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
235 "error: specified offset+length exceed flash bank size (0x%lx)\n", |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
236 (u_long) bi->total_size); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
237 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
238 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
239 } else |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
240 dumplen = maxlen; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
241 switch (argv[1][5]) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
242 case 'b': |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
243 format = 0; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
244 break; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
245 case 's': |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
246 format = 1; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
247 break; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
248 default: |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
249 fprintf(stderr, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
250 "internal bug: bad format in flashcmd_dump2file()\n"); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
251 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
252 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
253 return loadtool_memdump(bi->base_addr + offset, dumplen, argv[2], |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
254 format); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
255 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
256 |
105
02cb0206aa47
fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
257 flashcmd_help() |
02cb0206aa47
fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
258 { |
02cb0206aa47
fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
259 return loadtool_help("flash"); |
02cb0206aa47
fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
260 } |
02cb0206aa47
fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
261 |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
262 flashcmd_info(argc, argv, bank) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
263 char **argv; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
264 { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
265 struct flash_bank_info *bi; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
266 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
267 if (argc > 2) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
268 fprintf(stderr, "error: too many arguments\n"); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
269 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
270 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
271 bi = flash_bank_info + bank; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
272 printf("Flash device type: %s\n", selected_flash_device->name); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
273 printf("Bank %d base address: %08lX\n", bank, (u_long) bi->base_addr); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
274 printf("Bank %d total size: %lx\n", bank, (u_long) bi->total_size); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
275 printf("Sectors in bank %d: %u\n", bank, bi->nsectors); |
205
cd12d1049f91
fc-loadtool: flash ID check moved into flash info, added to erase and program
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
204
diff
changeset
|
276 flash_id_check(bank, 1); |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
277 if (selected_flash_device->nbanks == 2 && !bank) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
278 printf("\nFlash device has 2 banks; flash2 command available\n"); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
279 return(0); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
280 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
281 |
64
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
282 flashcmd_quickprog(argc, argv, bank) |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
283 char **argv; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
284 { |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
285 char *targv[4], targ_base[10]; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
286 int stat; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
287 |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
288 if (argc != 4) { |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
289 inv: fprintf(stderr, "usage: %s %s hex-offset hex-data-string\n", |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
290 argv[0], argv[1]); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
291 return(-1); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
292 } |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
293 sprintf(targ_base, "%lx", (u_long) flash_bank_info[bank].base_addr); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
294 targv[0] = "AMFB"; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
295 targv[1] = targ_base; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
296 targv[2] = 0; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
297 tpinterf_make_cmd(targv); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
298 if (tpinterf_send_cmd() < 0) |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
299 return(-1); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
300 stat = tpinterf_pass_output(1); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
301 if (stat) |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
302 return(stat); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
303 targv[0] = "AMFW"; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
304 targv[1] = argv[2]; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
305 targv[2] = argv[3]; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
306 targv[3] = 0; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
307 if (tpinterf_make_cmd(targv) < 0) { |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
308 fprintf(stderr, "error: unable to form AMFW target command\n"); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
309 return(-1); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
310 } |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
311 if (tpinterf_send_cmd() < 0) |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
312 return(-1); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
313 return tpinterf_pass_output(1); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
314 } |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
315 |
62
6fb41cfa773d
fc-loadtool: flash erase implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
61
diff
changeset
|
316 extern int flashcmd_erase(); |
65
a7da6648a7f8
fc-loadtool: flash program-bin command implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
64
diff
changeset
|
317 extern int flashcmd_progbin(); |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
96
diff
changeset
|
318 extern int flashcmd_program_m0(); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
96
diff
changeset
|
319 extern int flashcmd_program_srec(); |
61
a10491da8c3a
fc-loadtool flash support: sector table generation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
60
diff
changeset
|
320 extern int flashcmd_sectors(); |
a10491da8c3a
fc-loadtool flash support: sector table generation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
60
diff
changeset
|
321 |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
322 static struct cmdtab { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
323 char *cmd; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
324 int (*func)(); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
325 } cmdtab[] = { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
326 {"blankchk", flashcmd_blankchk}, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
327 {"dump2bin", flashcmd_dump2file}, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
328 {"dump2srec", flashcmd_dump2file}, |
62
6fb41cfa773d
fc-loadtool: flash erase implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
61
diff
changeset
|
329 {"erase", flashcmd_erase}, |
105
02cb0206aa47
fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
330 {"help", flashcmd_help}, |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
331 {"info", flashcmd_info}, |
65
a7da6648a7f8
fc-loadtool: flash program-bin command implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
64
diff
changeset
|
332 {"program-bin", flashcmd_progbin}, |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
96
diff
changeset
|
333 {"program-m0", flashcmd_program_m0}, |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
96
diff
changeset
|
334 {"program-srec", flashcmd_program_srec}, |
64
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
335 {"quickprog", flashcmd_quickprog}, |
61
a10491da8c3a
fc-loadtool flash support: sector table generation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
60
diff
changeset
|
336 {"sectors", flashcmd_sectors}, |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
337 {0, 0} |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
338 }; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
339 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
340 cmd_flash(argc, argv) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
341 char **argv; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
342 { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
343 int bank; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
344 struct cmdtab *tp; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
345 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
346 if (!selected_flash_device) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
347 fprintf(stderr, "No flash configuration defined\n"); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
348 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
349 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
350 if (argv[0][5] == '2') { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
351 if (selected_flash_device->nbanks < 2) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
352 fprintf(stderr, "Flash device %s has only one bank\n", |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
353 selected_flash_device->name); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
354 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
355 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
356 bank = 1; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
357 } else |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
358 bank = 0; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
359 for (tp = cmdtab; tp->cmd; tp++) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
360 if (!strcmp(tp->cmd, argv[1])) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
361 break; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
362 if (!tp->func) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
363 fprintf(stderr, "%s %s: unknown/unimplemented subcommand\n", |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
364 argv[0], argv[1]); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
365 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
366 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
367 return tp->func(argc, argv, bank); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
368 } |