Fixed erase command on chips with code start > 0x8000.
This commit is contained in:
parent
d543360bd0
commit
15b6148cd4
111
fet.c
111
fet.c
|
@ -42,7 +42,8 @@ struct fet_device {
|
||||||
int version;
|
int version;
|
||||||
int have_breakpoint;
|
int have_breakpoint;
|
||||||
|
|
||||||
/* FIXME: need to record code start somewhere */
|
/* Device-specific information */
|
||||||
|
u_int16_t code_start;
|
||||||
|
|
||||||
uint8_t fet_buf[65538];
|
uint8_t fet_buf[65538];
|
||||||
int fet_len;
|
int fet_len;
|
||||||
|
@ -453,68 +454,85 @@ static int xfer(struct fet_device *dev,
|
||||||
* MSP430 high-level control functions
|
* MSP430 high-level control functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int do_identify(struct fet_device *dev, const char *force_id)
|
static int identify_old(struct fet_device *dev)
|
||||||
{
|
{
|
||||||
if (dev->version < 20300000) {
|
char idtext[64];
|
||||||
char idtext[64];
|
|
||||||
|
|
||||||
if (xfer(dev, C_IDENTIFY, NULL, 0, 2, 70, 0) < 0)
|
if (xfer(dev, C_IDENTIFY, NULL, 0, 2, 70, 0) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!dev->fet_reply.data) {
|
if (!dev->fet_reply.datalen < 0x26) {
|
||||||
fprintf(stderr, "fet: missing info\n");
|
fprintf(stderr, "fet: missing info\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(idtext, dev->fet_reply.data + 4, 32);
|
memcpy(idtext, dev->fet_reply.data + 4, 32);
|
||||||
idtext[32] = 0;
|
idtext[32] = 0;
|
||||||
|
|
||||||
printf("Device: %s\n", idtext);
|
dev->code_start = LE_WORD(dev->fet_reply.data, 0x24);
|
||||||
} else {
|
|
||||||
const struct fet_db_record *r;
|
|
||||||
|
|
||||||
if (xfer(dev, 0x28, NULL, 0, 2, 0, 0) < 0) {
|
printf("Device: %s\n", idtext);
|
||||||
fprintf(stderr, "fet: command 0x28 failed\n");
|
printf("Code memory starts at 0x%04x\n", dev->code_start);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dev->fet_reply.datalen < 2) {
|
return 0;
|
||||||
fprintf(stderr, "fet: missing info\n");
|
}
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Device ID: 0x%02x%02x\n",
|
static int identify_new(struct fet_device *dev, const char *force_id)
|
||||||
dev->fet_reply.data[0], dev->fet_reply.data[1]);
|
{
|
||||||
|
const struct fet_db_record *r;
|
||||||
|
|
||||||
if (force_id)
|
if (xfer(dev, 0x28, NULL, 0, 2, 0, 0) < 0) {
|
||||||
r = fet_db_find_by_name(force_id);
|
fprintf(stderr, "fet: command 0x28 failed\n");
|
||||||
else
|
return -1;
|
||||||
r = fet_db_find_by_msg28(dev->fet_reply.data,
|
}
|
||||||
dev->fet_reply.datalen);
|
|
||||||
|
|
||||||
if (!r) {
|
if (dev->fet_reply.datalen < 2) {
|
||||||
fprintf(stderr, "fet: unknown device\n");
|
fprintf(stderr, "fet: missing info\n");
|
||||||
debug_hexdump("msg28_data:", dev->fet_reply.data,
|
return -1;
|
||||||
dev->fet_reply.datalen);
|
}
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Device: %s\n", r->name);
|
printf("Device ID: 0x%02x%02x\n",
|
||||||
|
dev->fet_reply.data[0], dev->fet_reply.data[1]);
|
||||||
|
|
||||||
if (xfer(dev, 0x2b, r->msg2b_data, FET_DB_MSG2B_LEN, 0) < 0)
|
if (force_id)
|
||||||
fprintf(stderr, "fet: warning: message 0x2b failed\n");
|
r = fet_db_find_by_name(force_id);
|
||||||
|
else
|
||||||
|
r = fet_db_find_by_msg28(dev->fet_reply.data,
|
||||||
|
dev->fet_reply.datalen);
|
||||||
|
|
||||||
if (xfer(dev, 0x29, r->msg29_data, FET_DB_MSG29_LEN,
|
if (!r) {
|
||||||
3, r->msg29_params[0], r->msg29_params[1],
|
fprintf(stderr, "fet: unknown device\n");
|
||||||
r->msg29_params[2]) < 0) {
|
debug_hexdump("msg28_data:", dev->fet_reply.data,
|
||||||
fprintf(stderr, "fet: message 0x29 failed\n");
|
dev->fet_reply.datalen);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dev->code_start = LE_WORD(r->msg29_data, 0);
|
||||||
|
|
||||||
|
printf("Device: %s\n", r->name);
|
||||||
|
printf("Code memory starts at 0x%04x\n", dev->code_start);
|
||||||
|
|
||||||
|
if (xfer(dev, 0x2b, r->msg2b_data, FET_DB_MSG2B_LEN, 0) < 0)
|
||||||
|
fprintf(stderr, "fet: warning: message 0x2b failed\n");
|
||||||
|
|
||||||
|
if (xfer(dev, 0x29, r->msg29_data, FET_DB_MSG29_LEN,
|
||||||
|
3, r->msg29_params[0], r->msg29_params[1],
|
||||||
|
r->msg29_params[2]) < 0) {
|
||||||
|
fprintf(stderr, "fet: message 0x29 failed\n");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int do_identify(struct fet_device *dev, const char *force_id)
|
||||||
|
{
|
||||||
|
if (dev->version < 20300000)
|
||||||
|
return identify_old(dev);
|
||||||
|
|
||||||
|
return identify_new(dev, force_id);
|
||||||
|
}
|
||||||
|
|
||||||
static int do_run(struct fet_device *dev, int type)
|
static int do_run(struct fet_device *dev, int type)
|
||||||
{
|
{
|
||||||
if (xfer(dev, C_RUN, NULL, 0, 2, type, 0) < 0) {
|
if (xfer(dev, C_RUN, NULL, 0, 2, type, 0) < 0) {
|
||||||
|
@ -542,7 +560,8 @@ static int do_erase(struct fet_device *dev)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xfer(dev, C_ERASE, NULL, 0, 3, FET_ERASE_MAIN, 0x8000, 2) < 0) {
|
if (xfer(dev, C_ERASE, NULL, 0, 3, FET_ERASE_MAIN,
|
||||||
|
dev->code_start, 0) < 0) {
|
||||||
fprintf(stderr, "fet: erase command failed\n");
|
fprintf(stderr, "fet: erase command failed\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
8
fet_db.c
8
fet_db.c
|
@ -358,10 +358,10 @@ static const struct fet_db_record fet_db[] = {
|
||||||
0x00, 0x00
|
0x00, 0x00
|
||||||
},
|
},
|
||||||
.msg29_params = {0x00, 0x39, 0x31},
|
.msg29_params = {0x00, 0x39, 0x31},
|
||||||
.msg29_data = { /* Copied from MSP430F2274 */
|
.msg29_data = { /* Copied from MSP430F2274, with changes */
|
||||||
0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x10,
|
0x00, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x00, 0x10,
|
||||||
0xff, 0x10, 0x40, 0x00, 0x00, 0x02, 0xff, 0x05,
|
0xff, 0x10, 0x40, 0x00, 0x00, 0x02, 0x7f, 0x02,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
|
||||||
0x01, 0x00, 0xd7, 0x60, 0x00, 0x00, 0x00, 0x00,
|
0x01, 0x00, 0xd7, 0x60, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x08, 0x07, 0x10, 0x0e, 0xc4, 0x09, 0x70, 0x17,
|
0x08, 0x07, 0x10, 0x0e, 0xc4, 0x09, 0x70, 0x17,
|
||||||
0x58, 0x1b, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00,
|
0x58, 0x1b, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||||
|
|
Loading…
Reference in New Issue