X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fflash%2Fnor%2Fatsame5.c;h=50e56a72ae9f43150f5420d94674e5e6b1d6d15c;hb=f13bb10e267f9d474901a0f7b4fbb2975920668c;hp=baa86acd09eaeae278e66b451d336d1203d0484c;hpb=a2e6982a1816a0229bd5644156f3025a0e8cb6ce;p=fw%2Fopenocd diff --git a/src/flash/nor/atsame5.c b/src/flash/nor/atsame5.c index baa86acd0..50e56a72a 100644 --- a/src/flash/nor/atsame5.c +++ b/src/flash/nor/atsame5.c @@ -31,10 +31,10 @@ #include /* A note to prefixing. - * Definitions and functions ingerited from at91samd.c without - * any change retained the original prefix samd_ so they eventualy + * Definitions and functions inherited from at91samd.c without + * any change retained the original prefix samd_ so they eventually * may go to samd_common.h and .c - * As currently there are olny 3 short functions identical with + * As currently there are only 3 short functions identical with * the original source, no common file was created. */ #define SAME5_PAGES_PER_BLOCK 16 @@ -113,7 +113,7 @@ struct samd_part { }; /* See SAM D5x/E5x Family Silicon Errata and Data Sheet Clarification - * DS80000748B */ + * DS80000748K */ /* Known SAMD51 parts. */ static const struct samd_part samd51_parts[] = { { 0x00, "SAMD51P20A", 1024, 256 }, @@ -134,6 +134,8 @@ static const struct samd_part same51_parts[] = { { 0x02, "SAME51J19A", 512, 192 }, { 0x03, "SAME51J18A", 256, 128 }, { 0x04, "SAME51J20A", 1024, 256 }, + { 0x05, "SAME51G19A", 512, 192 }, /* New in rev D */ + { 0x06, "SAME51G18A", 256, 128 }, /* New in rev D */ }; /* Known SAME53 parts. */ @@ -231,7 +233,7 @@ static const struct samd_part *samd_find_part(uint32_t id) static int same5_protect_check(struct flash_bank *bank) { - int res, prot_block; + int res; uint32_t lock; res = target_read_u32(bank->target, @@ -240,7 +242,7 @@ static int same5_protect_check(struct flash_bank *bank) return res; /* Lock bits are active-low */ - for (prot_block = 0; prot_block < bank->num_prot_blocks; prot_block++) + for (unsigned int prot_block = 0; prot_block < bank->num_prot_blocks; prot_block++) bank->prot_blocks[prot_block].is_protected = !(lock & (1u<prot_blocks[prot_block].is_protected) { /* Load an address that is within this protection block (we use offset 0) */ res = target_write_u32(bank->target, @@ -606,7 +608,7 @@ static int same5_protect(struct flash_bank *bank, int set, int first_prot_bl, in const uint8_t unlock[4] = { 0xff, 0xff, 0xff, 0xff }; uint8_t mask[4] = { 0, 0, 0, 0 }; - buf_set_u32(mask, first_prot_bl, last_prot_bl + 1 - first_prot_bl, 0xffffffff); + buf_set_u32(mask, first, last + 1 - first, 0xffffffff); res = same5_modify_user_row_masked(bank->target, set ? lock : unlock, mask, 8, 4); @@ -621,9 +623,10 @@ exit: return res; } -static int same5_erase(struct flash_bank *bank, int first_sect, int last_sect) +static int same5_erase(struct flash_bank *bank, unsigned int first, + unsigned int last) { - int res, s; + int res; struct samd_info *chip = (struct samd_info *)bank->driver_priv; if (bank->target->state != TARGET_HALTED) { @@ -636,7 +639,7 @@ static int same5_erase(struct flash_bank *bank, int first_sect, int last_sect) return ERROR_FLASH_BANK_NOT_PROBED; /* For each sector to be erased */ - for (s = first_sect; s <= last_sect; s++) { + for (unsigned int s = first; s <= last; s++) { res = same5_erase_block(bank->target, bank->sectors[s].offset); if (res != ERROR_OK) { LOG_ERROR("SAM: failed to erase sector %d at 0x%08" PRIx32, s, bank->sectors[s].offset); @@ -730,9 +733,7 @@ static int same5_write(struct flash_bank *bank, const uint8_t *buffer, } free_pb: - if (pb) - free(pb); - + free(pb); return res; } @@ -741,7 +742,7 @@ FLASH_BANK_COMMAND_HANDLER(same5_flash_bank_command) { if (bank->base != SAMD_FLASH) { LOG_ERROR("Address " TARGET_ADDR_FMT " invalid bank address (try " - "0x%08" PRIx32 "[same5] )", bank->base, SAMD_FLASH); + "0x%08x[same5] )", bank->base, SAMD_FLASH); return ERROR_FAIL; }