X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fflash%2Fnor%2Fatsame5.c;h=c590081fcc7f575814f882cff9ada7e3a5158197;hp=ed0bef463b61d830073092d72c06fb72da3dbb44;hb=HEAD;hpb=e66593f8242d49dd05f6b9c4a5121fa466a158aa diff --git a/src/flash/nor/atsame5.c b/src/flash/nor/atsame5.c index ed0bef463b..c590081fcc 100644 --- a/src/flash/nor/atsame5.c +++ b/src/flash/nor/atsame5.c @@ -1,3 +1,5 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + /*************************************************************************** * Copyright (C) 2017 by Tomas Vanek * * vanekt@fbl.cz * @@ -5,19 +7,6 @@ * Based on at91samd.c * * Copyright (C) 2013 by Andrey Yurovsky * * Andrey Yurovsky * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * ***************************************************************************/ #ifdef HAVE_CONFIG_H @@ -28,6 +17,7 @@ #include "helper/binarybuffer.h" #include +#include #include /* A note to prefixing. @@ -103,7 +93,7 @@ #define SAMD_GET_DEVSEL(id) (id & 0xFF) /* Bits to mask user row */ -#define NVMUSERROW_SAM_E5_D5_MASK ((uint64_t)0x7FFF00FF3C007FFF) +#define NVMUSERROW_SAM_E5_D5_MASK 0x7FFF00FF3C007FFFULL struct samd_part { uint8_t id; @@ -113,7 +103,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 +124,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. */ @@ -143,6 +135,9 @@ static const struct samd_part same53_parts[] = { { 0x04, "SAME53J20A", 1024, 256 }, { 0x05, "SAME53J19A", 512, 192 }, { 0x06, "SAME53J18A", 256, 128 }, + { 0x55, "LAN9255/ZMX020", 1024, 256 }, + { 0x56, "LAN9255/ZMX019", 512, 192 }, + { 0x57, "LAN9255/ZMX018", 256, 128 }, }; /* Known SAME54 parts. */ @@ -218,7 +213,7 @@ static const struct samd_part *samd_find_part(uint32_t id) { uint8_t devsel = SAMD_GET_DEVSEL(id); const struct samd_family *family = samd_find_family(id); - if (family == NULL) + if (!family) return NULL; for (unsigned i = 0; i < family->num_parts; i++) { @@ -285,7 +280,7 @@ static int same5_probe(struct flash_bank *bank) } part = samd_find_part(id); - if (part == NULL) { + if (!part) { LOG_ERROR("Couldn't find part corresponding to DID %08" PRIx32, id); return ERROR_FAIL; } @@ -795,11 +790,12 @@ COMMAND_HANDLER(same5_handle_userpage_command) } if (CMD_ARGC >= 1) { - uint64_t mask = NVMUSERROW_SAM_E5_D5_MASK; - uint64_t value = strtoull(CMD_ARGV[0], NULL, 0); + uint64_t value, mask = NVMUSERROW_SAM_E5_D5_MASK; + COMMAND_PARSE_NUMBER(u64, CMD_ARGV[0], value); if (CMD_ARGC == 2) { - uint64_t mask_temp = strtoull(CMD_ARGV[1], NULL, 0); + uint64_t mask_temp; + COMMAND_PARSE_NUMBER(u64, CMD_ARGV[1], mask_temp); mask &= mask_temp; } @@ -835,7 +831,9 @@ COMMAND_HANDLER(same5_handle_bootloader_command) return ERROR_FAIL; if (CMD_ARGC >= 1) { - unsigned long size = strtoul(CMD_ARGV[0], NULL, 0); + unsigned long size; + + COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[0], size); uint32_t code = (size + 8191) / 8192; if (code > 15) { command_print(CMD, "Invalid bootloader size. Please "