Merge commit 'f3790b90e5ecf44525dc05f05a4e72f74baea411' into sam-update
This commit is contained in:
commit
63449912e2
@ -375,11 +375,7 @@ static bool cmd_target_power(target *t, int argc, const char **argv)
|
|||||||
#ifdef PLATFORM_HAS_TRACESWO
|
#ifdef PLATFORM_HAS_TRACESWO
|
||||||
static bool cmd_traceswo(target *t, int argc, const char **argv)
|
static bool cmd_traceswo(target *t, int argc, const char **argv)
|
||||||
{
|
{
|
||||||
#if defined(STM32L0) || defined(STM32F3) || defined(STM32F4)
|
extern char *serial_no;
|
||||||
extern char serial_no[13];
|
|
||||||
#else
|
|
||||||
extern char serial_no[9];
|
|
||||||
#endif
|
|
||||||
(void)t;
|
(void)t;
|
||||||
#if TRACESWO_PROTOCOL == 2
|
#if TRACESWO_PROTOCOL == 2
|
||||||
uint32_t baudrate = SWO_DEFAULT_BAUD;
|
uint32_t baudrate = SWO_DEFAULT_BAUD;
|
||||||
|
@ -120,12 +120,13 @@ static void cl_help(char **argv, BMP_CL_OPTIONS_t *opt)
|
|||||||
printf("\t-h\t\t: This help.\n");
|
printf("\t-h\t\t: This help.\n");
|
||||||
printf("\t-v[1|2]\t\t: Increasing verbosity\n");
|
printf("\t-v[1|2]\t\t: Increasing verbosity\n");
|
||||||
printf("\t-d \"path\"\t: Use serial device at \"path\"\n");
|
printf("\t-d \"path\"\t: Use serial device at \"path\"\n");
|
||||||
|
printf("\t-P <num>\t: Use device found as <num>");
|
||||||
printf("\t-s \"string\"\t: Use dongle with (partial) "
|
printf("\t-s \"string\"\t: Use dongle with (partial) "
|
||||||
"serial number \"string\"\n");
|
"serial number \"string\"\n");
|
||||||
printf("\t-c \"string\"\t: Use ftdi dongle with type \"string\"\n");
|
printf("\t-c \"string\"\t: Use ftdi dongle with type \"string\"\n");
|
||||||
printf("\t-C\t\t: Connect under reset\n");
|
|
||||||
printf("\t-n\t\t: Exit immediate if no device found\n");
|
printf("\t-n\t\t: Exit immediate if no device found\n");
|
||||||
printf("\tRun mode related options:\n");
|
printf("\tRun mode related options:\n");
|
||||||
|
printf("\t-C\t\t: Connect under reset\n");
|
||||||
printf("\t-t\t\t: Scan SWD, with no target found scan jtag and exit\n");
|
printf("\t-t\t\t: Scan SWD, with no target found scan jtag and exit\n");
|
||||||
printf("\t-E\t\t: Erase flash until flash end or for given size\n");
|
printf("\t-E\t\t: Erase flash until flash end or for given size\n");
|
||||||
printf("\t-V\t\t: Verify flash against binary file\n");
|
printf("\t-V\t\t: Verify flash against binary file\n");
|
||||||
@ -149,7 +150,7 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv)
|
|||||||
opt->opt_target_dev = 1;
|
opt->opt_target_dev = 1;
|
||||||
opt->opt_flash_start = 0x08000000;
|
opt->opt_flash_start = 0x08000000;
|
||||||
opt->opt_flash_size = 16 * 1024 *1024;
|
opt->opt_flash_size = 16 * 1024 *1024;
|
||||||
while((c = getopt(argc, argv, "Ehv::d:s:c:CnN:tVta:S:jprR")) != -1) {
|
while((c = getopt(argc, argv, "Ehv::d:s:I:c:CnN:tVta:S:jpP:rR")) != -1) {
|
||||||
switch(c) {
|
switch(c) {
|
||||||
case 'c':
|
case 'c':
|
||||||
if (optarg)
|
if (optarg)
|
||||||
@ -181,6 +182,10 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv)
|
|||||||
if (optarg)
|
if (optarg)
|
||||||
opt->opt_serial = optarg;
|
opt->opt_serial = optarg;
|
||||||
break;
|
break;
|
||||||
|
case 'I':
|
||||||
|
if (optarg)
|
||||||
|
opt->opt_ident_string = optarg;
|
||||||
|
break;
|
||||||
case 'E':
|
case 'E':
|
||||||
opt->opt_mode = BMP_MODE_FLASH_ERASE;
|
opt->opt_mode = BMP_MODE_FLASH_ERASE;
|
||||||
break;
|
break;
|
||||||
@ -207,6 +212,10 @@ void cl_init(BMP_CL_OPTIONS_t *opt, int argc, char **argv)
|
|||||||
if (optarg)
|
if (optarg)
|
||||||
opt->opt_target_dev = strtol(optarg, NULL, 0);
|
opt->opt_target_dev = strtol(optarg, NULL, 0);
|
||||||
break;
|
break;
|
||||||
|
case 'P':
|
||||||
|
if (optarg)
|
||||||
|
opt->opt_position = atoi(optarg);
|
||||||
|
break;
|
||||||
case 'S':
|
case 'S':
|
||||||
if (optarg) {
|
if (optarg) {
|
||||||
char *endptr;
|
char *endptr;
|
||||||
@ -276,8 +285,6 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||||||
} else {
|
} else {
|
||||||
target_foreach(display_target, NULL);
|
target_foreach(display_target, NULL);
|
||||||
}
|
}
|
||||||
if (opt->opt_mode == BMP_MODE_TEST)
|
|
||||||
return 0;
|
|
||||||
if (opt->opt_target_dev > num_targets) {
|
if (opt->opt_target_dev > num_targets) {
|
||||||
DEBUG("Given target nummer %d not available\n", opt->opt_target_dev);
|
DEBUG("Given target nummer %d not available\n", opt->opt_target_dev);
|
||||||
return res;
|
return res;
|
||||||
@ -287,6 +294,44 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||||||
DEBUG("Can not attach to target %d\n", opt->opt_target_dev);
|
DEBUG("Can not attach to target %d\n", opt->opt_target_dev);
|
||||||
goto target_detach;
|
goto target_detach;
|
||||||
}
|
}
|
||||||
|
if (opt->opt_mode == BMP_MODE_TEST) {
|
||||||
|
char map [1024], *p = map;
|
||||||
|
if (target_mem_map(t, map, sizeof(map))) {
|
||||||
|
while (*p && (*p == '<')) {
|
||||||
|
unsigned int start, size;
|
||||||
|
char *res;
|
||||||
|
int match;
|
||||||
|
match = strncmp(p, "<memory-map>", strlen("<memory-map>"));
|
||||||
|
if (!match) {
|
||||||
|
p += strlen("<memory-map>");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
match = strncmp(p, "<memory type=\"flash\" ", strlen("<memory type=\"flash\" "));
|
||||||
|
if (!match) {
|
||||||
|
unsigned int blocksize;
|
||||||
|
if (sscanf(p, "<memory type=\"flash\" start=\"%x\" length=\"%x\">"
|
||||||
|
"<property name=\"blocksize\">%x</property></memory>",
|
||||||
|
&start, &size, &blocksize))
|
||||||
|
printf("Flash Start: 0x%08x, length %#9x, blocksize %#8x\n",
|
||||||
|
start, size, blocksize);
|
||||||
|
res = strstr(p, "</memory>");
|
||||||
|
p = res + strlen("</memory>");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
match = strncmp(p, "<memory type=\"ram\" ", strlen("<memory type=\"ram\" "));
|
||||||
|
if (!match) {
|
||||||
|
if (sscanf(p, "<memory type=\"ram\" start=\"%x\" length=\"%x\"/",
|
||||||
|
&start, &size))
|
||||||
|
printf("Ram Start: 0x%08x, length %#9x\n", start, size);
|
||||||
|
res = strstr(p, "/>");
|
||||||
|
p = res + strlen("/>");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
goto target_detach;
|
||||||
|
}
|
||||||
int read_file = -1;
|
int read_file = -1;
|
||||||
if ((opt->opt_mode == BMP_MODE_FLASH_WRITE) ||
|
if ((opt->opt_mode == BMP_MODE_FLASH_WRITE) ||
|
||||||
(opt->opt_mode == BMP_MODE_FLASH_VERIFY)) {
|
(opt->opt_mode == BMP_MODE_FLASH_VERIFY)) {
|
||||||
@ -297,7 +342,7 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||||||
}
|
}
|
||||||
} else if (opt->opt_mode == BMP_MODE_FLASH_READ) {
|
} else if (opt->opt_mode == BMP_MODE_FLASH_READ) {
|
||||||
/* Open as binary */
|
/* Open as binary */
|
||||||
read_file = open(opt->opt_flash_file, O_CREAT | O_RDWR | O_BINARY,
|
read_file = open(opt->opt_flash_file, O_TRUNC | O_CREAT | O_RDWR | O_BINARY,
|
||||||
S_IRUSR | S_IWUSR);
|
S_IRUSR | S_IWUSR);
|
||||||
if (read_file == -1) {
|
if (read_file == -1) {
|
||||||
printf("Error opening flashfile %s for read: %s\n",
|
printf("Error opening flashfile %s for read: %s\n",
|
||||||
@ -323,6 +368,7 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||||||
} else if (opt->opt_mode == BMP_MODE_FLASH_WRITE) {
|
} else if (opt->opt_mode == BMP_MODE_FLASH_WRITE) {
|
||||||
DEBUG("Erase %zu bytes at 0x%08" PRIx32 "\n", map.size,
|
DEBUG("Erase %zu bytes at 0x%08" PRIx32 "\n", map.size,
|
||||||
opt->opt_flash_start);
|
opt->opt_flash_start);
|
||||||
|
uint32_t start_time = platform_time_ms();
|
||||||
unsigned int erased = target_flash_erase(t, opt->opt_flash_start,
|
unsigned int erased = target_flash_erase(t, opt->opt_flash_start,
|
||||||
map.size);
|
map.size);
|
||||||
if (erased) {
|
if (erased) {
|
||||||
@ -343,9 +389,12 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||||||
}
|
}
|
||||||
target_flash_done(t);
|
target_flash_done(t);
|
||||||
target_reset(t);
|
target_reset(t);
|
||||||
|
uint32_t end_time = platform_time_ms();
|
||||||
|
printf("Flash Write succeeded for %d bytes, %8.3f kiB/s\n",
|
||||||
|
(int)map.size, (((map.size * 1.0)/(end_time - start_time))));
|
||||||
} else {
|
} else {
|
||||||
#define WORKSIZE 1024
|
#define WORKSIZE 1024
|
||||||
uint8_t *data = malloc(WORKSIZE);
|
uint8_t *data = alloca(WORKSIZE);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
printf("Can not malloc memory for flash read/verify operation\n");
|
printf("Can not malloc memory for flash read/verify operation\n");
|
||||||
return res;
|
return res;
|
||||||
@ -359,6 +408,7 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||||||
map.size;
|
map.size;
|
||||||
int bytes_read = 0;
|
int bytes_read = 0;
|
||||||
void *flash = map.data;
|
void *flash = map.data;
|
||||||
|
uint32_t start_time = platform_time_ms();
|
||||||
while (size) {
|
while (size) {
|
||||||
int worksize = (size > WORKSIZE) ? WORKSIZE : size;
|
int worksize = (size > WORKSIZE) ? WORKSIZE : size;
|
||||||
int n_read = target_mem_read(t, data, flash_src, worksize);
|
int n_read = target_mem_read(t, data, flash_src, worksize);
|
||||||
@ -396,9 +446,11 @@ int cl_execute(BMP_CL_OPTIONS_t *opt)
|
|||||||
if (size <= 0)
|
if (size <= 0)
|
||||||
res = 0;
|
res = 0;
|
||||||
}
|
}
|
||||||
|
uint32_t end_time = platform_time_ms();
|
||||||
if (read_file != -1)
|
if (read_file != -1)
|
||||||
close(read_file);
|
close(read_file);
|
||||||
printf("Read/Verifed succeeded for %d bytes\n", bytes_read);
|
printf("Read/Verified succeeded for %d bytes, %8.3f kiB/s\n",
|
||||||
|
bytes_read, (((bytes_read * 1.0)/(end_time - start_time))));
|
||||||
}
|
}
|
||||||
free_map:
|
free_map:
|
||||||
if (map.size)
|
if (map.size)
|
||||||
|
@ -43,6 +43,8 @@ typedef struct BMP_CL_OPTIONS_s {
|
|||||||
char *opt_flash_file;
|
char *opt_flash_file;
|
||||||
char *opt_device;
|
char *opt_device;
|
||||||
char *opt_serial;
|
char *opt_serial;
|
||||||
|
char *opt_ident_string;
|
||||||
|
int opt_position;
|
||||||
char *opt_cable;
|
char *opt_cable;
|
||||||
int opt_debuglevel;
|
int opt_debuglevel;
|
||||||
int opt_target_dev;
|
int opt_target_dev;
|
||||||
|
@ -184,8 +184,10 @@ bool msp432_probe(target *t)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Check for the right HW revision: at least C, as no flash support for B */
|
/* Check for the right HW revision: at least C, as no flash support for B */
|
||||||
if (target_mem_read32(t, HWREV_ADDR) < HWREV_MIN_VALUE)
|
if (target_mem_read32(t, HWREV_ADDR) < HWREV_MIN_VALUE) {
|
||||||
|
DEBUG("MSP432 Version not handled\n");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/* If we got till this point, we are most probably looking at a real TLV */
|
/* If we got till this point, we are most probably looking at a real TLV */
|
||||||
/* Device Information structure. Now check for the correct device */
|
/* Device Information structure. Now check for the correct device */
|
||||||
|
@ -256,6 +256,8 @@ int target_flash_write(target *t,
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
while (len) {
|
while (len) {
|
||||||
struct target_flash *f = flash_for_addr(t, dest);
|
struct target_flash *f = flash_for_addr(t, dest);
|
||||||
|
if (!f)
|
||||||
|
return 1;
|
||||||
size_t tmptarget = MIN(dest + len, f->start + f->length);
|
size_t tmptarget = MIN(dest + len, f->start + f->length);
|
||||||
size_t tmplen = tmptarget - dest;
|
size_t tmplen = tmptarget - dest;
|
||||||
ret |= target_flash_write_buffered(f, dest, src, tmplen);
|
ret |= target_flash_write_buffered(f, dest, src, tmplen);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user