X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fflash%2Fat91sam7.c;h=6ac795b079ec30ec3593127a7d10bba006c90718;hb=f90d8fa45f2d4c9d4b7990f198b232ee55cbb4e1;hp=2ab1cd3f2957a5a20e6ca7a9a19042c4991f5212;hpb=8959de9f679cfd0436d731fd91b88a68b9a75fa6;p=fw%2Fopenocd diff --git a/src/flash/at91sam7.c b/src/flash/at91sam7.c index 2ab1cd3f2..6ac795b07 100644 --- a/src/flash/at91sam7.c +++ b/src/flash/at91sam7.c @@ -107,7 +107,7 @@ static int at91sam7_register_commands(struct command_context_s *cmd_ctx) command_t *at91sam7_cmd = register_command(cmd_ctx, NULL, "at91sam7", NULL, COMMAND_ANY, NULL); register_command(cmd_ctx, at91sam7_cmd, "gpnvm", at91sam7_handle_gpnvm_command, COMMAND_EXEC, - "at91sam7 gpnvm set|clear, set or clear one gpnvm bit"); + "at91sam7 gpnvm set | clear, set or clear one gpnvm bit"); return ERROR_OK; } @@ -187,7 +187,7 @@ static void at91sam7_read_clock_info(flash_bank_t *bank) } /* Prescaler adjust */ - if ( (((mckr & PMC_MCKR_PRES) >> 2) == 7) || (tmp == 0) ) + if ((((mckr & PMC_MCKR_PRES) >> 2) == 7) || (tmp == 0) ) { at91sam7_info->mck_valid = 0; at91sam7_info->mck_freq = 0; @@ -284,7 +284,7 @@ static int at91sam7_flash_command(struct flash_bank_s *bank, uint8_t cmd, uint16 target_write_u32(target, MC_FCR[bank->bank_number], fcr); LOG_DEBUG("Flash command: 0x%" PRIx32 ", flash bank: %i, page number: %u", fcr, bank->bank_number + 1, pagen); - if ((at91sam7_info->cidr_arch == 0x60) && ((cmd == SLB)|(cmd == CLB))) + if ((at91sam7_info->cidr_arch == 0x60) && ((cmd == SLB) | (cmd == CLB))) { /* Lock bit manipulation on AT91SAM7A3 waits for FC_FSR bit 1, EOL */ if (at91sam7_wait_status_busy(bank, MC_FSR_EOL, 10)&0x0C) @@ -550,7 +550,7 @@ static int at91sam7_read_part_info(struct flash_bank_s *bank) /* calculate bank size */ bank_size = sectors_num * pages_per_sector * page_size; - for (bnk = 0; bnk 0) { @@ -575,7 +575,7 @@ static int at91sam7_read_part_info(struct flash_bank_s *bank) /* allocate sectors */ t_bank->sectors = malloc(sectors_num * sizeof(flash_sector_t)); - for (sec = 0; secsectors[sec].offset = sec * pages_per_sector * page_size; t_bank->sectors[sec].size = pages_per_sector * page_size; @@ -639,7 +639,7 @@ static int at91sam7_erase_check(struct flash_bank_s *bank) at91sam7_set_flash_mode(bank, FMR_TIMING_FLASH); fast_check = 1; - for (nSector = 0; nSectornum_sectors; nSector++) + for (nSector = 0; nSector < bank->num_sectors; nSector++) { retval = target_blank_check_memory(target, bank->base + bank->sectors[nSector].offset, bank->sectors[nSector].size, &blank); @@ -662,7 +662,7 @@ static int at91sam7_erase_check(struct flash_bank_s *bank) LOG_USER("Running slow fallback erase check - add working memory"); buffer = malloc(bank->sectors[0].size); - for (nSector = 0; nSectornum_sectors; nSector++) + for (nSector = 0; nSector < bank->num_sectors; nSector++) { bank->sectors[nSector].is_erased = 1; retval = target_read_memory(target, bank->base + bank->sectors[nSector].offset, 4, @@ -670,7 +670,7 @@ static int at91sam7_erase_check(struct flash_bank_s *bank) if (retval != ERROR_OK) return retval; - for (nByte = 0; nBytesectors[nSector].size; nByte++) + for (nByte = 0; nByte < bank->sectors[nSector].size; nByte++) { if (buffer[nByte] != 0xFF) { @@ -705,9 +705,9 @@ static int at91sam7_protect_check(struct flash_bank_s *bank) at91sam7_info->lockbits = (status >> 16); at91sam7_info->num_lockbits_on = 0; - for (lock_pos = 0; lock_posnum_sectors; lock_pos++) + for (lock_pos = 0; lock_pos < bank->num_sectors; lock_pos++) { - if ( ((status >> (16 + lock_pos))&(0x0001)) == 1) + if (((status >> (16 + lock_pos))&(0x0001)) == 1) { at91sam7_info->num_lockbits_on++; bank->sectors[lock_pos].is_protected = 1; @@ -723,9 +723,9 @@ static int at91sam7_protect_check(struct flash_bank_s *bank) at91sam7_info->nvmbits = (status >> 8)&0xFF; at91sam7_info->num_nvmbits_on = 0; - for (gpnvm_pos = 0; gpnvm_posnum_nvmbits; gpnvm_pos++) + for (gpnvm_pos = 0; gpnvm_pos < at91sam7_info->num_nvmbits; gpnvm_pos++) { - if ( ((status >> (8 + gpnvm_pos))&(0x01)) == 1) + if (((status >> (8 + gpnvm_pos))&(0x01)) == 1) { at91sam7_info->num_nvmbits_on++; } @@ -809,7 +809,7 @@ static int at91sam7_flash_bank_command(struct command_context_s *cmd_ctx, char * /* calculate bank size */ bank_size = num_sectors * pages_per_sector * page_size; - for (bnk = 0; bnk 0) { @@ -834,7 +834,7 @@ static int at91sam7_flash_bank_command(struct command_context_s *cmd_ctx, char * /* allocate sectors */ t_bank->sectors = malloc(num_sectors * sizeof(flash_sector_t)); - for (sec = 0; secsectors[sec].offset = sec * pages_per_sector * page_size; t_bank->sectors[sec].size = pages_per_sector * page_size; @@ -902,12 +902,12 @@ static int at91sam7_erase(struct flash_bank_s *bank, int first, int last) /* allocate and clean buffer */ nbytes = (last - first + 1) * bank->sectors[first].size; buffer = malloc(nbytes * sizeof(uint8_t)); - for (pos = 0; possectors[first].offset, nbytes) != ERROR_OK) + if (at91sam7_write(bank, buffer, bank->sectors[first].offset, nbytes) != ERROR_OK) { return ERROR_FLASH_OPERATION_FAILED; } @@ -1016,9 +1016,9 @@ static int at91sam7_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t o at91sam7_read_clock_info(bank); at91sam7_set_flash_mode(bank, FMR_TIMING_FLASH); - for (pagen = first_page; pagen "); + command_print(cmd_ctx, "at91sam7 gpnvm "); return ERROR_OK; }