1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath <Dominic.Rath@gmx.de> *
3 * Copyright (C) 2007,2008 Øyvind Harboe <oyvind.harboe@zylin.com> *
4 * Copyright (C) 2008 by Spencer Oliver <spen@spen-soft.co.uk> *
5 * Copyright (C) 2009 Zachary T Welch <zw@superlucidity.net> *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the *
19 * Free Software Foundation, Inc., *
20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21 ***************************************************************************/
27 COMMAND_HANDLER(handle_flash_bank_command
)
31 LOG_ERROR("usage: flash bank <name> <driver> "
32 "<base> <size> <chip_width> <bus_width>");
33 return ERROR_COMMAND_SYNTAX_ERROR
;
35 // save bank name and advance arguments for compatibility
36 const char *bank_name
= *CMD_ARGV
++;
39 struct target
*target
;
40 if ((target
= get_target(CMD_ARGV
[5])) == NULL
)
42 LOG_ERROR("target '%s' not defined", CMD_ARGV
[5]);
46 const char *driver_name
= CMD_ARGV
[0];
47 struct flash_driver
*driver
= flash_driver_find_by_name(driver_name
);
50 /* no matching flash driver found */
51 LOG_ERROR("flash driver '%s' not found", driver_name
);
55 /* register flash specific commands */
56 if (NULL
!= driver
->commands
)
58 int retval
= register_commands(CMD_CTX
, NULL
,
60 if (ERROR_OK
!= retval
)
62 LOG_ERROR("couldn't register '%s' commands",
68 struct flash_bank
*c
= malloc(sizeof(*c
));
69 c
->name
= strdup(bank_name
);
72 c
->driver_priv
= NULL
;
73 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[1], c
->base
);
74 COMMAND_PARSE_NUMBER(u32
, CMD_ARGV
[2], c
->size
);
75 COMMAND_PARSE_NUMBER(int, CMD_ARGV
[3], c
->chip_width
);
76 COMMAND_PARSE_NUMBER(int, CMD_ARGV
[4], c
->bus_width
);
82 retval
= CALL_COMMAND_HANDLER(driver
->flash_bank_command
, c
);
83 if (ERROR_OK
!= retval
)
85 LOG_ERROR("'%s' driver rejected flash bank at 0x%8.8" PRIx32
,
86 driver_name
, c
->base
);
96 static int jim_flash_banks(Jim_Interp
*interp
, int argc
, Jim_Obj
*const *argv
)
99 Jim_WrongNumArgs(interp
, 1, argv
, "no arguments to flash_banks command");
103 Jim_Obj
*list
= Jim_NewListObj(interp
, NULL
, 0);
105 for (struct flash_bank
*p
= flash_bank_list(); p
; p
= p
->next
)
107 Jim_Obj
*elem
= Jim_NewListObj(interp
, NULL
, 0);
109 Jim_ListAppendElement(interp
, elem
, Jim_NewStringObj(interp
, "name", -1));
110 Jim_ListAppendElement(interp
, elem
, Jim_NewStringObj(interp
, p
->driver
->name
, -1));
111 Jim_ListAppendElement(interp
, elem
, Jim_NewStringObj(interp
, "base", -1));
112 Jim_ListAppendElement(interp
, elem
, Jim_NewIntObj(interp
, p
->base
));
113 Jim_ListAppendElement(interp
, elem
, Jim_NewStringObj(interp
, "size", -1));
114 Jim_ListAppendElement(interp
, elem
, Jim_NewIntObj(interp
, p
->size
));
115 Jim_ListAppendElement(interp
, elem
, Jim_NewStringObj(interp
, "bus_width", -1));
116 Jim_ListAppendElement(interp
, elem
, Jim_NewIntObj(interp
, p
->bus_width
));
117 Jim_ListAppendElement(interp
, elem
, Jim_NewStringObj(interp
, "chip_width", -1));
118 Jim_ListAppendElement(interp
, elem
, Jim_NewIntObj(interp
, p
->chip_width
));
120 Jim_ListAppendElement(interp
, list
, elem
);
123 Jim_SetResult(interp
, list
);
129 COMMAND_HANDLER(handle_flash_init_command
)
132 return ERROR_COMMAND_SYNTAX_ERROR
;
134 static bool flash_initialized
= false;
135 if (flash_initialized
)
137 LOG_INFO("'flash init' has already been called");
140 flash_initialized
= true;
142 LOG_DEBUG("Initializing flash devices...");
143 return flash_init_drivers(CMD_CTX
);
146 static const struct command_registration flash_config_command_handlers
[] = {
149 .handler
= &handle_flash_bank_command
,
150 .mode
= COMMAND_CONFIG
,
151 .usage
= "<name> <driver> <base> <size> "
152 "<chip_width> <bus_width> <target> "
153 "[driver_options ...]",
154 .help
= "Define a new bank with the given name, "
155 "using the specified NOR flash driver.",
159 .mode
= COMMAND_CONFIG
,
160 .handler
= &handle_flash_init_command
,
161 .help
= "initialize flash devices",
166 .jim_handler
= &jim_flash_banks
,
167 .help
= "return information about the flash banks",
169 COMMAND_REGISTRATION_DONE
171 static const struct command_registration flash_command_handlers
[] = {
175 .help
= "NOR flash command group",
176 .chain
= flash_config_command_handlers
,
178 COMMAND_REGISTRATION_DONE
181 int flash_register_commands(struct command_context
*cmd_ctx
)
183 return register_commands(cmd_ctx
, NULL
, flash_command_handlers
);
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)