1 /***************************************************************************
2 * Copyright (C) 2009 Øyvind Harboe *
3 * oyvind.harboe@zylin.com *
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 ***************************************************************************/
28 static int faux_register_commands(struct command_context_s
*cmd_ctx
);
29 static int faux_flash_bank_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
, struct flash_bank_s
*bank
);
30 static int faux_erase(struct flash_bank_s
*bank
, int first
, int last
);
31 static int faux_protect(struct flash_bank_s
*bank
, int set
, int first
, int last
);
32 static int faux_write(struct flash_bank_s
*bank
, uint8_t *buffer
, uint32_t offset
, uint32_t count
);
33 static int faux_probe(struct flash_bank_s
*bank
);
34 static int faux_protect_check(struct flash_bank_s
*bank
);
35 static int faux_info(struct flash_bank_s
*bank
, char *buf
, int buf_size
);
37 flash_driver_t faux_flash
=
40 .register_commands
= faux_register_commands
,
41 .flash_bank_command
= faux_flash_bank_command
,
43 .protect
= faux_protect
,
46 .auto_probe
= faux_probe
,
47 .erase_check
= default_flash_blank_check
,
48 .protect_check
= faux_protect_check
,
52 typedef struct faux_flash_bank_s
54 struct target_s
*target
;
56 uint32_t start_address
;
59 static const int sectorSize
= 0x10000;
62 /* flash bank faux <base> <size> <chip_width> <bus_width> <target#> <driverPath>
64 static int faux_flash_bank_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
, struct flash_bank_s
*bank
)
66 faux_flash_bank_t
*info
;
70 LOG_WARNING("incomplete flash_bank faux configuration");
71 return ERROR_FLASH_BANK_INVALID
;
74 info
= malloc(sizeof(faux_flash_bank_t
));
77 LOG_ERROR("no memory for flash bank info");
80 info
->memory
= malloc(bank
->size
);
84 LOG_ERROR("no memory for flash bank info");
87 bank
->driver_priv
= info
;
89 /* Use 0x10000 as a fixed sector size. */
92 bank
->num_sectors
= bank
->size
/sectorSize
;
93 bank
->sectors
= malloc(sizeof(flash_sector_t
) * bank
->num_sectors
);
94 for (i
= 0; i
< bank
->num_sectors
; i
++)
96 bank
->sectors
[i
].offset
= offset
;
97 bank
->sectors
[i
].size
= sectorSize
;
98 offset
+= bank
->sectors
[i
].size
;
99 bank
->sectors
[i
].is_erased
= -1;
100 bank
->sectors
[i
].is_protected
= 0;
103 info
->target
= get_target(args
[5]);
104 if (info
->target
== NULL
)
106 LOG_ERROR("target '%s' not defined", args
[5]);
114 static int faux_register_commands(struct command_context_s
*cmd_ctx
)
119 static int faux_erase(struct flash_bank_s
*bank
, int first
, int last
)
121 faux_flash_bank_t
*info
= bank
->driver_priv
;
122 memset(info
->memory
+ first
*sectorSize
, 0xff, sectorSize
*(last
-first
+ 1));
126 static int faux_protect(struct flash_bank_s
*bank
, int set
, int first
, int last
)
128 LOG_USER("set protection sector %d to %d to %s", first
, last
, set
?"on":"off");
132 static int faux_write(struct flash_bank_s
*bank
, uint8_t *buffer
, uint32_t offset
, uint32_t count
)
134 faux_flash_bank_t
*info
= bank
->driver_priv
;
135 memcpy(info
->memory
+ offset
, buffer
, count
);
139 static int faux_protect_check(struct flash_bank_s
*bank
)
144 static int faux_info(struct flash_bank_s
*bank
, char *buf
, int buf_size
)
146 snprintf(buf
, buf_size
, "faux flash driver");
150 static int faux_probe(struct flash_bank_s
*bank
)
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)