flash: Constify write buffer 40/2040/2
authorAndreas Fritiofson <andreas.fritiofson@gmail.com>
Mon, 10 Mar 2014 21:23:07 +0000 (22:23 +0100)
committerSpencer Oliver <spen@spen-soft.co.uk>
Mon, 17 Mar 2014 12:47:18 +0000 (12:47 +0000)
Change-Id: Ic812098d3ed5a2992c26bb57d08ae350e2c5d5d8
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2040
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
39 files changed:
src/flash/nor/aduc702x.c
src/flash/nor/at91sam3.c
src/flash/nor/at91sam4.c
src/flash/nor/at91sam4l.c
src/flash/nor/at91sam7.c
src/flash/nor/at91samd.c
src/flash/nor/avrf.c
src/flash/nor/cfi.c
src/flash/nor/driver.h
src/flash/nor/dsp5680xx_flash.c
src/flash/nor/efm32.c
src/flash/nor/em357.c
src/flash/nor/faux.c
src/flash/nor/fm3.c
src/flash/nor/kinetis.c
src/flash/nor/lpc2000.c
src/flash/nor/lpc288x.c
src/flash/nor/lpc2900.c
src/flash/nor/lpcspifi.c
src/flash/nor/mdr.c
src/flash/nor/mini51.c
src/flash/nor/nrf51.c
src/flash/nor/nuc1x.c
src/flash/nor/ocl.c
src/flash/nor/pic32mx.c
src/flash/nor/stellaris.c
src/flash/nor/stm32f1x.c
src/flash/nor/stm32f2x.c
src/flash/nor/stm32lx.c
src/flash/nor/stmsmi.c
src/flash/nor/str7x.c
src/flash/nor/str9x.c
src/flash/nor/str9xpec.c
src/flash/nor/tms470.c
src/flash/nor/virtual.c
src/target/dsp5680xx.c
src/target/dsp5680xx.h
src/target/target.c
src/target/target.h

