From c832cb04e7a9acfcb3013b089f042aa5d7e56e9f Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Wed, 29 Dec 2021 22:10:18 +0800 Subject: [PATCH] samd: add support for SAMD09 The SAMD09 CPU is used in boards such as the Adafruit Seesaw. It has a smaller amount of memory and flash than other SAMD ports. This was tested with an Adafruit Seesaw. These boards come with preloaded firmware. As a test, the firmware was dumped and flash was erased. Then, flash was verified to be all zeroes. Finally, the firmware was loaded back in: (gdb) p/x *(unsigned int *)0@32 $8 = {0x20000f88, 0x1db, 0x1d1, 0x1d9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1d9, 0x0, 0x0, 0xf5, 0x1081, 0x1d9, 0x1d9, 0x1d9, 0x1d9, 0x1d9, 0x1d9, 0x1d9, 0x0, 0x1d9, 0x1d9, 0x25e9, 0x0, 0x0, 0x1d9, 0x1d9, 0x1d9} (gdb) dump ihex memory flash.ihex 0 8192 (gdb) mon erase_mass Erase successful! (gdb) p/x *(unsigned int *)0@32 $9 = {0xffffffff } (gdb) load flash.ihex Loading section .sec1, size 0x2000 lma 0x0 Start address 0x00000000, load size 8192 Transfer rate: 5 KB/sec, 910 bytes/write. (gdb) p/x *(unsigned int *)0@32 $10 = {0x20000f88, 0x1db, 0x1d1, 0x1d9, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1d9, 0x0, 0x0, 0xf5, 0x1081, 0x1d9, 0x1d9, 0x1d9, 0x1d9, 0x1d9, 0x1d9, 0x1d9, 0x0, 0x1d9, 0x1d9, 0x25e9, 0x0, 0x0, 0x1d9, 0x1d9, 0x1d9} (gdb) Signed-off-by: Sean Cross --- src/target/samd.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/src/target/samd.c b/src/target/samd.c index 86acbaa9..f6134088 100644 --- a/src/target/samd.c +++ b/src/target/samd.c @@ -22,6 +22,7 @@ * programming. * * Tested with + * * SAMD09D14A (rev B) * * SAMD20E17A (rev C) * * SAMD20J18A (rev B) * * SAMD21J18A (rev B) @@ -128,7 +129,7 @@ const struct command_s samd_cmd_list[] = { #define SAMD_STATUSB_PROT (1 << 16) /* Device Identification Register (DID) */ -#define SAMD_DID_MASK 0xFF3C0000 +#define SAMD_DID_MASK 0xFF380000 #define SAMD_DID_CONST_VALUE 0x10000000 #define SAMD_DID_DEVSEL_MASK 0xFF #define SAMD_DID_DEVSEL_POS 0 @@ -384,6 +385,7 @@ struct samd_descr samd_parse_device_id(uint32_t did) } break; case 3: samd.series = 11; break; + case 4: samd.series = 9; break; default: samd.series = 0; break; } /* Revision */ @@ -423,6 +425,23 @@ struct samd_descr samd_parse_device_id(uint32_t did) samd.mem = 14 - (devsel % 3); samd.variant = 'A'; break; + case 9: /* SAM D09 */ + samd.ram_size = 4096; + switch (devsel) { + case 0: + samd.pin = 'D'; + samd.mem = 14; + samd.flash_size = 16384; + samd.package[0] = 'M'; + break; + case 7: + samd.pin = 'C'; + samd.mem = 13; + samd.flash_size = 8192; + break; + } + samd.variant = 'A'; + break; } return samd; @@ -479,14 +498,14 @@ bool samd_probe(target *t) /* Part String */ if (protected) { sprintf(priv_storage->samd_variant_string, - "Atmel SAM%c%d%c%d%c%s (rev %c) (PROT=1)", + "Atmel SAM%c%02d%c%d%c%s (rev %c) (PROT=1)", samd.family, samd.series, samd.pin, samd.mem, samd.variant, samd.package, samd.revision); } else { sprintf(priv_storage->samd_variant_string, - "Atmel SAM%c%d%c%d%c%s (rev %c)", + "Atmel SAM%c%02d%c%d%c%s (rev %c)", samd.family, samd.series, samd.pin, samd.mem, samd.variant,