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>
This commit is contained in:
committed by
Spencer Oliver
parent
592d0d514d
commit
db4b2c2536
@@ -5045,6 +5045,34 @@ at91samd set-security enable
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
@deffn Command {at91samd eeprom}
|
||||
Shows or sets the EEPROM emulation size configuration, stored in the User Row
|
||||
of the Flash. When setting, the EEPROM size must be specified in bytes and it
|
||||
must be one of the permitted sizes according to the datasheet. Settings are
|
||||
written immediately but only take effect on MCU reset. EEPROM emulation
|
||||
requires additional firmware support and the minumum EEPROM size may not be
|
||||
the same as the minimum that the hardware supports. Set the EEPROM size to 0
|
||||
in order to disable this feature.
|
||||
|
||||
@example
|
||||
at91samd eeprom
|
||||
at91samd eeprom 1024
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
@deffn Command {at91samd bootloader}
|
||||
Shows or sets the bootloader size configuration, stored in the User Row of the
|
||||
Flash. This is called the BOOTPROT region. When setting, the bootloader size
|
||||
must be specified in bytes and it must be one of the permitted sizes according
|
||||
to the datasheet. Settings are written immediately but only take effect on
|
||||
MCU reset. Setting the bootloader size to 0 disables bootloader protection.
|
||||
|
||||
@example
|
||||
at91samd bootloader
|
||||
at91samd bootloader 16384
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
@end deffn
|
||||
|
||||
@anchor{at91sam3}
|
||||
|
||||
Reference in New Issue
Block a user