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 <repeats 32 times>}
	(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 <sean@xobs.io>
This commit is contained in:
Sean Cross 2021-12-29 22:10:18 +08:00 committed by UweBonnes
parent d00607f71a
commit c832cb04e7
1 changed files with 22 additions and 3 deletions

View File

@ -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,