FreeCalypso > hg > freecalypso-sw
annotate loadtools/ltflash.c @ 401:7ceeec049be4
fc-loadtool flash: bank configurations for CFI
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 15 Jun 2014 20:24:51 +0000 |
parents | f027c6fbe37e |
children |
rev | line source |
---|---|
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
2 * This module contains the "core" of fc-loadtool flash operations; |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
3 * fl*.c modules contain the rest. |
55
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 |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
16 static struct cfi_info k5a32xx_topboot_hardcfi = { |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
17 .cmdset_style = 2, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
18 .total_size = 0x400000, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
19 .nregions = 2, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
20 .regions = {0x10000, 63, 0x2000, 8}, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
21 .total_sectors = 71 |
96
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
22 }; |
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
23 |
203
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
24 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
|
25 {0x00, 0x00EC}, |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
26 {0x02, 0x22A0} |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
27 }; |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
28 |
96
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
29 static struct flash_bank_desc k5a32xx_topboot_bankdesc = { |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
30 0x400000, &k5a32xx_topboot_hardcfi, k5a32xx_topboot_idcheck, 2 |
96
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
31 }; |
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
32 |
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 /* S{29,71}PL129N device description */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
35 static struct cfi_info pl129n_ce1_hardcfi = { |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
36 .cmdset_style = 2, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
37 .total_size = 0x800000, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
38 .nregions = 2, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
39 .regions = {0x10000, 4, 0x40000, 31}, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
40 .total_sectors = 35 |
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 }; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
43 static struct cfi_info pl129n_ce2_hardcfi = { |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
44 .cmdset_style = 2, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
45 .total_size = 0x800000, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
46 .nregions = 2, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
47 .regions = {0x40000, 31, 0x10000, 4}, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
48 .total_sectors = 35 |
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 }; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 |
203
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
51 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
|
52 {0x00, 0x0001}, |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
53 {0x02, 0x227E}, |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
54 {0x1C, 0x2221}, |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
55 {0x1E, 0x2200} |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
56 }; |
99c234bf6a9b
fc-loadtool flash ID check: definitions created
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
105
diff
changeset
|
57 |
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 static struct flash_bank_desc pl129n_banks[2] = { |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
59 {0x800000, &pl129n_ce1_hardcfi, pl129n_idcheck, 4}, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
60 {0x800000, &pl129n_ce2_hardcfi, pl129n_idcheck, 4} |
55
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 |
401
7ceeec049be4
fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
63 /* bank configurations for CFI */ |
7ceeec049be4
fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
64 |
7ceeec049be4
fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
65 static struct flash_bank_desc cfi_4M_bankdesc = { |
7ceeec049be4
fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
66 0x400000, 0, 0, 0 |
7ceeec049be4
fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
67 }; |
7ceeec049be4
fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
68 |
7ceeec049be4
fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
69 static struct flash_bank_desc cfi_8M_bankdesc = { |
7ceeec049be4
fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
70 0x800000, 0, 0, 0 |
7ceeec049be4
fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
71 }; |
7ceeec049be4
fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
72 |
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 /* list of supported flash devices */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 struct flash_device_desc flash_device_list[] = { |
401
7ceeec049be4
fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
76 {"cfi-4M", &cfi_4M_bankdesc, 1}, |
7ceeec049be4
fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
77 {"cfi-8M", &cfi_8M_bankdesc, 1}, |
96
57b8dbb029c2
fc-loadtool: GTA0x flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
65
diff
changeset
|
78 {"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
|
79 {"pl129n", pl129n_banks, 2}, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 {0, 0, 0} /* array terminator */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 }; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 /* 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
|
84 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 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
|
86 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
|
87 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 /* 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
|
89 void |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 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
|
91 char *arg; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 char *filename_for_errs; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 int lineno_for_errs; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 char *cp, *np, *ep; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 struct flash_device_desc *tp; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 int bank; |
56
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
98 struct flash_bank_info *bi; |
55
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 (selected_flash_device) { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 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
|
102 filename_for_errs, lineno_for_errs); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 exit(1); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 for (cp = arg; isspace(*cp); cp++) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 ; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 if (!*cp || *cp == '#') { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 too_few_arg: fprintf(stderr, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 "%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
|
110 filename_for_errs, lineno_for_errs); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 exit(1); |
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 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
|
114 ; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 if (*cp) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 *cp++ = '\0'; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 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
|
118 if (!strcmp(tp->name, np)) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 break; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 if (!tp->name) { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 fprintf(stderr, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 "%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
|
123 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
|
124 exit(1); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
125 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
126 selected_flash_device = tp; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 /* now initialize flash_bank_info */ |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 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
|
130 while (isspace(*cp)) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 cp++; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 if (!*cp || *cp == '#') |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 goto too_few_arg; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 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
|
135 ; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 if (*cp) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 *cp++ = '\0'; |
56
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
138 bi = flash_bank_info + bank; |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
139 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
|
140 if (*ep) { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 fprintf(stderr, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 "%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
|
143 filename_for_errs, lineno_for_errs); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 exit(1); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
145 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 /* 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
|
147 bi->bank_desc = selected_flash_device->bank_desc + bank; |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
148 if (bi->base_addr & (bi->bank_desc->align_size - 1)) { |
56
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
149 fprintf(stderr, |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
150 "%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
|
151 filename_for_errs, lineno_for_errs, bank, |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
152 (u_long) bi->bank_desc->align_size); |
56
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
153 exit(1); |
d98137625c0d
fc-loadtool flash: total_size logic implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
55
diff
changeset
|
154 } |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
155 bi->cfi = bi->bank_desc->hard_cfi; |
55
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
157 while (isspace(*cp)) |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
158 cp++; |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 if (*cp && *cp != '#') { |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
160 fprintf(stderr, |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
161 "%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
|
162 filename_for_errs, lineno_for_errs); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
163 exit(1); |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
164 } |
278052b6afda
loadtools: started laying the foundation for flash support
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
165 } |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
166 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
167 flashcmd_blankchk(argc, argv, bank) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
168 char **argv; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
169 { |
60
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
170 struct flash_bank_info *bi; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
171 u_long offset, len; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
172 char *strtoul_endp; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
173 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
|
174 |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
175 if (argc != 4) { |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
176 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
|
177 argv[0], argv[1]); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
178 return(-1); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
179 } |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
180 offset = strtoul(argv[2], &strtoul_endp, 16); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
181 if (*strtoul_endp) |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
182 goto inv; |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
183 if (flash_get_cfi(bank) < 0) |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
184 return(-1); |
60
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
185 bi = flash_bank_info + bank; |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
186 if (offset >= bi->cfi->total_size) { |
60
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
187 fprintf(stderr, |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
188 "error: specified offset exceeds flash bank size (0x%lx)\n", |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
189 (u_long) bi->cfi->total_size); |
60
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
190 return(-1); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
191 } |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
192 len = strtoul(argv[3], &strtoul_endp, 16); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
193 if (*strtoul_endp) |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
194 goto inv; |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
195 if (len > bi->cfi->total_size - offset) { |
60
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
196 fprintf(stderr, |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
197 "error: specified offset+length exceed flash bank size (0x%lx)\n", |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
198 (u_long) bi->cfi->total_size); |
60
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
199 return(-1); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
200 } |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
201 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
|
202 sprintf(targ_len, "%lx", len); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
203 targv[0] = "blankchk"; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
204 targv[1] = targ_start; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
205 targv[2] = targ_len; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
206 targv[3] = 0; |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
207 tpinterf_make_cmd(targv); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
208 if (tpinterf_send_cmd() < 0) |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
209 return(-1); |
048329d0888e
fc-loadtool: flash blankchk implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
58
diff
changeset
|
210 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
|
211 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
212 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
213 flashcmd_dump2file(argc, argv, bank) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
214 char **argv; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
215 { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
216 struct flash_bank_info *bi; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
217 u_long offset, dumplen, maxlen; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
218 char *strtoul_endp; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
219 int format; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
220 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
221 if (argc < 3 || argc > 5) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
222 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
|
223 argv[0], argv[1]); |
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 } |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
226 if (flash_get_cfi(bank) < 0) |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
227 return(-1); |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
228 bi = flash_bank_info + bank; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
229 if (argc >= 4) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
230 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
|
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; |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
233 if (offset >= bi->cfi->total_size) { |
58
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 exceeds flash bank size (0x%lx)\n", |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
236 (u_long) bi->cfi->total_size); |
58
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 offset = 0; |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
241 maxlen = bi->cfi->total_size - offset; |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
242 if (argc >= 5) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
243 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
|
244 if (*strtoul_endp) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
245 goto inv; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
246 if (dumplen > maxlen) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
247 fprintf(stderr, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
248 "error: specified offset+length exceed flash bank size (0x%lx)\n", |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
249 (u_long) bi->cfi->total_size); |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
250 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
251 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
252 } else |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
253 dumplen = maxlen; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
254 switch (argv[1][5]) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
255 case 'b': |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
256 format = 0; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
257 break; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
258 case 's': |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
259 format = 1; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
260 break; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
261 default: |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
262 fprintf(stderr, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
263 "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
|
264 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
265 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
266 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
|
267 format); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
268 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
269 |
105
02cb0206aa47
fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
270 flashcmd_help() |
02cb0206aa47
fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
271 { |
02cb0206aa47
fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
272 return loadtool_help("flash"); |
02cb0206aa47
fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
273 } |
02cb0206aa47
fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
274 |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
275 flashcmd_info(argc, argv, bank) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
276 char **argv; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
277 { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
278 struct flash_bank_info *bi; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
279 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
280 if (argc > 2) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
281 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
|
282 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
283 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
284 bi = flash_bank_info + bank; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
285 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
|
286 printf("Bank %d base address: %08lX\n", bank, (u_long) bi->base_addr); |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
287 if (flash_get_cfi(bank) < 0) |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
288 return(-1); |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
289 printf("Bank %d total size: %lx\n", bank, (u_long) bi->cfi->total_size); |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
290 printf("Sectors in bank %d: %u (%u regions)\n", bank, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
291 bi->cfi->total_sectors, bi->cfi->nregions); |
401
7ceeec049be4
fc-loadtool flash: bank configurations for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
292 printf("Command set style: %04X\n", bi->cfi->cmdset_style); |
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
|
293 flash_id_check(bank, 1); |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
294 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
|
295 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
|
296 return(0); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
297 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
298 |
64
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
299 flashcmd_quickprog(argc, argv, bank) |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
300 char **argv; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
301 { |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
302 char *targv[4], targ_base[10]; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
303 int stat; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
304 |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
305 if (flash_get_cfi(bank) < 0) |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
306 return(-1); |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
307 if (flash_bank_info[bank].cfi->cmdset_style != 2) { |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
308 fprintf(stderr, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
309 "error: this command is currently only implemented for AMD-style flash\n"); |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
310 return(-1); |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
311 } |
64
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
312 if (argc != 4) { |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
313 fprintf(stderr, "usage: %s %s hex-offset hex-data-string\n", |
64
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
314 argv[0], argv[1]); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
315 return(-1); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
316 } |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
317 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
|
318 targv[0] = "AMFB"; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
319 targv[1] = targ_base; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
320 targv[2] = 0; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
321 tpinterf_make_cmd(targv); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
322 if (tpinterf_send_cmd() < 0) |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
323 return(-1); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
324 stat = tpinterf_pass_output(1); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
325 if (stat) |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
326 return(stat); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
327 targv[0] = "AMFW"; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
328 targv[1] = argv[2]; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
329 targv[2] = argv[3]; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
330 targv[3] = 0; |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
331 if (tpinterf_make_cmd(targv) < 0) { |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
332 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
|
333 return(-1); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
334 } |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
335 if (tpinterf_send_cmd() < 0) |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
336 return(-1); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
337 return tpinterf_pass_output(1); |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
338 } |
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
339 |
62
6fb41cfa773d
fc-loadtool: flash erase implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
61
diff
changeset
|
340 extern int flashcmd_erase(); |
65
a7da6648a7f8
fc-loadtool: flash program-bin command implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
64
diff
changeset
|
341 extern int flashcmd_progbin(); |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
96
diff
changeset
|
342 extern int flashcmd_program_m0(); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
96
diff
changeset
|
343 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
|
344 extern int flashcmd_sectors(); |
a10491da8c3a
fc-loadtool flash support: sector table generation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
60
diff
changeset
|
345 |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
346 static struct cmdtab { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
347 char *cmd; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
348 int (*func)(); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
349 } cmdtab[] = { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
350 {"blankchk", flashcmd_blankchk}, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
351 {"dump2bin", flashcmd_dump2file}, |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
352 {"dump2srec", flashcmd_dump2file}, |
62
6fb41cfa773d
fc-loadtool: flash erase implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
61
diff
changeset
|
353 {"erase", flashcmd_erase}, |
105
02cb0206aa47
fc-loadtool help implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
354 {"help", flashcmd_help}, |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
355 {"info", flashcmd_info}, |
65
a7da6648a7f8
fc-loadtool: flash program-bin command implemented, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
64
diff
changeset
|
356 {"program-bin", flashcmd_progbin}, |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
96
diff
changeset
|
357 {"program-m0", flashcmd_program_m0}, |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
96
diff
changeset
|
358 {"program-srec", flashcmd_program_srec}, |
64
a481d648278a
fc-loadtool: "quick program" command implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
62
diff
changeset
|
359 {"quickprog", flashcmd_quickprog}, |
61
a10491da8c3a
fc-loadtool flash support: sector table generation implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
60
diff
changeset
|
360 {"sectors", flashcmd_sectors}, |
58
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
361 {0, 0} |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
362 }; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
363 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
364 cmd_flash(argc, argv) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
365 char **argv; |
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 int bank; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
368 struct cmdtab *tp; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
369 |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
370 if (!selected_flash_device) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
371 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
|
372 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
373 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
374 if (argv[0][5] == '2') { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
375 if (selected_flash_device->nbanks < 2) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
376 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
|
377 selected_flash_device->name); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
378 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
379 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
380 bank = 1; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
381 } else |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
382 bank = 0; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
383 for (tp = cmdtab; tp->cmd; tp++) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
384 if (!strcmp(tp->cmd, argv[1])) |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
385 break; |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
386 if (!tp->func) { |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
387 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
|
388 argv[0], argv[1]); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
389 return(-1); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
390 } |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
391 return tp->func(argc, argv, bank); |
1f9302b6f342
fc-loadtool: started flash/flash2 command implementation
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
56
diff
changeset
|
392 } |