kopia lustrzana https://github.com/stlink-org/stlink
Porównaj commity
9 Commity
20c4ae1e0f
...
40ee5f4bd1
Autor | SHA1 | Data |
---|---|---|
nightwalker-87 | 40ee5f4bd1 | |
nightwalker-87 | 1ee7f6b6c0 | |
nightwalker-87 | 4f3761b6bc | |
nightwalker-87 | 95862cc687 | |
nightwalker-87 | 710e1d3c3b | |
nightwalker-87 | a1fc8b70b1 | |
murray | 2d483db866 | |
murray | 7a93f7a24d | |
murray | 9f84dcdef8 |
|
@ -3,7 +3,7 @@
|
|||
###
|
||||
|
||||
cmake_minimum_required(VERSION 3.10.2)
|
||||
cmake_policy(SET CMP0153 NEW)
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules)
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
|
||||
|
|
|
@ -44,25 +44,39 @@ static void cleanup(int32_t signum) {
|
|||
}
|
||||
|
||||
static void usage(void) {
|
||||
puts("command line: ./st-flash [--debug] [--reset] [--connect-under-reset] [--hot-plug] [--opt] [--serial <serial>] [--format <format>] [--flash=<fsize>] [--freq=<kHz>] [--area=<area>] {read|write} [path] [addr] [size]");
|
||||
puts("command line: ./st-flash [--debug] [--connect-under-reset] [--hot-plug] [--freq=<kHz>] [--serial <serial>] erase [addr] [size]");
|
||||
puts("command line: ./st-flash [--debug] [--freq=<kHz>] [--serial <serial>] reset");
|
||||
puts(" <addr>, <serial> and <size>: Use hex format.");
|
||||
puts(" <fsize>: Use decimal, octal or hex (prefix 0xXXX) format, optionally followed by k=KB, or m=MB (eg. --flash=128k)");
|
||||
puts(" <format>: Can be 'binary' (default) or 'ihex', although <addr> must be specified for binary format only.");
|
||||
puts(" <area>: Can be 'main' (default), 'system', 'otp', 'optcr', 'optcr1', 'option' or 'option_boot_add'");
|
||||
puts("print tool version info: ./st-flash [--version]");
|
||||
puts("example read option byte: ./st-flash --area=option read [path] [size]");
|
||||
puts("example write option byte: ./st-flash --area=option write 0xXXXXXXXX");
|
||||
puts("On selected targets:");
|
||||
puts("example read boot_add option byte: ./st-flash --area=option_boot_add read");
|
||||
puts("example write boot_add option byte: ./st-flash --area=option_boot_add write 0xXXXXXXXX");
|
||||
puts("example read option control register byte: ./st-flash --area=optcr read");
|
||||
puts("example write option control register1 byte: ./st-flash --area=optcr write 0xXXXXXXXX");
|
||||
puts("example read option control register1 byte: ./st-flash --area=optcr1 read");
|
||||
puts("example write option control register1 byte: ./st-flash --area=optcr1 write 0xXXXXXXXX");
|
||||
puts("example read OTP area: ./st-flash --area=otp read [path]");
|
||||
puts("example write OTP area: ./st-flash --area=otp write [path] 0xXXXXXXXX");
|
||||
puts("usage: st-flash [options] read [file] [addr] [size]");
|
||||
puts(" st-flash [options] write <file> [addr] [size]");
|
||||
puts(" st-flash [options] write <value>");
|
||||
puts(" st-flash [options] erase <addr> <size>");
|
||||
puts(" st-flash [options] reset");
|
||||
puts("");
|
||||
puts("options:");
|
||||
puts(" --freq <kHz> Frequency of JTAG/SWD, default 1800kHz.");
|
||||
puts(" --serial <serial> STLink device to use.");
|
||||
puts(" --connect-under-reset Pull reset low while connecting.");
|
||||
puts(" --hot-plug Connect without reset.");
|
||||
puts(" --reset Reset after writing.");
|
||||
puts(" --format {binary|ihex} Format of file to read or write. When writing");
|
||||
puts(" with ihex specifying addr is not needed.");
|
||||
puts(" --flash <size> Specify size of flash, e.g. 128k, 1M.");
|
||||
puts(" --area <area> Area to access, one of: main(default), system,");
|
||||
puts(" otp, option, option_boot_add, optcr, optcr1.");
|
||||
puts(" --opt Skip writing empty bytes at the tail end.");
|
||||
puts(" --debug Output extra debug information.");
|
||||
puts(" --version Print version information.");
|
||||
puts(" --help Show this help.");
|
||||
puts("");
|
||||
puts("examples:");
|
||||
puts(" st-flash --area=option read [file] [size]");
|
||||
puts(" st-flash --area=option write 0xXXXXXXXX");
|
||||
puts(" st-flash --area=option_boot_add read");
|
||||
puts(" st-flash --area=option_boot_add write 0xXXXXXXXX");
|
||||
puts(" st-flash --area=optcr read");
|
||||
puts(" st-flash --area=optcr write 0xXXXXXXXX");
|
||||
puts(" st-flash --area=optcr1 read");
|
||||
puts(" st-flash --area=optcr1 write 0xXXXXXXXX");
|
||||
puts(" st-flash --area=otp read <file>");
|
||||
puts(" st-flash --area=otp write <file> 0xXXXXXXXX");
|
||||
}
|
||||
|
||||
int32_t main(int32_t ac, char** av) {
|
||||
|
@ -70,14 +84,19 @@ int32_t main(int32_t ac, char** av) {
|
|||
struct flash_opts o;
|
||||
int32_t err = -1;
|
||||
uint8_t * mem = NULL;
|
||||
int32_t getopt_ret;
|
||||
|
||||
o.size = 0;
|
||||
o.connect = CONNECT_NORMAL;
|
||||
|
||||
if (flash_get_opts(&o, ac - 1, av + 1) == -1) {
|
||||
getopt_ret = flash_get_opts(&o, ac - 1, av + 1);
|
||||
if (getopt_ret == -1) {
|
||||
printf("invalid command line\n");
|
||||
usage();
|
||||
return (-1);
|
||||
} else if (getopt_ret == 1) {
|
||||
usage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("st-flash %s\n", STLINK_VERSION);
|
||||
|
|
|
@ -98,6 +98,8 @@ int32_t flash_get_opts(struct flash_opts* o, int32_t ac, char** av) {
|
|||
if (strcmp(av[0], "--version") == 0) {
|
||||
printf("v%s\n", STLINK_VERSION);
|
||||
exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(av[0], "--help") == 0 || strcmp(av[0], "-h") == 0) {
|
||||
return 1;
|
||||
} else if (strcmp(av[0], "--debug") == 0) {
|
||||
o->log_level = DEBUG_LOG_LEVEL;
|
||||
} else if (strcmp(av[0], "--opt") == 0) {
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <win32_socket.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <sys/poll.h>
|
||||
#include <poll.h>
|
||||
#endif
|
||||
|
||||
#include "gdb-remote.h"
|
||||
|
|
|
@ -750,8 +750,8 @@ int32_t stlink_flashloader_write(stlink_t *sl, flash_loader_t *fl, stm32_addr_t
|
|||
sl->flash_type == STM32_FLASH_TYPE_C0) {
|
||||
|
||||
if (sl->flash_type == STM32_FLASH_TYPE_L5_U5_H5 && (len % 16)) {
|
||||
WLOG("Data size is aligned to 16 byte");
|
||||
len += 16 - len%16;
|
||||
WLOG("Aligning data size to 16 bytes\n");
|
||||
len += 16 - len % 16;
|
||||
}
|
||||
DLOG("Starting %3u page write\n", len / sl->flash_pgsz);
|
||||
for (off = 0; off < len; off += sizeof(uint32_t)) {
|
||||
|
|
Ładowanie…
Reference in New Issue