1 // SPDX-License-Identifier: GPL-2.0-or-later
3 /***************************************************************************
4 * Copyright (C) 2009 Øyvind Harboe *
5 * oyvind.harboe@zylin.com *
6 ***************************************************************************/
13 #include <target/image.h>
16 struct faux_flash_bank
{
17 struct target
*target
;
19 uint32_t start_address
;
22 static const int sector_size
= 0x10000;
25 /* flash bank faux <base> <size> <chip_width> <bus_width> <target#> <driverPath>
27 FLASH_BANK_COMMAND_HANDLER(faux_flash_bank_command
)
29 struct faux_flash_bank
*info
;
32 return ERROR_COMMAND_SYNTAX_ERROR
;
34 info
= malloc(sizeof(struct faux_flash_bank
));
36 LOG_ERROR("no memory for flash bank info");
39 info
->memory
= malloc(bank
->size
);
42 LOG_ERROR("no memory for flash bank info");
45 bank
->driver_priv
= info
;
47 /* Use 0x10000 as a fixed sector size. */
49 bank
->num_sectors
= bank
->size
/sector_size
;
50 bank
->sectors
= malloc(sizeof(struct flash_sector
) * bank
->num_sectors
);
51 for (unsigned int i
= 0; i
< bank
->num_sectors
; i
++) {
52 bank
->sectors
[i
].offset
= offset
;
53 bank
->sectors
[i
].size
= sector_size
;
54 offset
+= bank
->sectors
[i
].size
;
55 bank
->sectors
[i
].is_erased
= -1;
56 bank
->sectors
[i
].is_protected
= 0;
59 info
->target
= get_target(CMD_ARGV
[5]);
61 LOG_ERROR("target '%s' not defined", CMD_ARGV
[5]);
69 static int faux_erase(struct flash_bank
*bank
, unsigned int first
,
72 struct faux_flash_bank
*info
= bank
->driver_priv
;
73 memset(info
->memory
+ first
*sector_size
, 0xff, sector_size
*(last
-first
+ 1));
77 static int faux_write(struct flash_bank
*bank
, const uint8_t *buffer
, uint32_t offset
, uint32_t count
)
79 struct faux_flash_bank
*info
= bank
->driver_priv
;
80 memcpy(info
->memory
+ offset
, buffer
, count
);
84 static int faux_info(struct flash_bank
*bank
, struct command_invocation
*cmd
)
86 command_print_sameline(cmd
, "faux flash driver");
90 static int faux_probe(struct flash_bank
*bank
)
95 static const struct command_registration faux_command_handlers
[] = {
99 .help
= "faux flash command group",
100 .chain
= hello_command_handlers
,
103 COMMAND_REGISTRATION_DONE
106 const struct flash_driver faux_flash
= {
108 .commands
= faux_command_handlers
,
109 .flash_bank_command
= faux_flash_bank_command
,
112 .read
= default_flash_read
,
114 .auto_probe
= faux_probe
,
115 .erase_check
= default_flash_blank_check
,
117 .free_driver_priv
= default_flash_free_driver_priv
,
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)