bank->sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- for (int i = 0; i < bank->num_sectors; i++) {
+ for (unsigned int i = 0; i < bank->num_sectors; i++) {
if (i < 8) {
bank->sectors[i].offset = offset;
bank->sectors[i].size = 4 * 1024;
bank->sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- for (int i = 0; i < bank->num_sectors; i++) {
+ for (unsigned int i = 0; i < bank->num_sectors; i++) {
bank->sectors[i].offset = offset;
/* sectors 0-15 are 4kB-sized, 16 and above are 32kB-sized for LPC17xx/LPC40xx devices */
bank->sectors[i].size = (i < 16) ? 4 * 1024 : 32 * 1024;
bank->sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- for (int i = 0; i < bank->num_sectors; i++) {
+ for (unsigned int i = 0; i < bank->num_sectors; i++) {
bank->sectors[i].offset = offset;
/* sectors 0-7 are 8kB-sized, 8 and above are 64kB-sized for LPC43xx devices */
bank->sectors[i].size = (i < 8) ? 8 * 1024 : 64 * 1024;
bank->sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- for (int i = 0; i < bank->num_sectors; i++) {
+ for (unsigned int i = 0; i < bank->num_sectors; i++) {
bank->sectors[i].offset = offset;
/* all sectors are 1kB-sized for LPC8xx devices */
bank->sectors[i].size = 1 * 1024;
bank->sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- for (int i = 0; i < bank->num_sectors; i++) {
+ for (unsigned int i = 0; i < bank->num_sectors; i++) {
bank->sectors[i].offset = offset;
bank->sectors[i].size = (i < LPC11xx_REG_SECTORS ? 4 : 32) * 1024;
offset += bank->sectors[i].size;
bank->sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- for (int i = 0; i < bank->num_sectors; i++) {
+ for (unsigned int i = 0; i < bank->num_sectors; i++) {
bank->sectors[i].offset = offset;
/* all sectors are 4kB-sized */
bank->sectors[i].size = 4 * 1024;
bank->sectors = malloc(sizeof(struct flash_sector) * bank->num_sectors);
- for (int i = 0; i < bank->num_sectors; i++) {
+ for (unsigned int i = 0; i < bank->num_sectors; i++) {
bank->sectors[i].offset = offset;
/* all sectors are 32kB-sized */
bank->sectors[i].size = 32 * 1024;
int retval = target_write_memory(target, (*iap_working_area)->address, 4, 2, jump_gate);
if (retval != ERROR_OK) {
- LOG_ERROR("Write memory at address 0x%8.8" TARGET_PRIxADDR " failed (check work_area definition)",
+ LOG_ERROR("Write memory at address " TARGET_ADDR_FMT " failed (check work_area definition)",
(*iap_working_area)->address);
target_free_working_area(target, *iap_working_area);
}
return status_code;
}
-static int lpc2000_iap_blank_check(struct flash_bank *bank, int first, int last)
+static int lpc2000_iap_blank_check(struct flash_bank *bank, unsigned int first,
+ unsigned int last)
{
- if ((first < 0) || (last >= bank->num_sectors))
+ if (last >= bank->num_sectors)
return ERROR_FLASH_SECTOR_INVALID;
uint32_t param_table[5] = {0};
if (lpc2000_info->variant == lpc4300)
param_table[2] = lpc2000_info->lpc4300_bank;
- for (int i = first; i <= last && retval == ERROR_OK; i++) {
+ for (unsigned int i = first; i <= last && retval == ERROR_OK; i++) {
/* check single sector */
param_table[0] = param_table[1] = i;
int status_code = lpc2000_iap_call(bank, iap_working_area, 53, param_table, result_table);
return ERROR_OK;
}
-static int lpc2000_erase(struct flash_bank *bank, int first, int last)
+static int lpc2000_erase(struct flash_bank *bank, unsigned int first,
+ unsigned int last)
{
if (bank->target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
int first_sector = 0;
int last_sector = 0;
- for (int i = 0; i < bank->num_sectors; i++) {
+ for (unsigned int i = 0; i < bank->num_sectors; i++) {
if (offset >= bank->sectors[i].offset)
first_sector = i;
if (offset + DIV_ROUND_UP(count, dst_min_alignment) * dst_min_alignment > bank->sectors[i].offset)
break;
}
- /* Exit if error occured */
+ /* Exit if error occurred */
if (retval != ERROR_OK)
break;
free(last_buffer);
}
- LOG_DEBUG("writing 0x%" PRIx32 " bytes to address 0x%" PRIx32, thisrun_bytes,
- bank->base + offset + bytes_written);
+ LOG_DEBUG("writing 0x%" PRIx32 " bytes to address " TARGET_ADDR_FMT,
+ thisrun_bytes, bank->base + offset + bytes_written);
/* Write data */
param_table[0] = bank->base + offset + bytes_written;
break;
}
- /* Exit if error occured */
+ /* Exit if error occurred */
if (retval != ERROR_OK)
break;
{
struct lpc2000_flash_bank *lpc2000_info = bank->driver_priv;
- snprintf(buf, buf_size, "lpc2000 flash driver variant: %i, clk: %" PRIi32 "kHz", lpc2000_info->variant,
+ snprintf(buf, buf_size, "lpc2000 flash driver variant: %i, clk: %" PRIu32 "kHz", lpc2000_info->variant,
lpc2000_info->cclk);
return ERROR_OK;
int status_code = get_lpc2000_part_id(bank, &part_id);
if (status_code != 0x0) {
if (status_code == ERROR_FLASH_OPERATION_FAILED) {
- command_print(CMD_CTX, "no sufficient working area specified, can't access LPC2000 IAP interface");
+ command_print(CMD, "no sufficient working area specified, can't access LPC2000 IAP interface");
} else
- command_print(CMD_CTX, "lpc2000 IAP returned status code %i", status_code);
+ command_print(CMD, "lpc2000 IAP returned status code %i", status_code);
} else
- command_print(CMD_CTX, "lpc2000 part id: 0x%8.8" PRIx32, part_id);
+ command_print(CMD, "lpc2000 part id: 0x%8.8" PRIx32, part_id);
return retval;
}
COMMAND_REGISTRATION_DONE
};
-struct flash_driver lpc2000_flash = {
+const struct flash_driver lpc2000_flash = {
.name = "lpc2000",
.commands = lpc2000_command_handlers,
.flash_bank_command = lpc2000_flash_bank_command,