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:
parent
e728bb75d4
commit
1b5c1098f5
3
AUTHORS
3
AUTHORS
|
@ -25,3 +25,6 @@ Bessam Abdulrazak (http://pages.usherbrooke.ca/babdulrazak/):
|
||||||
|
|
||||||
Andres Vahter <andres.vahter@gmail.com>:
|
Andres Vahter <andres.vahter@gmail.com>:
|
||||||
* Support for MSP430F2234.
|
* Support for MSP430F2234.
|
||||||
|
|
||||||
|
Robert Spanton <rspanton@zepler.net>:
|
||||||
|
* Support for FET430UIF bootloader programming.
|
||||||
|
|
45
bsl.c
45
bsl.c
|
@ -211,9 +211,32 @@ static void bsl_destroy(device_t dev_base)
|
||||||
free(dev);
|
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)
|
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;
|
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,
|
static int bsl_writemem(device_t dev_base,
|
||||||
address_t addr, const uint8_t *mem, address_t len)
|
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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mem += wlen;
|
||||||
|
len -= wlen;
|
||||||
|
addr += wlen;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int bsl_readmem(device_t dev_base,
|
static int bsl_readmem(device_t dev_base,
|
||||||
address_t addr, uint8_t *mem, address_t len)
|
address_t addr, uint8_t *mem, address_t len)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue