-static int dsp5680xx_flash_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count){
- int retval;
- if((offset + count/2)>bank->size){
- LOG_ERROR("%s: Flash bank cannot fit data.",__FUNCTION__);
- return ERROR_FAIL;
- }
- if(offset%2){
- LOG_ERROR("%s: Writing to odd addresses not supported. This chip uses word addressing, Openocd only supports byte addressing. The workaround results in disabling writing to odd byte addresses.",__FUNCTION__);
- return ERROR_FAIL;
- }
- retval = dsp5680xx_f_wr(bank->target, buffer, bank->base + offset/2, count, 0);
- uint32_t addr_word;
- for(addr_word = bank->base + offset/2;addr_word<count/2;addr_word+=(HFM_SECTOR_SIZE/2)){
- if(retval == ERROR_OK)
- bank->sectors[addr_word/(HFM_SECTOR_SIZE/2)].is_erased = 0;
- else
- bank->sectors[addr_word/(HFM_SECTOR_SIZE/2)].is_erased = -1;
- }
- return retval;
+static int dsp5680xx_flash_write(struct flash_bank *bank, uint8_t * buffer,
+ uint32_t offset, uint32_t count)
+{
+ int retval;
+
+ if ((offset + count / 2) > bank->size) {
+ LOG_ERROR("%s: Flash bank cannot fit data.", __func__);
+ return ERROR_FAIL;
+ }
+ if (offset % 2) {
+ /**
+ * Writing to odd addresses not supported.
+ * This chip uses word addressing, Openocd only supports byte addressing.
+ * The workaround results in disabling writing to odd byte addresses
+ */
+ LOG_ERROR("%s: Writing to odd addresses not supported for this target", __func__);
+ return ERROR_FAIL;
+ }
+ retval = dsp5680xx_f_wr(bank->target, buffer, bank->base + offset / 2, count, 0);
+ uint32_t addr_word;
+
+ for (addr_word = bank->base + offset / 2; addr_word < count / 2;
+ addr_word += (HFM_SECTOR_SIZE / 2)) {
+ if (retval == ERROR_OK)
+ bank->sectors[addr_word / (HFM_SECTOR_SIZE / 2)].is_erased = 0;
+ else
+ bank->sectors[addr_word / (HFM_SECTOR_SIZE / 2)].is_erased = -1;
+ }
+ return retval;