Fixed erase command on chips with code start > 0x8000.
This commit is contained in:
parent
d543360bd0
commit
15b6148cd4
33
fet.c
33
fet.c
|
@ -42,7 +42,8 @@ struct fet_device {
|
|||
int version;
|
||||
int have_breakpoint;
|
||||
|
||||
/* FIXME: need to record code start somewhere */
|
||||
/* Device-specific information */
|
||||
u_int16_t code_start;
|
||||
|
||||
uint8_t fet_buf[65538];
|
||||
int fet_len;
|
||||
|
@ -453,15 +454,14 @@ static int xfer(struct fet_device *dev,
|
|||
* 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];
|
||||
|
||||
if (xfer(dev, C_IDENTIFY, NULL, 0, 2, 70, 0) < 0)
|
||||
return -1;
|
||||
|
||||
if (!dev->fet_reply.data) {
|
||||
if (!dev->fet_reply.datalen < 0x26) {
|
||||
fprintf(stderr, "fet: missing info\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -469,8 +469,16 @@ static int do_identify(struct fet_device *dev, const char *force_id)
|
|||
memcpy(idtext, dev->fet_reply.data + 4, 32);
|
||||
idtext[32] = 0;
|
||||
|
||||
dev->code_start = LE_WORD(dev->fet_reply.data, 0x24);
|
||||
|
||||
printf("Device: %s\n", idtext);
|
||||
} else {
|
||||
printf("Code memory starts at 0x%04x\n", dev->code_start);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int identify_new(struct fet_device *dev, const char *force_id)
|
||||
{
|
||||
const struct fet_db_record *r;
|
||||
|
||||
if (xfer(dev, 0x28, NULL, 0, 2, 0, 0) < 0) {
|
||||
|
@ -499,7 +507,10 @@ static int do_identify(struct fet_device *dev, const char *force_id)
|
|||
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");
|
||||
|
@ -510,11 +521,18 @@ static int do_identify(struct fet_device *dev, const char *force_id)
|
|||
fprintf(stderr, "fet: message 0x29 failed\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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");
|
||||
return -1;
|
||||
}
|
||||
|
|
8
fet_db.c
8
fet_db.c
|
@ -358,10 +358,10 @@ static const struct fet_db_record fet_db[] = {
|
|||
0x00, 0x00
|
||||
},
|
||||
.msg29_params = {0x00, 0x39, 0x31},
|
||||
.msg29_data = { /* Copied from MSP430F2274 */
|
||||
0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0x00, 0x10,
|
||||
0xff, 0x10, 0x40, 0x00, 0x00, 0x02, 0xff, 0x05,
|
||||
0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00,
|
||||
.msg29_data = { /* Copied from MSP430F2274, with changes */
|
||||
0x00, 0xf8, 0xff, 0xff, 0x00, 0x00, 0x00, 0x10,
|
||||
0xff, 0x10, 0x40, 0x00, 0x00, 0x02, 0x7f, 0x02,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
|
||||
0x01, 0x00, 0xd7, 0x60, 0x00, 0x00, 0x00, 0x00,
|
||||
0x08, 0x07, 0x10, 0x0e, 0xc4, 0x09, 0x70, 0x17,
|
||||
0x58, 0x1b, 0x01, 0x00, 0x03, 0x00, 0x00, 0x00,
|
||||
|
|
Loading…
Reference in New Issue