Commit Graph

18 Commits

Author SHA1 Message Date
Andrey Yurovsky
2cf48d2c79 flash: at91samd: add SAML21 support, fix part ID issue
This adds support for the new Atmel SAML21 family of low-power Cortex
M0+ devices.  Their Flash controller is essentially the SAMDxx one so
the change consists of adding the new part IDs.  Unfortunately the
device ID logic had a couple of mistakes in it that did not affect
anything on SAMD2x devices (due to 0 values expected there) but that is
a problem on L21, it's therefore addressed here and things should now
match the datasheets.

Tested on Amtel SAML21 Xplained Pro development kit against the included
SAML21J18A there.  Also tested for regressions on a SAMD20 and SAMD21
using their dev kits.

Change-Id: I768f75e064b8656c15148730dacaa4c3acfc4101
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/2690
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2015-04-16 20:30:34 +01:00
Paul Fertser
5387d616a3 Fix several format specifiers errors exposed by arm-none-eabi
Change-Id: I1fe5c5c0b22cc23deedcf13ad5183c957551a1b7
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2719
Tested-by: jenkins
2015-04-16 20:24:50 +01:00
Andrej Kazmin
7c59257834 flash/nor/at91samd: add small delay before checking nvm status
OpenOCD's SWD subsystem doesn't currently have a consistent WAIT
handling (i.e. it doesn't ever retry, just returns an error), so right
after a row write a small delay is needed as AHB access is stalled
during the flashing operation.

The issue was exposed with a samd20 using ftdi SWD transport.

Change-Id: I07d99d3a96845cc689c3904a41f4d41344f200aa
Signed-off-by: Andrej Kazmin <funnyfish@funnyfish.botik.ru>
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2268
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
2015-02-11 23:22:40 +00:00
Andrey Yurovsky
08607aefc0 flash: at91samd: fix use of is_erased in check
is_erased can be one of -1, 0, or 1 so it must not be checked like a
boolean value.  In this case we want to erase a page unless we know it's
already erased so we just check for is_erased != 1.

Thanks to Jim Paris for pointing this out on another driver.

Change-Id: I4591186228153b64e5a9608a2aac18745e578d4a
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/2368
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-11-24 22:18:59 +00:00
Andrey Yurovsky
db4b2c2536 at91samd: fix protect, add EEPROM and boot commands
There were two problems with the _protect() feature:
1. The address written was off by a factor of two because the address
register takes 16-bit rather than 8-bit addresses.  As a result the
wrong sectors were (un)protected with the protect command.  This has
been fixed.
2. The protection settings issued via the lock or unlock region commands
don't persist after reset.  Making them persist requires modifying the
LOCK bits in the User Row using the infrastructure described below.

The Atmel SAMD2x MCUs provide a User Row (the size of which is one
page).  This contains a few settings that users may wish to modify from
the debugger, especially during production.  This change adds commands
to inspect and set:
- EEPROM size, the size in bytes of the emulated EEPROM region of the
  Flash.
- Bootloader size, the size in bytes of the protected "boot" section of
  the Flash.

This is done by a careful read-modify-write of the special User Row
page, avoiding erasing when possible and disallowing the changing of
documented reserved bits.  The Atmel SAMD20 datasheet was used for bit
positions and descriptions, size tables, etc. and testing was done on a
SAMD20 Xplained Pro board.

It's technically possible to store arbitrary user data (ex: serial
numbers, MAC addresses, etc) in the remaining portion of the User Row
page (that is, beyond the first 64 bits of it).  The infrastructure used
by the eeprom and bootloader commands can be used to access this as
well, and this seems safer than exposing the User Row as a normal Flash
sector that openocd understands due to the delicate nature of some of
the data stored there.

Change-Id: I29ca1bdbdc7884bc0ba0ad18af1b6bab78c7ad38
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/2326
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 11:56:40 +00:00
Andrey Yurovsky
592d0d514d at91samd: add erase/secure commands, minor fix
Reference code for the SAMD2x disables caching in the NVM controller when
issuing NVM commands.  Let's do this as well to be consistent and safer.

Add a "chip-erase" for the Atmel SAMD targets that issues a complete Chip Erase
via the Device Service Unit (DSU).  This can be used to "unlock" or otherwise
unbrick a chip that can't be halted or inspected, allowing the user to reflash
with new firmware.

Add a "set-security" command which issues an SSB.  Once that's done and the
device is power-cycled, the flash cannot be written to until a "chip-erase" is
issued.  The chip-erase cannot be issued by openocd at this time because
the device will not respond to a request for the DAP IDCODE.

Change-Id: I80122f0bbf7e3aedffe052c1e77d69dc2dba25ed
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/2239
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-10-06 11:56:27 +00:00
Andrey Yurovsky
32e0fa6bcb flash: samd: add missing ID for SAMD20E18A
This was somehow missed in the chip ID table and of course that's
exactly the one on my board (as such, tested on hardware).

Change-Id: I212d7c729d979e0357f1d4635f40935e25fe6ff3
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/2260
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-08-19 20:24:02 +00:00
Thomas Schmid
48d2431968 Adding support for the Atmel SAMR21.
The Atmel SAMR21 is a Atmel SAMD21 with an Atmel RF233 in one package (two
dies). Tested with the SAMR21 Xplained Pro eval kit.

