From: Andrey Yurovsky Date: Tue, 30 Sep 2014 20:02:49 +0000 (-0700) Subject: at91samd: fix protect, add EEPROM and boot commands X-Git-Tag: v0.9.0-rc1~261 X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=commitdiff_plain;h=db4b2c25360d7adadb9198e4c817f0d1d211976d;hp=db4b2c25360d7adadb9198e4c817f0d1d211976d 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 Reviewed-on: http://openocd.zylin.com/2326 Tested-by: jenkins Reviewed-by: Spencer Oliver ---