]> git.sur5r.net Git - openocd/blobdiff - src/flash/nor/pic32mx.c
flash: Constify write buffer
[openocd] / src / flash / nor / pic32mx.c
index 842fd76bba7fc5193fca83ad3c6b3eaeb8a74820..5e82ba63d58b08c72255e1f0b06bee72f548ec73 100644 (file)
@@ -21,7 +21,7 @@
  *   You should have received a copy of the GNU General Public License     *
  *   along with this program; if not, write to the                         *
  *   Free Software Foundation, Inc.,                                       *
- *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
  ***************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -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;
@@ -449,8 +449,10 @@ static int pic32mx_write_block(struct flash_bank *bank, uint8_t *buffer,
                row_size = 512;
        }
 
-       retval = target_write_buffer(target, write_algorithm->address,
-                       sizeof(pic32mx_flash_write_code), (uint8_t *)pic32mx_flash_write_code);
+       uint8_t code[sizeof(pic32mx_flash_write_code)];
+       target_buffer_set_u32_array(target, code, ARRAY_SIZE(pic32mx_flash_write_code),
+                       pic32mx_flash_write_code);
+       retval = target_write_buffer(target, write_algorithm->address, sizeof(code), code);
        if (retval != ERROR_OK)
                return retval;
 
@@ -569,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);