X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fflash%2Fflash.c;h=e910e42f9bc5e45026589e674f77fb691a4bcdd5;hp=7023ef97a9c3e610a92bae8380d8748c941a7fef;hb=6512e5e36b067ae458cb7f6a9fdfb08d38da3583;hpb=3f8aa3cb035a97988fd38dfb08db5a4224f4b591 diff --git a/src/flash/flash.c b/src/flash/flash.c index 7023ef97a9..e910e42f9b 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -30,7 +30,7 @@ #include "flash.h" #include "common.h" #include "image.h" -#include "time_support.h" +#include static int flash_write_unlock(struct target *target, struct image *image, uint32_t *written, int erase, bool unlock); @@ -1375,6 +1375,23 @@ int flash_init_drivers(struct command_context *cmd_ctx) return register_commands(cmd_ctx, parent, flash_exec_command_handlers); } +COMMAND_HANDLER(handle_flash_init_command) +{ + if (CMD_ARGC != 0) + return ERROR_COMMAND_SYNTAX_ERROR; + + static bool flash_initialized = false; + if (flash_initialized) + { + LOG_INFO("'flash init' has already been called"); + return ERROR_OK; + } + flash_initialized = true; + + LOG_DEBUG("Initializing flash devices..."); + return flash_init_drivers(CMD_CTX); +} + static const struct command_registration flash_config_command_handlers[] = { { .name = "bank", @@ -1386,6 +1403,12 @@ static const struct command_registration flash_config_command_handlers[] = { .help = "Define a new bank with the given name, " "using the specified NOR flash driver.", }, + { + .name = "init", + .mode = COMMAND_CONFIG, + .handler = &handle_flash_init_command, + .help = "initialize flash devices", + }, { .name = "banks", .mode = COMMAND_ANY,