Add support for writing the FET430's firmware in uif-bsl.

This patch adds support to the uif-bsl driver for erasing the FET430's
memory, and writing to it. It also adds graceful ignoring of halt and
reset requests, which the "prog" command tries to get it to do.

I've tried this with my UIF and it appears to work fine.  It no longer
complains when I present it with an MSP430F247 after updating its
firmware :)

Be very careful!  I do *not* provide any guarantee that this won't
brick your UIF (which would require a second MSP430 programmer to
program the first...).
This commit is contained in:
Robert Spanton 2010-08-16 11:11:14 +12:00 committed by Daniel Beer
parent e728bb75d4
commit 1b5c1098f5
2 changed files with 47 additions and 3 deletions

View File

@ -25,3 +25,6 @@ Bessam Abdulrazak (http://pages.usherbrooke.ca/babdulrazak/):
Andres Vahter <andres.vahter@gmail.com>:
* Support for MSP430F2234.
Robert Spanton <rspanton@zepler.net>:
* Support for FET430UIF bootloader programming.

45
bsl.c
View File

@ -211,9 +211,32 @@ static void bsl_destroy(device_t dev_base)
free(dev);
}
static int bsl_erase(struct bsl_device *dev)
{
/* Constants found from viewing gdbproxy's activities */
return bsl_xfer(dev, CMD_ERASE, 0x2500, NULL, 0x0069);
}
static int bsl_ctl(device_t dev_base, device_ctl_t type)
{
fprintf(stderr, "bsl: CPU control is not implemented\n");
struct bsl_device *dev = (struct bsl_device *)dev_base;
switch (type) {
case DEVICE_CTL_ERASE:
return bsl_erase(dev);
case DEVICE_CTL_HALT:
/* Ignore halt requests */
return 0;
case DEVICE_CTL_RESET:
/* Ignore reset requests */
return 0;
default:
fprintf(stderr, "bsl: CPU control is not possible\n");
}
return -1;
}
@ -237,10 +260,28 @@ static int bsl_setregs(device_t dev_base, const address_t *regs)
static int bsl_writemem(device_t dev_base,
address_t addr, const uint8_t *mem, address_t len)
{
fprintf(stderr, "bsl: memory write is not implemented\n");
struct bsl_device *dev = (struct bsl_device *)dev_base;
while (len) {
int wlen = len > 100 ? 100 : len;
int r;
r = bsl_xfer(dev, CMD_RX_DATA, addr, mem, wlen);
if( r < 0 ) {
fprintf(stderr, "bsl: failed to write to 0x%04x\n",
addr);
return -1;
}
mem += wlen;
len -= wlen;
addr += wlen;
}
return 0;
}
static int bsl_readmem(device_t dev_base,
address_t addr, uint8_t *mem, address_t len)
{