mirror of
https://github.com/linux-msm/openocd.git
synced 2026-02-25 13:15:07 -08:00
flash/nor: flash driver and cfg for SAM E54, E53, E51 and D51
The new Microchip (former Atmel) series powered by Cortex-M4 looks very similar to older M0+ powered SAM D2x at the first sight. Unfortunately the new series differs a lot in important details. NVMCTRL has different register addresses, moved important bits and even changed binary command set. An universal driver for all SAM D/E would be very complicated. That's why a new driver was derived. Tested on Microchip SAM E54 Xplained Pro kit (board cfg included). Adjusted for the restructured dap support. Checked by valgrind and clang static analyzer. Change-Id: I26c67047a552076f4b207b9b89285a53d69b4ca4 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: http://openocd.zylin.com/4272 Tested-by: jenkins Reviewed-by: Andres Vahter <andres.vahter@gmail.com>
This commit is contained in:
@@ -5440,9 +5440,16 @@ the flash.
|
||||
@anchor{at91samd}
|
||||
@deffn {Flash Driver} at91samd
|
||||
@cindex at91samd
|
||||
All members of the ATSAMD, ATSAMR, ATSAML and ATSAMC microcontroller
|
||||
All members of the ATSAM D2x, D1x, D0x, ATSAMR, ATSAML and ATSAMC microcontroller
|
||||
families from Atmel include internal flash and use ARM's Cortex-M0+ core.
|
||||
This driver uses the same command names/syntax as @xref{at91sam3}.
|
||||
|
||||
Do not use for ATSAM D51 and E5x: use @xref{atsame5} instead.
|
||||
|
||||
The devices have one flash bank:
|
||||
|
||||
@example
|
||||
flash bank $_FLASHNAME at91samd 0x00000000 0 1 1 $_TARGETNAME
|
||||
@end example
|
||||
|
||||
@deffn Command {at91samd chip-erase}
|
||||
Issues a complete Flash erase via the Device Service Unit (DSU). This can be
|
||||
@@ -5604,9 +5611,72 @@ Command is used internally in event event reset-deassert-post.
|
||||
@end deffn
|
||||
@end deffn
|
||||
|
||||
@anchor{atsame5}
|
||||
@deffn {Flash Driver} atsame5
|
||||
@cindex atsame5
|
||||
All members of the SAM E54, E53, E51 and D51 microcontroller
|
||||
families from Microchip (former Atmel) include internal flash
|
||||
and use ARM's Cortex-M4 core.
|
||||
|
||||
The devices have two ECC flash banks with a swapping feature.
|
||||
This driver handles both banks together as it were one.
|
||||
Bank swapping is not supported yet.
|
||||
|
||||
@example
|
||||
flash bank $_FLASHNAME atsame5 0x00000000 0 1 1 $_TARGETNAME
|
||||
@end example
|
||||
|
||||
@deffn Command {atsame5 bootloader}
|
||||
Shows or sets the bootloader size configuration, stored in the User Page of the
|
||||
Flash. This is called the BOOTPROT region. When setting, the bootloader size
|
||||
must be specified in bytes. The nearest bigger protection size is used.
|
||||
Settings are written immediately but only take effect on MCU reset.
|
||||
Setting the bootloader size to 0 disables bootloader protection.
|
||||
|
||||
@example
|
||||
atsame5 bootloader
|
||||
atsame5 bootloader 16384
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
@deffn Command {atsame5 chip-erase}
|
||||
Issues a complete Flash erase via the Device Service Unit (DSU). This can be
|
||||
used to erase a chip back to its factory state and does not require the
|
||||
processor to be halted.
|
||||
@end deffn
|
||||
|
||||
@deffn Command {atsame5 dsu_reset_deassert}
|
||||
This command releases internal reset held by DSU
|
||||
and prepares reset vector catch in case of reset halt.
|
||||
Command is used internally in event event reset-deassert-post.
|
||||
@end deffn
|
||||
|
||||
@deffn Command {atsame5 userpage}
|
||||
Writes or reads the first 64 bits of NVM User Page which is located at
|
||||
0x804000. This field includes various fuses.
|
||||
Reading is done by invoking this command without any arguments.
|
||||
Writing is possible by giving 1 or 2 hex values. The first argument
|
||||
is the value to be written and the second one is an optional bit mask
|
||||
(a zero bit in the mask means the bit stays unchanged).
|
||||
The reserved fields are always masked out and cannot be changed.
|
||||
|
||||
@example
|
||||
# Read
|
||||
>atsame5 userpage
|
||||
USER PAGE: 0xAEECFF80FE9A9239
|
||||
# Write
|
||||
>atsame5 userpage 0xAEECFF80FE9A9239
|
||||
# Write 2 to SEESBLK and 4 to SEEPSZ fields but leave other bits unchanged
|
||||
# (setup SmartEEPROM of virtual size 8192 bytes)
|
||||
>atsame5 userpage 0x4200000000 0x7f00000000
|
||||
@end example
|
||||
@end deffn
|
||||
|
||||
@end deffn
|
||||
|
||||
@deffn {Flash Driver} atsamv
|
||||
@cindex atsamv
|
||||
All members of the ATSAMV, ATSAMS, and ATSAME families from
|
||||
All members of the ATSAMV7x, ATSAMS70, and ATSAME70 families from
|
||||
Atmel include internal flash and use ARM's Cortex-M7 core.
|
||||
This driver uses the same command names/syntax as @xref{at91sam3}.
|
||||
@end deffn
|
||||
|
||||
@@ -17,6 +17,7 @@ NOR_DRIVERS = \
|
||||
%D%/at91sam7.c \
|
||||
%D%/ath79.c \
|
||||
%D%/atsamv.c \
|
||||
%D%/atsame5.c \
|
||||
%D%/avrf.c \
|
||||
%D%/bluenrg-x.c \
|
||||
%D%/cc3220sf.c \
|
||||
|
||||
955
src/flash/nor/atsame5.c
Normal file
955
src/flash/nor/atsame5.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -29,6 +29,7 @@ extern struct flash_driver at91sam4l_flash;
|
||||
extern struct flash_driver at91sam7_flash;
|
||||
extern struct flash_driver at91samd_flash;
|
||||
extern struct flash_driver ath79_flash;
|
||||
extern struct flash_driver atsame5_flash;
|
||||
extern struct flash_driver atsamv_flash;
|
||||
extern struct flash_driver avr_flash;
|
||||
extern struct flash_driver bluenrgx_flash;
|
||||
@@ -97,6 +98,7 @@ static struct flash_driver *flash_drivers[] = {
|
||||
&at91sam7_flash,
|
||||
&at91samd_flash,
|
||||
&ath79_flash,
|
||||
&atsame5_flash,
|
||||
&atsamv_flash,
|
||||
&avr_flash,
|
||||
&bluenrgx_flash,
|
||||
|
||||
13
tcl/board/microchip_same54_xplained_pro.cfg
Normal file
13
tcl/board/microchip_same54_xplained_pro.cfg
Normal file
@@ -0,0 +1,13 @@
|
||||
#
|
||||
# Microchip (former Atmel) SAM E54 Xplained Pro evaluation kit.
|
||||
# http://www.microchip.com/developmenttools/productdetails.aspx?partno=atsame54-xpro
|
||||
#
|
||||
|
||||
source [find interface/cmsis-dap.cfg]
|
||||
|
||||
set CHIPNAME same54
|
||||
|
||||
source [find target/atsame5x.cfg]
|
||||
|
||||
reset_config srst_only
|
||||
|
||||
75
tcl/target/atsame5x.cfg
Normal file
75
tcl/target/atsame5x.cfg
Normal file
@@ -0,0 +1,75 @@
|
||||
#
|
||||
# Microchip (former Atmel) SAM E54, E53, E51 and D51 devices
|
||||
# with a Cortex-M4 core
|
||||
#
|
||||
|
||||
#
|
||||
# Devices only support SWD transports.
|
||||
#
|
||||
source [find target/swj-dp.tcl]
|
||||
|
||||
if { [info exists CHIPNAME] } {
|
||||
set _CHIPNAME $CHIPNAME
|
||||
} else {
|
||||
set _CHIPNAME atsame5
|
||||
}
|
||||
|
||||
if { [info exists ENDIAN] } {
|
||||
set _ENDIAN $ENDIAN
|
||||
} else {
|
||||
set _ENDIAN little
|
||||
}
|
||||
|
||||
# Work-area is a space in RAM used for flash programming
|
||||
# By default use 32kB (the smallest RAM size is 128kB)
|
||||
if { [info exists WORKAREASIZE] } {
|
||||
set _WORKAREASIZE $WORKAREASIZE
|
||||
} else {
|
||||
set _WORKAREASIZE 0x8000
|
||||
}
|
||||
|
||||
if { [info exists CPUTAPID] } {
|
||||
set _CPUTAPID $CPUTAPID
|
||||
} else {
|
||||
set _CPUTAPID 0x4ba00477
|
||||
}
|
||||
|
||||
swj_newdap $_CHIPNAME cpu -irlen 4 -expected-id $_CPUTAPID
|
||||
dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
|
||||
|
||||
set _TARGETNAME $_CHIPNAME.cpu
|
||||
target create $_TARGETNAME cortex_m -endian $_ENDIAN -dap $_CHIPNAME.dap
|
||||
|
||||
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
|
||||
|
||||
# SAM DSU will hold the CPU in reset if TCK is low when RESET_N
|
||||
# deasserts
|
||||
#
|
||||
# dsu_reset_deassert configures whether we want to run or halt out of reset,
|
||||
# then instruct the DSU to let us out of reset.
|
||||
$_TARGETNAME configure -event reset-deassert-post {
|
||||
atsame5 dsu_reset_deassert
|
||||
}
|
||||
|
||||
# SRST (wired to RESET_N) resets debug circuitry
|
||||
# srst_pulls_trst is not configured here to avoid an error raised in reset halt
|
||||
reset_config srst_gates_jtag
|
||||
|
||||
# Do not use a reset button with other SWD adapter than Atmel's EDBG.
|
||||
# DSU usually locks MCU in reset state until you issue a reset command
|
||||
# in OpenOCD.
|
||||
|
||||
# SAM E5x/D51 runs at SYSCLK = 48 MHz from RC oscillator after reset.
|
||||
# Atmel's EDBG (on-board cmsis-dap adapter of Xplained kits) works
|
||||
# without problem at clock speed over 5000 khz. Atmel recommends
|
||||
# adapter speed less than 10 * CPU clock.
|
||||
adapter_khz 2000
|
||||
|
||||
if {![using_hla]} {
|
||||
# if srst is not fitted use SYSRESETREQ to
|
||||
# perform a soft reset
|
||||
cortex_m reset_config sysresetreq
|
||||
}
|
||||
|
||||
set _FLASHNAME $_CHIPNAME.flash
|
||||
flash bank $_FLASHNAME atsame5 0x00000000 0 1 1 $_TARGETNAME
|
||||
Reference in New Issue
Block a user