index 60ec7d3863312e5797879ed94d24c2979e89d875..88522458d307eae7cf66bec407a173e7677a5111 100644 (file)
@@ -144,7 +144,7 @@ static int aduc702x_protect(struct flash_bank *bank, int set, int first, int las
  * Caller should not check for other return values specifically
  */
 static int aduc702x_write_block(struct flash_bank *bank,
-       uint8_t *buffer,
+       const uint8_t *buffer,
        uint32_t offset,
        uint32_t count)
 {
@@ -285,7 +285,7 @@ static int aduc702x_write_block(struct flash_bank *bank,
 /* All-JTAG, single-access method.  Very slow.  Used only if there is no
  * working area available. */
 static int aduc702x_write_single(struct flash_bank *bank,
-       uint8_t *buffer,
+       const uint8_t *buffer,
        uint32_t offset,
        uint32_t count)
 {
@@ -326,7 +326,7 @@ static int aduc702x_write_single(struct flash_bank *bank,
        return ERROR_OK;
 }
 
-static int aduc702x_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int aduc702x_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 {
        int retval;
 
index a05ab169a07591885b766ef66862d0215569e681..bbdb58cb2482b4ad3d0bea553b9af41b93b2cb10 100644 (file)
@@ -3285,7 +3285,7 @@ static const uint8_t
        0x00, 0xBE                              /* bkpt #0 */
 };
 
-static int sam3_page_write(struct sam3_bank_private *pPrivate, unsigned pagenum, uint8_t *buf)
+static int sam3_page_write(struct sam3_bank_private *pPrivate, unsigned pagenum, const uint8_t *buf)
 {
        uint32_t adr;
        uint32_t status;
@@ -3344,7 +3344,7 @@ static int sam3_page_write(struct sam3_bank_private *pPrivate, unsigned pagenum,
 }
 
 static int sam3_write(struct flash_bank *bank,
-       uint8_t *buffer,
+       const uint8_t *buffer,
        uint32_t offset,
        uint32_t count)
 {
index 84d09c2117bf0cf6dc7ab9f5c6e2915ccf4eaf1b..4d5ba2e074dc315fd736d79704f5cb43f746f10c 100644 (file)
@@ -1877,7 +1877,7 @@ static int sam4_page_read(struct sam4_bank_private *pPrivate, unsigned pagenum,
        return r;
 }
 
-static int sam4_page_write(struct sam4_bank_private *pPrivate, unsigned pagenum, uint8_t *buf)
+static int sam4_page_write(struct sam4_bank_private *pPrivate, unsigned pagenum, const uint8_t *buf)
 {
        uint32_t adr;
        uint32_t status;
@@ -1939,7 +1939,7 @@ static int sam4_page_write(struct sam4_bank_private *pPrivate, unsigned pagenum,
 }
 
 static int sam4_write(struct flash_bank *bank,
-       uint8_t *buffer,
+       const uint8_t *buffer,
        uint32_t offset,
        uint32_t count)
 {
index d3bdbfe67b8227d63adc520d78387cfc7886366b..9f1319b663754c9af4102bc81fbea57f74a9ec50 100644 (file)
@@ -495,7 +495,7 @@ static int sam4l_erase(struct flash_bank *bank, int first, int last)
 /* Write an entire page from host buffer 'buf' to page-aligned 'address' in the
  * Flash. */
 static int sam4l_write_page(struct sam4l_info *chip, struct target *target,
-               uint32_t address, uint8_t *buf)
+               uint32_t address, const uint8_t *buf)
 {
        int res;
 
@@ -527,7 +527,7 @@ static int sam4l_write_page(struct sam4l_info *chip, struct target *target,
 /* Write partial contents into page-aligned 'address' on the Flash from host
  * buffer 'buf' by writing 'nb' of 'buf' at 'offset' into the Flash page. */
 static int sam4l_write_page_partial(struct sam4l_info *chip,
-               struct flash_bank *bank, uint32_t address, uint8_t *buf,
+               struct flash_bank *bank, uint32_t address, const uint8_t *buf,
                uint32_t page_offset, uint32_t nb)
 {
        int res;
@@ -556,7 +556,7 @@ static int sam4l_write_page_partial(struct sam4l_info *chip,
        return res;
 }
 
-static int sam4l_write(struct flash_bank *bank, uint8_t *buffer,
+static int sam4l_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        int res;
index 9cda3f2d7a69f2f49f6e5a3bd15e0fdac4bc9378..c7334ca53dbaacf9d49fe687a0b1958b0463e5fc 100644 (file)
@@ -98,7 +98,7 @@
 #define FLASH_SIZE_2048KB       14
 
 static int at91sam7_protect_check(struct flash_bank *bank);
-static int at91sam7_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset,
+static int at91sam7_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset,
                uint32_t count);
 
 static uint32_t at91sam7_get_flash_status(struct target *target, int bank_number);
@@ -954,7 +954,7 @@ static int at91sam7_protect(struct flash_bank *bank, int set, int first, int las
        return ERROR_OK;
 }
 
-static int at91sam7_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int at91sam7_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 {
        int retval;
        struct at91sam7_flash_bank *at91sam7_info = bank->driver_priv;
index 8b0f14dd173d010a844fdfadf77bed37bd20fed9..5af61ab4ddcc337e5a64a1ac37bf340b2884aaab 100644 (file)
@@ -385,7 +385,7 @@ static int samd_erase(struct flash_bank *bank, int first, int last)
 /* Write an entire row (four pages) from host buffer 'buf' to row-aligned
  * 'address' in the Flash. */
 static int samd_write_row(struct flash_bank *bank, uint32_t address,
-               uint8_t *buf)
+               const uint8_t *buf)
 {
        int res;
        struct samd_info *chip = (struct samd_info *)bank->driver_priv;
@@ -424,7 +424,7 @@ static int samd_write_row(struct flash_bank *bank, uint32_t address,
 /* Write partial contents into row-aligned 'address' on the Flash from host
  * buffer 'buf' by writing 'nb' of 'buf' at 'row_offset' into the Flash row. */
 static int samd_write_row_partial(struct flash_bank *bank, uint32_t address,
-               uint8_t *buf, uint32_t row_offset, uint32_t nb)
+               const uint8_t *buf, uint32_t row_offset, uint32_t nb)
 {
        int res;
        struct samd_info *chip = (struct samd_info *)bank->driver_priv;
@@ -453,7 +453,7 @@ static int samd_write_row_partial(struct flash_bank *bank, uint32_t address,
        return res;
 }
 
-static int samd_write(struct flash_bank *bank, uint8_t *buffer,
+static int samd_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        int res;
index e408282b5cbcd895ac67cbd628339142a9140308..ecc09046ca3f488883805a62a7df6627f95ca611 100644 (file)
@@ -142,7 +142,7 @@ static int avr_jtagprg_chiperase(struct avr_common *avr)
 }
 
 static int avr_jtagprg_writeflashpage(struct avr_common *avr,
-       uint8_t *page_buf,
+       const uint8_t *page_buf,
        uint32_t buf_size,
        uint32_t addr,
        uint32_t page_size)
@@ -239,7 +239,7 @@ static int avrf_protect(struct flash_bank *bank, int set, int first, int last)
        return ERROR_OK;
 }
 
-static int avrf_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int avrf_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
        struct avr_common *avr = target->arch_info;
index 56d8e6e85d20e772508e1c899313680ae593ce18..97d3f190c42d26ce39d346a5ccd9a38a6bb0f37d 100644 (file)
@@ -1126,7 +1126,7 @@ static uint32_t cfi_command_val(struct flash_bank *bank, uint8_t cmd)
        }
 }
 
-static int cfi_intel_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int cfi_intel_write_block(struct flash_bank *bank, const uint8_t *buffer,
        uint32_t address, uint32_t count)
 {
        struct target *target = bank->target;
@@ -1379,7 +1379,7 @@ cleanup:
        return retval;
 }
 
-static int cfi_spansion_write_block_mips(struct flash_bank *bank, uint8_t *buffer,
+static int cfi_spansion_write_block_mips(struct flash_bank *bank, const uint8_t *buffer,
        uint32_t address, uint32_t count)
 {
        struct cfi_flash_bank *cfi_info = bank->driver_priv;
@@ -1592,7 +1592,7 @@ static int cfi_spansion_write_block_mips(struct flash_bank *bank, uint8_t *buffe
        return retval;
 }
 
-static int cfi_spansion_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int cfi_spansion_write_block(struct flash_bank *bank, const uint8_t *buffer,
        uint32_t address, uint32_t count)
 {
        struct cfi_flash_bank *cfi_info = bank->driver_priv;
@@ -2002,7 +2002,7 @@ static int cfi_intel_write_word(struct flash_bank *bank, uint8_t *word, uint32_t
        return ERROR_OK;
 }
 
-static int cfi_intel_write_words(struct flash_bank *bank, uint8_t *word,
+static int cfi_intel_write_words(struct flash_bank *bank, const uint8_t *word,
        uint32_t wordcount, uint32_t address)
 {
        int retval;
@@ -2122,7 +2122,7 @@ static int cfi_spansion_write_word(struct flash_bank *bank, uint8_t *word, uint3
        return ERROR_OK;
 }
 
-static int cfi_spansion_write_words(struct flash_bank *bank, uint8_t *word,
+static int cfi_spansion_write_words(struct flash_bank *bank, const uint8_t *word,
        uint32_t wordcount, uint32_t address)
 {
        int retval;
@@ -2215,7 +2215,7 @@ static int cfi_write_word(struct flash_bank *bank, uint8_t *word, uint32_t addre
        return ERROR_FLASH_OPERATION_FAILED;
 }
 
-static int cfi_write_words(struct flash_bank *bank, uint8_t *word,
+static int cfi_write_words(struct flash_bank *bank, const uint8_t *word,
        uint32_t wordcount, uint32_t address)
 {
        struct cfi_flash_bank *cfi_info = bank->driver_priv;
@@ -2312,7 +2312,7 @@ static int cfi_read(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, u
        return ERROR_OK;
 }
 
-static int cfi_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int cfi_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 {
        struct cfi_flash_bank *cfi_info = bank->driver_priv;
        struct target *target = bank->target;
index 4e1720748b926912329b24e9007c162be04f93aa..8f2e1cc2328b4bb4147344121627be4b4ee7be0e 100644 (file)
@@ -137,7 +137,7 @@ struct flash_driver {
         * @returns ERROR_OK if successful; otherwise, an error code.
         */
        int (*write)(struct flash_bank *bank,
-                       uint8_t *buffer, uint32_t offset, uint32_t count);
+                       const uint8_t *buffer, uint32_t offset, uint32_t count);
 
        /**
         * Read data from the flash. Note CPU address will be
index 9368d892c3296d42d9671e6bed14ab58aebc0901..693ff487edd71c024fb14e4ac1a8358fbc84c968 100644 (file)
@@ -156,7 +156,7 @@ static int dsp5680xx_flash_protect(struct flash_bank *bank, int set, int first,
  *
  * @return
  */
-static int dsp5680xx_flash_write(struct flash_bank *bank, uint8_t * buffer,
+static int dsp5680xx_flash_write(struct flash_bank *bank, const uint8_t* buffer,
                                 uint32_t offset, uint32_t count)
 {
        int retval;
index 6e2ebce25767e34e2533f7fe007583475c04751c..3c46c76da0b02eec183a4f0f153a5ee78d8743e0 100644 (file)
@@ -98,7 +98,7 @@ struct efm32_info {
        uint16_t page_size;
 };
 
-static int efm32x_write(struct flash_bank *bank, uint8_t *buffer,
+static int efm32x_write(struct flash_bank *bank, const uint8_t *buffer,
        uint32_t offset, uint32_t count);
 
 static int efm32x_get_flash_size(struct flash_bank *bank, uint16_t *flash_sz)
@@ -499,7 +499,7 @@ static int efm32x_protect(struct flash_bank *bank, int set, int first, int last)
        return ERROR_OK;
 }
 
-static int efm32x_write_block(struct flash_bank *bank, uint8_t *buf,
+static int efm32x_write_block(struct flash_bank *bank, const uint8_t *buf,
        uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
@@ -735,7 +735,7 @@ static int efm32x_write_word(struct flash_bank *bank, uint32_t addr,
        return ERROR_OK;
 }
 
-static int efm32x_write(struct flash_bank *bank, uint8_t *buffer,
+static int efm32x_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
index 56f44b38d828d539c6e3cc2740e75b9f4f534661..70a5431ac68880b2827bbc1984a4db091edd6d3e 100644 (file)
@@ -455,7 +455,7 @@ static int em357_protect(struct flash_bank *bank, int set, int first, int last)
        return em357_write_options(bank);
 }
 
-static int em357_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int em357_write_block(struct flash_bank *bank, const uint8_t *buffer,
        uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
@@ -583,7 +583,7 @@ static int em357_write_block(struct flash_bank *bank, uint8_t *buffer,
        return retval;
 }
 
-static int em357_write(struct flash_bank *bank, uint8_t *buffer,
+static int em357_write(struct flash_bank *bank, const uint8_t *buffer,
        uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
index 8e51b8e55ca261f7431871fc5956692ac144318c..1fd1da216b684890afc86d6f458459e4a5e2bc75 100644 (file)
@@ -93,7 +93,7 @@ static int faux_protect(struct flash_bank *bank, int set, int first, int last)
        return ERROR_OK;
 }
 
-static int faux_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int faux_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 {
        struct faux_flash_bank *info = bank->driver_priv;
        memcpy(info->memory + offset, buffer, count);
index 1859912918d2bb86e951200776e1fe5e88effb34..d4bd5b9c120cf8ccb9ca0f1ef27daee49541f4a0 100644 (file)
@@ -347,7 +347,7 @@ static int fm3_erase(struct flash_bank *bank, int first, int last)
        return retval;
 }
 
-static int fm3_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int fm3_write_block(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct fm3_flash_bank *fm3_info = bank->driver_priv;
index dc9208cf4c570b722a0855f95907a87f81eb6a9d..86785905211f2522fd703d6462f01d7aefc41487 100644 (file)
@@ -278,7 +278,7 @@ static const uint8_t kinetis_flash_write_code[] = {
 };
 
 /* Program LongWord Block Write */
-static int kinetis_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int kinetis_write_block(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t wcount)
 {
        struct target *target = bank->target;
@@ -586,7 +586,7 @@ static int kinetis_erase(struct flash_bank *bank, int first, int last)
        return ERROR_OK;
 }
 
-static int kinetis_write(struct flash_bank *bank, uint8_t *buffer,
+static int kinetis_write(struct flash_bank *bank, const uint8_t *buffer,
                         uint32_t offset, uint32_t count)
 {
        unsigned int i, result, fallback = 0;
index 259b42f1c4b7ab784750c5be2ec75c56afafd875..69c8b0341e02ced7a1d8a7ffc138fb8930979cfe 100644 (file)
@@ -711,7 +711,7 @@ static int lpc2000_protect(struct flash_bank *bank, int set, int first, int last
        return ERROR_OK;
 }
 
-static int lpc2000_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int lpc2000_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
 
@@ -746,6 +746,7 @@ static int lpc2000_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offs
 
        /* check if exception vectors should be flashed */
        if ((offset == 0) && (count >= 0x20) && lpc2000_info->calc_checksum) {
+               assert(lpc2000_info->checksum_vector < 8);
                uint32_t checksum = 0;
                for (int i = 0; i < 8; i++) {
                        LOG_DEBUG("Vector 0x%2.2x: 0x%8.8" PRIx32, i * 4, buf_get_u32(buffer + (i * 4), 0, 32));
@@ -763,7 +764,8 @@ static int lpc2000_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offs
                                        "checksum.");
                }
 
-               buf_set_u32(buffer + (lpc2000_info->checksum_vector * 4), 0, 32, checksum);
+               /* FIXME: WARNING! This code is broken because it modifies the callers buffer in place. */
+               buf_set_u32((uint8_t *)buffer + (lpc2000_info->checksum_vector * 4), 0, 32, checksum);
        }
 
        struct working_area *iap_working_area;
index b602619d8e56c24ac852f0e5a3f9af09b038afa7..89f79e3213a665623a8693757238fa5525faa9a6 100644 (file)
@@ -277,7 +277,7 @@ static int lpc288x_erase(struct flash_bank *bank, int first, int last)
        return ERROR_OK;
 }
 
-static int lpc288x_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int lpc288x_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 {
        uint8_t page_buffer[FLASH_PAGE_SIZE];
        uint32_t status, source_offset, dest_offset;
index 018d94ade2eb8a88ff9a5a5c1b77b68388f87e8c..7c3e67580e8aba196e1bd87dfa5b0db9263212c8 100644 (file)
@@ -1058,7 +1058,7 @@ static int lpc2900_protect(struct flash_bank *bank, int set, int first, int last
  * @param offset Start address (relative to bank start)
  * @param count Number of bytes to be programmed
  */
-static int lpc2900_write(struct flash_bank *bank, uint8_t *buffer,
+static int lpc2900_write(struct flash_bank *bank, const uint8_t *buffer,
        uint32_t offset, uint32_t count)
 {
        uint8_t page[FLASH_PAGE_SIZE];
@@ -1186,7 +1186,7 @@ static int lpc2900_write(struct flash_bank *bank, uint8_t *buffer,
                /* Write to flash in large blocks */
                while (count != 0) {
                        uint32_t this_npages;
-                       uint8_t *this_buffer;
+                       const uint8_t *this_buffer;
                        int start_sector = lpc2900_address2sector(bank, offset);
 
                        /* First page / last page / rest */
index 7566c275f863e3a32209a126fa4cfbf1782f0a31..2f4c6010e1da3fc2a3707dc85d6c8c7fbe59f555 100644 (file)
@@ -581,7 +581,7 @@ static int lpcspifi_protect(struct flash_bank *bank, int set,
        return ERROR_OK;
 }
 
-static int lpcspifi_write(struct flash_bank *bank, uint8_t *buffer,
+static int lpcspifi_write(struct flash_bank *bank, const uint8_t *buffer,
        uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
index 650abfd62d650e6c313ad4d8a0e5d3e7fa83d270..ed76aab097cb78b0ee45bbfbefd187188eb71b1b 100644 (file)
@@ -223,7 +223,7 @@ static int mdr_protect(struct flash_bank *bank, int set, int first, int last)
        return ERROR_OK;
 }
 
-static int mdr_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int mdr_write_block(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
@@ -314,7 +314,7 @@ static int mdr_write_block(struct flash_bank *bank, uint8_t *buffer,
        return retval;
 }
 
-static int mdr_write(struct flash_bank *bank, uint8_t *buffer,
+static int mdr_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
@@ -345,7 +345,7 @@ static int mdr_write(struct flash_bank *bank, uint8_t *buffer,
                LOG_INFO("odd number of bytes to write, padding with 0xff");
                buffer = memcpy(new_buffer, buffer, count);
                while (rem--)
-                       buffer[count++] = 0xff;
+                       new_buffer[count++] = 0xff;
        }
 
        uint32_t flash_cmd, cur_per_clock;
index 19b1444820255c3034fa663528594bc5d82bd0b3..61aee5d703191109c4f49c958f816396a9b335b4 100644 (file)
@@ -312,7 +312,7 @@ static int mini51_protect(struct flash_bank *bank, int set, int first, int last)
        return ERROR_FLASH_OPERATION_FAILED;
 }
 
-static int mini51_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int mini51_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 {
        int status;
        int timeout;
index 4b3ab3e0a8c852fb41e20d4e797bd3903bbed1a8..444db6110c2ac0cc4f60f09b77e6ec0b674682b2 100644 (file)
@@ -429,7 +429,7 @@ static int nrf51_erase_page(struct nrf51_info *chip, struct flash_sector *sector
        return res;
 }
 
-static int nrf51_write_page(struct flash_bank *bank, uint32_t offset, uint8_t *buffer)
+static int nrf51_write_page(struct flash_bank *bank, uint32_t offset, const uint8_t *buffer)
 {
        assert(offset % 4 == 0);
 
@@ -484,7 +484,7 @@ static int nrf51_erase(struct flash_bank *bank, int first, int last)
        return res;
 }
 
-static int nrf51_write(struct flash_bank *bank, uint8_t *buffer,
+static int nrf51_write(struct flash_bank *bank, const uint8_t *buffer,
                       uint32_t offset, uint32_t count)
 {
        int res;
@@ -502,7 +502,7 @@ static int nrf51_write(struct flash_bank *bank, uint8_t *buffer,
 
        struct {
                size_t   length;
-               uint8_t *buffer;
+               const uint8_t *buffer;
        }  start_extra, end_extra;
 
        start_extra.length      = region.start % chip->code_page_size;
index 6ca858ec938080ee5628dfcfac34aa40d8872f79..179302e0f4eac9f95868a448918dc5765e551498 100644 (file)
@@ -378,7 +378,7 @@ static int nuc1x_erase(struct flash_bank *bank, int first, int last)
 }
 
 /* The write routine stub. */
-static int nuc1x_write(struct flash_bank *bank, uint8_t *buffer,
+static int nuc1x_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
index 6b297b0d366c929c8d8dfa18d8a25d797f9e72e5..c547d9a1746c528ff4c53604b074ea160535d989 100644 (file)
@@ -118,7 +118,7 @@ static int ocl_protect(struct flash_bank *bank, int set, int first, int last)
        return ERROR_OK;
 }
 
-static int ocl_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int ocl_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 {
        struct ocl_priv *ocl = bank->driver_priv;
        int retval;
index 2b27ec5b8bd5cddbc812e0dfa0867c1a69f81baf..5e82ba63d58b08c72255e1f0b06bee72f548ec73 100644 (file)
@@ -410,7 +410,7 @@ static uint32_t pic32mx_flash_write_code[] = {
        0x00000000              /* nop */
 };
 
-static int pic32mx_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int pic32mx_write_block(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
@@ -571,7 +571,7 @@ static int pic32mx_write_word(struct flash_bank *bank, uint32_t address, uint32_
        return pic32mx_nvm_exec(bank, NVMCON_OP_WORD_PROG, 5);
 }
 
-static int pic32mx_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int pic32mx_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 {
        uint32_t words_remaining = (count / 4);
        uint32_t bytes_remaining = (count & 0x00000003);
index 8886c195a8a9f1383180f425ecba8213576022ff..7665ab38a9611479d720091d9b18fa2276dd9544 100644 (file)
@@ -997,7 +997,7 @@ static const uint8_t stellaris_write_code[] = {
        0x01, 0x00, 0x42, 0xA4  /* .word        0xA4420001 */
 };
 static int stellaris_write_block(struct flash_bank *bank,
-               uint8_t *buffer, uint32_t offset, uint32_t wcount)
+               const uint8_t *buffer, uint32_t offset, uint32_t wcount)
 {
        struct target *target = bank->target;
        uint32_t buffer_size = 16384;
@@ -1078,7 +1078,7 @@ static int stellaris_write_block(struct flash_bank *bank,
        return retval;
 }
 
-static int stellaris_write(struct flash_bank *bank, uint8_t *buffer,
+static int stellaris_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct stellaris_flash_bank *stellaris_info = bank->driver_priv;
index 1b67ff0331d0a07619a5cd2da202307261765d53..aacf6dcd942da3d7db06689fecad1570381ba688 100644 (file)
@@ -130,7 +130,7 @@ struct stm32x_flash_bank {
 
 static int stm32x_mass_erase(struct flash_bank *bank);
 static int stm32x_get_device_id(struct flash_bank *bank, uint32_t *device_id);
-static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int stm32x_write_block(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count);
 
 /* flash bank stm32x <base> <size> 0 0 <target#>
@@ -561,7 +561,7 @@ static int stm32x_protect(struct flash_bank *bank, int set, int first, int last)
        return stm32x_write_options(bank);
 }
 
-static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int stm32x_write_block(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct stm32x_flash_bank *stm32x_info = bank->driver_priv;
@@ -692,7 +692,7 @@ static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer,
        return retval;
 }
 
-static int stm32x_write(struct flash_bank *bank, uint8_t *buffer,
+static int stm32x_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
@@ -720,7 +720,7 @@ static int stm32x_write(struct flash_bank *bank, uint8_t *buffer,
                }
                LOG_INFO("odd number of bytes to write, padding with 0xff");
                buffer = memcpy(new_buffer, buffer, count);
-               buffer[count++] = 0xff;
+               new_buffer[count++] = 0xff;
        }
 
        uint32_t words_remaining = count / 2;
index be96d98195ab50bfcd2a12b14cced2ea42d4c97f..41973e6526e319f5c716bc45985abf8a6df3daa9 100644 (file)
@@ -481,7 +481,7 @@ static int stm32x_protect(struct flash_bank *bank, int set, int first, int last)
        return ERROR_OK;
 }
 
-static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int stm32x_write_block(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
@@ -608,7 +608,7 @@ static int stm32x_write_block(struct flash_bank *bank, uint8_t *buffer,
        return retval;
 }
 
-static int stm32x_write(struct flash_bank *bank, uint8_t *buffer,
+static int stm32x_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
index eb4f96ddca2eabce2ec92654e9ab484192580912..75cecce61e5c923fd8d0fed88a86fff3ea9b19f1 100644 (file)
@@ -212,7 +212,7 @@ static int stm32lx_protect(struct flash_bank *bank, int set, int first,
        return ERROR_OK;
 }
 
-static int stm32lx_write_half_pages(struct flash_bank *bank, uint8_t *buffer,
+static int stm32lx_write_half_pages(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
@@ -403,7 +403,7 @@ static int stm32lx_write_half_pages(struct flash_bank *bank, uint8_t *buffer,
        return retval;
 }
 
-static int stm32lx_write(struct flash_bank *bank, uint8_t *buffer,
+static int stm32lx_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
index eea1d9f48e650fae2ab20e6cbaaabfe8577cbebb..6f73c3684eaf81e9f6a4258a3842d09dcb66515b 100644 (file)
@@ -372,7 +372,7 @@ static int stmsmi_protect(struct flash_bank *bank, int set,
        return ERROR_OK;
 }
 
-static int smi_write_buffer(struct flash_bank *bank, uint8_t *buffer,
+static int smi_write_buffer(struct flash_bank *bank, const uint8_t *buffer,
        uint32_t address, uint32_t len)
 {
        struct target *target = bank->target;
@@ -397,7 +397,7 @@ static int smi_write_buffer(struct flash_bank *bank, uint8_t *buffer,
        return ERROR_OK;
 }
 
-static int stmsmi_write(struct flash_bank *bank, uint8_t *buffer,
+static int stmsmi_write(struct flash_bank *bank, const uint8_t *buffer,
        uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
index 32c8ebd5e034880a5f9e7cca3cddd95834a2fe23..515b9751272fabf44d879d9e0ccdb17ddbad3ddd 100644 (file)
@@ -442,7 +442,7 @@ static int str7x_protect(struct flash_bank *bank, int set, int first, int last)
        return ERROR_OK;
 }
 
-static int str7x_write_block(struct flash_bank *bank, uint8_t *buffer,
+static int str7x_write_block(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct str7x_flash_bank *str7x_info = bank->driver_priv;
@@ -559,7 +559,7 @@ static int str7x_write_block(struct flash_bank *bank, uint8_t *buffer,
        return retval;
 }
 
-static int str7x_write(struct flash_bank *bank, uint8_t *buffer,
+static int str7x_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
index 2158622a10016c80a7e945a6ff01bafaa8228706..8b3c1371484dbce5fdc7ca788a870984282af917 100644 (file)
@@ -347,7 +347,7 @@ static int str9x_protect(struct flash_bank *bank,
 }
 
 static int str9x_write_block(struct flash_bank *bank,
-               uint8_t *buffer, uint32_t offset, uint32_t count)
+               const uint8_t *buffer, uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
        uint32_t buffer_size = 32768;
@@ -459,7 +459,7 @@ static int str9x_write_block(struct flash_bank *bank,
 }
 
 static int str9x_write(struct flash_bank *bank,
-               uint8_t *buffer, uint32_t offset, uint32_t count)
+               const uint8_t *buffer, uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
        uint32_t words_remaining = (count / 2);
index e08495da05494b012fda61836b1178d33a2d111a..f0af53a4154801647a2b15d86708ce90490cdd0b 100644 (file)
@@ -565,7 +565,7 @@ static int str9xpec_set_address(struct flash_bank *bank, uint8_t sector)
        return ERROR_OK;
 }
 
-static int str9xpec_write(struct flash_bank *bank, uint8_t *buffer,
+static int str9xpec_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct str9xpec_flash_controller *str9xpec_info = bank->driver_priv;
index 3851504d67f4ec6c93c23ca57d1b03dde3ac3c14..86858a84ed9ffea3a9e11869b8eec827ec9b477e 100644 (file)
@@ -890,7 +890,7 @@ static int tms470_protect(struct flash_bank *bank, int set, int first, int last)
 
 /* ---------------------------------------------------------------------- */
 
-static int tms470_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count)
+static int tms470_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
        uint32_t glbctrl, fmbac2, orig_fmregopt, fmbsea, fmbseb, fmmaxpp, fmmstat;
index fab521dd6cff296df8f4b7aa982109dacd1957be..599a9c09d739e84d344d4405f7bb115bae20dc38 100644 (file)
@@ -119,7 +119,7 @@ static int virtual_erase(struct flash_bank *bank, int first, int last)
        return ERROR_OK;
 }
 
-static int virtual_write(struct flash_bank *bank, uint8_t *buffer,
+static int virtual_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct flash_bank *master_bank = virtual_get_master_bank(bank);
index f72d336378b2f484fc964edf4396962052bda5a7..8a58cab473e17ec2c89d94bcab7771cf7d845138 100644 (file)
@@ -1524,7 +1524,7 @@ static int dsp5680xx_checksum_memory(struct target *t, uint32_t a, uint32_t s,
  *
  * @return
  */
-static int perl_crc(uint8_t *buff8, uint32_t word_count)
+static int perl_crc(const uint8_t *buff8, uint32_t word_count)
 {
        uint16_t checksum = 0xffff;
 
@@ -1983,14 +1983,14 @@ const uint16_t pgm_write_pflash[] = { 0x8A46, 0x0013, 0x807D, 0xE700,
 
 const uint32_t pgm_write_pflash_length = 31;
 
-int dsp5680xx_f_wr(struct target *t, uint8_t *b, uint32_t a, uint32_t count,
+int dsp5680xx_f_wr(struct target *t, const uint8_t *b, uint32_t a, uint32_t count,
                   int is_flash_lock)
 {
        struct target *target = t;
 
        uint32_t address = a;
 
-       uint8_t *buffer = b;
+       const uint8_t *buffer = b;
 
        int retval = ERROR_OK;
 
index 1b71009086d97b05513deea2e92d86acce492da2..cb3bf2a4f559113be762922fc9ac5ec0ce561a41 100644 (file)
@@ -317,7 +317,7 @@ static inline struct dsp5680xx_common *target_to_dsp5680xx(struct target
  *
  * @return
  */
-int dsp5680xx_f_wr(struct target *target, uint8_t * buffer, uint32_t address,
+int dsp5680xx_f_wr(struct target *target, const uint8_t * buffer, uint32_t address,
                uint32_t count, int is_flash_lock);
 
 /**
index 43c897d9ffa06ea27d2f63f19cde6c55556520b1..c09dfd865e5b087a40c41d34f89e349aa5bf0e49 100644 (file)
@@ -853,7 +853,7 @@ done:
  */
 
 int target_run_flash_async_algorithm(struct target *target,
-               uint8_t *buffer, uint32_t count, int block_size,
+               const uint8_t *buffer, uint32_t count, int block_size,
                int num_mem_params, struct mem_param *mem_params,
                int num_reg_params, struct reg_param *reg_params,
                uint32_t buffer_start, uint32_t buffer_size,
index 3ce164a2052115222a2f0c3b5ab3e69302500175..8e1c8f95da5dac0f8f0542e3276b2cce58a9f99f 100644 (file)
@@ -474,7 +474,7 @@ int target_wait_algorithm(struct target *target,
  *
  */
 int target_run_flash_async_algorithm(struct target *target,
-               uint8_t *buffer, uint32_t count, int block_size,
+               const uint8_t *buffer, uint32_t count, int block_size,
                int num_mem_params, struct mem_param *mem_params,
                int num_reg_params, struct reg_param *reg_params,
                uint32_t buffer_start, uint32_t buffer_size,

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)