X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fflash%2Fnor%2Fstr7x.c;h=515b9751272fabf44d879d9e0ccdb17ddbad3ddd;hb=30f802493d1237eeef21282d4224ed89d8a4d480;hp=3d8ce5423e96ee46e7a8375147f669a3f877b4c7;hpb=43fc460559bb779a8867cc1eb9728e0e68fb7609;p=openocd.git diff --git a/src/flash/nor/str7x.c b/src/flash/nor/str7x.c index 3d8ce5423e..515b975127 100644 --- a/src/flash/nor/str7x.c +++ b/src/flash/nor/str7x.c @@ -113,7 +113,7 @@ enum str7x_status_codes { STR7X_BUSY = 11 }; -static struct str7x_mem_layout mem_layout_str7bank0[] = { +static const struct str7x_mem_layout mem_layout_str7bank0[] = { {0x00000000, 0x02000, 0x01}, {0x00002000, 0x02000, 0x02}, {0x00004000, 0x02000, 0x04}, @@ -124,7 +124,7 @@ static struct str7x_mem_layout mem_layout_str7bank0[] = { {0x00030000, 0x10000, 0x80} }; -static struct str7x_mem_layout mem_layout_str7bank1[] = { +static const struct str7x_mem_layout mem_layout_str7bank1[] = { {0x00000000, 0x02000, 0x10000}, {0x00002000, 0x02000, 0x20000} }; @@ -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; @@ -489,9 +489,10 @@ static int str7x_write_block(struct flash_bank *bank, uint8_t *buffer, return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; }; - target_write_buffer(target, write_algorithm->address, - sizeof(str7x_flash_write_code), - (uint8_t *)str7x_flash_write_code); + uint8_t code[sizeof(str7x_flash_write_code)]; + target_buffer_set_u32_array(target, code, ARRAY_SIZE(str7x_flash_write_code), + str7x_flash_write_code); + target_write_buffer(target, write_algorithm->address, sizeof(code), code); /* memory buffer */ while (target_alloc_working_area_try(target, buffer_size, &source) != ERROR_OK) { @@ -558,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;