diff options
Diffstat (limited to 'controller/fw/src/mspdebug_wrapper.c')
-rw-r--r-- | controller/fw/src/mspdebug_wrapper.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/controller/fw/src/mspdebug_wrapper.c b/controller/fw/src/mspdebug_wrapper.c index aada33a..aaf75ab 100644 --- a/controller/fw/src/mspdebug_wrapper.c +++ b/controller/fw/src/mspdebug_wrapper.c @@ -1,6 +1,7 @@ #include <unistd.h> #include <errno.h> +#include <string.h> #include "output.h" #include "jtaglib.h" @@ -53,6 +54,18 @@ void mspd_jtag_init() { gpio_pin_setup(gpios[i].gpio, gpios[i].pin, gpios[i].mode, 3, 0, 0); } +static void sr_gpio_write(int num, int out) { + if (out) + gpios[num].gpio->BSRR = 1<<gpios[num].pin; + else + gpios[num].gpio->BSRR = 1<<gpios[num].pin<<16; +} + +static void sr_jtdev_rst(struct jtdev *p, int out) { + UNUSED(p); + sr_gpio_write(SR_GPIO_RST, out); +} + int mspd_jtag_flash_and_reset(size_t img_start, size_t img_len, ssize_t (*read_block)(void *usr, int addr, size_t len, uint8_t *out), void *usr) { union { @@ -73,18 +86,17 @@ int mspd_jtag_flash_and_reset(size_t img_start, size_t img_len, ssize_t (*read_b if (jtag_id != 0x89 && jtag_id != 0x91) return -EINVAL; - /* FIXME DEBUG */ - +#if 0 con_printf("Memory dump:\r\n"); - for (size_t i=0; i<256;) { + for (size_t i=0x1000; i<=0x10ff;) { con_printf("%04x: ", i); - for (size_t j=0; j<16; i+=2, j+=2) { - con_printf("%04x ", jtag_read_mem(&sr_jtdev, 16, 0xc000 + i)); + for (size_t j=0; j<16; i+=1, j+=1) { + con_printf("%02x ", jtag_read_mem(&sr_jtdev, 8, i)); } con_printf("\r\n"); } return 0; - /* END DEBUG */ +#endif /* Clear flash */ jtag_erase_flash(&sr_jtdev, JTAG_ERASE_MAIN, 0); @@ -93,6 +105,7 @@ int mspd_jtag_flash_and_reset(size_t img_start, size_t img_len, ssize_t (*read_b /* Write flash */ for (size_t p = img_start; p < img_start + img_len; p += BLOCK_SIZE) { + con_printf("Writing block %04zx\r\n", p); ssize_t nin = read_block(usr, p, BLOCK_SIZE, block.bytes); if (nin < 0) @@ -122,6 +135,8 @@ int mspd_jtag_flash_and_reset(size_t img_start, size_t img_len, ssize_t (*read_b if (sr_jtdev.failed) return -EPIPE; + jtag_release_device(&sr_jtdev, 0xfffe); + return 0; } @@ -153,13 +168,6 @@ static void sr_jtdev_connect(struct jtdev *p) { /* ignore */ } -static void sr_gpio_write(int num, int out) { - if (out) - gpios[num].gpio->BSRR = 1<<gpios[num].pin; - else - gpios[num].gpio->BSRR = 1<<gpios[num].pin<<16; -} - static void sr_jtdev_tck(struct jtdev *p, int out) { UNUSED(p); sr_gpio_write(SR_GPIO_TCK, out); @@ -175,11 +183,6 @@ static void sr_jtdev_tdi(struct jtdev *p, int out) { sr_gpio_write(SR_GPIO_TDI, out); } -static void sr_jtdev_rst(struct jtdev *p, int out) { - UNUSED(p); - sr_gpio_write(SR_GPIO_RST, out); -} - static void sr_jtdev_tst(struct jtdev *p, int out) { UNUSED(p); sr_gpio_write(SR_GPIO_TST, out); |