1 /***************************************************************************
2 * Copyright (C) 2008 by Kevin McGuire *
3 * Copyright (C) 2008 by Marcel Wijlaars *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
26 #include "replacements.h"
32 #include "algorithm.h"
33 #include "binarybuffer.h"
39 int x7026_flash_bank_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
, struct flash_bank_s
*bank
);
40 int x7026_register_commands(struct command_context_s
*cmd_ctx
);
41 int x7026_erase(struct flash_bank_s
*bank
, int first
, int last
);
42 int x7026_protect(struct flash_bank_s
*bank
, int set
, int first
, int last
);
43 int x7026_write(struct flash_bank_s
*bank
, u8
*buffer
, u32 offset
, u32 count
);
44 int x7026_probe(struct flash_bank_s
*bank
);
45 int x7026_info(struct flash_bank_s
*bank
, char *buf
, int buf_size
);
46 int x7026_protect_check(struct flash_bank_s
*bank
);
47 int x7026_erase_check(struct flash_bank_s
*bank
);
49 #define ADUC7026_FLASH 0xfffff800
50 #define ADUC7026_FLASH_FEESTA (0*4)
51 #define ADUC7026_FLASH_FEEMOD (1*4)
52 #define ADUC7026_FLASH_FEECON (2*4)
53 #define ADUC7026_FLASH_FEEDAT (3*4)
54 #define ADUC7026_FLASH_FEEADR (4*4)
55 #define ADUC7026_FLASH_FEESIGN (5*4)
56 #define ADUC7026_FLASH_FEEPRO (6*4)
57 #define ADUC7026_FLASH_FEEHIDE (7*4)
68 } ADUC7026_FLASH_MMIO
;
75 flash_driver_t x7026_flash
=
78 .register_commands
= x7026_register_commands
,
79 .flash_bank_command
= x7026_flash_bank_command
,
81 .protect
= x7026_protect
,
84 .auto_probe
= x7026_probe
,
85 .erase_check
= x7026_erase_check
,
86 .protect_check
= x7026_protect_check
,
90 int x7026_register_commands(struct command_context_s
*cmd_ctx
)
92 printf("x7026_register_commands not implemented yet.\n");
96 /* flash bank str7x <base> <size> 0 0 <target#> */
97 int x7026_flash_bank_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
, struct flash_bank_s
*bank
)
103 LOG_WARNING("incomplete flash_bank x7026 configuration");
104 return ERROR_FLASH_BANK_INVALID
;
107 nbank
= malloc(sizeof(X7026_BANK
));
108 /* just warn that we are used to normally using 0x80000 */
109 if(bank
->base
!= 0x80000)
111 LOG_WARNING("Default base address is 0x80000 on the ADuC7026!");
114 bank
->driver_priv
= nbank
;
118 int x7026_protect_check(struct flash_bank_s
*bank
)
120 printf("x7026_protect_check not implemented yet.\n");
124 int x7026_erase(struct flash_bank_s
*bank
, int first
, int last
)
129 target_t
*target
= bank
->target
;
132 if((first
| last
) == 0)
134 printf("performing mass erase.\n");
135 target_write_u32(target
, ADUC7026_FLASH
+ ADUC7026_FLASH_FEEDAT
, 0x3cff);
136 target_write_u32(target
, ADUC7026_FLASH
+ ADUC7026_FLASH_FEEADR
, 0xffc3);
137 target_read_u32(target
, ADUC7026_FLASH
+ ADUC7026_FLASH_FEEMOD
, &v
);
138 target_write_u32(target
, ADUC7026_FLASH
+ ADUC7026_FLASH_FEEMOD
, v
| 0x8);
139 target_write_u32(target
, ADUC7026_FLASH
+ ADUC7026_FLASH_FEECON
, 0x06);
140 for(v
= 0x4; v
& 0x4;
141 target_read_u32(target
, ADUC7026_FLASH
+ ADUC7026_FLASH_FEESTA
, &v
));
145 printf("mass erase failed.\n");
148 printf("mass erase successful.\n");
152 count
= last
- first
;
153 for(x
= 0; x
< (unsigned int)count
; ++x
)
155 target_write_u32(target
, ADUC7026_FLASH
+ ADUC7026_FLASH_FEEADR
, bank
->base
+ first
* 512 + x
* 512);
156 target_write_u32(target
, ADUC7026_FLASH
+ ADUC7026_FLASH_FEECON
, 0x05);
157 for(v
= 0x4; v
& 0x4; target_read_u32(target
, ADUC7026_FLASH
+ ADUC7026_FLASH_FEESTA
, &v
));
160 printf("erase failed for page address %x\n", bank
->base
+ first
* 512 + x
* 512);
163 printf("erased page address %x\n", bank
->base
+ first
* 512 + x
* 512);
168 int x7026_protect(struct flash_bank_s
*bank
, int set
, int first
, int last
)
170 printf("x7026_protect not implemented yet.\n");
174 int x7026_write(struct flash_bank_s
*bank
, u8
*buffer
, u32 offset
, u32 count
)
178 target_t
*target
= bank
->target
;
179 for(x
= 0; x
< count
; x
+= 2)
181 target_write_u32(target
, ADUC7026_FLASH
+ ADUC7026_FLASH_FEEADR
, offset
+ x
);
182 /* if we able to encounter a single byte instead of a word */
185 target_write_u32(target
, ADUC7026_FLASH
+ ADUC7026_FLASH_FEEDAT
, buffer
[x
]);
187 target_write_u32(target
, ADUC7026_FLASH
+ ADUC7026_FLASH_FEEDAT
, buffer
[x
] | (buffer
[x
+1] << 8));
189 target_write_u32(target
, ADUC7026_FLASH
+ ADUC7026_FLASH_FEECON
, 0x02);
190 for(v
= 0x4; v
& 0x4; target_read_u32(target
, ADUC7026_FLASH
+ ADUC7026_FLASH_FEESTA
, &v
));
193 printf("single write failed for address %x.\n", offset
+ x
);
196 printf("single write for address %x.\n", offset
+ x
);
201 int x7026_probe(struct flash_bank_s
*bank
)
203 printf("x7026_probe not implemented yet.\n");
207 int x7026_info(struct flash_bank_s
*bank
, char *buf
, int buf_size
)
209 snprintf(buf
, buf_size
, "x7026 flash driver info" );
213 int x7026_erase_check(struct flash_bank_s
*bank
)
215 printf("x7026_erase_check not implemented yet.\n");
Linking to existing account procedure
If you already have an account and want to add another login method
you
MUST first sign in with your existing account and
then change URL to read
https://review.openocd.org/login/?link
to get to this page again but this time it'll work for linking. Thank you.
SSH host keys fingerprints
1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=.. |
|+o.. . |
|*.o . . |
|+B . . . |
|Bo. = o S |
|Oo.+ + = |
|oB=.* = . o |
| =+=.+ + E |
|. .=o . o |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)