This is an automated email from Gerrit. Andrey Smirnov ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/2050
-- gerrit commit ecc9e85aa99f02d89bc72fbae00d9cab10e5bab1 Author: Andrey Smirnov <[email protected]> Date: Sat Mar 15 10:40:23 2014 -0700 nrf51: Fix incorrect flash writing sequence nRF51 doesn't have any sort of flash page cache so we need to write all of the data on the word-by-word basis and poll for "Flash Ready" bit each time. Signed-off-by: Andrey Smirnov <[email protected]> Change-Id: I8caffbf69ebf9a69915724704ddbe270d1bb8d92 diff --git a/src/flash/nor/nrf51.c b/src/flash/nor/nrf51.c index 746703b..373b5a7 100644 --- a/src/flash/nor/nrf51.c +++ b/src/flash/nor/nrf51.c @@ -602,10 +602,30 @@ static int nrf51_erase_page(struct nrf51_info *chip, struct flash_sector *sector return res; } +static int nrf51_ll_flash_write(struct nrf51_info *chip, uint32_t offset, const uint8_t *buffer, uint32_t buffer_size) +{ + int res; + assert(buffer_size % 4 == 0); + + for (; buffer_size > 0; buffer_size -= 4) { + res = target_write_u32(chip->target, offset, *(uint32_t *)buffer); + if (res != ERROR_OK) + return res; + + res = nrf51_wait_for_nvmc(chip); + if (res != ERROR_OK) + return res; + + offset += 4; + buffer += 4; + } + + return ERROR_OK; +} + static int nrf51_write_page(struct flash_bank *bank, uint32_t offset, uint8_t *buffer) { assert(offset % 4 == 0); - int res = ERROR_FAIL; struct nrf51_info *chip = (struct nrf51_info *)bank->driver_priv; struct flash_sector *sector = nrf51_find_sector_by_address(bank, offset); @@ -629,8 +649,8 @@ static int nrf51_write_page(struct flash_bank *bank, uint32_t offset, uint8_t *b goto error; sector->is_erased = 0; - res = target_write_memory(bank->target, offset, 4, - chip->code_page_size / 4, buffer); + + res = nrf51_ll_flash_write(chip, offset, buffer, chip->code_page_size); if (res != ERROR_OK) goto set_read_only; @@ -770,11 +790,7 @@ static int nrf51_uicr_flash_write(struct flash_bank *bank, memcpy(&uicr[offset], buffer, count); - res = target_write_memory(bank->target, - NRF51_UICR_BASE, - 4, - NRF51_UICR_SIZE / 4, - uicr); + res = nrf51_ll_flash_write(chip, NRF51_UICR_BASE, uicr, NRF51_UICR_SIZE); if (res != ERROR_OK) { nrf51_nvmc_read_only(chip); return res; -- ------------------------------------------------------------------------------ Learn Graph Databases - Download FREE O'Reilly Book "Graph Databases" is the definitive new guide to graph databases and their applications. Written by three acclaimed leaders in the field, this first edition is now available. Download your free book today! http://p.sf.net/sfu/13534_NeoTech _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
