X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fflash%2Fnor%2Fbluenrg-x.c;h=f1b2062019edf1a550dca1a7a65b160f44e2b2f4;hp=c4a8080476d5d4729a051afb9afb20bc694eb9d7;hb=refs%2Fchanges%2F19%2F4919%2F8;hpb=cb2f21bf3608f24de5c2e4219626cc464269e830 diff --git a/src/flash/nor/bluenrg-x.c b/src/flash/nor/bluenrg-x.c index c4a8080476..f1b2062019 100644 --- a/src/flash/nor/bluenrg-x.c +++ b/src/flash/nor/bluenrg-x.c @@ -274,6 +274,7 @@ static int bluenrgx_write_bytes(struct target *target, uint32_t address_base, ui if (pre_bytes) { if (target_read_u32(target, pre_address, &pre_word)) { LOG_ERROR("Memory read failed"); + free(new_buffer); return ERROR_FAIL; } @@ -282,6 +283,7 @@ static int bluenrgx_write_bytes(struct target *target, uint32_t address_base, ui if (post_bytes) { if (target_read_u32(target, post_address, &post_word)) { LOG_ERROR("Memory read failed"); + free(new_buffer); return ERROR_FAIL; } @@ -402,9 +404,9 @@ static int bluenrgx_write(struct flash_bank *bank, const uint8_t *buffer, /* Stack pointer for program working area */ buf_set_u32(reg_params[4].value, 0, 32, write_algorithm_sp->address); - LOG_DEBUG("source->address = %08" TARGET_PRIxADDR, source->address); - LOG_DEBUG("source->address+ source->size = %08" TARGET_PRIxADDR, source->address+source->size); - LOG_DEBUG("write_algorithm_sp->address = %08" TARGET_PRIxADDR, write_algorithm_sp->address); + LOG_DEBUG("source->address = " TARGET_ADDR_FMT, source->address); + LOG_DEBUG("source->address+ source->size = " TARGET_ADDR_FMT, source->address+source->size); + LOG_DEBUG("write_algorithm_sp->address = " TARGET_ADDR_FMT, write_algorithm_sp->address); LOG_DEBUG("address = %08x", address+pre_size); LOG_DEBUG("count = %08x", count); @@ -450,6 +452,9 @@ static int bluenrgx_write(struct flash_bank *bank, const uint8_t *buffer, destroy_reg_param(®_params[2]); destroy_reg_param(®_params[3]); destroy_reg_param(®_params[4]); + if (retval != ERROR_OK) + return retval; + } /* Program chunk at end, not addressable by fast burst write algorithm */