flash: EFM32 GG/LG page size detection fix 16/1116/2
authorRoman D <me@iamroman.org>
Fri, 18 Jan 2013 06:53:43 +0000 (10:53 +0400)
committerSpencer Oliver <spen@spen-soft.co.uk>
Fri, 18 Jan 2013 09:19:21 +0000 (09:19 +0000)
Fixed flash page size detection according to EFM32 GG/LG errata.
MEM_INFO_PAGE_SIZE register containts invalid value in devices with
revision number lower than 18 and should not be used.

Change-Id: Idb2832246efcbbec2fd98a5c458f72a36df386fb
Signed-off-by: Roman D <me@iamroman.org>
Reviewed-on: http://openocd.zylin.com/1116
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/flash/nor/efm32.c

index 57566499908e54d74c7946ca136e5e8e7838e2bd..37cb79b40d6a2dd40c123b47bc0c5e579f67e0d2 100644 (file)
@@ -169,14 +169,22 @@ static int efm32x_read_info(struct flash_bank *bank,
                efm32_info->page_size = 512;
        else if (EFM_FAMILY_ID_GIANT_GECKO == efm32_info->part_family ||
                        EFM_FAMILY_ID_LEOPARD_GECKO == efm32_info->part_family) {
-               uint8_t pg_size = 0;
-
-               ret = target_read_u8(bank->target, EFM32_MSC_DI_PAGE_SIZE,
-                       &pg_size);
-               if (ERROR_OK != ret)
-                       return ret;
-
-               efm32_info->page_size = (1 << ((pg_size+10) & 0xff));
+               if (efm32_info->prod_rev >= 18) {
+                       uint8_t pg_size = 0;
+                       ret = target_read_u8(bank->target, EFM32_MSC_DI_PAGE_SIZE,
+                               &pg_size);
+                       if (ERROR_OK != ret)
+                               return ret;
+
+                       efm32_info->page_size = (1 << ((pg_size+10) & 0xff));
+               } else {
+                       /* EFM32 GG/LG errata: MEM_INFO_PAGE_SIZE is invalid
+                          for MCUs with PROD_REV < 18 */
+                       if (efm32_info->flash_sz_kib < 512)
+                               efm32_info->page_size = 2048;
+                       else
+                               efm32_info->page_size = 4096;
+               }
 
                if ((2048 != efm32_info->page_size) &&
                                (4096 != efm32_info->page_size)) {

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)