kopia lustrzana https://github.com/stlink-org/stlink
flash: added easy way to reset the target (#505)
* flash: added easy way to reset the target st-flash does now have a 'reset' command makes it easy to reset the Target * Doc: added man page entry for reset command of st-flashpull/511/head
rodzic
9c05837566
commit
7ab464527e
|
@ -32,6 +32,8 @@ read *FILE* *ADDR* *SIZE*
|
|||
erase
|
||||
: Perform a mass erasing of the device firmware
|
||||
|
||||
reset
|
||||
: Reset the target
|
||||
|
||||
# OPTIONS
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#define DEBUG_LOG_LEVEL 100
|
||||
#define STND_LOG_LEVEL 50
|
||||
|
||||
enum flash_cmd {FLASH_CMD_NONE = 0, FLASH_CMD_WRITE = 1, FLASH_CMD_READ = 2, FLASH_CMD_ERASE = 3};
|
||||
enum flash_cmd {FLASH_CMD_NONE = 0, FLASH_CMD_WRITE = 1, FLASH_CMD_READ = 2, FLASH_CMD_ERASE = 3, CMD_RESET = 4};
|
||||
enum flash_format {FLASH_FORMAT_BINARY = 0, FLASH_FORMAT_IHEX = 1};
|
||||
struct flash_opts
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@ static void usage(void)
|
|||
puts("stlinkv1 command line: ./st-flash [--debug] /dev/sgX erase");
|
||||
puts("stlinkv2 command line: ./st-flash [--debug] [--reset] [--serial <serial>] [--format <format>] {read|write} <path> <addr> <size>");
|
||||
puts("stlinkv2 command line: ./st-flash [--debug] [--serial <serial>] erase");
|
||||
puts("stlinkv2 command line: ./st-flash [--debug] [--serial <serial>] reset");
|
||||
puts(" Use hex format for addr, <serial> and <size>.");
|
||||
puts(" Format may be 'binary' (default) or 'ihex', although <addr> must be specified for binary format only.");
|
||||
puts(" ./st-flash [--version]");
|
||||
|
@ -168,6 +169,17 @@ int main(int ac, char** av)
|
|||
printf("stlink_erase_flash_mass() == -1\n");
|
||||
goto on_error;
|
||||
}
|
||||
} else if (o.cmd == CMD_RESET)
|
||||
{
|
||||
if (stlink_jtag_reset(sl, 2)) {
|
||||
printf("Failed to reset JTAG\n");
|
||||
goto on_error;
|
||||
}
|
||||
|
||||
if (stlink_reset(sl)) {
|
||||
printf("Failed to reset device\n");
|
||||
goto on_error;
|
||||
}
|
||||
}
|
||||
else /* read */
|
||||
{
|
||||
|
|
|
@ -99,6 +99,10 @@ int flash_get_opts(struct flash_opts* o, int ac, char** av)
|
|||
if (o->cmd != FLASH_CMD_NONE) return -1;
|
||||
o->cmd = FLASH_CMD_WRITE;
|
||||
}
|
||||
else if (strcmp(av[0], "reset") == 0) {
|
||||
if (o->cmd != FLASH_CMD_NONE) return -1;
|
||||
o->cmd = CMD_RESET;
|
||||
}
|
||||
else if(starts_with(av[0], "/dev/")) {
|
||||
if (o->devname) return -1;
|
||||
o->devname = av[0];
|
||||
|
|
Ładowanie…
Reference in New Issue