diff --git a/upgrade/main.c b/upgrade/main.c index 38fa575..3e10b9a 100644 --- a/upgrade/main.c +++ b/upgrade/main.c @@ -157,7 +157,7 @@ retry: printf("Progress: %d%%\r", (offset*100)/bindatalen); fflush(stdout); assert(stm32_mem_erase(handle, iface, LOAD_ADDRESS + offset) == 0); - stm32_mem_write(handle, iface, (void*)&bindata[offset], 1024); + stm32_mem_write(handle, iface, (void*)&bindata[offset], 1024, LOAD_ADDRESS + offset); } stm32_mem_manifest(handle, iface); diff --git a/upgrade/stm32mem.c b/upgrade/stm32mem.c index 53bbb5b..2d9d136 100644 --- a/upgrade/stm32mem.c +++ b/upgrade/stm32mem.c @@ -69,8 +69,13 @@ int stm32_mem_erase(usb_dev_handle *dev, uint16_t iface, uint32_t addr) return stm32_download(dev, iface, 0, request, sizeof(request)); } -int stm32_mem_write(usb_dev_handle *dev, uint16_t iface, void *data, int size) +int stm32_mem_write(usb_dev_handle *dev, uint16_t iface, void *data, int size, uint32_t addr) { + uint8_t request[5]; + + request[0] = STM32_CMD_SETADDRESSPOINTER; + memcpy(request+1, &addr, sizeof(addr)); + stm32_download(dev, iface, 0, request, sizeof(request)); return stm32_download(dev, iface, 2, data, size); } diff --git a/upgrade/stm32mem.h b/upgrade/stm32mem.h index fd99c65..b8a013a 100644 --- a/upgrade/stm32mem.h +++ b/upgrade/stm32mem.h @@ -27,7 +27,7 @@ #endif int stm32_mem_erase(usb_dev_handle *dev, uint16_t iface, uint32_t addr); -int stm32_mem_write(usb_dev_handle *dev, uint16_t iface, void *data, int size); +int stm32_mem_write(usb_dev_handle *dev, uint16_t iface, void *data, int size, uint32_t addr); int stm32_mem_manifest(usb_dev_handle *dev, uint16_t iface); #endif