flash/nor: mrvlqspi: fix printf formatting issues
[openocd.git] / src / flash / nor / efm32.c
index 858bb0a70885257d3f3799baef33b39e8ebe4b59..35c0732089a40cbcf57513801f66da81d57293d5 100644 (file)
  *                                                                         *
  *   Copyright (C) 2013 by Roman Dmitrienko                                *
  *   me@iamroman.org                                                       *
- *
+ *                                                                         *
+ *   Copyright (C) 2014 Nemui Trinomius                                    *
+ *   nemuisan_kawausogasuki@live.jp                                        *
+ *                                                                         *
  *   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     *
@@ -43,6 +46,7 @@
 #define EFM_FAMILY_ID_TINY_GECKO        73
 #define EFM_FAMILY_ID_LEOPARD_GECKO     74
 #define EFM_FAMILY_ID_WONDER_GECKO      75
+#define EFM_FAMILY_ID_ZERO_GECKO        76
 
 #define EFM32_FLASH_ERASE_TMO           100
 #define EFM32_FLASH_WDATAREADY_TMO      100
@@ -98,7 +102,7 @@ struct efm32_info {
        uint16_t page_size;
 };
 
-static int efm32x_write(struct flash_bank *bank, uint8_t *buffer,
+static int efm32x_write(struct flash_bank *bank, const uint8_t *buffer,
        uint32_t offset, uint32_t count);
 
 static int efm32x_get_flash_size(struct flash_bank *bank, uint16_t *flash_sz)
@@ -141,9 +145,11 @@ static int efm32x_read_info(struct flash_bank *bank,
        if (((cpuid >> 4) & 0xfff) == 0xc23) {
                /* Cortex M3 device */
        } else if (((cpuid >> 4) & 0xfff) == 0xc24) {
-               /* Cortex M4 device */
+               /* Cortex M4 device(WONDER GECKO) */
+       } else if (((cpuid >> 4) & 0xfff) == 0xc60) {
+               /* Cortex M0plus device(ZERO GECKO) */
        } else {
-               LOG_ERROR("Target is not CortexM3 or M4");
+               LOG_ERROR("Target is not Cortex-Mx Device");
                return ERROR_FAIL;
        }
 
@@ -170,6 +176,8 @@ static int efm32x_read_info(struct flash_bank *bank,
        if (EFM_FAMILY_ID_GECKO == efm32_info->part_family ||
                        EFM_FAMILY_ID_TINY_GECKO == efm32_info->part_family)
                efm32_info->page_size = 512;
+       else if (EFM_FAMILY_ID_ZERO_GECKO == efm32_info->part_family)
+               efm32_info->page_size = 1024;
        else if (EFM_FAMILY_ID_GIANT_GECKO == efm32_info->part_family ||
                        EFM_FAMILY_ID_LEOPARD_GECKO == efm32_info->part_family) {
                if (efm32_info->prod_rev >= 18) {
@@ -499,7 +507,7 @@ static int efm32x_protect(struct flash_bank *bank, int set, int first, int last)
        return ERROR_OK;
 }
 
-static int efm32x_write_block(struct flash_bank *bank, uint8_t *buf,
+static int efm32x_write_block(struct flash_bank *bank, const uint8_t *buf,
        uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
@@ -735,7 +743,7 @@ static int efm32x_write_word(struct flash_bank *bank, uint32_t addr,
        return ERROR_OK;
 }
 
-static int efm32x_write(struct flash_bank *bank, uint8_t *buffer,
+static int efm32x_write(struct flash_bank *bank, const uint8_t *buffer,
                uint32_t offset, uint32_t count)
 {
        struct target *target = bank->target;
@@ -763,7 +771,7 @@ static int efm32x_write(struct flash_bank *bank, uint8_t *buffer,
                }
                LOG_INFO("odd number of bytes to write (%" PRIu32 "), extending to %" PRIu32 " "
                        "and padding with 0xff", old_count, count);
-               memset(buffer, 0xff, count);
+               memset(new_buffer, 0xff, count);
                buffer = memcpy(new_buffer, buffer, old_count);
        }
 
@@ -843,6 +851,9 @@ static int efm32x_probe(struct flash_bank *bank)
                case EFM_FAMILY_ID_WONDER_GECKO:
                        LOG_INFO("Wonder Gecko MCU detected");
                        break;
+               case EFM_FAMILY_ID_ZERO_GECKO:
+                       LOG_INFO("Zero Gecko MCU detected");
+                       break;
                default:
                        LOG_ERROR("Unsupported MCU family %d",
                                efm32_mcu_info.part_family);
@@ -956,6 +967,9 @@ static int get_efm32x_info(struct flash_bank *bank, char *buf, int buf_size)
                case EFM_FAMILY_ID_WONDER_GECKO:
                        printed = snprintf(buf, buf_size, "Wonder Gecko");
                        break;
+               case EFM_FAMILY_ID_ZERO_GECKO:
+                       printed = snprintf(buf, buf_size, "Zero Gecko");
+                       break;
        }
 
        buf += printed;

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)