Change-Id: I1d79ea05834b925d7ec810527206fe86854e684b
Signed-off-by: Thomas Schmid <thomas@rfranging.com>
Reviewed-on: http://openocd.zylin.com/2194
Tested-by: jenkins
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-07-10 21:18:30 +00:00
Andrey Yurovsky
eea49ce509 flash: samd: add SAMD10 and SAMD11 part IDs
Add part IDs for the new SAMD10 and SAMD11 parts within the Atmel SAMD
family, they have the same Flash controller as the other samd parts and
should be supported by the at91samd driver.  Compile-tested only.

Change-Id: I493ae96a7d7e8d19e607fd9a4b6544a982be42b3
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/2170
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-06-22 08:47:49 +00:00
Paul Fertser
b1a1a48b30 Fix some C99 format specifiers
As exposed by arm-none-eabi build, fix the wrong modifiers.

Change-Id: Ia6ce7c5c1d40e95059525c3e5d81b752df2fea7c
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2122
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-05-05 20:18:38 +00:00
Andrey Smirnov
dba153bbce at91smad: Fixes to 'samd_protect'
Some fixes to 'samd_protect' including:
     - Fix a bug in which the value of 'set' parameter passed into the
     function was ignored so it was impossible to remove flash
     protection once it was set.
     - Check the protection status of the sector via 'is_protected'
     field of the  corresponding 'flash_sector' structure to see if
     any actual HW manipulations needs to be done.
     - Change the way the errors during protection activation are
     handled. Now even in the case of error in the middle of
     protecting a number of sectors the subroutine would still update
     the state of the sector protection in sectors array so as to
     avoid cases where openocd thinks that the sector is not protected
     while it actually is.

Change-Id: I4cc6445a98ec13bdd94c89f0711c17840738a215
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Reviewed-on: http://openocd.zylin.com/2027
Tested-by: jenkins
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-03-29 08:44:16 +00:00
Andrey Smirnov
c92a605e26 at91samd: Bail early if trying to erase protected sector
Bail early if trying to erase protected sector and also do not double-erase already
erased sectors.

Change-Id: Ic2d39af48c3b8e10e78d52dd978b9bc01f671c6a
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Reviewed-on: http://openocd.zylin.com/2026
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-03-29 08:44:08 +00:00
Andrey Smirnov
34db6b9c0a at91samd: Bail early if trying to write to protected sector
Bail early if trying to write to protected sector also mark the sector
we are writing to as dirty.

Change-Id: I892f83461792e1cc2dcccade7aa65717831a6805
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Reviewed-on: http://openocd.zylin.com/2025
Tested-by: jenkins
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-03-29 08:43:52 +00:00
Andrey Smirnov
e0f0ce965d at91samd: Remove 'first' and 'last' checks in 'samd_erase'
Remove 'first' and 'last' checks in 'samd_protect' since those
parameters are checked in 'handle_flash_erase_command'.

Change-Id: I30e5598a9ab656d81055f26cc63e291377605300
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Reviewed-on: http://openocd.zylin.com/2024
Tested-by: jenkins
Reviewed-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-by: Paul Fertser <fercerpav@gmail.com>
2014-03-29 08:43:43 +00:00
Andreas Fritiofson
565f8481c7 flash: Constify write buffer
Change-Id: Ic812098d3ed5a2992c26bb57d08ae350e2c5d5d8
Signed-off-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
Reviewed-on: http://openocd.zylin.com/2040
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-03-17 12:47:18 +00:00
Andrey Yurovsky
0b263763f5 flash: samd: declare const data
Make the chip information lookup tables const (thanks to Spencer Oliver for
pointing this out).  Also fix spacing on one macro.  No functional changes.

Change-Id: I053c4951c2626b8aa4541a79673b500394ef08e8
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/1874
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-01-20 14:25:54 +00:00
Andrey Yurovsky
32eea3f68e Atmel samd: add support for SAMD21
Tested with SAMD21J18A on the SAMD21 Xplained Pro board.

Change-Id: Ice9ebcd229ed038b3193baf92d910f9256d7ce91
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/1873
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-01-15 11:38:25 +00:00
Andrey Yurovsky
215c41c017 add support for Atmel SAMD NOR Flash
This adds a new NOR Flash driver, "at91samd", which supports the
built-in Flash on Atmel's D-series Cortex M MCUs, starting with the D20.
Parts and their geometry are detected automatically using the DSU and
lookup schemes described in the D20 document, 42129F–SAM–10/2013.
Future D-series variants and families should presumably use this
controller as well (possibly with minor changes and improvements).

Tested on the SAMD20 Xplained Pro board, for which we also add the
corresponding Flash configuration.

Change-Id: Id8d3dd601e9f53121682d1a1190d0be4ea3b83eb
Signed-off-by: Andrey Yurovsky <yurovsky@gmail.com>
Reviewed-on: http://openocd.zylin.com/1684
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
2014-01-09 15:23:27 +00:00