aboutsummaryrefslogtreecommitdiff
path: root/platform/atm2/ATM22xx-x1x/openocd
diff options
context:
space:
mode:
Diffstat (limited to 'platform/atm2/ATM22xx-x1x/openocd')
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/atm2x_flash.tcl1463
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/atm2x_gdb.tcl14
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/atm2x_nvm.tcl203
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/atm2x_openocd.cfg42
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/atm2x_peripheral_wrapper_operations.tcl515
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/atm2x_pseq.tcl57
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/atm2x_rom.tcl65
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/atm_coredump.tcl84
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/atm_ftdi.tcl89
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/atm_jlink.tcl50
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/atm_nvds.tcl22
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/atm_top.tcl25
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/coredump.tcl298
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/http/app.tcl22
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/http/bin_svc_server.tcl707
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/http/openocd_http.tcl35
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/http/run_bin_svc_server.tcl24
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/http/source_jimhttp.tcl8
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/m0_cpu.tcl52
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/regs/nvm.tcl80
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/regs/pmu.tcl43
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/regs/pseq.tcl388
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/regs/qspi.tcl87
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/regs/radio.tcl43
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/regs/regs_for_program.tcl10
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/regs/spi0.tcl43
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/regs/spi1.tcl43
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/regs/spi2.tcl43
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/regs/wrpr.tcl256
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/regs/wrpr1.tcl68
-rw-r--r--platform/atm2/ATM22xx-x1x/openocd/servers.tcl8
31 files changed, 4887 insertions, 0 deletions
diff --git a/platform/atm2/ATM22xx-x1x/openocd/atm2x_flash.tcl b/platform/atm2/ATM22xx-x1x/openocd/atm2x_flash.tcl
new file mode 100644
index 0000000..c4f6f84
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/atm2x_flash.tcl
@@ -0,0 +1,1463 @@
+#
+# atm2x_flash.tcl
+# Production APIs for flash operations
+# Copyright (C) Atmosic 2018-2022
+#
+
+#
+# SPI
+#
+
+array set SPI0 {
+ clkdiv 3
+ dummy 0
+}
+set SPI0(base) $CMSDK_SPI0_BASE
+set SPI0(TRANSACTION_SETUP) [expr {$CMSDK_SPI0_TRANSACTION_SETUP}]
+set SPI0(TRANSACTION_STATUS) [expr {$CMSDK_SPI0_TRANSACTION_STATUS}]
+set SPI0(DATA_BYTES_LOWER) [expr {$CMSDK_SPI0_DATA_BYTES_LOWER}]
+set SPI0(DATA_BYTES_UPPER) [expr {$CMSDK_SPI0_DATA_BYTES_UPPER}]
+set SPI0(INTERRUPT_MASK) [expr {$CMSDK_SPI0_INTERRUPT_MASK}]
+set SPI0(INTERRUPT_STATUS) [expr {$CMSDK_SPI0_INTERRUPT_STATUS}]
+set SPI0(SET_INTERRUPT) [expr {$CMSDK_SPI0_SET_INTERRUPT}]
+set SPI0(RESET_INTERRUPT) [expr {$CMSDK_SPI0_RESET_INTERRUPT}]
+set SPI0(CORE_ID) [expr {$CMSDK_SPI0_CORE_ID}]
+
+array set SPI1 {
+ clkdiv 3
+ dummy 0
+}
+set SPI1(base) $CMSDK_SPI1_BASE
+set SPI1(TRANSACTION_SETUP) [expr {$CMSDK_SPI1_TRANSACTION_SETUP}]
+set SPI1(TRANSACTION_STATUS) [expr {$CMSDK_SPI1_TRANSACTION_STATUS}]
+set SPI1(DATA_BYTES_LOWER) [expr {$CMSDK_SPI1_DATA_BYTES_LOWER}]
+set SPI1(DATA_BYTES_UPPER) [expr {$CMSDK_SPI1_DATA_BYTES_UPPER}]
+set SPI1(INTERRUPT_MASK) [expr {$CMSDK_SPI1_INTERRUPT_MASK}]
+set SPI1(INTERRUPT_STATUS) [expr {$CMSDK_SPI1_INTERRUPT_STATUS}]
+set SPI1(SET_INTERRUPT) [expr {$CMSDK_SPI1_SET_INTERRUPT}]
+set SPI1(RESET_INTERRUPT) [expr {$CMSDK_SPI1_RESET_INTERRUPT}]
+set SPI1(CORE_ID) [expr {$CMSDK_SPI1_CORE_ID}]
+
+array set SPI2 {
+ clkdiv 3
+ dummy 0
+}
+set SPI2(base) $CMSDK_SPI2_BASE
+set SPI2(TRANSACTION_SETUP) [expr {$CMSDK_SPI2_TRANSACTION_SETUP}]
+set SPI2(TRANSACTION_STATUS) [expr {$CMSDK_SPI2_TRANSACTION_STATUS}]
+set SPI2(DATA_BYTES_LOWER) [expr {$CMSDK_SPI2_DATA_BYTES_LOWER}]
+set SPI2(DATA_BYTES_UPPER) [expr {$CMSDK_SPI2_DATA_BYTES_UPPER}]
+set SPI2(INTERRUPT_MASK) [expr {$CMSDK_SPI2_INTERRUPT_MASK}]
+set SPI2(INTERRUPT_STATUS) [expr {$CMSDK_SPI2_INTERRUPT_STATUS}]
+set SPI2(SET_INTERRUPT) [expr {$CMSDK_SPI2_SET_INTERRUPT}]
+set SPI2(RESET_INTERRUPT) [expr {$CMSDK_SPI2_RESET_INTERRUPT}]
+set SPI2(CORE_ID) [expr {$CMSDK_SPI2_CORE_ID}]
+
+array set RADIO {
+ clkdiv 0
+ dummy 3
+}
+set RADIO(base) $CMSDK_RADIO_BASE
+set RADIO(TRANSACTION_SETUP) [expr {$CMSDK_RADIO_TRANSACTION_SETUP}]
+set RADIO(TRANSACTION_STATUS) [expr {$CMSDK_RADIO_TRANSACTION_STATUS}]
+set RADIO(DATA_BYTES_LOWER) [expr {$CMSDK_RADIO_DATA_BYTES_LOWER}]
+set RADIO(DATA_BYTES_UPPER) [expr {$CMSDK_RADIO_DATA_BYTES_UPPER}]
+set RADIO(INTERRUPT_MASK) [expr {$CMSDK_RADIO_INTERRUPT_MASK}]
+set RADIO(INTERRUPT_STATUS) [expr {$CMSDK_RADIO_INTERRUPT_STATUS}]
+set RADIO(SET_INTERRUPT) [expr {$CMSDK_RADIO_SET_INTERRUPT}]
+set RADIO(RESET_INTERRUPT) [expr {$CMSDK_RADIO_RESET_INTERRUPT}]
+set RADIO(CORE_ID) [expr {$CMSDK_RADIO_CORE_ID}]
+
+array set PMU {
+ clkdiv 0
+ dummy 3
+}
+set PMU(base) $CMSDK_PMU_BASE
+set PMU(TRANSACTION_SETUP) [expr {$CMSDK_PMU_TRANSACTION_SETUP}]
+set PMU(TRANSACTION_STATUS) [expr {$CMSDK_PMU_TRANSACTION_STATUS}]
+set PMU(DATA_BYTES_LOWER) [expr {$CMSDK_PMU_DATA_BYTES_LOWER}]
+set PMU(DATA_BYTES_UPPER) [expr {$CMSDK_PMU_DATA_BYTES_UPPER}]
+set PMU(INTERRUPT_MASK) [expr {$CMSDK_PMU_INTERRUPT_MASK}]
+set PMU(INTERRUPT_STATUS) [expr {$CMSDK_PMU_INTERRUPT_STATUS}]
+set PMU(SET_INTERRUPT) [expr {$CMSDK_PMU_SET_INTERRUPT}]
+set PMU(RESET_INTERRUPT) [expr {$CMSDK_PMU_RESET_INTERRUPT}]
+set PMU(CORE_ID) [expr {$CMSDK_PMU_CORE_ID}]
+
+
+proc do_spi_transaction { spi_name csn_stays_low opcode num_data_bytes upper lower } {
+ upvar #0 $spi_name spi
+ set transaction [expr {($spi(dummy) << 26) | ($csn_stays_low << 25) | ($opcode << 16) | ($spi(clkdiv) << 6) | (0x00000020) | ($num_data_bytes << 1)}]
+
+ mww $spi(DATA_BYTES_LOWER) $lower
+ mww $spi(DATA_BYTES_UPPER) $upper
+ mww $spi(TRANSACTION_SETUP) $transaction
+ mww $spi(TRANSACTION_SETUP) [expr {$transaction | 0x00000001}]
+
+ while {([mrw $spi(TRANSACTION_STATUS)] & 0x00000002) == 0x00000002} {}
+}
+
+proc do_spi_read { spi_name opcode {len 1} } {
+ upvar #0 $spi_name spi
+ do_spi_transaction $spi_name 0 $opcode $len 0x0 0x0
+ return [mrw $spi(DATA_BYTES_LOWER)]
+}
+
+proc spi_write_enable { spi_name } {
+ do_spi_transaction $spi_name 0 0x06 0 0x0 0x0
+}
+
+proc spi_vsr_write_enable { spi_name } {
+ do_spi_transaction $spi_name 0 0x50 0 0x0 0x0
+}
+
+proc spi_macronix_exit_deep_power_down { spi_name } {
+ do_spi_transaction $spi_name 0 0xab 0 0x0 0x0
+}
+
+proc spi_macronix_enter_secured_otp { spi_name } {
+ do_spi_transaction $spi_name 0 0xb1 0 0x0 0x0
+}
+
+proc spi_macronix_exit_secured_otp { spi_name } {
+ do_spi_transaction $spi_name 0 0xc1 0 0x0 0x0
+}
+
+proc spi_macronix_make_quad { spi_name } {
+ spi_write_enable $spi_name
+# WRITE STATUS REG - High perf, Quad Enable
+ do_spi_transaction $spi_name 0 0x01 3 0x0 0x020040
+}
+
+proc spi_giga_make_quad { spi_name } {
+ spi_write_enable $spi_name
+# WRITE STATUS REG - Quad Enable
+ do_spi_transaction $spi_name 0 0x01 2 0x0 0x0200
+}
+
+proc spi_fudan_make_quad { spi_name } {
+ spi_write_enable $spi_name
+ do_spi_transaction $spi_name 0 0x31 1 0x0 0x02
+}
+
+proc spi_puya_make_quad { spi_name } {
+ spi_write_enable $spi_name
+# WRITE STATUS REG - Quad Enable
+ do_spi_transaction $spi_name 0 0x01 2 0x0 0x0200
+}
+
+proc spi_winbond_make_quad { spi_name } {
+ spi_vsr_write_enable $spi_name
+ do_spi_transaction $spi_name 0 0x31 1 0x0 0x02
+}
+
+proc flash_lower_from_addr { addr } {
+ return [expr {(($addr & 0xff) << 16) | ($addr & 0xff00) | (($addr & 0xff0000) >> 16)}]
+}
+
+proc spi_read_flash_byte { spi_name addr } {
+ upvar #0 $spi_name spi
+
+ do_spi_transaction $spi_name 0 0x03 4 0x0 [flash_lower_from_addr $addr]
+ return [expr {[mrw $spi(DATA_BYTES_LOWER)] >> 24}]
+}
+
+proc flash_upper_lower_to_be_word { upper lower } {
+ return [expr {($lower & 0xff000000) | (($upper & 0xff) << 16) | ($upper & 0xff00) | (($upper & 0xff0000) >> 16)}]
+}
+
+proc flash_upper_lower_to_le_word { upper lower } {
+ return [expr {(($upper & 0xffffff) << 8) | ($lower >> 24)}]
+}
+
+proc spi_read_flash_be_word { spi_name addr } {
+ upvar #0 $spi_name spi
+
+ do_spi_transaction $spi_name 0 0x03 7 0x0 [flash_lower_from_addr $addr]
+ set lower [mrw $spi(DATA_BYTES_LOWER)]
+ set upper [mrw $spi(DATA_BYTES_UPPER)]
+ return [flash_upper_lower_to_be_word $upper $lower]
+}
+
+proc spi_read_flash_le_word { spi_name addr } {
+ upvar #0 $spi_name spi
+
+ do_spi_transaction $spi_name 0 0x03 7 0x0 [flash_lower_from_addr $addr]
+ set lower [mrw $spi(DATA_BYTES_LOWER)]
+ set upper [mrw $spi(DATA_BYTES_UPPER)]
+ return [flash_upper_lower_to_le_word $upper $lower]
+}
+
+proc spi_fdb { spi_name addr count } {
+ set ret ""
+
+ for {set i 0} {$i < $count} {incr i} {
+ set ret [concat $ret [format " %02x" [spi_read_flash_byte $spi_name [expr {$addr+$i}]]]]
+ }
+ return $ret
+}
+
+proc spi_read_pmuradio_word { spi_name block addr } {
+ upvar #0 $spi_name spi
+
+ set opcode [expr {$block << 4}]
+ do_spi_transaction $spi_name 0 $opcode 5 0x0 $addr
+ set lower [mrw $spi(DATA_BYTES_LOWER)]
+ set upper [mrw $spi(DATA_BYTES_UPPER)]
+ return [expr {(($upper & 0xff) << 24) | ($lower >> 8)}]
+}
+
+proc spi_write_pmuradio_word { spi_name block addr data } {
+ upvar #0 $spi_name spi
+
+ set opcode [expr {($block << 4) | 0x01}]
+ set lower [expr {(($data & 0xffffff) << 8) | $addr}]
+ set upper [expr {$data >> 24}]
+ do_spi_transaction $spi_name 0 $opcode 5 $upper $lower
+}
+
+proc spi_write_disable { spi_name } {
+ do_spi_transaction $spi_name 0 0x04 0 0x0 0x0
+}
+
+proc spi_read_status { spi_name {opcode 0x05} } {
+ return [do_spi_read $spi_name $opcode]
+}
+
+proc spi_wait_for_no_wip { spi_name } {
+ while {1} {
+ set ret [spi_read_status $spi_name]
+ if {($ret & 0x1) == 0x0} {
+ return $ret
+ }
+ }
+}
+
+proc spi_macronix_chip_erase { spi_name } {
+ spi_write_enable $spi_name
+ do_spi_transaction $spi_name 0 0xc7 0 0x0 0x0
+ set status [spi_wait_for_no_wip $spi_name]
+ if {($status & 0x02) != 0x00} {
+ error [format "Chip erase command FAILED! Status Register 0x%02x" $status]
+ }
+ set scur [spi_macronix_read_scur $spi_name]
+ if {($scur & 0x40) != 0x00} {
+ error [format "Chip erase FAILED! Security Register 0x%02x" $scur]
+ }
+}
+
+proc spi_macronix_sector_erase { spi_name addr } {
+ spi_write_enable $spi_name
+ do_spi_transaction $spi_name 0 0x20 3 0x0 [flash_lower_from_addr $addr]
+ set status [spi_wait_for_no_wip $spi_name]
+ if {($status & 0x02) != 0x00} {
+ error [format "Sector 0x%06x erase command FAILED! Status Register 0x%02x" $addr $status]
+ }
+ set scur [spi_macronix_read_scur $spi_name]
+ if {($scur & 0x40) != 0x00} {
+ error [format "Sector 0x%06x erase FAILED! Security Register 0x%02x" $addr $scur]
+ }
+}
+
+proc spi_winbond_chip_erase { spi_name } {
+ spi_write_enable $spi_name
+ do_spi_transaction $spi_name 0 0xc7 0 0x0 0x0
+ set status [spi_wait_for_no_wip $spi_name]
+ if {($status & 0x02) != 0x00} {
+ error [format "Chip erase command FAILED! Status Register 0x%02x" $status]
+ }
+}
+
+proc spi_winbond_sector_erase { spi_name addr } {
+ spi_write_enable $spi_name
+ do_spi_transaction $spi_name 0 0x20 3 0x0 [flash_lower_from_addr $addr]
+ set status [spi_wait_for_no_wip $spi_name]
+ if {($status & 0x02) != 0x00} {
+ error [format "Sector 0x%06x erase command FAILED! Status Register 0x%02x" $addr $status]
+ }
+}
+
+proc spi_macronix_read_scur { spi_name } {
+ return [do_spi_read $spi_name 0x2b]
+}
+
+proc spi_micron_read_evcr { spi_name } {
+ return [do_spi_read $spi_name 0x65]
+}
+
+proc spi_micron_read_flag_status { spi_name } {
+ return [do_spi_read $spi_name 0x70]
+}
+
+proc spi_micron_make_quad { spi_name } {
+ set evcr [spi_micron_read_evcr $spi_name]
+ spi_write_enable $spi_name
+ do_spi_transaction $spi_name 0 0x61 1 0x0 [expr {$evcr & ~0xd0}]
+}
+
+proc spi_reset { spi_name } {
+ do_spi_transaction $spi_name 0 0x66 0 0x0 0x0
+ do_spi_transaction $spi_name 0 0x99 0 0x0 0x0
+}
+
+proc spi_read_flash_id { spi_name {len 1} } {
+ return [do_spi_read $spi_name 0x9f $len]
+}
+
+
+#
+# QSPI
+#
+
+array set QSPI_MICRON {
+ type micron
+ dummy 2
+}
+array set QSPI_MACRONIX {
+ type macronix
+ dummy 4
+}
+
+proc qspi_drive_start {} {
+ global CMSDK_QSPI_TRANSACTION_SETUP
+
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0x02000000
+}
+
+proc to_oe_format_quad { nibble } {
+ switch $nibble {
+ 0 {return 0x2222}
+ 1 {return 0x2223}
+ 2 {return 0x2232}
+ 3 {return 0x2233}
+ 4 {return 0x2322}
+ 5 {return 0x2323}
+ 6 {return 0x2332}
+ 7 {return 0x2333}
+ 8 {return 0x3222}
+ 9 {return 0x3223}
+ 10 {return 0x3232}
+ 11 {return 0x3233}
+ 12 {return 0x3322}
+ 13 {return 0x3323}
+ 14 {return 0x3332}
+ 15 {return 0x3333}
+ default {return 0}
+ }
+}
+
+proc qspi_drive_nibble { nibble } {
+ global CMSDK_QSPI_TRANSACTION_SETUP
+
+ set oe [expr {[to_oe_format_quad $nibble] << 8}]
+ mww $CMSDK_QSPI_TRANSACTION_SETUP $oe
+ mww $CMSDK_QSPI_TRANSACTION_SETUP [expr {0x01000000 | $oe}]
+}
+
+proc qspi_drive_byte { byte } {
+ qspi_drive_nibble [expr {($byte & 0xf0) >> 4}]
+ qspi_drive_nibble [expr {$byte & 0x0f}]
+}
+
+proc qspi_micron_drive_opcode { opcode } {
+ qspi_drive_byte $opcode
+}
+
+proc qspi_macronix_drive_opcode { opcode } {
+ global CMSDK_QSPI_TRANSACTION_SETUP
+
+ for {set i 0} {$i < 8} {incr i} {
+ set opcode [expr {$opcode << 1}]
+ set drive [expr {($opcode & 0x100) | 0x200}]
+ mww $CMSDK_QSPI_TRANSACTION_SETUP $drive
+ mww $CMSDK_QSPI_TRANSACTION_SETUP [expr {0x01000000 | $drive}]
+ }
+}
+
+proc qspi_winbond_drive_opcode { opcode } {
+ global CMSDK_QSPI_TRANSACTION_SETUP
+
+ for {set i 0} {$i < 8} {incr i} {
+ set opcode [expr {$opcode << 1}]
+ set drive [expr {($opcode & 0x100) | 0x200}]
+ mww $CMSDK_QSPI_TRANSACTION_SETUP $drive
+ mww $CMSDK_QSPI_TRANSACTION_SETUP [expr {0x01000000 | $drive}]
+ }
+}
+
+proc qspi_capture_byte {} {
+ global CMSDK_QSPI_TRANSACTION_SETUP
+
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0x01000000
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0x010000f0
+
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0x01000000
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0x0100000f
+}
+
+proc qspi_drive_stop {} {
+ global CMSDK_QSPI_TRANSACTION_SETUP
+
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0x02000000
+}
+
+proc do_qspi_cmd { qspi_name opcode } {
+ upvar #0 $qspi_name qspi
+
+ qspi_drive_start
+ qspi_${qspi(type)}_drive_opcode $opcode
+ qspi_drive_stop
+}
+
+proc do_qspi_write { qspi_name opcode data } {
+ upvar #0 $qspi_name qspi
+
+ qspi_drive_start
+ qspi_${qspi(type)}_drive_opcode $opcode
+ qspi_drive_byte $data
+ qspi_drive_stop
+}
+
+proc do_qspi_read_byte { qspi_name opcode } {
+ upvar #0 $qspi_name qspi
+ global CMSDK_QSPI_READ_DATA
+
+ qspi_drive_start
+ qspi_${qspi(type)}_drive_opcode $opcode
+ qspi_capture_byte
+ qspi_drive_stop
+ return [mrw $CMSDK_QSPI_READ_DATA]
+}
+
+proc qspi_write_disable { qspi_name } {
+ do_qspi_cmd $qspi_name 0x04
+}
+
+proc qspi_write_enable { qspi_name } {
+ do_qspi_cmd $qspi_name 0x06
+}
+
+proc qspi_read_flash_byte { qspi_name addr } {
+ upvar #0 $qspi_name qspi
+ global CMSDK_QSPI_READ_DATA
+
+ qspi_drive_start
+ qspi_${qspi(type)}_drive_opcode 0xeb
+ qspi_drive_byte [expr {($addr >> 16) & 0xff}]
+ qspi_drive_byte [expr {($addr >> 8) & 0xff}]
+ qspi_drive_byte [expr {$addr & 0xff}]
+ for {set i 0} {$i < $qspi(dummy)} {incr i} {
+ qspi_drive_byte 0x00
+ }
+ qspi_capture_byte
+ qspi_drive_stop
+ return [mrw $CMSDK_QSPI_READ_DATA]
+}
+
+proc qspi_read_flash_be { qspi_name addr {len 4} } {
+ upvar #0 $qspi_name qspi
+ global CMSDK_QSPI_READ_DATA
+
+ qspi_drive_start
+ qspi_${qspi(type)}_drive_opcode 0xeb
+ qspi_drive_byte [expr {($addr >> 16) & 0xff}]
+ qspi_drive_byte [expr {($addr >> 8) & 0xff}]
+ qspi_drive_byte [expr {$addr & 0xff}]
+ for {set i 0} {$i < $qspi(dummy)} {incr i} {
+ qspi_drive_byte 0x00
+ }
+ set ret 0
+ for {set i 0} {$i < $len} {incr i} {
+ qspi_capture_byte
+ set ret [expr {($ret << 8) | [mrw $CMSDK_QSPI_READ_DATA]}]
+ }
+ qspi_drive_stop
+ return $ret
+}
+
+proc qspi_read_flash_le { qspi_name addr {len 4} } {
+ upvar #0 $qspi_name qspi
+ global CMSDK_QSPI_READ_DATA
+
+ qspi_drive_start
+ qspi_${qspi(type)}_drive_opcode 0xeb
+ qspi_drive_byte [expr {($addr >> 16) & 0xff}]
+ qspi_drive_byte [expr {($addr >> 8) & 0xff}]
+ qspi_drive_byte [expr {$addr & 0xff}]
+ for {set i 0} {$i < $qspi(dummy)} {incr i} {
+ qspi_drive_byte 0x00
+ }
+ set ret 0
+ for {set i 0} {$i < $len} {incr i} {
+ qspi_capture_byte
+ set ret [expr {$ret | ([mrw $CMSDK_QSPI_READ_DATA] << ($i*8))}]
+ }
+ qspi_drive_stop
+ return $ret
+}
+
+proc qspi_fdb { qspi_name addr count } {
+ set ret ""
+
+ for {set i 0} {$i < $count} {incr i} {
+ set ret [concat $ret [format " %02x" [qspi_read_flash_byte $qspi_name [expr {$addr+$i}]]]]
+ }
+ return $ret
+}
+
+proc qspi_reset { qspi_name } {
+ do_qspi_cmd $qspi_name 0x66
+ do_qspi_cmd $qspi_name 0x99
+}
+
+proc qspi_micron_read_status {} {
+ return [do_qspi_read_byte QSPI_MICRON 0x05]
+}
+
+proc qspi_micron_wait_for_no_wip {} {
+ while {1} {
+ set ret [qspi_micron_read_status]
+ if {($ret & 0x1) == 0x0} {
+ return $ret
+ }
+ }
+}
+
+proc qspi_micron_read_evcr {} {
+ return [do_qspi_read_byte QSPI_MICRON 0x65]
+}
+
+proc qspi_micron_read_flag_status {} {
+ return [do_qspi_read_byte QSPI_MICRON 0x70]
+}
+
+proc qspi_micron_read_flash_id {} {
+ return [do_qspi_read_byte QSPI_MICRON 0xaf]
+}
+
+proc qspi_micron_bulk_erase { } {
+ qspi_write_enable QSPI_MICRON
+
+ qspi_drive_start
+ qspi_micron_drive_opcode 0xc7
+ qspi_drive_stop
+
+ set status [qspi_micron_wait_for_no_wip]
+ if {($status & 0x02) != 0x00} {
+ error [format "Chip erase command FAILED! Status Register 0x%02x" $status]
+ }
+ set flag_status [qspi_micron_read_flag_status]
+ if {($flag_status & 0x20) != 0x00} {
+ error [format "Chip erase FAILED! Flag Status Register 0x%02x" $flag_status]
+ }
+}
+
+proc qspi_micron_subsector_erase { addr } {
+ qspi_write_enable QSPI_MICRON
+
+ qspi_drive_start
+ qspi_micron_drive_opcode 0x20
+ qspi_drive_byte [expr {($addr >> 16) & 0xff}]
+ qspi_drive_byte [expr {($addr >> 8) & 0xff}]
+ qspi_drive_byte [expr {$addr & 0xff}]
+ qspi_drive_stop
+
+ set status [qspi_micron_wait_for_no_wip]
+ if {($status & 0x02) != 0x00} {
+ error [format "Sector 0x%06x erase command FAILED! Status Register 0x%02x" $addr $status]
+ }
+ set flag_status [qspi_micron_read_flag_status]
+ if {($flag_status & 0x20) != 0x00} {
+ error [format "Sector 0x%06x erase FAILED! Flag Status Register 0x%02x" $addr $flag_status]
+ }
+}
+
+proc qspi_macronix_make_ahb {} {
+ global CMSDK_QSPI_TRANSACTION_SETUP
+ global CMSDK_QSPI_REMOTE_AHB_SETUP
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_2
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_3
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_5
+
+ # Byte swaps, macronix, div by 1, opcode 0xeb, mode 2, dummy 4
+ set REMOTE_AHB_SETUP 0x10eceb64
+ if {![info exists ::env(NO_HYPER)]} {
+ enable_hpc
+ # Slip half cycle, hyper
+ set REMOTE_AHB_SETUP [expr {$REMOTE_AHB_SETUP | 0x60000000}]
+ }
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP $REMOTE_AHB_SETUP
+ # READ STATUS REG, 4PP, WRITE ENABLE
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_2 0x00053806
+ # Check wle, wip bit 0+, wle bit 1+
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_3 0x81300000
+ # Stall: WE2PP 32, WLE 32, PP WIP 1023
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_5 0x020083ff
+ # Give AHB control
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0x12000000
+
+ adapter speed 75
+}
+
+proc qspi_giga_make_ahb {} {
+ global CMSDK_QSPI_TRANSACTION_SETUP
+ global CMSDK_QSPI_REMOTE_AHB_SETUP
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_2
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_3
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_5
+
+ # Serial PP addr, swaps, macronix, div by 1, opcode 0xeb, mode 2, dummy 4
+ set REMOTE_AHB_SETUP 0x18eceb64
+ if {![info exists ::env(NO_HYPER)]} {
+ enable_hpc
+ # Slip half cycle, hyper
+ set REMOTE_AHB_SETUP [expr {$REMOTE_AHB_SETUP | 0x60000000}]
+ }
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP $REMOTE_AHB_SETUP
+ # READ STATUS REG, QIPP, WRITE ENABLE
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_2 0x00053206
+ # Check wle, wip bit 0+, wle bit 1+
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_3 0x81300000
+ # Stall: WE2PP 32, WLE 32, PP WIP 1023
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_5 0x020083ff
+ # Give AHB control
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0x12000000
+
+ adapter speed 75
+}
+
+proc qspi_fudan_make_ahb {} {
+ global CMSDK_QSPI_TRANSACTION_SETUP
+ global CMSDK_QSPI_REMOTE_AHB_SETUP
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_2
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_3
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_5
+
+ # Serial PP addr, swaps, macronix, div by 1, opcode 0xeb, mode 2, dummy 4
+ set REMOTE_AHB_SETUP 0x18eceb64
+ if {![info exists ::env(NO_HYPER)]} {
+ enable_hpc
+ # Slip half cycle, hyper
+ set REMOTE_AHB_SETUP [expr {$REMOTE_AHB_SETUP | 0x60000000}]
+ }
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP $REMOTE_AHB_SETUP
+ # READ STATUS REG, QIPP, WRITE ENABLE
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_2 0x00053206
+ # Check wle, wip bit 0+, wle bit 1+
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_3 0x81300000
+ # Stall: WE2PP 32, WLE 32, PP WIP 1023
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_5 0x020083ff
+ # Give AHB control
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0x12000000
+
+ adapter speed 75
+}
+
+proc qspi_puya_make_ahb {} {
+ global CMSDK_QSPI_TRANSACTION_SETUP
+ global CMSDK_QSPI_REMOTE_AHB_SETUP
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_2
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_3
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_5
+
+ # Serial PP addr, swaps, macronix, div by 1, opcode 0xeb, mode 2, dummy 4
+ set REMOTE_AHB_SETUP 0x18eceb64
+ if {![info exists ::env(NO_HYPER)]} {
+ enable_hpc
+ # Slip half cycle, hyper
+ set REMOTE_AHB_SETUP [expr {$REMOTE_AHB_SETUP | 0x60000000}]
+ }
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP $REMOTE_AHB_SETUP
+ # READ STATUS REG, QIPP, WRITE ENABLE
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_2 0x00053206
+ # Check wle, wip bit 0+, wle bit 1+
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_3 0x81300000
+ # Stall: WE2PP 32, WLE 32, PP WIP 1023
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_5 0x020083ff
+ # Give AHB control
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0x12000000
+
+ adapter speed 75
+}
+
+proc qspi_winbond_make_ahb {} {
+ global CMSDK_QSPI_TRANSACTION_SETUP
+ global CMSDK_QSPI_REMOTE_AHB_SETUP
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_2
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_3
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_5
+
+ # Serial PP addr, swaps, macronix, div by 1, opcode 0xeb, mode 2, dummy 4
+ set REMOTE_AHB_SETUP 0x18eceb64
+ if {![info exists ::env(NO_HYPER)]} {
+ enable_hpc
+ # Slip half cycle, hyper
+ set REMOTE_AHB_SETUP [expr {$REMOTE_AHB_SETUP | 0x60000000}]
+ }
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP $REMOTE_AHB_SETUP
+ # READ STATUS REG, QIPP, WRITE ENABLE
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_2 0x00053206
+ # Check wle, wip bit 0+, wle bit 1+
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_3 0x81300000
+ # Stall: WE2PP 32, WLE 32, PP WIP 1023
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_5 0x020083ff
+ # Give AHB control
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0x12000000
+
+ adapter speed 75
+}
+
+proc qspi_micron_make_ahb {} {
+ global CMSDK_QSPI_TRANSACTION_SETUP
+ global CMSDK_QSPI_REMOTE_AHB_SETUP
+ global CMSDK_QSPI_REMOTE_AHB_SETUP_2
+
+ qspi_write_enable QSPI_MICRON
+ # WRITE VOLATILE CONFIG REG
+ do_qspi_write QSPI_MICRON 0x81 0x2b
+
+ # Byte swaps, div by 1, opcode 0xeb, mode 2, dummy 2
+ set REMOTE_AHB_SETUP 0x10e4eb62
+ if {![info exists ::env(NO_HYPER)]} {
+ enable_hpc
+ # Slip half cycle, hyper
+ set REMOTE_AHB_SETUP [expr {$REMOTE_AHB_SETUP | 0x60000000}]
+ }
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP $REMOTE_AHB_SETUP
+ # READ STATUS REG, PAGE PROGRAM, WRITE ENABLE
+ mww $CMSDK_QSPI_REMOTE_AHB_SETUP_2 0x00050206
+ # Give AHB control
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0x12000000
+
+ adapter speed 75
+}
+
+proc qspi_disable_ahb {} {
+ global CMSDK_QSPI_TRANSACTION_SETUP
+
+ mww $CMSDK_QSPI_TRANSACTION_SETUP 0x02000000
+ if {![info exists ::env(NO_HYPER)]} {
+ disable_hpc
+ }
+}
+
+proc qspi_micron_make_spi {} {
+ qspi_write_enable QSPI_MICRON
+ # WRITE VOLATILE CONFIG REG
+ do_qspi_write QSPI_MICRON 0x81 0xfb
+
+ set evcr [qspi_micron_read_evcr]
+ qspi_write_enable QSPI_MICRON
+ # WRITE ENHANCED VOLATILE CONFIG REG
+ do_qspi_write QSPI_MICRON 0x61 [expr {$evcr | 0xd0}]
+}
+
+
+#
+# Sydney procs
+#
+
+proc sydney_setup_5x5 {} {
+ global CMSDK_WRPR_PIN_SELECTION_C
+ global CMSDK_WRPR_PIN_SELECTION_D
+ global CMSDK_WRPR_PIN_SELECTION_E
+
+ mww $CMSDK_WRPR_PIN_SELECTION_C 0x003fff84
+ mww $CMSDK_WRPR_PIN_SELECTION_D 0x19120528
+ mww $CMSDK_WRPR_PIN_SELECTION_E 0x50000000
+}
+
+proc sydney_setup_5x5_stacked {} {
+ global CMSDK_WRPR_PIN_SELECTION_A
+ global CMSDK_WRPR_PIN_SELECTION_B
+ global CMSDK_WRPR_PIN_SELECTION_C
+ global CMSDK_WRPR_PIN_SELECTION_D
+
+ mww $CMSDK_WRPR_PIN_SELECTION_A 0x0000052c
+ mww $CMSDK_WRPR_PIN_SELECTION_B 0x6b400000
+ mww $CMSDK_WRPR_PIN_SELECTION_C 0x003fff84
+ mww $CMSDK_WRPR_PIN_SELECTION_D 0x18000000
+}
+
+proc sydney_print_part_number { nvm_efuse_autoread } {
+ set pkg [expr {$nvm_efuse_autoread & 0x08}]
+ set stacked [expr {$nvm_efuse_autoread & 0x10}]
+ set non_harv [expr {$nvm_efuse_autoread & 0x100}]
+ set csp [expr {$nvm_efuse_autoread & 0x2000}]
+ set pkg_7x7 [expr {$nvm_efuse_autoread & 0x4000}]
+
+ puts [format "ATM%d2%d%d-x1x silicon: %s pkg, %s" \
+ [expr {$non_harv ? 2 : 3}] \
+ [expr {$pkg ? [expr {$csp ? 5 : 0}] : [expr {$pkg_7x7 ? 3 : 2}]}] \
+ [expr {$stacked ? 2 : 1}] \
+ [expr {$pkg ? [expr {$csp ? "CSP" : "5x5"}] : [expr {$pkg_7x7 ? "7x7" : "6x6"}]}] \
+ [expr {$stacked ? "Stacked flash" : "External flash"}]]
+}
+
+proc check_flash_mem_cap { maker mem_cap region_end } {
+ set byte_size [expr {1 << $mem_cap}]
+ puts [format "%s %uMb flash (%u bytes)" $maker [expr {1 << ($mem_cap - 17)}] $byte_size]
+ if {!$region_end} {
+ return $byte_size
+ }
+ if {$byte_size >= $region_end} {
+ return $byte_size
+ }
+ error [format "Check FLASH_SIZE setting: region_end 0x%x too large for flash device size 0x%x" $region_end $byte_size]
+}
+
+proc sydney_discover_flash { {region_end 0x0} } {
+ global CMSDK_NVM_EFUSE_AUTOREAD
+
+ enable_nvm
+ set nvm_EFUSE_AUTOREAD [mrw $CMSDK_NVM_EFUSE_AUTOREAD]
+ set pkg_opts [expr {$nvm_EFUSE_AUTOREAD & 0x18}]
+ if {$pkg_opts == 0x08} {
+ sydney_setup_5x5
+ } elseif {$pkg_opts == 0x18} {
+ sydney_setup_5x5_stacked
+ }
+ sydney_print_part_number $nvm_EFUSE_AUTOREAD
+
+ for {set i 0} {$i < 2} {incr i} {
+ set id [spi_read_flash_id SPI2 3]
+# puts [format "flash id 0x%06x" $id]
+ set flash_id [expr {$id & 0xffff}]
+ set mem_cap [expr {$id >> 16}]
+ if {$flash_id == 0x28c2} {
+ set flash_size [check_flash_mem_cap "Macronix" $mem_cap $region_end]
+ return [list "macronix" $flash_size $mem_cap]
+ } elseif {$flash_id == 0x65c8} {
+ set flash_size [check_flash_mem_cap "GigaDevice" $mem_cap $region_end]
+ return [list "giga" $flash_size $mem_cap]
+ } elseif {$flash_id == 0x28a1} {
+ set flash_size [check_flash_mem_cap "Fudan" $mem_cap $region_end]
+ return [list "fudan" $flash_size $mem_cap]
+ } elseif {($flash_id == 0x2085) || ($flash_id == 0x4085) || ($flash_id == 0x6085)} {
+ set flash_size [check_flash_mem_cap "Puya" $mem_cap $region_end]
+ return [list "puya" $flash_size $mem_cap]
+ } elseif {$flash_id == 0x60ef} {
+ set flash_size [check_flash_mem_cap "Winbond" $mem_cap $region_end]
+ return [list "winbond" $flash_size $mem_cap]
+ } elseif {$flash_id == 0xba20} {
+ set flash_size [check_flash_mem_cap "Micron" $mem_cap $region_end]
+ return [list "micron" $flash_size $mem_cap]
+ } else {
+ # Might have been in deep power down or performance enhanced mode
+ spi_macronix_exit_deep_power_down SPI2
+
+ # Might be a micron in qspi mode
+ enable_qspi
+ sydney_micron_qspi_2_spi
+ }
+ }
+ error [format "Unknown flash 0x%06x" $id]
+}
+
+proc sydney_macronix_enable_ahb_bridge {} {
+ spi_macronix_make_quad SPI2
+ if {([spi_read_status SPI2] & 0x40) == 0x00} {
+ error "Failed to set QE"
+ }
+ enable_qspi
+ qspi_macronix_make_ahb
+ return "Macronix OK"
+}
+
+proc sydney_giga_enable_ahb_bridge {} {
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ spi_giga_make_quad SPI2
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ error "Failed to set QE"
+ }
+ }
+ enable_qspi
+ qspi_giga_make_ahb
+ return "Giga OK"
+}
+
+proc sydney_fudan_enable_ahb_bridge {} {
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ spi_fudan_make_quad SPI2
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ error "Failed to set QE"
+ }
+ }
+ enable_qspi
+ qspi_fudan_make_ahb
+ return "Fudan OK"
+}
+
+proc sydney_puya_enable_ahb_bridge {} {
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ spi_puya_make_quad SPI2
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ error "Failed to set QE"
+ }
+ }
+ enable_qspi
+ qspi_puya_make_ahb
+ return "Puya OK"
+}
+
+proc sydney_winbond_enable_ahb_bridge {} {
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ spi_winbond_make_quad SPI2
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ error "Failed to set QE"
+ }
+ }
+ enable_qspi
+ qspi_winbond_make_ahb
+ return "Winbond OK"
+}
+
+proc sydney_micron_enable_ahb_bridge {} {
+ spi_micron_make_quad SPI2
+ enable_qspi
+ if {[qspi_micron_read_flash_id] != 0x20} {
+ error "Failed to read qspi flash id"
+ }
+ qspi_micron_make_ahb
+ return "Micron OK"
+}
+
+proc sydney_enable_ahb_bridge {} {
+ enable_spi2
+ lassign [sydney_discover_flash] flash size
+
+ sydney_${flash}_enable_ahb_bridge
+}
+
+proc sydney_disable_ahb_bridge {} {
+ global _SWD_KHZ
+
+ adapter speed $_SWD_KHZ
+ qspi_disable_ahb
+}
+
+proc sydney_macronix_qspi_2_spi {} {
+ reset_qspi
+}
+
+proc sydney_giga_qspi_2_spi {} {
+ reset_qspi
+}
+
+proc sydney_fudan_qspi_2_spi {} {
+ reset_qspi
+}
+
+proc sydney_puya_qspi_2_spi {} {
+ reset_qspi
+}
+
+proc sydney_winbond_qspi_2_spi {} {
+ reset_qspi
+}
+
+proc sydney_micron_qspi_2_spi {} {
+ qspi_micron_make_spi
+ reset_qspi
+}
+
+proc sydney_macronix_ahb_2_spi {} {
+ sydney_disable_ahb_bridge
+ sydney_macronix_qspi_2_spi
+}
+
+proc sydney_giga_ahb_2_spi {} {
+ sydney_disable_ahb_bridge
+ sydney_giga_qspi_2_spi
+}
+
+proc sydney_fudan_ahb_2_spi {} {
+ sydney_disable_ahb_bridge
+ sydney_fudan_qspi_2_spi
+}
+
+proc sydney_puya_ahb_2_spi {} {
+ sydney_disable_ahb_bridge
+ sydney_puya_qspi_2_spi
+}
+
+proc sydney_winbond_ahb_2_spi {} {
+ sydney_disable_ahb_bridge
+ sydney_winbond_qspi_2_spi
+}
+
+proc sydney_micron_ahb_2_spi {} {
+ sydney_disable_ahb_bridge
+ sydney_micron_qspi_2_spi
+}
+
+proc sydney_macronix_erase_whole { } {
+ spi_macronix_make_quad SPI2
+ if {([spi_read_status SPI2] & 0x40) == 0x00} {
+ error "Failed to set QE"
+ }
+ spi_macronix_chip_erase SPI2
+ enable_qspi
+}
+
+proc sydney_macronix_erase { start end } {
+ spi_macronix_make_quad SPI2
+ if {([spi_read_status SPI2] & 0x40) == 0x00} {
+ error "Failed to set QE"
+ }
+ for {set i $start} {$i < $end} {set i [expr {$i + 0x1000}]} {
+ spi_macronix_sector_erase SPI2 $i
+ }
+ enable_qspi
+}
+
+proc sydney_giga_erase_whole { } {
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ spi_giga_make_quad SPI2
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ error "Failed to set QE"
+ }
+ }
+ spi_winbond_chip_erase SPI2
+ enable_qspi
+}
+
+proc sydney_giga_erase { start end } {
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ spi_giga_make_quad SPI2
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ error "Failed to set QE"
+ }
+ }
+ for {set i $start} {$i < $end} {set i [expr {$i + 0x1000}]} {
+ spi_winbond_sector_erase SPI2 $i
+ }
+ enable_qspi
+}
+
+proc sydney_fudan_erase_whole { } {
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ spi_fudan_make_quad SPI2
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ error "Failed to set QE"
+ }
+ }
+ spi_winbond_chip_erase SPI2
+ enable_qspi
+}
+
+proc sydney_fudan_erase { start end } {
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ spi_fudan_make_quad SPI2
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ error "Failed to set QE"
+ }
+ }
+ for {set i $start} {$i < $end} {set i [expr {$i + 0x1000}]} {
+ spi_winbond_sector_erase SPI2 $i
+ }
+ enable_qspi
+}
+
+proc sydney_puya_erase_whole { } {
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ spi_puya_make_quad SPI2
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ error "Failed to set QE"
+ }
+ }
+ spi_winbond_chip_erase SPI2
+ enable_qspi
+}
+
+proc sydney_puya_erase { start end } {
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ spi_puya_make_quad SPI2
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ error "Failed to set QE"
+ }
+ }
+ for {set i $start} {$i < $end} {set i [expr {$i + 0x1000}]} {
+ spi_winbond_sector_erase SPI2 $i
+ }
+ enable_qspi
+}
+
+proc sydney_winbond_erase_whole { } {
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ spi_winbond_make_quad SPI2
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ error "Failed to set QE"
+ }
+ }
+ spi_winbond_chip_erase SPI2
+ enable_qspi
+}
+
+proc sydney_winbond_erase { start end } {
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ spi_winbond_make_quad SPI2
+ if {([spi_read_status SPI2 0x35] & 0x02) == 0x00} {
+ error "Failed to set QE"
+ }
+ }
+ for {set i $start} {$i < $end} {set i [expr {$i + 0x1000}]} {
+ spi_winbond_sector_erase SPI2 $i
+ }
+ enable_qspi
+}
+
+proc sydney_winbond_protect_flash { {mpr_lock_size 0} } {
+ puts [format "sydney_winbond_protect_flash: mpr_lock_size = 0x%x" $mpr_lock_size]
+
+ set status_reg 0
+ if {$mpr_lock_size == 0} {
+ puts "disable protection"
+ } elseif {$mpr_lock_size == 0x1000} {
+ puts "protect - 4KB (07F000 - 07FFFF)"
+ # WRITE STATUS REG - SEC, TB, BP2, BP1, BP0 [1,0,0,0,1]
+ set status_reg 0x44
+ } elseif {$mpr_lock_size == 0x2000} {
+ puts "protect - 8KB (07E000 - 07FFFF)"
+ # WRITE STATUS REG - SEC, TB, BP2, BP1, BP0 [1,0,0,1,0]
+ set status_reg 0x48
+ } elseif {$mpr_lock_size == 0x4000} {
+ puts "protect - 16KB (07C000 - 07FFFF)"
+ # WRITE STATUS REG - SEC, TB, BP2, BP1, BP0 [1,0,0,1,1]
+ set status_reg 0x4c
+ } elseif {$mpr_lock_size == 0x8000} {
+ puts "protect - 32KB (078000 - 07FFFF)"
+ # WRITE STATUS REG - SEC, TB, BP2, BP1, BP0 [1,0,1,1,0]
+ set status_reg 0x58
+ } else {
+ error "Protection size not supported."
+ }
+ return $status_reg
+}
+
+proc sydney_micron_erase_whole { } {
+ spi_micron_make_quad SPI2
+ enable_qspi
+ if {[qspi_micron_read_flash_id] != 0x20} {
+ error "Failed to read qspi flash id"
+ }
+ qspi_micron_bulk_erase
+}
+
+proc sydney_micron_erase { start end } {
+ spi_micron_make_quad SPI2
+ enable_qspi
+ if {[qspi_micron_read_flash_id] != 0x20} {
+ error "Failed to read qspi flash id"
+ }
+ for {set i $start} {$i < $end} {set i [expr {$i + 0x1000}]} {
+ qspi_micron_subsector_erase $i
+ }
+}
+
+proc sydney_macronix_dump_otp { image {len 8192} } {
+ reset halt
+ enable_spi2
+ lassign [sydney_discover_flash] flash size
+ if {$flash != "macronix"} {
+ error [format "Wrong flash type: %s" $flash]
+ }
+
+ set scur [spi_macronix_read_scur SPI2]
+ puts [format "Security Register 0x%02x" $scur]
+
+ spi_macronix_enter_secured_otp SPI2
+
+ sydney_${flash}_enable_ahb_bridge
+
+ dump_image $image 0x10000000 $len
+
+ sydney_${flash}_ahb_2_spi
+
+ spi_macronix_exit_secured_otp SPI2
+}
+
+proc sydney_erase_upgd_data {flash size} {
+ set part_offset [expr {$size / 2}]
+ set end [expr {$part_offset + 0x1000}]
+ puts [format "Erasing upgd sector at 0x%08x to 0x%08x " $part_offset $end]
+ sydney_${flash}_erase $part_offset $end
+}
+
+proc sydney_erase_flash { {len 0x78000} } {
+ reset halt
+ enable_spi2
+ lassign [sydney_discover_flash $len] flash size
+
+ if {[info exists ::env(ERASE_WHOLE)]} {
+ puts [format "Erasing whole device"]
+ sydney_${flash}_erase_whole
+ } else {
+ sydney_${flash}_erase 0x00000 $len
+ if {[info exists ::env(ERASE_UPGRADE_DATA)]} {
+ sydney_erase_upgd_data $flash $size
+ }
+ }
+
+ sydney_${flash}_qspi_2_spi
+ return "OK"
+}
+
+proc sydney_flash_size { } {
+ reset halt
+ enable_spi2
+ lassign [sydney_discover_flash] flash size
+
+ return $size
+}
+
+proc sydney_dump_flash { image {len 0x78000} } {
+ reset halt
+ enable_spi2
+ lassign [sydney_discover_flash $len] flash size
+
+ # Dump entire flash for len == 0
+ if {!$len} {
+ set len $size
+ }
+
+ sydney_${flash}_enable_ahb_bridge
+
+ dump_image $image 0x10000000 $len
+
+ sydney_${flash}_ahb_2_spi
+}
+
+proc sydney_load_flash { image {region_start 0x0} {region_size 0x78000} {address ""} } {
+ reset halt
+ enable_spi2
+ set region_end [expr {$region_start + $region_size}]
+ lassign [sydney_discover_flash $region_end] flash size
+
+ if {[info exists ::env(ERASE_WHOLE)]} {
+ puts [format "Erasing whole device"]
+ sydney_${flash}_erase_whole
+ } else {
+ sydney_${flash}_erase $region_start $region_end
+ if {[info exists ::env(ERASE_UPGRADE_DATA)]} {
+ sydney_erase_upgd_data $flash $size
+ }
+ }
+
+ qspi_${flash}_make_ahb
+
+ if {$address == ""} {
+ puts -nonewline [load_image $image]
+ } else {
+ puts -nonewline [load_image $image $address]
+ }
+
+ sydney_${flash}_ahb_2_spi
+ spi_wait_for_no_wip SPI2
+}
+
+proc sydney_verify_flash { image {address ""} } {
+ reset halt
+ enable_spi2
+ lassign [sydney_discover_flash] flash size
+
+ sydney_${flash}_enable_ahb_bridge
+
+ if {$address == ""} {
+ puts -nonewline [verify_image $image]
+ } else {
+ puts -nonewline [verify_image $image $address]
+ }
+
+ sydney_${flash}_ahb_2_spi
+}
+
+proc sydney_protect_flash { {mpr_lock_size 0} } {
+ reset halt
+ enable_spi2
+ lassign [sydney_discover_flash] flash size
+ set id [spi_read_flash_id SPI2 3]
+ if { $id != 0x1360ef} {
+ puts [format "flash id 0x%06x" $id]
+ error "Not a W25Q40EW part"
+ }
+
+ set cur_status [spi_read_status SPI2]
+ puts [format "sydney_protect_flash: current status register1 = 0x%02x" $cur_status]
+
+ set write_status [sydney_${flash}_protect_flash $mpr_lock_size]
+
+ if { $cur_status == $write_status } {
+ puts [format "Not update status register"]
+ return $cur_status
+ }
+
+ spi_write_enable SPI2
+ do_spi_transaction SPI2 0 0x01 1 0x0 $write_status
+ while {1} {
+ set ret [spi_read_status SPI2]
+ if {($ret & $write_status) == $write_status} {
+ return $ret
+ }
+ }
+}
+
+proc sydney_erase_flash_nvds { region_start region_size } {
+ reset halt
+ enable_spi2
+ set region_end [expr {$region_start + $region_size}]
+ lassign [sydney_discover_flash $region_end] flash size
+
+ sydney_${flash}_erase $region_start $region_end
+
+ sydney_${flash}_qspi_2_spi
+ return "OK"
+}
+
+proc return_winning_seq { seq0 seq1 mem_cap } {
+ set seq [expr {$seq0 + 1}]
+ set seq0 [expr {$seq & 0x0f}]
+ if {$seq0 == $seq1} {
+ return 1
+ } else {
+ return 0
+ }
+}
+
+proc id_is_valid { upgrade_status } {
+ set FLASH_UPGRADE_STATUS_ID_MASK 0xffffff00
+ set FLASH_UPGRADE_STATUS_ID_ROM 0x4d4f5200
+ set FLASH_UPGRADE_STATUS_ID_USR 0x52535500
+ set id [expr {$upgrade_status & $FLASH_UPGRADE_STATUS_ID_MASK}]
+ set id_rom [expr {$id == $FLASH_UPGRADE_STATUS_ID_ROM}]
+ set id_usr [expr {$id == $FLASH_UPGRADE_STATUS_ID_USR}]
+ set ret [expr {$id_rom || $id_usr}]
+ puts "$id $id_rom $id_usr $ret\n"
+ return $ret
+}
+
+proc status_is_all_good { upgrade_status } {
+ set FLASH_UPGRADE_STATUS_STATE_MASK 0x0f
+ set FLASH_UPGRADE_STATUS_nBAD_MASK 0x08
+ set FLASH_UPGRADE_STATUS_nBOOTED_MASK 0x04
+ set upgd_status_mask [expr {$upgrade_status & $FLASH_UPGRADE_STATUS_STATE_MASK}]
+ set bad_booted_mask [expr {$FLASH_UPGRADE_STATUS_nBAD_MASK | $FLASH_UPGRADE_STATUS_nBOOTED_MASK}]
+ set ret [expr {$upgd_status_mask != $bad_booted_mask}]
+ return $ret
+}
+
+proc sydney_get_active_bank_addr { region_start region_size mem_bank mem_cap } {
+ set FLASH_START_ADDR 0x10000000
+ set FLASH_UPGRADE_STATUS_WOFF 0x10
+ set FLASH_UPGRADE_STATUS_SEQ_MASK 0xf0
+ set active_standby_flag 0
+
+ set bank_off [expr {1 << ($mem_cap-3)}]
+ #convert $bank_off to byte address
+ set bank_off [expr {$bank_off*4}]
+
+ if {$mem_bank=="active"} {
+ puts "$mem_bank\n"
+ set active_standby_flag 0
+ } elseif {$mem_bank=="standby"} {
+ puts "$mem_bank\n"
+ set active_standby_flag 1
+ } elseif {$mem_bank=="bank0"} {
+ puts "Bank 0\n"
+ return $FLASH_START_ADDR
+ } elseif {$mem_bank=="bank1"} {
+ puts "Bank 1\n"
+ return [expr {$FLASH_START_ADDR + $bank_off}]
+ } else {
+ error "$mem_bank is not a valid MEM_BANK value. Allowed values 'active', 'standby', 'bank0', or 'bank1'"
+ }
+
+ set b0_us_addr [expr {$FLASH_START_ADDR + $FLASH_UPGRADE_STATUS_WOFF}]
+ set b1_us_addr [expr {$FLASH_START_ADDR + $FLASH_UPGRADE_STATUS_WOFF + $bank_off}]
+ puts "bank_off $bank_off\nb0 $b0_us_addr\nb1 $b1_us_addr\n"
+ set region_end [expr {$region_start + $region_size}]
+ set b0_us [mrw $b0_us_addr]
+ set b1_us [mrw $b1_us_addr]
+ puts "mem_cap $mem_cap\nb0_us $b0_us\nb1_us $b1_us\n"
+ set b0 [id_is_valid $b0_us]
+ set b1 [id_is_valid $b1_us]
+
+ if {$b0} {
+ set b0 [status_is_all_good $b0_us]
+ }
+
+ if {$b1} {
+ set b1 [status_is_all_good $b1_us]
+ }
+
+ #map winning sequence if both b0 and b1 pass
+ if {$b0 && $b1} {
+ set b0_seq_mask [expr { $b0_us & $FLASH_UPGRADE_STATUS_SEQ_MASK} ]
+ set b1_seq_mask [expr { $b1_us & $FLASH_UPGRADE_STATUS_SEQ_MASK} ]
+ set b0_seq [expr { $b0_seq_mask >> 4 } ]
+ set b1_seq [expr { $b1_seq_mask >> 4 } ]
+ set b1 [return_winning_seq $b0_seq $b1_seq $mem_cap]
+ }
+ puts "b0 b1 $b0 $b1\n"
+ #if bank 1 is not active, default to bank 0
+ if {$b1} {
+ if {$active_standby_flag == 0} {
+ return [expr {$FLASH_START_ADDR + $bank_off}]
+ } else {
+ return $FLASH_START_ADDR
+ }
+
+ } else {
+ if {$active_standby_flag == 0} {
+ return $FLASH_START_ADDR
+ } else {
+ return [expr {$FLASH_START_ADDR + $bank_off}]
+ }
+ }
+}
+
+proc sydney_dump_flash_nvds { image region_start region_size mem_bank } {
+ reset halt
+ enable_spi2
+ set region_end [expr {$region_start + $region_size}]
+ lassign [sydney_discover_flash $region_end] flash size mem_cap
+
+ sydney_${flash}_enable_ahb_bridge
+
+ set active_bank_addr [sydney_get_active_bank_addr $region_start $region_size $mem_bank $mem_cap]
+ puts "Returned bank address is $active_bank_addr\n"
+ dump_image $image [expr {$active_bank_addr + $region_start}] $region_size
+
+ sydney_${flash}_ahb_2_spi
+}
+
+proc sydney_load_flash_nvds { image region_start region_size } {
+ reset halt
+ enable_spi2
+ set region_end [expr {$region_start + $region_size}]
+ lassign [sydney_discover_flash $region_end] flash size
+
+ sydney_${flash}_erase $region_start $region_end
+
+ qspi_${flash}_make_ahb
+
+ puts -nonewline [load_image $image [expr {0x10000000 + $region_start}]]
+
+ sydney_${flash}_ahb_2_spi
+ spi_wait_for_no_wip SPI2
+}
+
+proc sydney_verify_flash_nvds { image region_start region_size } {
+ reset halt
+ enable_spi2
+ set region_end [expr {$region_start + $region_size}]
+ lassign [sydney_discover_flash $region_end] flash size
+
+ sydney_${flash}_enable_ahb_bridge
+
+ puts -nonewline [verify_image $image [expr {0x10000000 + $region_start}]]
+
+ sydney_${flash}_ahb_2_spi
+}
diff --git a/platform/atm2/ATM22xx-x1x/openocd/atm2x_gdb.tcl b/platform/atm2/ATM22xx-x1x/openocd/atm2x_gdb.tcl
new file mode 100644
index 0000000..070ecc5
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/atm2x_gdb.tcl
@@ -0,0 +1,14 @@
+#
+# atm2x_gdb.tcl
+# GDB helper functions for ATM2x devices
+# Copyright (C) Atmosic 2020
+#
+
+# Fully reset target device and halt at first instruction.
+# (gdb) monitor reset_hard_halt
+proc reset_hard_halt {} {
+ set_benign_boot
+ reset_hard
+ set_normal_boot
+ reset halt
+}
diff --git a/platform/atm2/ATM22xx-x1x/openocd/atm2x_nvm.tcl b/platform/atm2/ATM22xx-x1x/openocd/atm2x_nvm.tcl
new file mode 100644
index 0000000..15ea45e
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/atm2x_nvm.tcl
@@ -0,0 +1,203 @@
+#
+# atm2x_nvm.tcl
+# Production APIs for NVM (aka: OTP, efuse) operations
+# Copyright (C) Atmosic 2018-2019
+#
+
+#
+# NVM
+#
+
+set NVM_SIZE 4096
+
+proc nvm_read_byte { addr } {
+ global CMSDK_AHB_NVM_BASE
+
+ return [mrb [expr {$CMSDK_AHB_NVM_BASE + $addr}]]
+}
+
+proc nvm_set_bit { byte_addr bit } {
+ global CMSDK_NVM_OPMODE
+ global CMSDK_NVM_ADDRESS
+ global CMSDK_NVM_STATUS
+
+ set bit_addr [expr {(($byte_addr & ~0x3ff) << 3) | (($bit & 0x7) << 10) | ($byte_addr & 0x3ff)}]
+ mww $CMSDK_NVM_ADDRESS $bit_addr
+ mww $CMSDK_NVM_OPMODE 0x80000002
+ while {([mrw $CMSDK_NVM_STATUS] & 0x80000000) == 0x80000000} {}
+}
+
+proc nvm_fdb { addr count } {
+ set ret ""
+
+ for {set i 0} {$i < $count} {incr i} {
+ set ret [concat $ret [format " %02x" [nvm_read_byte [expr {$addr+$i}]]]]
+ }
+ return $ret
+}
+
+proc sydney_dump_nvm { image } {
+ global CMSDK_AHB_NVM_BASE
+ global NVM_SIZE
+
+ reset halt
+
+ enable_nvm
+
+ dump_image $image $CMSDK_AHB_NVM_BASE $NVM_SIZE
+}
+
+proc sydney_precheck_nvm { image } {
+ global CMSDK_RAM_BASE
+ global NVM_SIZE
+
+ reset halt
+
+ mww $CMSDK_RAM_BASE 0x00000000 [expr {$NVM_SIZE / 4}]
+ load_image $image $CMSDK_RAM_BASE
+
+ enable_nvm
+ for {set i 0} {$i < $NVM_SIZE} {incr i} {
+ set old [nvm_read_byte $i]
+ set maddr [expr {$CMSDK_RAM_BASE + $i}]
+ set new [mrb $maddr]
+
+ if {($old & $new) != $old} {
+ error [format "ERROR: bit cleared @0x%x: %02x->%02x" $i $old $new]
+ }
+ }
+
+ return "OK"
+}
+
+proc sydney_burn_nvm { image } {
+ global CMSDK_RAM_BASE
+ global NVM_SIZE
+ global CMSDK_WRPR_PIN_SELECTION_E
+
+ reset halt
+
+ mww $CMSDK_RAM_BASE 0x00000000 [expr {$NVM_SIZE / 4}]
+ load_image $image $CMSDK_RAM_BASE
+
+ enable_nvm
+ # Compute the change set
+ for {set i 0} {$i < $NVM_SIZE} {incr i} {
+ set old [nvm_read_byte $i]
+ set maddr [expr {$CMSDK_RAM_BASE + $i}]
+ set new [mrb $maddr]
+
+ if {($old & $new) != $old} {
+ error [format "ERROR: bit cleared @0x%x: %02x->%02x" $i $old $new]
+ }
+
+ mwb $maddr [expr {$old ^ $new}]
+ }
+
+ # Set the changed bits
+ for {set i 0} {$i < $NVM_SIZE} {incr i} {
+ set maddr [expr {$CMSDK_RAM_BASE + $i}]
+ set new [mrb $maddr]
+
+ if {$new == 0x00} {
+ continue
+ }
+ for {set bit 0} {$bit < 8} {incr bit} {
+ if {($new & (1 << $bit)) == 0} {
+ continue
+ }
+ nvm_set_bit $i $bit
+ }
+ }
+
+ return "OK"
+}
+
+proc sydney_verify_nvm { image } {
+ global CMSDK_RAM_BASE
+ global NVM_SIZE
+
+ reset halt
+
+ mww $CMSDK_RAM_BASE 0x00000000 [expr {$NVM_SIZE / 4}]
+ load_image $image $CMSDK_RAM_BASE
+
+ enable_nvm
+ for {set i 0} {$i < $NVM_SIZE} {incr i} {
+ set old [nvm_read_byte $i]
+ set maddr [expr {$CMSDK_RAM_BASE + $i}]
+ set new [mrb $maddr]
+
+ if {$old != $new} {
+ error [format "ERROR: difference @0x%x: %02x-%02x" $i $old $new]
+ }
+ }
+
+ return "OK"
+}
+
+proc sydney_burn_autoread_bit { byte_off bit_off } {
+ global NVM_SIZE
+
+ reset halt
+
+ enable_nvm
+ set addr [expr {$NVM_SIZE - 4 + $byte_off}]
+ set old [nvm_read_byte $addr]
+
+ if {($old & (1 << $bit_off)) == 0} {
+ nvm_set_bit $addr $bit_off
+ }
+}
+
+set AUTOREAD_SWD_DISABLE_BIT_OFF 0
+set AUTOREAD_SWD_DISABLE_BYTE_OFF 0
+
+# !!!! Warning !!!!
+# This operation will disable SWD interfacer permanently and can't be reverted.
+proc sydney_burn_swd_disable {} {
+
+ sydney_burn_autoread_bit $::AUTOREAD_SWD_DISABLE_BYTE_OFF $::AUTOREAD_SWD_DISABLE_BIT_OFF
+}
+
+set AUTOREAD_5x5_BIT_OFF 3
+set AUTOREAD_5x5_BYTE_OFF 0
+proc sydney_burn_5x5 {} {
+ global AUTOREAD_5x5_BIT_OFF
+ global AUTOREAD_5x5_BYTE_OFF
+
+ sydney_burn_autoread_bit $AUTOREAD_5x5_BYTE_OFF $AUTOREAD_5x5_BIT_OFF
+}
+
+set AUTOREAD_STACKED_BIT_OFF 4
+set AUTOREAD_STACKED_BYTE_OFF 0
+proc sydney_burn_stacked {} {
+ global AUTOREAD_STACKED_BIT_OFF
+ global AUTOREAD_STACKED_BYTE_OFF
+
+ sydney_burn_autoread_bit $AUTOREAD_STACKED_BYTE_OFF $AUTOREAD_STACKED_BIT_OFF
+}
+
+set AUTOREAD_HARV_TYPE_BIT_OFF 2
+set AUTOREAD_HARV_TYPE_BYTE_OFF 3
+proc sydney_burn_harv_type {} {
+ global AUTOREAD_HARV_TYPE_BIT_OFF
+ global AUTOREAD_HARV_TYPE_BYTE_OFF
+
+ sydney_burn_autoread_bit $AUTOREAD_HARV_TYPE_BYTE_OFF $AUTOREAD_HARV_TYPE_BIT_OFF
+}
+
+set AUTOREAD_NO_32K_XTAL_BIT_OFF 7
+set AUTOREAD_NO_32K_XTAL_BYTE_OFF 3
+proc sydney_burn_no_32k_xtal {} {
+ global AUTOREAD_NO_32K_XTAL_BIT_OFF
+ global AUTOREAD_NO_32K_XTAL_BYTE_OFF
+
+ sydney_burn_autoread_bit $AUTOREAD_NO_32K_XTAL_BYTE_OFF $AUTOREAD_NO_32K_XTAL_BIT_OFF
+}
+
+set AUTOREAD_IGNORE_32K_XTAL_CHECK_BIT_OFF 0
+set AUTOREAD_IGNORE_32K_XTAL_CHECK_BYTE_OFF 3
+proc sydney_burn_ignore_32k_xtal_check {} {
+ sydney_burn_autoread_bit $::AUTOREAD_IGNORE_32K_XTAL_CHECK_BYTE_OFF $::AUTOREAD_IGNORE_32K_XTAL_CHECK_BIT_OFF
+}
diff --git a/platform/atm2/ATM22xx-x1x/openocd/atm2x_openocd.cfg b/platform/atm2/ATM22xx-x1x/openocd/atm2x_openocd.cfg
new file mode 100644
index 0000000..c1b35c9
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/atm2x_openocd.cfg
@@ -0,0 +1,42 @@
+if {[info exists ::env(SWDIF)]} {
+ if {$::env(SWDIF) eq "JLINK"} {
+ puts "Using JLINK"
+ source [find atm_jlink.tcl]
+ } else {
+ error [format "Unknown SWDIF=%s setting" $::env(SWDIF)]
+ }
+} else {
+ puts "Using FTDI"
+ source [find atm_ftdi.tcl]
+}
+
+if {![info exists ::env(FTDI_HARD_RESET)]} {
+ source [find m0_cpu.tcl]
+}
+
+proc set_reset {} {
+ assert_pwd
+}
+
+proc release_reset {} {
+ deassert_pwd
+}
+
+proc set_benign_boot {} {
+ assert_bboot
+}
+
+proc set_normal_boot {} {
+ deassert_bboot
+}
+
+# Tested as high as 20000, but openocd complains a lot when the
+# AHB bus is busy (ex: when running from flash)
+set _SWD_KHZ [expr {[info exists ::env(SYDNEY_SWD_KHZ)] ? $::env(SYDNEY_SWD_KHZ) : 1000}]
+adapter speed $_SWD_KHZ
+
+gdb_port disabled
+telnet_port disabled
+tcl_port disabled
+
+source [find atm_top.tcl]
diff --git a/platform/atm2/ATM22xx-x1x/openocd/atm2x_peripheral_wrapper_operations.tcl b/platform/atm2/ATM22xx-x1x/openocd/atm2x_peripheral_wrapper_operations.tcl
new file mode 100644
index 0000000..a0ef3ef
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/atm2x_peripheral_wrapper_operations.tcl
@@ -0,0 +1,515 @@
+# Generated by ./sydney_gen_resets_tcl.sh from soc/BP200-BU-00000-r1p0-00rel0/software/cmsis/Device/ARM/CMSDK_CM0/Include/base_addr.h
+
+source [find regs/regs_for_program.tcl]
+
+proc parse_id { id } {
+ set c0 [expr [expr $id & 0xff000000] >> 24]
+ set c1 [expr [expr $id & 0x00ff0000] >> 16]
+ set c2 [expr [expr $id & 0x0000ff00] >> 8]
+ set c3 [expr [expr $id & 0x000000ff] >> 0]
+ format "%c%c%c%c" $c0 $c1 $c2 $c3
+}
+
+proc enable_pwm {} {
+ global CMSDK_WRPR_APB6_CTRL
+ mww $CMSDK_WRPR_APB6_CTRL 0x00000001
+}
+
+proc disable_pwm {} {
+ global CMSDK_WRPR_APB6_CTRL
+ mww $CMSDK_WRPR_APB6_CTRL 0x00000000
+}
+
+proc reset_pwm {} {
+ global CMSDK_WRPR_APB6_CTRL
+ mww $CMSDK_WRPR_APB6_CTRL 0x00000002
+}
+
+proc getid_pwm {} {
+ enable_pwm
+ global CMSDK_PWM_CORE_ID
+ parse_id [mrw $CMSDK_PWM_CORE_ID]
+}
+
+proc enable_spi0 {} {
+ global CMSDK_WRPR_APB7_CTRL
+ mww $CMSDK_WRPR_APB7_CTRL 0x00000001
+}
+
+proc disable_spi0 {} {
+ global CMSDK_WRPR_APB7_CTRL
+ mww $CMSDK_WRPR_APB7_CTRL 0x00000000
+}
+
+proc reset_spi0 {} {
+ global CMSDK_WRPR_APB7_CTRL
+ mww $CMSDK_WRPR_APB7_CTRL 0x00000002
+}
+
+proc getid_spi0 {} {
+ enable_spi0
+ global CMSDK_SPI0_CORE_ID
+ parse_id [mrw $CMSDK_SPI0_CORE_ID]
+}
+
+proc enable_oled {} {
+ global CMSDK_WRPR_APB9_CTRL
+ mww $CMSDK_WRPR_APB9_CTRL 0x00000001
+}
+
+proc disable_oled {} {
+ global CMSDK_WRPR_APB9_CTRL
+ mww $CMSDK_WRPR_APB9_CTRL 0x00000000
+}
+
+proc reset_oled {} {
+ global CMSDK_WRPR_APB9_CTRL
+ mww $CMSDK_WRPR_APB9_CTRL 0x00000002
+}
+
+proc getid_oled {} {
+ enable_oled
+ global CMSDK_OLED_CORE_ID
+ parse_id [mrw $CMSDK_OLED_CORE_ID]
+}
+
+proc enable_ksm {} {
+ global CMSDK_WRPR_APB10_CTRL
+ mww $CMSDK_WRPR_APB10_CTRL 0x00000001
+}
+
+proc disable_ksm {} {
+ global CMSDK_WRPR_APB10_CTRL
+ mww $CMSDK_WRPR_APB10_CTRL 0x00000000
+}
+
+proc reset_ksm {} {
+ global CMSDK_WRPR_APB10_CTRL
+ mww $CMSDK_WRPR_APB10_CTRL 0x00000002
+}
+
+proc getid_ksm {} {
+ enable_ksm
+ global CMSDK_KSM_CORE_ID
+ parse_id [mrw $CMSDK_KSM_CORE_ID]
+}
+
+proc enable_spi2 {} {
+ global CMSDK_WRPR_APB11_CTRL
+ mww $CMSDK_WRPR_APB11_CTRL 0x00000001
+}
+
+proc disable_spi2 {} {
+ global CMSDK_WRPR_APB11_CTRL
+ mww $CMSDK_WRPR_APB11_CTRL 0x00000000
+}
+
+proc reset_spi2 {} {
+ global CMSDK_WRPR_APB11_CTRL
+ mww $CMSDK_WRPR_APB11_CTRL 0x00000002
+}
+
+proc getid_spi2 {} {
+ enable_spi2
+ global CMSDK_SPI2_CORE_ID
+ parse_id [mrw $CMSDK_SPI2_CORE_ID]
+}
+
+proc enable_qdec {} {
+ global CMSDK_WRPR_APB12_CTRL
+ mww $CMSDK_WRPR_APB12_CTRL 0x00000001
+}
+
+proc disable_qdec {} {
+ global CMSDK_WRPR_APB12_CTRL
+ mww $CMSDK_WRPR_APB12_CTRL 0x00000000
+}
+
+proc reset_qdec {} {
+ global CMSDK_WRPR_APB12_CTRL
+ mww $CMSDK_WRPR_APB12_CTRL 0x00000002
+}
+
+proc getid_qdec {} {
+ enable_qdec
+ global CMSDK_QDEC_CORE_ID
+ parse_id [mrw $CMSDK_QDEC_CORE_ID]
+}
+
+proc enable_spi1 {} {
+ global CMSDK_WRPR_APB13_CTRL
+ mww $CMSDK_WRPR_APB13_CTRL 0x00000001
+}
+
+proc disable_spi1 {} {
+ global CMSDK_WRPR_APB13_CTRL
+ mww $CMSDK_WRPR_APB13_CTRL 0x00000000
+}
+
+proc reset_spi1 {} {
+ global CMSDK_WRPR_APB13_CTRL
+ mww $CMSDK_WRPR_APB13_CTRL 0x00000002
+}
+
+proc getid_spi1 {} {
+ enable_spi1
+ global CMSDK_SPI1_CORE_ID
+ parse_id [mrw $CMSDK_SPI1_CORE_ID]
+}
+
+proc enable_slwtimer {} {
+ global CMSDK_WRPR_APB14_CTRL
+ mww $CMSDK_WRPR_APB14_CTRL 0x00000001
+}
+
+proc disable_slwtimer {} {
+ global CMSDK_WRPR_APB14_CTRL
+ mww $CMSDK_WRPR_APB14_CTRL 0x00000000
+}
+
+proc reset_slwtimer {} {
+ global CMSDK_WRPR_APB14_CTRL
+ mww $CMSDK_WRPR_APB14_CTRL 0x00000002
+}
+
+proc getid_slwtimer {} {
+ enable_slwtimer
+ global CMSDK_SLWTIMER_CORE_ID
+ parse_id [mrw $CMSDK_SLWTIMER_CORE_ID]
+}
+
+proc enable_qspi {} {
+ global CMSDK_WRPR_APB15_CTRL
+ mww $CMSDK_WRPR_APB15_CTRL 0x00000001
+}
+
+proc disable_qspi {} {
+ global CMSDK_WRPR_APB15_CTRL
+ mww $CMSDK_WRPR_APB15_CTRL 0x00000000
+}
+
+proc reset_qspi {} {
+ global CMSDK_WRPR_APB15_CTRL
+ mww $CMSDK_WRPR_APB15_CTRL 0x00000002
+}
+
+proc getid_qspi {} {
+ enable_qspi
+ global CMSDK_QSPI_CORE_ID
+ parse_id [mrw $CMSDK_QSPI_CORE_ID]
+}
+
+proc enable_i2c0 {} {
+ global CMSDK_WRPR1_APB0_CTRL
+ mww $CMSDK_WRPR1_APB0_CTRL 0x00000001
+}
+
+proc disable_i2c0 {} {
+ global CMSDK_WRPR1_APB0_CTRL
+ mww $CMSDK_WRPR1_APB0_CTRL 0x00000000
+}
+
+proc reset_i2c0 {} {
+ global CMSDK_WRPR1_APB0_CTRL
+ mww $CMSDK_WRPR1_APB0_CTRL 0x00000002
+}
+
+proc getid_i2c0 {} {
+ enable_i2c0
+ global CMSDK_I2C0_ID
+ parse_id [mrw $CMSDK_I2C0_ID]
+}
+
+proc enable_i2c1 {} {
+ global CMSDK_WRPR1_APB1_CTRL
+ mww $CMSDK_WRPR1_APB1_CTRL 0x00000001
+}
+
+proc disable_i2c1 {} {
+ global CMSDK_WRPR1_APB1_CTRL
+ mww $CMSDK_WRPR1_APB1_CTRL 0x00000000
+}
+
+proc reset_i2c1 {} {
+ global CMSDK_WRPR1_APB1_CTRL
+ mww $CMSDK_WRPR1_APB1_CTRL 0x00000002
+}
+
+proc getid_i2c1 {} {
+ enable_i2c1
+ global CMSDK_I2C1_ID
+ parse_id [mrw $CMSDK_I2C1_ID]
+}
+
+proc enable_nvm {} {
+ global CMSDK_WRPR1_APB2_CTRL
+ mww $CMSDK_WRPR1_APB2_CTRL 0x00000001
+}
+
+proc disable_nvm {} {
+ global CMSDK_WRPR1_APB2_CTRL
+ mww $CMSDK_WRPR1_APB2_CTRL 0x00000000
+}
+
+proc reset_nvm {} {
+ global CMSDK_WRPR1_APB2_CTRL
+ mww $CMSDK_WRPR1_APB2_CTRL 0x00000002
+}
+
+proc getid_nvm {} {
+ enable_nvm
+ global CMSDK_NVM_ID
+ parse_id [mrw $CMSDK_NVM_ID]
+}
+
+proc enable_rif {} {
+ global CMSDK_WRPR1_APB4_CTRL
+ mww $CMSDK_WRPR1_APB4_CTRL 0x00000001
+}
+
+proc disable_rif {} {
+ global CMSDK_WRPR1_APB4_CTRL
+ mww $CMSDK_WRPR1_APB4_CTRL 0x00000000
+}
+
+proc reset_rif {} {
+ global CMSDK_WRPR1_APB4_CTRL
+ mww $CMSDK_WRPR1_APB4_CTRL 0x00000002
+}
+
+proc getid_rif {} {
+ enable_rif
+ global CMSDK_RIF_ID
+ parse_id [mrw $CMSDK_RIF_ID]
+}
+
+proc enable_radio {} {
+ global CMSDK_WRPR1_APB5_CTRL
+ mww $CMSDK_WRPR1_APB5_CTRL 0x00000001
+}
+
+proc disable_radio {} {
+ global CMSDK_WRPR1_APB5_CTRL
+ mww $CMSDK_WRPR1_APB5_CTRL 0x00000000
+}
+
+proc reset_radio {} {
+ global CMSDK_WRPR1_APB5_CTRL
+ mww $CMSDK_WRPR1_APB5_CTRL 0x00000002
+}
+
+proc getid_radio {} {
+ enable_radio
+ global CMSDK_RADIO_CORE_ID
+ parse_id [mrw $CMSDK_RADIO_CORE_ID]
+}
+
+proc enable_mdm {} {
+ global CMSDK_WRPR1_APB6_CTRL
+ mww $CMSDK_WRPR1_APB6_CTRL 0x00000001
+}
+
+proc disable_mdm {} {
+ global CMSDK_WRPR1_APB6_CTRL
+ mww $CMSDK_WRPR1_APB6_CTRL 0x00000000
+}
+
+proc reset_mdm {} {
+ global CMSDK_WRPR1_APB6_CTRL
+ mww $CMSDK_WRPR1_APB6_CTRL 0x00000002
+}
+
+proc getid_mdm {} {
+ enable_mdm
+ global CMSDK_MDM_CORE_ID
+ parse_id [mrw $CMSDK_MDM_CORE_ID]
+}
+
+proc enable_pmu {} {
+ global CMSDK_WRPR1_APB7_CTRL
+ mww $CMSDK_WRPR1_APB7_CTRL 0x00000001
+}
+
+proc disable_pmu {} {
+ global CMSDK_WRPR1_APB7_CTRL
+ mww $CMSDK_WRPR1_APB7_CTRL 0x00000000
+}
+
+proc reset_pmu {} {
+ global CMSDK_WRPR1_APB7_CTRL
+ mww $CMSDK_WRPR1_APB7_CTRL 0x00000002
+}
+
+proc getid_pmu {} {
+ enable_pmu
+ global CMSDK_PMU_CORE_ID
+ parse_id [mrw $CMSDK_PMU_CORE_ID]
+}
+
+proc enable_pseq {} {
+ global CMSDK_WRPR1_APB8_CTRL
+ mww $CMSDK_WRPR1_APB8_CTRL 0x00000001
+}
+
+proc disable_pseq {} {
+ global CMSDK_WRPR1_APB8_CTRL
+ mww $CMSDK_WRPR1_APB8_CTRL 0x00000000
+}
+
+proc reset_pseq {} {
+ global CMSDK_WRPR1_APB8_CTRL
+ mww $CMSDK_WRPR1_APB8_CTRL 0x00000002
+}
+
+proc getid_pseq {} {
+ enable_pseq
+ global CMSDK_PSEQ_CORE_ID
+ parse_id [mrw $CMSDK_PSEQ_CORE_ID]
+}
+
+proc enable_swd {} {
+ global CMSDK_WRPR1_APB9_CTRL
+ mww $CMSDK_WRPR1_APB9_CTRL 0x00000001
+}
+
+proc disable_swd {} {
+ global CMSDK_WRPR1_APB9_CTRL
+ mww $CMSDK_WRPR1_APB9_CTRL 0x00000000
+}
+
+proc reset_swd {} {
+ global CMSDK_WRPR1_APB9_CTRL
+ mww $CMSDK_WRPR1_APB9_CTRL 0x00000002
+}
+
+proc getid_swd {} {
+ enable_swd
+ global CMSDK_SWD_CORE_ID
+ parse_id [mrw $CMSDK_SWD_CORE_ID]
+}
+
+proc enable_gadc {} {
+ global CMSDK_WRPR1_APB10_CTRL
+ mww $CMSDK_WRPR1_APB10_CTRL 0x00000001
+}
+
+proc disable_gadc {} {
+ global CMSDK_WRPR1_APB10_CTRL
+ mww $CMSDK_WRPR1_APB10_CTRL 0x00000000
+}
+
+proc reset_gadc {} {
+ global CMSDK_WRPR1_APB10_CTRL
+ mww $CMSDK_WRPR1_APB10_CTRL 0x00000002
+}
+
+proc getid_gadc {} {
+ enable_gadc
+ global CMSDK_GADC_CORE_ID
+ parse_id [mrw $CMSDK_GADC_CORE_ID]
+}
+
+proc enable_trng {} {
+ global CMSDK_WRPR1_APB11_CTRL
+ mww $CMSDK_WRPR1_APB11_CTRL 0x00000001
+}
+
+proc disable_trng {} {
+ global CMSDK_WRPR1_APB11_CTRL
+ mww $CMSDK_WRPR1_APB11_CTRL 0x00000000
+}
+
+proc reset_trng {} {
+ global CMSDK_WRPR1_APB11_CTRL
+ mww $CMSDK_WRPR1_APB11_CTRL 0x00000002
+}
+
+proc getid_trng {} {
+ enable_trng
+ global CMSDK_TRNG_CORE_ID
+ parse_id [mrw $CMSDK_TRNG_CORE_ID]
+}
+
+proc enable_rcos_cal {} {
+ global CMSDK_WRPR1_APB12_CTRL
+ mww $CMSDK_WRPR1_APB12_CTRL 0x00000001
+}
+
+proc disable_rcos_cal {} {
+ global CMSDK_WRPR1_APB12_CTRL
+ mww $CMSDK_WRPR1_APB12_CTRL 0x00000000
+}
+
+proc reset_rcos_cal {} {
+ global CMSDK_WRPR1_APB12_CTRL
+ mww $CMSDK_WRPR1_APB12_CTRL 0x00000002
+}
+
+proc getid_rcos_cal {} {
+ enable_rcos_cal
+ global CMSDK_RCOS_CAL_CORE_ID
+ parse_id [mrw $CMSDK_RCOS_CAL_CORE_ID]
+}
+
+proc enable_shub {} {
+ global CMSDK_WRPR1_APB13_CTRL
+ mww $CMSDK_WRPR1_APB13_CTRL 0x00000001
+}
+
+proc disable_shub {} {
+ global CMSDK_WRPR1_APB13_CTRL
+ mww $CMSDK_WRPR1_APB13_CTRL 0x00000000
+}
+
+proc reset_shub {} {
+ global CMSDK_WRPR1_APB13_CTRL
+ mww $CMSDK_WRPR1_APB13_CTRL 0x00000002
+}
+
+proc getid_shub {} {
+ enable_shub
+ global CMSDK_SHUB_ID
+ parse_id [mrw $CMSDK_SHUB_ID]
+}
+
+proc enable_atlc {} {
+ global CMSDK_WRPR1_APB14_CTRL
+ mww $CMSDK_WRPR1_APB14_CTRL 0x00000001
+}
+
+proc disable_atlc {} {
+ global CMSDK_WRPR1_APB14_CTRL
+ mww $CMSDK_WRPR1_APB14_CTRL 0x00000000
+}
+
+proc reset_atlc {} {
+ global CMSDK_WRPR1_APB14_CTRL
+ mww $CMSDK_WRPR1_APB14_CTRL 0x00000002
+}
+
+proc getid_atlc {} {
+ enable_atlc
+ global CMSDK_ATLC_ID
+ parse_id [mrw $CMSDK_ATLC_ID]
+}
+
+proc enable_pdm {} {
+ global CMSDK_WRPR1_APB15_CTRL
+ mww $CMSDK_WRPR1_APB15_CTRL 0x00000001
+}
+
+proc disable_pdm {} {
+ global CMSDK_WRPR1_APB15_CTRL
+ mww $CMSDK_WRPR1_APB15_CTRL 0x00000000
+}
+
+proc reset_pdm {} {
+ global CMSDK_WRPR1_APB15_CTRL
+ mww $CMSDK_WRPR1_APB15_CTRL 0x00000002
+}
+
+proc getid_pdm {} {
+ enable_pdm
+ global CMSDK_PDM_CORE_ID
+ parse_id [mrw $CMSDK_PDM_CORE_ID]
+}
diff --git a/platform/atm2/ATM22xx-x1x/openocd/atm2x_pseq.tcl b/platform/atm2/ATM22xx-x1x/openocd/atm2x_pseq.tcl
new file mode 100644
index 0000000..26989b1
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/atm2x_pseq.tcl
@@ -0,0 +1,57 @@
+#
+# atm2x_pseq.tcl
+# Production APIs for PSEQ operations
+# Copyright (C) Atmosic 2018-2019
+#
+
+proc enable_hpc {} {
+ global CMSDK_PSEQ_XTAL_BITS1
+
+ enable_pseq
+ set xb1 [mrw $CMSDK_PSEQ_XTAL_BITS1]
+ mww $CMSDK_PSEQ_XTAL_BITS1 [expr {$xb1 | (1 << 19)}]
+ disable_pseq
+}
+
+proc disable_hpc {} {
+ global CMSDK_PSEQ_XTAL_BITS1
+
+ enable_pseq
+ set xb1 [mrw $CMSDK_PSEQ_XTAL_BITS1]
+ mww $CMSDK_PSEQ_XTAL_BITS1 [expr {$xb1 & ~(1 << 19)}]
+ disable_pseq
+}
+
+proc enable_emram {} {
+ global CMSDK_PSEQ_EMRAM_OVERRIDES
+ global CMSDK_PSEQ_EMRAM_OVERRIDES2
+ global CMSDK_PSEQ_EMRAM_OVERRIDES3
+ global CMSDK_PSEQ_EMRAM_OVERRIDES4
+ global CMSDK_PSEQ_EMRAM_OVERRIDES5
+ global CMSDK_PSEQ_EMRAM_OVERRIDES6
+
+ enable_pseq
+ mww $CMSDK_PSEQ_EMRAM_OVERRIDES 0
+ mww $CMSDK_PSEQ_EMRAM_OVERRIDES6 0
+ mww $CMSDK_PSEQ_EMRAM_OVERRIDES5 0
+ mww $CMSDK_PSEQ_EMRAM_OVERRIDES4 0
+ mww $CMSDK_PSEQ_EMRAM_OVERRIDES3 0
+ mww $CMSDK_PSEQ_EMRAM_OVERRIDES2 0
+}
+
+proc enable_uram {} {
+ global CMSDK_PSEQ_SYSRAM_OVERRIDES
+ global CMSDK_PSEQ_SYSRAM_OVERRIDES2
+ global CMSDK_PSEQ_SYSRAM_OVERRIDES3
+ global CMSDK_PSEQ_SYSRAM_OVERRIDES4
+ global CMSDK_PSEQ_SYSRAM_OVERRIDES5
+ global CMSDK_PSEQ_SYSRAM_OVERRIDES6
+
+ enable_pseq
+ mww $CMSDK_PSEQ_SYSRAM_OVERRIDES 0
+ mww $CMSDK_PSEQ_SYSRAM_OVERRIDES6 0
+ mww $CMSDK_PSEQ_SYSRAM_OVERRIDES5 0
+ mww $CMSDK_PSEQ_SYSRAM_OVERRIDES4 0
+ mww $CMSDK_PSEQ_SYSRAM_OVERRIDES3 0
+ mww $CMSDK_PSEQ_SYSRAM_OVERRIDES2 0
+}
diff --git a/platform/atm2/ATM22xx-x1x/openocd/atm2x_rom.tcl b/platform/atm2/ATM22xx-x1x/openocd/atm2x_rom.tcl
new file mode 100644
index 0000000..ee4072d
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/atm2x_rom.tcl
@@ -0,0 +1,65 @@
+#
+# atm2x_rom.tcl
+# Production APIs for ROM operations
+# Copyright (C) Atmosic 2018-2020
+#
+
+proc verify_rom_version {} {
+ reset halt
+ if {[mrw 0x3f2c8] == 0x454c422d} {
+ return
+ }
+ if {[mrw 0x3cdb0] == 0x422d5752} {
+ error "Incompatible with ATM2xE1 or ATM2xE2 part!"
+ } elseif {[mrw 0x3d8e8] == 0x422d5752} {
+ error "Incompatible with ATM2xE2b part!"
+ } elseif {[mrw 0x3ae2c] == 0x422d5752} {
+ error "Incompatible with ATM2xE3, ATM2xE3a, or ATM2xE3b part!"
+ } elseif {[mrw 0x3ea30] == 0x422d5752} {
+ error "Incompatible with ATM2xE3c or ATMx2xx-x0x part!"
+ }
+ error "Not an ATMx2xx-x1x part!"
+}
+
+proc get_rom_version {} {
+ reset halt
+ if {[mrw 0x3cdb0] == 0x422d5752} {
+ return [list ATM2xE1 ATM2xE2]
+ } elseif {[mrw 0x3d8e8] == 0x422d5752} {
+ return [list ATM2xE2b]
+ } elseif {[mrw 0x3ae2c] == 0x422d5752} {
+ return [list ATM2xE3 ATM2xE3a ATM2xE3b]
+ } elseif {[mrw 0x3ea30] == 0x422d5752} {
+ return [list ATM2xE3c ATM22xx-x0x ATM32xx-x0x]
+ } elseif {[mrw 0x3f2c8] == 0x454c422d} {
+ return [list ATM22xx-x1x ATM32xx-x1x]
+ }
+ error "Unrecognized platform"
+}
+
+proc load_ram_image { external_flash_init image {entry_point 0x20014000} } {
+ reset halt
+
+ # Hijack flash app
+ bp $external_flash_init 2 hw
+ resume; sleep 1; wait_halt
+ rbp $external_flash_init
+
+ # Relocate stack if necessary
+ if {$entry_point != 0x20014000} {
+ set src 0x20014000
+ set end [lindex [reg sp] 2]
+ set dst $entry_point
+ puts -nonewline "Relocate stack $end..$src"
+ while {$src != $end} {
+ incr src -4
+ incr dst -4
+ mww $dst [mrw $src]
+ }
+ set dstx [format 0x%x $dst]
+ puts " to $dstx..$entry_point"
+ reg sp $dst
+ }
+
+ load_image $image $entry_point
+}
diff --git a/platform/atm2/ATM22xx-x1x/openocd/atm_coredump.tcl b/platform/atm2/ATM22xx-x1x/openocd/atm_coredump.tcl
new file mode 100644
index 0000000..18a5d5b
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/atm_coredump.tcl
@@ -0,0 +1,84 @@
+################################################################################
+#
+# @file atm_coredump.tcl
+#
+# @brief Implements Coredump Helper functions for ATM22/ATM32 paltform
+#
+# Copyright (C) Atmosic 2022
+#
+################################################################################
+
+proc reg_dump {} {
+ set index { 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 }
+
+ # First 18 ints are 0s
+ set str [string repeat "\u0000" 72]
+ foreach x $index {
+ append str [binary format i1 [ lindex [reg $x] 2]]
+ }
+ append str [binary format i1 0x0]
+ return $str
+}
+
+proc get_section_names {} {
+ set section_names {".shstrtab" ".flash" ".rom" ".sram" ".em"}
+ return $section_names
+}
+
+# Dumps flash using appropriate function for platform
+proc coredump_dump_flash { CoreDumpFile } {
+ set temp_file "tmpfile"
+
+ sydney_dump_flash $temp_file [sydney_flash_size]
+ copy_tempfile $temp_file $CoreDumpFile
+}
+
+proc get_headers { list_of_regions initial_offset string_table } {
+ set program_header ""
+ set section_headers ""
+
+ set data_offset $initial_offset
+ foreach region $list_of_regions {
+ set start_addr [lindex $region 0]
+ set region_size [lindex $region 1]
+ set string [lindex $region 2]
+
+ set string_offset [string first $string $string_table]
+
+ append program_headers [generate_program_header 1 $data_offset $start_addr 0 $region_size]
+ append section_headers [generate_section_header $string_offset 1 4 $start_addr $data_offset $region_size 0 0 1 0]
+
+ incr data_offset $region_size
+ }
+
+ return [list $program_headers $section_headers]
+}
+
+proc get_list_of_regions {} {
+ # Each region is of format {start_addr size section_name}
+ set list_of_regions [list]
+ lappend list_of_regions [list $::CMSDK_ROM_BASE 0x40000 ".rom"]
+
+ set num_sram_banks 6
+ set sram_bank_size 0x4000
+ set num_em_banks 2
+ set em_bank_size 0x4000
+
+ enable_pseq
+ set sram_override [mrw $::CMSDK_PSEQ_SYSRAM_OVERRIDES]
+ set emram_override [mrw $::CMSDK_PSEQ_EMRAM_OVERRIDES]
+ disable_pseq
+
+ set sram_active_sections [active_sections $::CMSDK_RAM_BASE $sram_bank_size $num_sram_banks $sram_override]
+ set em_active_sections [active_sections $::CMSDK_EM_BASE $em_bank_size $num_em_banks $emram_override]
+
+ foreach start $sram_active_sections {
+ lappend list_of_regions [list $start $sram_bank_size ".sram"]
+ }
+
+ foreach start $em_active_sections {
+ lappend list_of_regions [list $start $em_bank_size ".em"]
+ }
+
+ lappend list_of_regions [list $::CMSDK_FLASH_BASE [sydney_flash_size] ".flash"]
+}
diff --git a/platform/atm2/ATM22xx-x1x/openocd/atm_ftdi.tcl b/platform/atm2/ATM22xx-x1x/openocd/atm_ftdi.tcl
new file mode 100644
index 0000000..892ba54
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/atm_ftdi.tcl
@@ -0,0 +1,89 @@
+set IS_ATM_MP 0
+
+if {[info exists ::env(SWDBOARD)]} {
+ if {$::env(SWDBOARD) eq "APT"} {
+ set IS_ATM_MP 1
+ puts "Using APT"
+ } elseif {$::env(SWDBOARD) eq "DL"} {
+ set IS_ATM_MP 1
+ puts "Using DL"
+ }
+} else {
+ puts "Using Interface Board"
+}
+
+adapter driver ftdi
+if {$IS_ATM_MP} {
+ ftdi_vid_pid 0x0403 0x6011
+ set _FTDI_RESET 0x80
+ set _FTDI_BBOOT 0x40
+ # Use FT4232HQ ADBUS4 pin as GPIO (GPIOL0)
+ set _FTDI_SWD_ENABLE 0x10
+} else {
+ ftdi_vid_pid 0x0403 0x6010
+ set _FTDI_RESET 0x8000
+ set _FTDI_BBOOT 0x4000
+ # Use FT2232H ACBUS4 pin as GPIO (GPIOH4)
+ set _FTDI_SWD_ENABLE 0x1000
+}
+
+if {[info exists ::env(SYDNEY_SERIAL)]} {
+ if {!$IS_ATM_MP} {
+ set _FTDI_SERIAL [format "%s%s" $::env(SYDNEY_SERIAL) "USB1"]
+ } else {
+ set _FTDI_SERIAL $::env(SYDNEY_SERIAL)
+ }
+ puts "FTDI serial $_FTDI_SERIAL"
+ ftdi_serial $_FTDI_SERIAL
+}
+
+ftdi_channel 0
+set _FTDI_OD 0x0000
+set _FTDI_OE 0x0003
+
+if {[info exists ::env(FTDI_HARD_RESET)]} {
+ set _FTDI_OE [expr {$_FTDI_OE | $_FTDI_RESET}]
+ if {$::env(FTDI_HARD_RESET) ne "0"} {
+ set _FTDI_OD [expr {$_FTDI_OD | $_FTDI_RESET}]
+ }
+}
+
+if {[info exists ::env(FTDI_BENIGN_BOOT)]} {
+ set _FTDI_OE [expr {$_FTDI_OE | $_FTDI_BBOOT}]
+ if {$::env(FTDI_BENIGN_BOOT) ne "0"} {
+ set _FTDI_OD [expr {$_FTDI_OD | $_FTDI_BBOOT}]
+ }
+}
+
+set _FTDI_OE [expr {$_FTDI_OE | $_FTDI_SWD_ENABLE}]
+set _FTDI_OD [expr {$_FTDI_OD | $_FTDI_SWD_ENABLE}]
+
+ftdi_layout_init $_FTDI_OD $_FTDI_OE
+ftdi_layout_signal SRST -data $_FTDI_RESET -oe $_FTDI_RESET
+ftdi_layout_signal BBOOT -data $_FTDI_BBOOT -oe $_FTDI_BBOOT
+ftdi_layout_signal SWDENABLE -data $_FTDI_SWD_ENABLE -oe $_FTDI_SWD_ENABLE
+
+transport select swd
+ftdi_layout_signal SWD_EN -data 0
+ftdi_layout_signal SWDIO_OE -data 0
+
+
+proc assert_pwd {} {
+ ftdi_set_signal SRST 1
+}
+
+proc deassert_pwd {} {
+ ftdi_set_signal SWDENABLE 0
+ ftdi_set_signal SWDENABLE z
+ ftdi_set_signal SRST 0
+ ftdi_set_signal SRST z
+}
+
+proc assert_bboot {} {
+ ftdi_set_signal BBOOT 1
+}
+
+proc deassert_bboot {} {
+ ftdi_set_signal BBOOT 0
+ ftdi_set_signal BBOOT z
+}
diff --git a/platform/atm2/ATM22xx-x1x/openocd/atm_jlink.tcl b/platform/atm2/ATM22xx-x1x/openocd/atm_jlink.tcl
new file mode 100644
index 0000000..49ea09f
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/atm_jlink.tcl
@@ -0,0 +1,50 @@
+# Pin 5 - BBOOT, Pin 11 - PWD
+# Array element for mapping - pin3:pin5:pin7:pin9:pin11:pin13:pin15:pin17
+set JLINK_PIO_OUT_LOW 2
+set JLINK_PIO_OUT_HIGH 3
+set JLINK_PIO_MAP_DEFAULT 0:0:0:0:0:0:0:0
+set JLINK_PIO_MAP_BBOOT_H_PWD_L 0:$JLINK_PIO_OUT_HIGH:0:0:0:0:0:0
+set JLINK_PIO_MAP_BBOOT_L_PWD_H 0:$JLINK_PIO_OUT_LOW:0:0:$JLINK_PIO_OUT_HIGH:0:0:0
+set JLINK_PIO_MAP_BBOOT_L_PWD_L 0:$JLINK_PIO_OUT_LOW:0:0:$JLINK_PIO_OUT_LOW:0:0:0
+
+adapter driver jlink
+
+if {[info exists ::env(JLINK_SERIAL)]} {
+ set _JLINK_SERIAL [format "%s" $::env(JLINK_SERIAL)]
+ puts "JLINK serial $_JLINK_SERIAL"
+ jlink serial $_JLINK_SERIAL
+}
+
+transport select swd
+
+set BBOOT_ENABLE $JLINK_PIO_OUT_LOW
+if {[info exists ::env(FTDI_BENIGN_BOOT)]} {
+ if {$::env(FTDI_BENIGN_BOOT) ne "0"} {
+ set BBOOT_ENABLE $JLINK_PIO_OUT_HIGH
+ }
+}
+
+set PWD_ENABLE $JLINK_PIO_OUT_LOW
+if {[info exists ::env(FTDI_HARD_RESET)]} {
+ if {$::env(FTDI_HARD_RESET) ne "0"} {
+ set PWD_ENABLE $JLINK_PIO_OUT_HIGH
+ }
+}
+
+jlink gpioconfig 0:$BBOOT_ENABLE:0:0:$PWD_ENABLE:0:0:0
+
+proc assert_pwd {} {
+ jlink gpio map $::JLINK_PIO_MAP_BBOOT_L_PWD_H
+}
+
+proc deassert_pwd {} {
+ jlink gpio map $::JLINK_PIO_MAP_BBOOT_L_PWD_L
+}
+
+proc assert_bboot {} {
+ jlink gpio map $::JLINK_PIO_MAP_BBOOT_H_PWD_L
+}
+
+proc deassert_bboot {} {
+ jlink gpio map $::JLINK_PIO_MAP_BBOOT_L_PWD_L
+}
diff --git a/platform/atm2/ATM22xx-x1x/openocd/atm_nvds.tcl b/platform/atm2/ATM22xx-x1x/openocd/atm_nvds.tcl
new file mode 100644
index 0000000..ec9326e
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/atm_nvds.tcl
@@ -0,0 +1,22 @@
+#
+# atm_nvds.tcl
+# Provide NVDS functions
+# Copyright (C) Atmosic 2022
+#
+
+proc sydney_erase_nvds { {region_start 0x78000} {region_size 0x8000} } {
+ sydney_erase_flash_nvds $region_start $region_size
+}
+
+proc sydney_dump_nvds { image {region_start 0x78000} {region_size 0x8000} {mem_bank "bank0"} } {
+ sydney_dump_flash_nvds $image $region_start $region_size $mem_bank
+}
+
+proc sydney_load_nvds { image {region_start 0x78000} {region_size 0x8000} } {
+ sydney_load_flash_nvds $image $region_start $region_size
+}
+
+proc sydney_verify_nvds { image {region_start 0x78000} {region_size 0x8000} } {
+ sydney_verify_flash_nvds $image $region_start $region_size
+}
+
diff --git a/platform/atm2/ATM22xx-x1x/openocd/atm_top.tcl b/platform/atm2/ATM22xx-x1x/openocd/atm_top.tcl
new file mode 100644
index 0000000..a83eab1
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/atm_top.tcl
@@ -0,0 +1,25 @@
+#
+# atm_top.tcl
+# Production top level for ATM2/ATM3 devices
+# Copyright (C) Atmosic 2018-2022
+#
+
+source [find mem_helper.tcl]
+
+set CMSDK_ROM_BASE 0x00000000
+set CMSDK_FLASH_BASE 0x10000000
+set CMSDK_RAM_BASE 0x20000000
+set CMSDK_EM_BASE 0x30008000
+set CMSDK_AHB_NVM_BASE 0x60000000
+set CMSDK_AT_DMA_BASE 0x70000000
+set CMSDK_AHB_PDM_PP_BASE 0x80000000
+
+source [find atm2x_peripheral_wrapper_operations.tcl]
+source [find atm2x_pseq.tcl]
+source [find atm2x_flash.tcl]
+source [find atm_nvds.tcl]
+source [find atm2x_gdb.tcl]
+source [find atm2x_nvm.tcl]
+source [find atm2x_rom.tcl]
+source [find atm_coredump.tcl]
+source [find coredump.tcl]
diff --git a/platform/atm2/ATM22xx-x1x/openocd/coredump.tcl b/platform/atm2/ATM22xx-x1x/openocd/coredump.tcl
new file mode 100644
index 0000000..8d32fdd
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/coredump.tcl
@@ -0,0 +1,298 @@
+################################################################################
+#
+# @file coredump.tcl
+#
+# @brief Common File to Generate Coredump, relies on platform specific helper
+# files
+#
+# Copyright (C) Atmosic 2022
+#
+################################################################################
+
+proc generate_string_header { string_list } {
+
+ set string_str [binary format c1 0x0]
+
+ foreach name $string_list {
+ append string_str $name
+ append string_str [binary format c1 0x0]
+ }
+
+ return $string_str
+}
+
+proc generate_section_header { sh_name sh_type sh_flags sh_addr sh_offset sh_size sh_link sh_info sh_addralign sh_entsize } {
+ set str [binary format i1 $sh_name]
+ append str [binary format i1 $sh_type]
+ append str [binary format i1 $sh_flags]
+ append str [binary format i1 $sh_addr]
+ append str [binary format i1 $sh_offset]
+ append str [binary format i1 $sh_size]
+ append str [binary format i1 $sh_link]
+ append str [binary format i1 $sh_info]
+ append str [binary format i1 $sh_addralign]
+ append str [binary format i1 $sh_entsize]
+
+ return $str
+}
+
+proc generate_program_header { p_type p_offset p_vaddr p_paddr p_filesz } {
+ set str [binary format i1 $p_type]
+ append str [binary format i1 $p_offset]
+ append str [binary format i1 $p_vaddr]
+ append str [binary format i1 $p_paddr]
+ append str [binary format i1 $p_filesz]
+ #memsz
+ append str [binary format i1 0x0]
+ #flags
+ append str [binary format i1 0x0]
+ #align
+ append str [binary format i1 0x0]
+
+ return $str
+}
+
+proc generate_pt_note { reg_dump } {
+ # PT_NOTE Section
+ # namesz
+ set str [binary format i1 0x5]
+
+ # descsz
+ append str [binary format i1 [string length $reg_dump]]
+
+ # type (NT_PRSTATUS == 1)
+ append str [binary format i1 0x1]
+
+ # name (+ padding)
+ append str "CORE"
+ append str [string repeat "\u0000" 4]
+
+ # desc
+ append str $reg_dump
+
+ return $str
+}
+
+proc generate_elf_header { elf_header_size program_header_size num_prog_headers section_header_size num_sections } {
+
+ set symtbl_section [expr $num_sections - 1]
+
+ # e_ident/EI_MAGIC
+ set str [binary format c1a3 0x7f ELF]
+
+ # e_ident/EI_CLASS
+ append str [binary format c1 0x1]
+
+ # e_ident/EI_DATA (Little Endian)
+ append str [binary format c1 0x1]
+
+ # e_ident/EI_VERSION (EV_CURRENT)
+ append str [binary format c1 0x1]
+
+ # e_ident/EI_PAD (9 Bytes)
+ append str [binary format c9 {0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0}]
+
+ # e_type (Core File)
+ append str [binary format s1 0x4]
+
+ # e_machine (EM_ARM)
+ append str [binary format s1 40]
+
+ # e_version (0x1)
+ append str [binary format i1 0x1]
+
+ # e_entry (0x0)
+ append str [binary format i1 0x0]
+
+ # e_phoff (0x0)
+ append str [binary format i1 $elf_header_size]
+
+ # e_shoff
+ set e_shoff [expr $program_header_size * $num_prog_headers]
+ set e_shoff [expr $elf_header_size + $e_shoff]
+ append str [binary format i1 $e_shoff]
+
+ # e_flags (0x0)
+ append str [binary format i1 0x0]
+
+ # e_ehsize
+ append str [binary format s1 $elf_header_size]
+
+ # e_phentsize
+ append str [binary format s1 $program_header_size]
+
+ # e_phnum
+ append str [binary format s1 $num_prog_headers]
+
+ # e_shentsize
+ append str [binary format s1 $section_header_size]
+
+ # e_shnum
+ append str [binary format s1 $num_sections]
+
+ # e_shstrndx (last section is symbol table)
+ append str [binary format s1 $symtbl_section]
+
+ return $str
+}
+
+# Return list of active sections based on override flag
+proc active_sections { bank_start_addr bank_size no_of_banks override } {
+ set act_sec_list {}
+ for {set i 0} {$i < $no_of_banks} {incr i} {
+ set start [expr $bank_start_addr + ($i * $bank_size)]
+ if { !($override & [expr {1<<(12+$i) | 1<<$i}]) } {
+ lappend act_sec_list $start
+ }
+ }
+ return $act_sec_list
+}
+
+proc copy_tempfile { temp_file coredump_file } {
+ set platform $::tcl_platform(os)
+ if { $platform == "Windows NT" || $platform == "mingw" } {
+ exec cmd /c copy /b $coredump_file + $temp_file
+ } else {
+ exec cat $temp_file >> $coredump_file
+ }
+}
+
+# Dump all regions except external flash
+proc dump_core { list_of_regions CoreDumpFile } {
+ set temp_file "tmpfile"
+
+ # Each region is of format {start_addr size section_name}
+ foreach region $list_of_regions {
+ if {[string equal ".flash" [lindex $region 2]]} {
+ coredump_dump_flash $CoreDumpFile
+ } else {
+ dump_image $temp_file [lindex $region 0] [lindex $region 1]
+ copy_tempfile $temp_file $CoreDumpFile
+ }
+ }
+}
+
+proc get_coredump { {CoreDumpFile "Coredump"} } {
+# CoreFile Layout Details:
+# +++++++++++++++++++++++++++++++++++++++++++++++++++
+# + ELF header +
+# +++++++++++++++++++++++++++++++++++++++++++++++++++
+# + Program Header #1 +
+# +++++++++++++++++++++++++++++++++++++++++++++++++++
+# + Program Header #2 +
+# +++++++++++++++++++++++++++++++++++++++++++++++++++
+# ...
+# + Program Header #n +
+# +++++++++++++++++++++++++++++++++++++++++++++++++++
+# + Section Header #1 +
+# +++++++++++++++++++++++++++++++++++++++++++++++++++
+# + Section Header #2 +
+# +++++++++++++++++++++++++++++++++++++++++++++++++++
+# ...
+# + Section Header #n +
+# +++++++++++++++++++++++++++++++++++++++++++++++++++
+# + PT_NOTE/RegDump section data +
+# +++++++++++++++++++++++++++++++++++++++++++++++++++
+# + shstrtab/String table data +
+# +++++++++++++++++++++++++++++++++++++++++++++++++++
+# + +
+# + Dumped Data +
+# + +
+# +++++++++++++++++++++++++++++++++++++++++++++++++++
+#
+
+ halt
+ set saved_reg_dump [reg_dump]
+
+ set fp [open $CoreDumpFile w+]
+ fconfigure $fp -translation binary
+
+ set oss $::tcl_platform(os)
+ puts "Operating System: $oss"
+
+ # Constants
+ set elf_header_size 52
+ set section_header_size 40
+ set program_header_size 32
+
+ # 20 bytes is from namesz (4), descsz (4), type (4), name (8)
+ set ptnote_size [expr 20 + [string length $saved_reg_dump]]
+
+ set list_of_regions [get_list_of_regions]
+ set num_regions [llength $list_of_regions]
+
+ # + 1 for PT_NOTE
+ set num_prog_headers [expr $num_regions + 1]
+
+ # + 2 for EMPTY and SHSTRTAB sections
+ set num_sections [expr $num_regions + 2]
+
+ # Some constants to aid with offset calculation
+ set program_total_size [expr $program_header_size * $num_prog_headers]
+ set section_total_size [expr $section_header_size * $num_sections]
+ set header_size [expr $elf_header_size + $program_total_size + $section_total_size]
+
+ # Need to add length of array to add null terminator count (+ 1 is for EMPTY section header)
+ set section_names [get_section_names]
+ set string_tbl_size [expr [llength $section_names] + [string length [string map {"\"" "" " " ""} $section_names]] + 1]
+ set string_table [generate_string_header $section_names]
+
+ # Offset and size calculations
+ set strtab_string_offset [string first ".shstrtab" $string_table]
+
+ ######### Start Writing File #########
+
+ ### Write ELF_HEADER ###
+ puts -nonewline $fp [generate_elf_header $elf_header_size $program_header_size $num_prog_headers $section_header_size $num_sections]
+
+ # Generate Program Headers and Section Headers for memory regions
+ set headers [get_headers $list_of_regions [expr $header_size + $ptnote_size + $string_tbl_size] $string_table]
+ set program_headers [lindex $headers 0]
+ set section_headers [lindex $headers 1]
+
+ ### Write Program Headers ###
+
+ # Write Memory Region Program Headers
+ puts -nonewline $fp $program_headers
+
+ # Generate Program header for holding registers in PT_NOTE section
+ puts -nonewline $fp [generate_program_header 0x4 $header_size 0x0 0x0 $ptnote_size]
+
+ ### Write Section Headers ###
+ # Empty Section
+ puts -nonewline $fp [generate_section_header 0 0 0 0 0 0 0 0 0 0]
+
+ # Write Memory Region Sections
+ puts -nonewline $fp $section_headers
+
+ # String Table section header
+ set string_table_offset [expr $header_size + $ptnote_size]
+ # Not sure where it is documented but according to readelf flag of 0x20 corresponds to Strings
+ puts -nonewline $fp [generate_section_header $strtab_string_offset 3 0x20 0 $string_table_offset $string_tbl_size 0 0 1 0]
+
+ ### Write PT_NOTE (reg dump) ###
+ puts -nonewline $fp [generate_pt_note $saved_reg_dump]
+
+ ### Write String Table ###
+ puts -nonewline $fp $string_table
+
+ close $fp
+
+ ### Write Core Dump ###
+ dump_core $list_of_regions $CoreDumpFile
+
+ puts ""
+ puts "##########################################################"
+ puts " Dump saved to file: $CoreDumpFile"
+ puts "##########################################################"
+ puts ""
+ puts "##########################################################"
+ puts " In order to do offline Coredump analysis, please use gdb "
+ puts " from toolchain version "
+ puts " gcc-arm-11.2-2022.02-x86_64-arm-none-eabi or later "
+ puts " https://developer.arm.com/tools-and-software/ "
+ puts " open-source-software/developer-tools/gnu-toolchain/ "
+ puts " downloads "
+ puts "##########################################################"
+ puts ""
+}
diff --git a/platform/atm2/ATM22xx-x1x/openocd/http/app.tcl b/platform/atm2/ATM22xx-x1x/openocd/http/app.tcl
new file mode 100644
index 0000000..1e04580
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/http/app.tcl
@@ -0,0 +1,22 @@
+::http::add-handler OPTIONS /app/client-closing {
+ ::http::respond [::http::make-options-response {} 0 {} $request]
+}
+
+::http::add-handler POST /app/client-closing {
+ # There probably should be some key generation and exchange between the
+ # client and server so a request from a random HTTP client is rejected. For
+ # now, just ack the req.
+ ::http::respond [::http::make-bin-svc-response {} {} $request]
+ # Assumption: the sole client closed, so it's time to shutdown the OpenOCD
+ # server. (Multiple clients would require tracking, or at least counting,
+ # and shuting down the server when the last client closes. Or maybe the
+ # server should always stay up even when no client exist. That, however, is
+ # a problem for the future, if ever. Right now, there's a 1-to-1
+ # relationship between clients and servers, and each pair is tightly
+ # coupled.)
+ #
+ # Calling OpenOCD's shutdown makes the http server emit an handled critical
+ # error with an emtpy message. But that's OK since the program exists with
+ # 0 status.
+ shutdown
+}
diff --git a/platform/atm2/ATM22xx-x1x/openocd/http/bin_svc_server.tcl b/platform/atm2/ATM22xx-x1x/openocd/http/bin_svc_server.tcl
new file mode 100644
index 0000000..2dd611f
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/http/bin_svc_server.tcl
@@ -0,0 +1,707 @@
+source source_jimhttp.tcl
+source_jimhttp http.tcl
+
+variable nvds_tool nvds_tool
+variable atm_isp atm_isp
+variable bin_svc_http_err_code 206
+variable platforms {}
+global ::http::statusCodePhrases
+
+if {[dict exists $::http::statusCodePhrases $bin_svc_http_err_code]} {
+ puts "Warning: overriding ::http::statusCodePhrases($bin_svc_http_err_code)"
+}
+dict set ::http::statusCodePhrases $bin_svc_http_err_code {Atmosic Binary Service Error}
+
+::http::add-handler GET / {
+ ::http::respond [::http::make-response "Atmosic binary API server" {} $request]
+}
+
+proc ::http::make-options-response {body have_get {headers {}} {request {}}} {
+ set ::http::responseTemplate \
+ {HTTP/1.1 $headers(code) $::http::statusCodePhrases($headers(code))
+Content-Type: $headers(contentType)
+Content-Length: $length}
+
+ set ::http::headerDefaults [dict create {*}{
+ code 200
+ contentType text/html
+ }]
+
+ set headers [dict merge $::http::headerDefaults $headers]
+
+ if ($have_get) {
+ set opts [list OPTIONS GET POST]
+ } else {
+ set opts [list OPTIONS POST]
+ }
+ set opts_str [join $opts ", "]
+
+ # Handle response processing, e.g., compression.
+ foreach lambda $::http::responseFilters {
+ lassign [apply $lambda $body $headers $request] body headers
+ }
+
+ set length [string bytelength $body]
+
+ set response [subst $::http::responseTemplate]
+
+ append response \
+ "\nAccess-Control-Allow-Origin: *"
+ append response \
+ "\nAllow: $opts_str"
+
+ append response \
+ "\nAccess-Control-Allow-Methods: $opts_str"
+ append response \
+ "\nAccess-Control-Allow-Headers: X-PINGOTHER, content-type"
+ return $response
+}
+
+
+proc add-bin-svc-options {route have_get } {
+ ::http::add-handler OPTIONS $route [list apply {{have_get} {
+ upvar 1 request request
+ upvar 1 channel channel
+ ::http::respond [::http::make-options-response "" $have_get {} $request]
+ }} $have_get]
+}
+
+proc ::http::make-bin-svc-response {body {headers {}} {request {}}} {
+ set ::http::responseTemplate \
+ {HTTP/1.1 $headers(code) $::http::statusCodePhrases($headers(code))
+Content-Type: $headers(contentType)
+Content-Length: $length}
+
+ set ::http::headerDefaults [dict create {*}{
+ code 200
+ contentType text/html
+ }]
+
+ set headers [dict merge $::http::headerDefaults $headers]
+
+ # Handle response processing, e.g., compression.
+ foreach lambda $::http::responseFilters {
+ lassign [apply $lambda $body $headers $request] body headers
+ }
+
+ set length [string bytelength $body]
+
+ set response [subst $::http::responseTemplate]
+
+ # TODO: Generalize for other possible fields in the headers.
+ if {[dict exists $headers cookies]} {
+ foreach cookie $headers(cookies) {
+ append response "\nSet-Cookie: [::http::make-cookie $cookie]"
+ }
+ }
+ if {[dict exists $headers contentEncoding]} {
+ append response \
+ "\nContent-Encoding: [dict get $headers contentEncoding]"
+ }
+ append response \
+ "\nAccess-Control-Allow-Origin: *"
+
+ append response "\n\n$body"
+ return $response
+}
+
+proc ::http::make-bin-svc-err {body {request {}}} {
+ global bin_svc_http_err_code
+ return [::http::make-bin-svc-response $body [list code $bin_svc_http_err_code] $request]
+}
+
+proc handle-bin-get {oocd_cmd filename mimeType} {
+ ::http::log info "Running OpenOCD binary command $oocd_cmd $filename"
+ upvar 2 channel channel
+ upvar 2 request request
+ if { [catch {verify_rom_version} msg] } {
+ ::http::log error "Verify ROM version failed: $msg"
+ ::http::respond [::http::make-bin-svc-err "<p>$msg</p>" $request]
+ ::http::log debug "Sent ROM version mismatch error response"
+ return
+ }
+ ::http::log debug "Verify ROM succeeded"
+ if { [catch {$oocd_cmd $filename}] } {
+ ::http::respond [::http::make-bin-svc-err "<p>'$oocd_cmd' failed</p>" \
+ $request]
+ return
+ }
+ puts -nonewline $channel \
+ [::http::make-bin-svc-response \
+ [::http::read-file $filename] \
+ [list contentType $mimeType] \
+ $request]
+ file delete -- $filename
+}
+
+proc add-bin-svc-get {route oocd_cmd filename} {
+ ::http::add-handler GET $route [list apply {{oocd_cmd filename mimeType} {
+ poll on
+ handle-bin-get $oocd_cmd $filename $mimeType
+ polloff_n_reset_hard
+ }} $oocd_cmd $filename [::mime::type $filename]]
+}
+
+proc get-xargs {req_form} {
+ ::http::log debug "get-xargs"
+ if {! [dict exists $req_form xargs]} {
+ ::http::log debug "No xargs in URI"
+ return {}
+ }
+ set xargs_str [dict get $req_form xargs]
+ ::http::log debug "xargs_str: $xargs_str"
+ set xargs [lsearch -all -inline -not -exact [split $xargs_str] {}]
+ ::http::log debug "xargs: $xargs"
+ return $xargs
+}
+
+proc handle-bin-post {oocd_cmd filename mimeType} {
+ ::http::log info "Running OpenOCD SVC command $oocd_cmd $filename"
+ ::http::log debug "in [pwd]"
+ upvar 2 channel channel
+ upvar 2 request request
+ if { [catch {verify_rom_version} msg] } {
+ ::http::log error "Verify ROM version failed: $msg"
+ ::http::respond [::http::make-bin-svc-err "<p>$msg</p>" $request]
+ ::http::log debug "Sent ROM version mismatch error response"
+ return
+ }
+ ::http::log debug "Verify ROM succeeded"
+ if {$request(contentLength) != [string length $request(formPost)]} {
+ ::http::log warning "content and formPost lengths differ"
+ }
+ # First, write posted data to a file
+ set error 1
+ set fileopen 1
+ if { [catch {open $filename w} outfile] } {
+ ::http::log error "Could not open $filename for writing\n'$outfile'"
+ set fileopen 0
+ } elseif { [catch {puts -nonewline $outfile $request(formPost)}] } {
+ ::http::log error "Could not write to $filename\n$outfile"
+ } else {
+ set error 0
+ }
+ if {$fileopen} {
+ close $outfile
+ }
+ # Upon successful saving of bin/nvm, load/burn on device
+ set args [list $oocd_cmd $filename \
+ {*}[get-xargs [dict get $request form]]]
+ if {$error} {
+ set errMsg "Failed to save posted data to file"
+ } elseif { [catch {{*}$args} msg] } {
+ set errMsg "'$oocd_cmd' failed: $msg"
+ } else {
+ set errMsg ""
+ }
+ file delete -- $filename
+ if {$errMsg eq ""} {
+ ::http::log info "'$args' executed AOK"
+ set resp [::http::make-bin-svc-response "" {} $request]
+ } else {
+ ::http::log warning "Command '$args' failed"
+ ::http::log warning "Responding with error: $errMsg"
+ set resp [::http::make-bin-svc-err "<p>$errMsg</p>" $request]
+ }
+ ::http::respond $resp
+}
+
+proc add-bin-svc-post {route oocd_cmd filename} {
+ ::http::add-handler POST $route [list apply {{oocd_cmd filename mimeType} {
+ poll on
+ handle-bin-post $oocd_cmd $filename $mimeType
+ polloff_n_reset_hard
+ }} $oocd_cmd $filename [::mime::type $filename]]
+}
+
+proc add-service {route oocd_cmd_get oocd_cmd_post filename {have_get 1} } {
+ if ($have_get) {
+ add-bin-svc-get $route $oocd_cmd_get $filename
+ }
+ add-bin-svc-post $route $oocd_cmd_post $filename
+ add-bin-svc-options $route $have_get
+}
+
+# Filter out all args of the atm_isp burn subcommand except -e, -v,
+# -c, or their combinations
+proc filter_isp_burn_args { isp_burn_args args } {
+ return [lsearch -all -inline {*}$args -regexp $isp_burn_args {^\-[evc]+$}]
+}
+
+# Makes a system call to atm_isp with "burn -i <archive> -t
+# atm_ispX.tcl -d atm_isp_X <args...>" as arguments. <args...> is
+# filtered first.
+#
+# This function manages the files generated by atm_isp. If an atm_isp
+# error occurs in debug mode (::http::verbosity >= 3), the files used
+# as arguments to -t/-d won't be cleaned up.
+proc sydney_burn_archive { archive args } {
+ ::http::log debug "sydney_burn_archive archive=$archive args=$args"
+ global atm_isp
+ set atm_isp_xargs [filter_isp_burn_args $args]
+ set atm_isp_xargs_ignored [filter_isp_burn_args $args -not]
+ if {$atm_isp_xargs_ignored ne ""} {
+ ::http::log warning "Ignored archive xargs $atm_isp_xargs_ignored"
+ }
+ set atm_isp_tcl_script "atm_isp_[pid].tcl"
+ set atm_isp_tmp_dir "atm_isp_[pid]"
+ set argv [list $atm_isp burn -i $archive]
+ lappend argv -t $atm_isp_tcl_script
+ lappend argv -d $atm_isp_tmp_dir
+ lappend argv {*}$atm_isp_xargs
+ set errMsg {}
+ ::http::log debug "sydney_burn_archive: executing '$argv'"
+ if { [catch { file mkdir $atm_isp_tmp_dir } ] } {
+ set errMsg "Failed to make temp directory '$atm_isp_tmp_dir'"
+ } elseif { [catch { exec >@stdout 2>@stderr {*}$argv } msg] } {
+ set errMsg "Command '$argv' failed: $msg"
+ } elseif { [catch {source $atm_isp_tcl_script} msg] } {
+ set errMsg "Sourcing '$atm_isp_tcl_script' failed: $msg"
+ }
+ if { $errMsg ne {} && $::http::verbosity >= 3 } { # 3 is "debug"
+ ::http::log debug "Kept atm_isp_tcl_script=$atm_isp_tcl_script and atm_isp_tmp_dir=$atm_isp_tmp_dir"
+ } else {
+ file delete -- $atm_isp_tcl_script
+ file delete -force -- $atm_isp_tmp_dir
+ ::http::log debug "Deleted atm_isp_tcl_script=$atm_isp_tcl_script and atm_isp_tmp_dir=$atm_isp_tmp_dir"
+ }
+ if { $errMsg eq {} } {
+ ::http::log debug "Successfully executed '$argv' and sourced the generated script"
+ } else {
+ error $errMsg
+ }
+}
+
+add-service /verify_flash {} sydney_verify_flash image 0
+add-service /elf sydney_dump_flash sydney_load_flash image
+add-service /nvds/flash sydney_dump_nvds sydney_load_nvds flash_nvds_[pid].bin
+add-service /nvds/otp sydney_dump_nvm sydney_burn_nvm otp_nvds_[pid].nvm
+add-service /isp/burn {} sydney_burn_archive arch.atm 0
+
+# Takes individual tag data files and makes a system call to
+# "nvds_tool" with -b and the appropriate -e/-l -t&-d pairs.
+#
+# There are two methods to determine the arguments passed to nvds_tool:
+#
+# M-1) Get all arguments verbatim (modulo -hbvpSo:O:) from the URI as in:
+#
+# /nvds/tool/b?-i%20-e%20b6%20-t%2001%20-d%20foo.bin
+#
+# to execute "nvds_tool -b -i -e b6 -t 01 -d foo.bin"
+#
+# M-2) If no erasing or locking of a tag (nvds_tool -e or -l) is
+# needed, and there's no specific or non-lexicographic order in
+# which the tag data should be passed to nvds_tool, then the tags
+# can just come in as the "filename" metadata accomponied with the
+# uploaded tag data files. The URL can encode "?isotp=" for -i,
+# "?rebuild=<filename>" for -r <filename>, and "?sort_tags=" to
+# sort the <tag>s in the "-t <tag> -d <data>" pairs.
+#
+# Todo-1: allow option for tag data to come in as just binary blobs, not
+# necessarily as files.
+
+::http::add-handler OPTIONS /nvds/tool/b {
+ set resp [::http::make-options-response "" $have_get {} $request]
+
+ ::http::respond $resp
+}
+
+::http::add-handler POST /nvds/tool/b {
+ global nvds_tool
+ set err_msg {}
+ set tmp_files {}
+ set posted_files {}
+ set existing_nvds_filename {}
+ set out nvds
+ set argv [list $nvds_tool -b -o $out]
+ if {![dict exists $request files]} {
+ set err_msg "No files posted to /nvds/tool/b"
+ } elseif {3 <= $::http::verbosity} {
+ ::http::log debug "begin url form data"
+ dict for {key info} [dict get $request form] {
+ ::http::log debug "$key=[dict get $request form $key]"
+ }
+ ::http::log debug "end url form data"
+ }
+ # Create temporary files
+ set existing_nvds_fname_client {}
+ dict for {fname_client info} [dict get $request files] {
+ if {$err_msg ne ""} {
+ break
+ }
+ if {[dict exists $request files $fname_client filename]} {
+ set filename [dict get $request files $fname_client filename]
+ } else {
+ set filename [file tail $fname_client]
+ }
+ ::http::log debug "Received $fname_client as $filename"
+ if {$existing_nvds_filename eq $filename} {
+ set existing_nvds_fname_client $fname_client
+ }
+ set content [dict get $request files $fname_client content]
+ set fileopen 1
+ if { [catch {open $filename w} outfile] } {
+ set err_msg "Could not open $filename for writing\n'$outfile'"
+ set fileopen 0
+ } elseif { [catch {puts -nonewline $outfile $content}] } {
+ set err_msg "Could not write to $filename\n$outfile"
+ } else {
+ ::http::log debug "Saved [string length $content] bytes in $filename"
+ lappend tmp_files $filename
+ }
+ if {$fileopen} {
+ close $outfile
+ }
+ }
+ if {$err_msg eq ""} {
+ if {[dict exists $request form nvds_tool_args]} {
+ ::http::log debug "METHOD 1 -- verbatim nvds_tool_args"
+ # Method M-1
+ #
+ # Note: every nvds_tool opt, including those that don't
+ # take arguments, should have come in prefixed with a "-"
+ # and separated from its argument or the next option with
+ # a "%20". For example, "-ie01" to erase tag 01 from OTP
+ # is not acceptable, even though nvds_tool itself
+ # correctly recognizes these options because it uses
+ # getopts, which we don't have in tcl.
+ set xargs_str [dict get $request form nvds_tool_args]
+ ::http::log debug "xargs_str: $xargs_str"
+ set xargs [lsearch -all -inline -not -exact [split $xargs_str] {}]
+ ::http::log debug "xargs: $xargs"
+ proc filter_xargs { opt {has_arg 0} } {
+ ::http::log debug "opt=$opt,has_arg=$has_arg"
+ upvar 1 xargs xargs
+ set idx [lsearch $xargs $opt]
+ if {$idx != -1} {
+ set last $idx
+ if {$has_arg} {
+ incr last
+ }
+ ::http::log warning "ignoring '[lrange $xargs $idx $last]' in nvds_tool_args"
+ set xargs [lreplace $xargs $idx $last]
+ }
+ }
+ ::http::log debug "filter out opts with no args"
+ foreach opt {-h -b -v -p -S} {
+ filter_xargs $opt
+ }
+ ::http::log debug "filter out opts with args"
+ foreach opt {-o -O} {
+ filter_xargs $opt 1
+ }
+ lappend argv {*}$xargs
+ } else {
+ # Method M-2
+ ::http::log debug "METHOD 2 -- ?rebuild=<fname>&isotp=&sort_tags="
+ if {[dict exists $request form rebuild]} {
+ set existing_nvds_filename [dict get $request form rebuild]
+ }
+ if {[dict exists $request form isotp]} {
+ lappend argv -i
+ }
+ if {$existing_nvds_filename ne ""} {
+ lappend argv -r $existing_nvds_filename
+ }
+ set tags $tmp_files
+ if {$existing_nvds_filename ne ""} {
+ if {$existing_nvds_fname_client eq ""} {
+ set err_msg "$existing_nvds_filename to rebuild not uploaded"
+ } else {
+ set idx [lsearch -exact $tags $existing_nvds_filename]
+ if {$idx == -1} {
+ set err_msg "Could not find $existing_nvds_filename in temporary files list"
+ } else {
+ set tags [lreplace $tags $idx $idx]
+ }
+ }
+ }
+ set do_sort 0
+ if { [dict exists $request form sort_tags] } {
+ set do_sort 1
+ } elseif { [info exists ::env(HTTP_NVDS_SORT_TAGS)] } {
+ set do_sort $::env(HTTP_NVDS_SORT_TAGS)
+ }
+ if {$do_sort} {
+ set tags [lsort -ascii $tags]
+ }
+ foreach tag $tags {
+ lappend argv -t $tag -d $tag
+ }
+ }
+ ::http::log debug "argv: $argv"
+ if { [catch { exec >@stdout 2>@stderr {*}$argv } msg] } {
+ set err_msg "Failed to execute $nvds_tool: $msg"
+ } else {
+ ::http::log debug "responding with produced NVDS [file size $out]"
+ puts -nonewline $channel \
+ [::http::make-bin-svc-response \
+ [::http::read-file $out] \
+ [list contentType [::mime::type $out]] \
+ $request]
+ file delete -- $out
+ }
+ }
+ # Delete temporary files
+ foreach filename $tmp_files {
+ file delete -- $filename
+ }
+ if {$err_msg eq ""} {
+ set succ_msg "'$argv' succeeded"
+ ::http::log info $succ_msg
+ set resp [::http::make-response "<p><$succ_msg</p>" {} $request]
+ } else {
+ ::http::log error "$err_msg"
+ set resp [::http::make-bin-svc-err "<p>$err_msg</p>" $request]
+ }
+ ::http::respond $resp
+}
+
+::http::add-handler OPTIONS /nvds/tool/s {
+ set resp [::http::make-options-response "" $have_get {} $request]
+
+ ::http::respond $resp
+}
+
+# Takes an NVDS file and returns a list of address-tag-length
+# triplets. This information is sufficient for the client to extract
+# the individual tag data. For example,
+# "7,1,6;16,6,39;58,11,28;89,12,24;116,5,3;122,9,4;129,17,1;133,18,1"
+# corresponds to an NVDS file that pretty-prints as follows.
+#
+# @0007 01 c9 00 00 6b 69 7c
+# @0010 06 00 00 00 00 01 02 00 00 00 00 00 00 00 00 00 00 00 00 00 40 06 00 00 40 06 00 00 07 01 00 00 00 00 00 00 00 00 00 00
+# @003a 0b 03 03 aa fe 0e 16 aa fe 10 00 01 61 74 6d 6f 73 69 63 07 08 08 41 30 30 30 30 63 39
+# @0059 0c 17 09 41 54 4d 30 32 30 31 20 45 33 61 20 42 43 4e 20 30 30 30 30 63 39
+# @0074 05 00 00 1e
+# @007a 09 b8 0b 00 00
+# @0081 11 04
+# @0085 12 02
+#
+::http::add-handler POST /nvds/tool/s {
+ ::http::log debug "/nvds/tool/s"
+ set NVDS \x4e\x56\x44\x53
+ set NVDS_inv \xb1\xa9\xbb\xac
+ set errMsg {}
+ set reqLen [string length $request(formPost)]
+ ::http::log debug "reqLen=$reqLen"
+ if {$reqLen < 4} {
+ set errMsg "binary data length too short: $reqLen"
+ } else {
+ set magic_bytes [string range $request(formPost) 0 3]
+ if {[string equal $magic_bytes $NVDS]} {
+ set isOTP 0
+ } elseif {[string equal $magic_bytes $NVDS_inv]} {
+ set isOTP 1
+ } elseif {[string equal $magic_bytes \x00\x00\x00\x00]} {
+ set errMsg "NVDS is blank"
+ } else {
+ set errMsg "unknown bytes"
+ }
+ }
+ if {$errMsg ne ""} {
+ ::http::log error "Magic bytes check failed: $errMsg"
+ ::http::respond [::http::make-bin-svc-err "<p>Magic bytes check of NVDS failed: $errMsg</p>" $request]
+ return
+ }
+
+ ::http::log debug "isOTP=$isOTP"
+
+ global nvds_tool
+ # First, write posted data to a file
+ set filename nvds
+ set error 1
+ set fileopen 1
+ if { [catch {open $filename w} outfile] } {
+ ::http::log error "Could not open $filename for writing\n'$outfile'"
+ set fileopen 0
+ } elseif { [catch {puts -nonewline $outfile $request(formPost)}] } {
+ ::http::log error "Could not write to $filename\n$outfile"
+ } else {
+ set error 0
+ }
+ if {$fileopen} {
+ close $outfile
+ }
+ # Upon successful saving of bin/nvm, get the split instructions
+ # (addr-tag-len triplets) to send back to the client
+ set splitdir split_nvds
+ set argv [list $nvds_tool]
+ if {[dict exists $request form isotp] || $isOTP} {
+ lappend argv -i
+ }
+ lappend argv -vr $filename
+ if {$error} {
+ set errMsg "Failed to save posted data to file"
+ } elseif { [catch { file mkdir $splitdir } msg] } {
+ set errMsg $msg
+ } elseif { [catch { exec {*}$argv } nvds_tool_output] } {
+ set errMsg "'$argv' failed: $nvds_tool_output"
+ } else {
+ set errMsg ""
+ }
+ file delete -- $filename $splitdir
+ if {$errMsg eq ""} {
+ ::http::log info "split AOK with '$argv'"
+ set addr_tag_len_list {}
+ foreach tag_data_line [split $nvds_tool_output "\n"] {
+ set tokens [split $tag_data_line]
+ set addr [expr 0x[string trimleft [lindex $tokens 0] @]]
+ set tag [expr 0x[lindex $tokens 1]]
+ set len [expr [llength [lsearch -all -inline -not -exact $tokens {}]] - 2]
+ set addr_tag_len [join [list $addr $tag $len] ","]
+ ::http::log info "addr_tag_len=$addr_tag_len"
+ lappend addr_tag_len_list $addr_tag_len
+ }
+ set resp_text [join $addr_tag_len_list ";"]
+ ::http::log info "resp_text=$resp_text"
+ set resp [::http::make-bin-svc-response $resp_text {} $request]
+ } else {
+ ::http::log warning "Responding with error: $errMsg"
+ set resp [::http::make-bin-svc-err "<p>$errMsg</p>" $request]
+ }
+ ::http::respond $resp
+}
+
+::http::add-handler OPTIONS /nvds/otp/rmw {
+ ::http::respond [::http::make-options-response {} 0 {} $request]
+}
+
+::http::add-handler POST /nvds/otp/rmw {
+ ::http::log debug "/nvds/otp/rmw"
+ set NVDS \x4e\x56\x44\x53
+ set NVDS_inv \xb1\xa9\xbb\xac
+ set errMsg {}
+ set reqLen [string length $request(formPost)]
+ ::http::log debug "reqLen=$reqLen"
+ if {$reqLen < 4} {
+ set errMsg "binary data length too short: $reqLen"
+ } else {
+ set magic_bytes [string range $request(formPost) 0 3]
+ if {[string equal $magic_bytes $NVDS]} {
+ set errMsg "format is for flash, not OTP"
+ } elseif {[string equal $magic_bytes $NVDS_inv]} {
+ set isOTP 1
+ } elseif {[string equal $magic_bytes \x00\x00\x00\x00]} {
+ set errMsg "NVDS is blank"
+ } else {
+ set errMsg "unknown bytes"
+ }
+ }
+ if {$errMsg ne ""} {
+ ::http::log error "Magic bytes check failed: $errMsg"
+ ::http::respond [::http::make-bin-svc-err "<p>Magic bytes check of NVDS failed: $errMsg</p>" $request]
+ return
+ }
+
+ global nvds_tool
+ # First, write posted data to a file
+ set filename nvds_[pid].nvm
+ set error 1
+ set fileopen 1
+ if { [catch {open $filename w} outfile] } {
+ ::http::log error "Could not open $filename for writing\n'$outfile'"
+ set fileopen 0
+ } elseif { [catch {puts -nonewline $outfile $request(formPost)}] } {
+ ::http::log error "Could not write to $filename\n$outfile"
+ } else {
+ set error 0
+ }
+ if {$fileopen} {
+ close $outfile
+ }
+ if {$error} {
+ set errMsg "Failed to save posted data to file"
+ ::http::log warning "Responding with error: $errMsg"
+ ::http::respond [::http::make-bin-svc-err "<p>$errMsg</p>" $request]
+ return
+ }
+ if {$request(contentLength) != [string length $request(formPost)]} {
+ ::http::log warning "content and formPost lengths differ"
+ }
+ set dev_otp_old dev_otp_old_[pid].nvm
+ set dev_otp_new dev_otp_new_[pid].nvm
+ set argv [list $nvds_tool -i -r $dev_otp_old -r $filename -b -o $dev_otp_new]
+ poll on
+ if { [catch { verify_rom_version } msg] } {
+ set errMsg "Verify ROM version failed: $msg"
+ } elseif { [catch { sydney_dump_nvm $dev_otp_old } msg ] } {
+ set errMsg "Dump OTP failed: $msg"
+ } elseif { [catch { exec {*}$argv } msg] } {
+ set errMsg "Merging OTP with '$argv' failed: $msg"
+ } elseif { [catch { sydney_burn_nvm $dev_otp_new } msg ] } {
+ set errMsg "Burn OTP failed: $msg"
+ } else {
+ set errMsg ""
+ }
+ polloff_n_reset_hard
+ file delete -- $dev_otp_old $filename
+ file delete -force -- $dev_otp_new
+ if {$errMsg eq ""} {
+ ::http::log info "Read-modify-write of OTP went AOK"
+ set resp [::http::make-bin-svc-response {} {} $request]
+ } else {
+ ::http::log warning "Responding with error: $errMsg"
+ set resp [::http::make-bin-svc-err "<p>$errMsg</p>" $request]
+ }
+ ::http::respond $resp
+}
+
+proc set_platforms {} {
+ global platforms
+ if {$platforms ne ""} {
+ return ""
+ }
+ set errMsg {}
+ poll on
+ if { [ catch {get_rom_version} rom_ver ] } {
+ set errMsg "get_rom_ver err: $rom_ver"
+ }
+ polloff_n_reset_hard
+ if {$errMsg ne {}} {
+ error $errMsg
+ }
+ set platforms $rom_ver
+}
+
+if {[info exists ::env(HTTP_APP)] && $::env(HTTP_APP)} {
+ source [find app.tcl]
+}
+
+::http::add-handler GET /nvds/platforms {
+ # Thought: eagerly, rather than lazily, call set_platforms before starting
+ # the HTTP server. Do that once and read the result from that point on out.
+ if { [ catch {set_platforms} errMsg ] } {
+ ::http::log info "Error: $errMsg"
+ set resp [::http::make-bin-svc-err "<p>$errMsg</p>" $request]
+ } else {
+ global platforms
+ ::http::log info "Platforms: $platforms"
+ set resp [::http::make-bin-svc-response [join $platforms ","] {} $request]
+ }
+ ::http::respond $resp
+}
+
+# Start the HTTP server binding it to $ipAddress and $port. Similar
+# to ::http::start-server, but it has no wait.
+proc start-server-no-wait {ipAddress port} {
+ set ::http::serverSocket [socket stream.server $ipAddress:$port]
+ $::http::serverSocket readable {
+ set client [$::http::serverSocket accept addr]
+ ::http::serve-and-trap-errors $client {*}[split $addr :]
+ }
+}
+
+proc start-bin-server {args_dict} {
+ global ::http::crashOnError
+ global ::http::verbosity
+ global nvds_tool
+ global atm_isp
+ dict with args_dict {
+ set nvds_tool $nvds_tool
+ set atm_isp $atm_isp
+ set ::http::verbosity $verbosity
+ start-server-no-wait $ip $port
+ puts "Info : Listening on port $port for binary http requests"
+ }
+}
diff --git a/platform/atm2/ATM22xx-x1x/openocd/http/openocd_http.tcl b/platform/atm2/ATM22xx-x1x/openocd/http/openocd_http.tcl
new file mode 100644
index 0000000..5d25663
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/http/openocd_http.tcl
@@ -0,0 +1,35 @@
+# Routine for sourcing Jim Tcl scripts. Jim Tcl doesn't have a find
+# function. Therefore, Jim Tcl scripts don't use the idiom "source
+# [find X.tcl]" commonly used in OpenOCD scripts.
+proc source_jimtcl_script {jimtcl_script} {
+ set saved_pwd [pwd]
+ cd [file dirname [find $jimtcl_script]]
+ source $jimtcl_script
+ cd $saved_pwd
+}
+
+proc openocd_http_dir {} {
+ if {[info exists ::env(OPENOCD_HTTP_DIR)]} {
+ return $::env(OPENOCD_HTTP_DIR)
+ }
+ return [file dirname [file normalize [info script]]]
+}
+
+set argv {}
+set argv0 openocd_bin_http
+if {[info exists ::env(HTTP_BIN_PORT)]} {
+ lappend argv -p $::env(HTTP_BIN_PORT)
+}
+if {[info exists ::env(HTTP_BIN_IP)]} {
+ lappend argv -i $::env(HTTP_BIN_IP)
+}
+if {[info exists ::env(HTTP_BIN_VERBOSITY)]} {
+ lappend argv -v $::env(HTTP_BIN_VERBOSITY)
+}
+if {[info exists ::env(HTTP_NVDS_TOOL)]} {
+ lappend argv -n $::env(HTTP_NVDS_TOOL)
+}
+if {[info exists ::env(HTTP_ATM_ISP)]} {
+ lappend argv -s $::env(HTTP_ATM_ISP)
+}
+source_jimtcl_script [file join [openocd_http_dir] run_bin_svc_server.tcl]
diff --git a/platform/atm2/ATM22xx-x1x/openocd/http/run_bin_svc_server.tcl b/platform/atm2/ATM22xx-x1x/openocd/http/run_bin_svc_server.tcl
new file mode 100644
index 0000000..a4bb926
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/http/run_bin_svc_server.tcl
@@ -0,0 +1,24 @@
+source bin_svc_server.tcl
+source_jimhttp arguments.tcl
+
+proc main {} {
+ global argv
+ global argv0
+
+ stdout buffering line
+
+ set optionalArgs [list -p port 8080 -i ip 0.0.0.0 -v verbosity 2 -n nvds_tool nvds_tool -s atm_isp atm_isp]
+ set error [catch {
+ set args [::arguments::parse {} $optionalArgs $argv]
+ } errorMessage]
+ if {$error} {
+ puts "Error: $errorMessage"
+ puts [::arguments::usage {} $optionalArgs $argv0]
+ exit 1
+ }
+ if { [catch {start-bin-server $args} errMsg ] } {
+ puts "Error: could not start http server - $errMsg"
+ }
+}
+
+main
diff --git a/platform/atm2/ATM22xx-x1x/openocd/http/source_jimhttp.tcl b/platform/atm2/ATM22xx-x1x/openocd/http/source_jimhttp.tcl
new file mode 100644
index 0000000..8c11395
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/http/source_jimhttp.tcl
@@ -0,0 +1,8 @@
+proc source_jimhttp {scripts} {
+ set save [pwd]
+ cd [find jimhttp]
+ foreach script $scripts {
+ source $script
+ }
+ cd $save
+}
diff --git a/platform/atm2/ATM22xx-x1x/openocd/m0_cpu.tcl b/platform/atm2/ATM22xx-x1x/openocd/m0_cpu.tcl
new file mode 100644
index 0000000..4550b7e
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/m0_cpu.tcl
@@ -0,0 +1,52 @@
+source [find target/swj-dp.tcl]
+
+set _CHIPNAME Sydney
+set _ENDIAN little
+# JTAG IDCODE register
+set _CPUTAPID 0x0BA01477
+
+swj_newdap $_CHIPNAME cpu -expected-id $_CPUTAPID -irlen 4
+
+set _TARGETNAME $_CHIPNAME.cpu
+dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu
+target create $_TARGETNAME cortex_m -dap $_CHIPNAME.dap
+$_TARGETNAME configure -work-area-backup 1 -work-area-phys 0x20010000 -work-area-size 128
+
+set _RESET_HARD_ON_EXIT 0
+set _RESET_HARD_TIME 2000
+if {[info exists ::env(FTDI_RESET_HARD_TIME)]} {
+ set _RESET_HARD_TIME $::env(FTDI_RESET_HARD_TIME)
+ puts "_RESET_HARD_TIME set to $_RESET_HARD_TIME"
+}
+rename exit orig_exit
+proc exit {} {
+ poll off
+ # Deassert syspwrupreq and dbgpwrupreq
+ $::_CHIPNAME.dap dpreg 4 0x00000041
+ if {$::_RESET_HARD_ON_EXIT} {
+ set_reset
+ sleep $::_RESET_HARD_TIME
+ release_reset
+ }
+ orig_exit
+}
+
+reset_config none
+cortex_m reset_config sysresetreq
+
+proc reset_hard [list [list reset_time $_RESET_HARD_TIME] ] {
+ poll off
+ set_reset
+ sleep $reset_time
+ release_reset
+ sleep 100
+ poll on
+}
+
+proc polloff_n_reset_hard {} {
+ poll off
+ $::_CHIPNAME.dap dpreg 4 0x00000041
+ set_reset
+ sleep $::_RESET_HARD_TIME
+ release_reset
+}
diff --git a/platform/atm2/ATM22xx-x1x/openocd/regs/nvm.tcl b/platform/atm2/ATM22xx-x1x/openocd/regs/nvm.tcl
new file mode 100644
index 0000000..b83566e
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/regs/nvm.tcl
@@ -0,0 +1,80 @@
+set CMSDK_NVM_BASE 0x50002000
+set CMSDK_NVM_OPMODE [expr $CMSDK_NVM_BASE + 0x0]
+set CMSDK_NVM_OPMODE_READ__RESET_VALUE 0x00000000
+set CMSDK_NVM_OPMODE_PROGRAM__RESET_VALUE 0x00000000
+set CMSDK_NVM_OPMODE_WORD_SIZE__RESET_VALUE 0x00000000
+set CMSDK_NVM_OPMODE_AUTO_INC__RESET_VALUE 0x00000000
+set CMSDK_NVM_OPMODE_GO__RESET_VALUE 0x00000000
+set CMSDK_NVM_OPMODE__RESET_VALUE 0x00000000
+set CMSDK_NVM_ADDRESS [expr $CMSDK_NVM_BASE + 0x4]
+set CMSDK_NVM_ADDRESS_ADDRESS__RESET_VALUE 0x00000000
+set CMSDK_NVM_ADDRESS__RESET_VALUE 0x00000000
+set CMSDK_NVM_STATUS [expr $CMSDK_NVM_BASE + 0x8]
+set CMSDK_NVM_STATUS_RUNNING__RESET_VALUE 0x00000000
+set CMSDK_NVM_STATUS__RESET_VALUE 0x00000000
+set CMSDK_NVM_READ_DATA [expr $CMSDK_NVM_BASE + 0xc]
+set CMSDK_NVM_READ_DATA_READ_DATA__RESET_VALUE 0x00000000
+set CMSDK_NVM_READ_DATA__RESET_VALUE 0x00000000
+set CMSDK_NVM_T_SP_PG_AVDD [expr $CMSDK_NVM_BASE + 0x10]
+set CMSDK_NVM_T_SP_PG_AVDD_CYCLES__RESET_VALUE 0x0000000f
+set CMSDK_NVM_T_SP_PG_AVDD__RESET_VALUE 0x0000000f
+set CMSDK_NVM_T_SP_PGM [expr $CMSDK_NVM_BASE + 0x14]
+set CMSDK_NVM_T_SP_PGM_CYCLES__RESET_VALUE 0x00000000
+set CMSDK_NVM_T_SP_PGM__RESET_VALUE 0x00000000
+set CMSDK_NVM_T_PGM [expr $CMSDK_NVM_BASE + 0x18]
+set CMSDK_NVM_T_PGM_CYCLES__RESET_VALUE 0x0000008f
+set CMSDK_NVM_T_PGM__RESET_VALUE 0x0000008f
+set CMSDK_NVM_T_HP_PGM [expr $CMSDK_NVM_BASE + 0x1c]
+set CMSDK_NVM_T_HP_PGM_CYCLES__RESET_VALUE 0x00000000
+set CMSDK_NVM_T_HP_PGM__RESET_VALUE 0x00000000
+set CMSDK_NVM_T_HP_PG_AVDD [expr $CMSDK_NVM_BASE + 0x20]
+set CMSDK_NVM_T_HP_PG_AVDD_CYCLES__RESET_VALUE 0x0000000f
+set CMSDK_NVM_T_HP_PG_AVDD__RESET_VALUE 0x0000000f
+set CMSDK_NVM_T_SR_RD [expr $CMSDK_NVM_BASE + 0x24]
+set CMSDK_NVM_T_SR_RD_CYCLES__RESET_VALUE 0x00000001
+set CMSDK_NVM_T_SR_RD__RESET_VALUE 0x00000001
+set CMSDK_NVM_T_RD [expr $CMSDK_NVM_BASE + 0x28]
+set CMSDK_NVM_T_RD_CYCLES__RESET_VALUE 0x00000000
+set CMSDK_NVM_T_RD__RESET_VALUE 0x00000000
+set CMSDK_NVM_T_HR_RD [expr $CMSDK_NVM_BASE + 0x2c]
+set CMSDK_NVM_T_HR_RD_CYCLES__RESET_VALUE 0x00000001
+set CMSDK_NVM_T_HR_RD__RESET_VALUE 0x00000001
+set CMSDK_NVM_T_SETUP [expr $CMSDK_NVM_BASE + 0x30]
+set CMSDK_NVM_T_SETUP_CYCLES__RESET_VALUE 0x00000000
+set CMSDK_NVM_T_SETUP__RESET_VALUE 0x00000000
+set CMSDK_NVM_T_HOLD [expr $CMSDK_NVM_BASE + 0x34]
+set CMSDK_NVM_T_HOLD_CYCLES__RESET_VALUE 0x00000000
+set CMSDK_NVM_T_HOLD__RESET_VALUE 0x00000000
+set CMSDK_NVM_T_ADDR [expr $CMSDK_NVM_BASE + 0x38]
+set CMSDK_NVM_T_ADDR_CYCLES__RESET_VALUE 0x00000000
+set CMSDK_NVM_T_ADDR__RESET_VALUE 0x00000000
+set CMSDK_NVM_INTERRUPT_MASK [expr $CMSDK_NVM_BASE + 0x3c]
+set CMSDK_NVM_INTERRUPT_MASK_PASSTHRU0__RESET_VALUE 0x00000000
+set CMSDK_NVM_INTERRUPT_MASK__RESET_VALUE 0x00000000
+set CMSDK_NVM_INTERRUPT_STATUS [expr $CMSDK_NVM_BASE + 0x40]
+set CMSDK_NVM_INTERRUPT_STATUS_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_NVM_INTERRUPT_STATUS__RESET_VALUE 0x00000000
+set CMSDK_NVM_SET_INTERRUPT [expr $CMSDK_NVM_BASE + 0x44]
+set CMSDK_NVM_SET_INTERRUPT_SET_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_NVM_SET_INTERRUPT__RESET_VALUE 0x00000000
+set CMSDK_NVM_RESET_INTERRUPT [expr $CMSDK_NVM_BASE + 0x48]
+set CMSDK_NVM_RESET_INTERRUPT_RESET_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_NVM_RESET_INTERRUPT__RESET_VALUE 0x00000000
+set CMSDK_NVM_EFUSE_AUTOREAD [expr $CMSDK_NVM_BASE + 0x4c]
+set CMSDK_NVM_EFUSE_AUTOREAD_SWD_DISABLE__RESET_VALUE 0x00000000
+set CMSDK_NVM_EFUSE_AUTOREAD_SYSRAM_SVT_EN_HW__RESET_VALUE 0x00000000
+set CMSDK_NVM_EFUSE_AUTOREAD_SYSRAM_HVT_EN_HW__RESET_VALUE 0x00000000
+set CMSDK_NVM_EFUSE_AUTOREAD_PKG_6X6__RESET_VALUE 0x00000000
+set CMSDK_NVM_EFUSE_AUTOREAD_RESERVED1__RESET_VALUE 0x00000000
+set CMSDK_NVM_EFUSE_AUTOREAD_OTP_HARV_ALLOWED__RESET_VALUE 0x00000000
+set CMSDK_NVM_EFUSE_AUTOREAD_OTP_BROWNOUT_THR__RESET_VALUE 0x00000000
+set CMSDK_NVM_EFUSE_AUTOREAD_OTP_ENDOFLIFE_THR__RESET_VALUE 0x00000000
+set CMSDK_NVM_EFUSE_AUTOREAD_OTP_NABG_TRIM__RESET_VALUE 0x00000000
+set CMSDK_NVM_EFUSE_AUTOREAD_OTP_GEN_VDDIO__RESET_VALUE 0x00000000
+set CMSDK_NVM_EFUSE_AUTOREAD_OTP_HARV_TYPE__RESET_VALUE 0x00000000
+set CMSDK_NVM_EFUSE_AUTOREAD_OTP_BATT_TYPE__RESET_VALUE 0x00000000
+set CMSDK_NVM_EFUSE_AUTOREAD_RESERVED2__RESET_VALUE 0x00000000
+set CMSDK_NVM_EFUSE_AUTOREAD__RESET_VALUE 0x00000000
+set CMSDK_NVM_ID [expr $CMSDK_NVM_BASE + 0xffc]
+set CMSDK_NVM_ID_ID__RESET_VALUE 0x4e564d20
+set CMSDK_NVM_ID__RESET_VALUE 0x4e564d20
diff --git a/platform/atm2/ATM22xx-x1x/openocd/regs/pmu.tcl b/platform/atm2/ATM22xx-x1x/openocd/regs/pmu.tcl
new file mode 100644
index 0000000..4ec6d4f
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/regs/pmu.tcl
@@ -0,0 +1,43 @@
+set CMSDK_PMU_BASE 0x50007000
+set CMSDK_PMU_TRANSACTION_SETUP [expr $CMSDK_PMU_BASE + 0x0]
+set CMSDK_PMU_TRANSACTION_SETUP_START__RESET_VALUE 0x00000000
+set CMSDK_PMU_TRANSACTION_SETUP_NUM_DATA_BYTES__RESET_VALUE 0x00000000
+set CMSDK_PMU_TRANSACTION_SETUP_RWB__RESET_VALUE 0x00000000
+set CMSDK_PMU_TRANSACTION_SETUP_CLKDIV__RESET_VALUE 0x00000000
+set CMSDK_PMU_TRANSACTION_SETUP_OPCODE__RESET_VALUE 0x00000000
+set CMSDK_PMU_TRANSACTION_SETUP_LOOPBACK__RESET_VALUE 0x00000000
+set CMSDK_PMU_TRANSACTION_SETUP_CSN_STAYS_LOW__RESET_VALUE 0x00000000
+set CMSDK_PMU_TRANSACTION_SETUP_DUMMY_CYCLES__RESET_VALUE 0x00000000
+set CMSDK_PMU_TRANSACTION_SETUP__RESET_VALUE 0x00000000
+set CMSDK_PMU_TRANSACTION_STATUS [expr $CMSDK_PMU_BASE + 0x4]
+set CMSDK_PMU_TRANSACTION_STATUS_DONE__RESET_VALUE 0x00000000
+set CMSDK_PMU_TRANSACTION_STATUS_RUNNING__RESET_VALUE 0x00000000
+set CMSDK_PMU_TRANSACTION_STATUS_OPCODE_STATUS__RESET_VALUE 0x00000000
+set CMSDK_PMU_TRANSACTION_STATUS__RESET_VALUE 0x00000000
+set CMSDK_PMU_DATA_BYTES_LOWER [expr $CMSDK_PMU_BASE + 0x8]
+set CMSDK_PMU_DATA_BYTES_LOWER_BYTE0__RESET_VALUE 0x00000000
+set CMSDK_PMU_DATA_BYTES_LOWER_BYTE1__RESET_VALUE 0x00000000
+set CMSDK_PMU_DATA_BYTES_LOWER_BYTE2__RESET_VALUE 0x00000000
+set CMSDK_PMU_DATA_BYTES_LOWER_BYTE3__RESET_VALUE 0x00000000
+set CMSDK_PMU_DATA_BYTES_LOWER__RESET_VALUE 0x00000000
+set CMSDK_PMU_DATA_BYTES_UPPER [expr $CMSDK_PMU_BASE + 0xc]
+set CMSDK_PMU_DATA_BYTES_UPPER_BYTE4__RESET_VALUE 0x00000000
+set CMSDK_PMU_DATA_BYTES_UPPER_BYTE5__RESET_VALUE 0x00000000
+set CMSDK_PMU_DATA_BYTES_UPPER_BYTE6__RESET_VALUE 0x00000000
+set CMSDK_PMU_DATA_BYTES_UPPER_BYTE7__RESET_VALUE 0x00000000
+set CMSDK_PMU_DATA_BYTES_UPPER__RESET_VALUE 0x00000000
+set CMSDK_PMU_INTERRUPT_MASK [expr $CMSDK_PMU_BASE + 0x10]
+set CMSDK_PMU_INTERRUPT_MASK_PASSTHRU0__RESET_VALUE 0x00000000
+set CMSDK_PMU_INTERRUPT_MASK__RESET_VALUE 0x00000000
+set CMSDK_PMU_INTERRUPT_STATUS [expr $CMSDK_PMU_BASE + 0x14]
+set CMSDK_PMU_INTERRUPT_STATUS_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_PMU_INTERRUPT_STATUS__RESET_VALUE 0x00000000
+set CMSDK_PMU_SET_INTERRUPT [expr $CMSDK_PMU_BASE + 0x18]
+set CMSDK_PMU_SET_INTERRUPT_SET_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_PMU_SET_INTERRUPT__RESET_VALUE 0x00000000
+set CMSDK_PMU_RESET_INTERRUPT [expr $CMSDK_PMU_BASE + 0x1c]
+set CMSDK_PMU_RESET_INTERRUPT_RESET_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_PMU_RESET_INTERRUPT__RESET_VALUE 0x00000000
+set CMSDK_PMU_CORE_ID [expr $CMSDK_PMU_BASE + 0xffc]
+set CMSDK_PMU_CORE_ID_ID__RESET_VALUE 0x53504920
+set CMSDK_PMU_CORE_ID__RESET_VALUE 0x53504920
diff --git a/platform/atm2/ATM22xx-x1x/openocd/regs/pseq.tcl b/platform/atm2/ATM22xx-x1x/openocd/regs/pseq.tcl
new file mode 100644
index 0000000..38d5b05
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/regs/pseq.tcl
@@ -0,0 +1,388 @@
+set CMSDK_PSEQ_BASE 0x50008000
+set CMSDK_PSEQ_CTRL0 [expr $CMSDK_PSEQ_BASE + 0x0]
+set CMSDK_PSEQ_CTRL0_MANAGE_XTAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CTRL0_REQ_BLE_ONLY_LP_STATE__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CTRL0_REQ_RETAIN_ALL_STATE__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CTRL0_REQ_HIBERNATE_STATE__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CTRL0_ENABLE_DEBUG_BUS__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CTRL0_REQ_BLE_TO_BOOT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CTRL0_XTAL_WAITS_FOR_RETV__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CTRL0_BLE_BOOSTS_RETV__RESET_VALUE 0x00000001
+set CMSDK_PSEQ_CTRL0_BLOCK_DBG_WAKE__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CTRL0_WURX_DET0_SEL__RESET_VALUE 0x00000001
+set CMSDK_PSEQ_CTRL0_WURX_DET1_SEL__RESET_VALUE 0x00000001
+set CMSDK_PSEQ_CTRL0_RADIO_EN_I_SRC__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CTRL0_PINSEL_LATCH_OPEN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CTRL0_KSM_LATCH_OPEN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CTRL0_GPIO_LATCH_OPEN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CTRL0_REQ_SOC_OFF__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CTRL0__RESET_VALUE 0x002a0000
+set CMSDK_PSEQ_RETAIN_ALL_WAKE_MASK [expr $CMSDK_PSEQ_BASE + 0x4]
+set CMSDK_PSEQ_RETAIN_ALL_WAKE_MASK_WATCH_GPIO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_RETAIN_ALL_WAKE_MASK_WATCH_CNTDOWN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_RETAIN_ALL_WAKE_MASK_WATCH_WURX0__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_RETAIN_ALL_WAKE_MASK_WATCH_WURX1__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_RETAIN_ALL_WAKE_MASK_WATCH_QDEC__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_RETAIN_ALL_WAKE_MASK_WATCH_KSM__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_RETAIN_ALL_WAKE_MASK_WATCH_SHUB__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_RETAIN_ALL_WAKE_MASK__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_HIB_WAKE_MASK [expr $CMSDK_PSEQ_BASE + 0x8]
+set CMSDK_PSEQ_HIB_WAKE_MASK_WATCH_GPIO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_HIB_WAKE_MASK_WATCH_CNTDOWN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_HIB_WAKE_MASK_WATCH_WURX0__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_HIB_WAKE_MASK_WATCH_WURX1__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_HIB_WAKE_MASK_WATCH_QDEC__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_HIB_WAKE_MASK_WATCH_KSM__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_HIB_WAKE_MASK_WATCH_SHUB__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_HIB_WAKE_MASK__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_BLE_ACT_WAKE_MASK [expr $CMSDK_PSEQ_BASE + 0xc]
+set CMSDK_PSEQ_BLE_RET_TO_BLE_ACT_WAKE_MASK_WATCH_GPIO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_BLE_ACT_WAKE_MASK_WATCH_CNTDOWN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_BLE_ACT_WAKE_MASK_WATCH_WURX0__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_BLE_ACT_WAKE_MASK_WATCH_WURX1__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_BLE_ACT_WAKE_MASK_WATCH_QDEC__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_BLE_ACT_WAKE_MASK_WATCH_KSM__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_BLE_ACT_WAKE_MASK_WATCH_SHUB__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_BLE_ACT_WAKE_MASK__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_CPU_ACT_WAKE_MASK [expr $CMSDK_PSEQ_BASE + 0x10]
+set CMSDK_PSEQ_BLE_RET_TO_CPU_ACT_WAKE_MASK_WATCH_GPIO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_CPU_ACT_WAKE_MASK_WATCH_CNTDOWN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_CPU_ACT_WAKE_MASK_WATCH_WURX0__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_CPU_ACT_WAKE_MASK_WATCH_WURX1__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_CPU_ACT_WAKE_MASK_WATCH_QDEC__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_CPU_ACT_WAKE_MASK_WATCH_KSM__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_CPU_ACT_WAKE_MASK_WATCH_SHUB__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_BLE_RET_TO_CPU_ACT_WAKE_MASK__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_GPIO_WAKE_MASK [expr $CMSDK_PSEQ_BASE + 0x14]
+set CMSDK_PSEQ_GPIO_WAKE_MASK_LOWER__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_GPIO_WAKE_MASK_UPPER__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_GPIO_WAKE_MASK__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_GPIO_WAKE_TYPE [expr $CMSDK_PSEQ_BASE + 0x18]
+set CMSDK_PSEQ_GPIO_WAKE_TYPE_LOWER__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_GPIO_WAKE_TYPE_UPPER__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_GPIO_WAKE_TYPE__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_GPIO_WAKE_POL [expr $CMSDK_PSEQ_BASE + 0x1c]
+set CMSDK_PSEQ_GPIO_WAKE_POL_LOWER__RESET_VALUE 0x0000ffff
+set CMSDK_PSEQ_GPIO_WAKE_POL_UPPER__RESET_VALUE 0x0000ffff
+set CMSDK_PSEQ_GPIO_WAKE_POL__RESET_VALUE 0xffffffff
+set CMSDK_PSEQ_GPIO_WAKE_BOTH_EDGES [expr $CMSDK_PSEQ_BASE + 0x20]
+set CMSDK_PSEQ_GPIO_WAKE_BOTH_EDGES_LOWER__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_GPIO_WAKE_BOTH_EDGES_UPPER__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_GPIO_WAKE_BOTH_EDGES__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_WURX_CONFIG [expr $CMSDK_PSEQ_BASE + 0x24]
+set CMSDK_PSEQ_WURX_CONFIG_WURX_EN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_WURX_CONFIG_WURX_RSTB__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_WURX_CONFIG_WURX_CUTVDD_B__RESET_VALUE 0x00000001
+set CMSDK_PSEQ_WURX_CONFIG__RESET_VALUE 0x00000004
+set CMSDK_PSEQ_GADC_CONFIG [expr $CMSDK_PSEQ_BASE + 0x28]
+set CMSDK_PSEQ_GADC_CONFIG_GADC_EN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_GADC_CONFIG_GADC_RSTB__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_GADC_CONFIG_GADC_CUTVDD_B__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_GADC_CONFIG__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT0 [expr $CMSDK_PSEQ_BASE + 0x2c]
+set CMSDK_PSEQ_COUNT0_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT0__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT1 [expr $CMSDK_PSEQ_BASE + 0x30]
+set CMSDK_PSEQ_COUNT1_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT1__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT2 [expr $CMSDK_PSEQ_BASE + 0x34]
+set CMSDK_PSEQ_COUNT2_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT2__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT3 [expr $CMSDK_PSEQ_BASE + 0x38]
+set CMSDK_PSEQ_COUNT3_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT3__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT4 [expr $CMSDK_PSEQ_BASE + 0x3c]
+set CMSDK_PSEQ_COUNT4_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT4__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT5 [expr $CMSDK_PSEQ_BASE + 0x40]
+set CMSDK_PSEQ_COUNT5_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT5__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT6 [expr $CMSDK_PSEQ_BASE + 0x44]
+set CMSDK_PSEQ_COUNT6_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT6__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT7 [expr $CMSDK_PSEQ_BASE + 0x48]
+set CMSDK_PSEQ_COUNT7_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT7__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT8 [expr $CMSDK_PSEQ_BASE + 0x4c]
+set CMSDK_PSEQ_COUNT8_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT8__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT9 [expr $CMSDK_PSEQ_BASE + 0x50]
+set CMSDK_PSEQ_COUNT9_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT9__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT0_RADIO [expr $CMSDK_PSEQ_BASE + 0x54]
+set CMSDK_PSEQ_COUNT0_RADIO_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT0_RADIO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT1_RADIO [expr $CMSDK_PSEQ_BASE + 0x58]
+set CMSDK_PSEQ_COUNT1_RADIO_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT1_RADIO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT2_RADIO [expr $CMSDK_PSEQ_BASE + 0x5c]
+set CMSDK_PSEQ_COUNT2_RADIO_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT2_RADIO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT3_RADIO [expr $CMSDK_PSEQ_BASE + 0x60]
+set CMSDK_PSEQ_COUNT3_RADIO_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT3_RADIO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT4_RADIO [expr $CMSDK_PSEQ_BASE + 0x64]
+set CMSDK_PSEQ_COUNT4_RADIO_CNT__RESET_VALUE 0x00000004
+set CMSDK_PSEQ_COUNT4_RADIO__RESET_VALUE 0x00000004
+set CMSDK_PSEQ_COUNT5_RADIO [expr $CMSDK_PSEQ_BASE + 0x68]
+set CMSDK_PSEQ_COUNT5_RADIO_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT5_RADIO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT6_RADIO [expr $CMSDK_PSEQ_BASE + 0x6c]
+set CMSDK_PSEQ_COUNT6_RADIO_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT6_RADIO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT7_RADIO [expr $CMSDK_PSEQ_BASE + 0x70]
+set CMSDK_PSEQ_COUNT7_RADIO_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT7_RADIO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT8_RADIO [expr $CMSDK_PSEQ_BASE + 0x74]
+set CMSDK_PSEQ_COUNT8_RADIO_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT8_RADIO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT9_RADIO [expr $CMSDK_PSEQ_BASE + 0x78]
+set CMSDK_PSEQ_COUNT9_RADIO_CNT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT9_RADIO_EM_BLOCK_WDATA__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT9_RADIO_EM_BLOCK_ADDR__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT9_RADIO_SPARE__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNT9_RADIO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_XTAL_BITS0 [expr $CMSDK_PSEQ_BASE + 0x7c]
+set CMSDK_PSEQ_XTAL_BITS0_XTALFREQ__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_XTAL_BITS0_XOCAPIN__RESET_VALUE 0x0000000d
+set CMSDK_PSEQ_XTAL_BITS0_XOCAPOUT__RESET_VALUE 0x0000000d
+set CMSDK_PSEQ_XTAL_BITS0__RESET_VALUE 0x0000035a
+set CMSDK_PSEQ_XTAL_BITS1 [expr $CMSDK_PSEQ_BASE + 0x80]
+set CMSDK_PSEQ_XTAL_BITS1_XOBIAS__RESET_VALUE 0x0000000c
+set CMSDK_PSEQ_XTAL_BITS1_XOAGC_EN__RESET_VALUE 0x00000001
+set CMSDK_PSEQ_XTAL_BITS1_XOFASTSTART__RESET_VALUE 0x00000007
+set CMSDK_PSEQ_XTAL_BITS1_XOSETTLE__RESET_VALUE 0x00000010
+set CMSDK_PSEQ_XTAL_BITS1_RCOSCFREQ__RESET_VALUE 0x0000000b
+set CMSDK_PSEQ_XTAL_BITS1_DOUBLERDCC_EN__RESET_VALUE 0x00000001
+set CMSDK_PSEQ_XTAL_BITS1_CLKHPC_EN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_XTAL_BITS1_CLKMPC_EN__RESET_VALUE 0x00000001
+set CMSDK_PSEQ_XTAL_BITS1_EXTCLK__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_XTAL_BITS1_XTAL_SPARE__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_XTAL_BITS1__RESET_VALUE 0x0016d0fc
+set CMSDK_PSEQ_OVERRIDES [expr $CMSDK_PSEQ_BASE + 0x84]
+set CMSDK_PSEQ_OVERRIDES_FORCE_PRECISION_REQ__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES_FORCE_PRECISION_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES_FORCE_OSC_ON_REQ__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES_BLOCK_BLE_OSC_ON_REQ__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES_BLOCK_BLE_HIGH_PRECISION_REQ__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2 [expr $CMSDK_PSEQ_BASE + 0x88]
+set CMSDK_PSEQ_OVERRIDES2_BLOCK_CACHE_PSD__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2_BLOCK_CACHE_VDDCUT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2_OVERRIDE_CACHE_PSD_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2_OVERRIDE_CACHE_PSD__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2_OVERRIDE_CACHE_RET_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2_OVERRIDE_CACHE_RET__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2_OVERRIDE_CACHE_NAP_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2_OVERRIDE_CACHE_NAP__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2_OVERRIDE_CACHE_ISO_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2_OVERRIDE_CACHE_ISO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2_OVERRIDE_CACHE_CLKEN_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2_OVERRIDE_CACHE_CLKEN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2_OVERRIDE_CACHE_VDDCUT_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2_OVERRIDE_CACHE_VDDCUT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2_BLOCK_SYSROM_VDDCUT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2_BLOCK_EFUSE_VDDCUT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES2__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES3 [expr $CMSDK_PSEQ_BASE + 0x8c]
+set CMSDK_PSEQ_OVERRIDES3_OVERRIDE_SYSROM_CLKEN_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES3_OVERRIDE_SYSROM_CLKEN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES3_OVERRIDE_SYSROM_ISO_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES3_OVERRIDE_SYSROM_ISO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES3_OVERRIDE_SYSROM_PSD_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES3_OVERRIDE_SYSROM_PSD__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES3__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4 [expr $CMSDK_PSEQ_BASE + 0x90]
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_BLE_CLKEN_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_BLE_CLKEN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_BLE_FRST_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_BLE_FRST__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_BLE_ISO_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_BLE_ISO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_BLE_KILL_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_BLE_KILL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_BLE_SLEEP_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_BLE_SLEEP__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_BLE_LOADB_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_BLE_LOADB__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_BLE_RETN_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_BLE_RETN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_PNR_CLKEN_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_PNR_CLKEN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_PNR_FRST_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_PNR_FRST__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_PNR_ISO_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_PNR_ISO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_PNR_KILL_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_PNR_KILL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_PNR_SLEEP_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_PNR_SLEEP__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_PNR_LOADB_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_PNR_LOADB__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_PNR_RETN_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_PNR_RETN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_EFUSE_ISO_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_EFUSE_ISO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_EFUSE_VDDCUT_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4_OVERRIDE_EFUSE_VDDCUT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES4__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5 [expr $CMSDK_PSEQ_BASE + 0x94]
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_BLE_FRSTDP_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_BLE_FRSTDP__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_RADIO_ISO_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_RADIO_ISO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_WREQ_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_WREQ__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_RADIO_FRST_B_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_RADIO_FRST_B__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_CUTVDD_B_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_CUTVDD_B__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_RADIO_EN_O_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_RADIO_EN_O__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_RETV_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_RETV__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_XTAL_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5_OVERRIDE_XTAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_OVERRIDES5__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES [expr $CMSDK_PSEQ_BASE + 0x98]
+set CMSDK_PSEQ_SYSRAM_OVERRIDES_OVERRIDE_SYSRAM_VDDCUT_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES_OVERRIDE_SYSRAM_VDDCUT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES2 [expr $CMSDK_PSEQ_BASE + 0x9c]
+set CMSDK_PSEQ_SYSRAM_OVERRIDES2_OVERRIDE_SYSRAM_CLKEN_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES2_OVERRIDE_SYSRAM_CLKEN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES2__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES3 [expr $CMSDK_PSEQ_BASE + 0xa0]
+set CMSDK_PSEQ_SYSRAM_OVERRIDES3_OVERRIDE_SYSRAM_ISO_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES3_OVERRIDE_SYSRAM_ISO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES3__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES4 [expr $CMSDK_PSEQ_BASE + 0xa4]
+set CMSDK_PSEQ_SYSRAM_OVERRIDES4_OVERRIDE_SYSRAM_NAP_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES4_OVERRIDE_SYSRAM_NAP__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES4__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES5 [expr $CMSDK_PSEQ_BASE + 0xa8]
+set CMSDK_PSEQ_SYSRAM_OVERRIDES5_OVERRIDE_SYSRAM_RET_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES5_OVERRIDE_SYSRAM_RET__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES5__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES6 [expr $CMSDK_PSEQ_BASE + 0xac]
+set CMSDK_PSEQ_SYSRAM_OVERRIDES6_OVERRIDE_SYSRAM_PSD_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES6_OVERRIDE_SYSRAM_PSD__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES6__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES7 [expr $CMSDK_PSEQ_BASE + 0xb0]
+set CMSDK_PSEQ_SYSRAM_OVERRIDES7_BLOCK_SYSRAM_VDDCUT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES7__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES8 [expr $CMSDK_PSEQ_BASE + 0xb4]
+set CMSDK_PSEQ_SYSRAM_OVERRIDES8_BLOCK_SYSRAM_PSD__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_OVERRIDES8__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_CONF [expr $CMSDK_PSEQ_BASE + 0xb8]
+set CMSDK_PSEQ_SYSRAM_CONF_SYSRAM_HVT_EN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_CONF_SYSRAM_SVT_EN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_CONF_SW_OVERRIDE__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SYSRAM_CONF__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES [expr $CMSDK_PSEQ_BASE + 0xbc]
+set CMSDK_PSEQ_EMRAM_OVERRIDES_OVERRIDE_EMRAM_VDDCUT_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES_OVERRIDE_EMRAM_VDDCUT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES2 [expr $CMSDK_PSEQ_BASE + 0xc0]
+set CMSDK_PSEQ_EMRAM_OVERRIDES2_OVERRIDE_EMRAM_CLKEN_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES2_OVERRIDE_EMRAM_CLKEN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES2__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES3 [expr $CMSDK_PSEQ_BASE + 0xc4]
+set CMSDK_PSEQ_EMRAM_OVERRIDES3_OVERRIDE_EMRAM_ISO_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES3_OVERRIDE_EMRAM_ISO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES3__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES4 [expr $CMSDK_PSEQ_BASE + 0xc8]
+set CMSDK_PSEQ_EMRAM_OVERRIDES4_OVERRIDE_EMRAM_NAP_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES4_OVERRIDE_EMRAM_NAP__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES4__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES5 [expr $CMSDK_PSEQ_BASE + 0xcc]
+set CMSDK_PSEQ_EMRAM_OVERRIDES5_OVERRIDE_EMRAM_RET_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES5_OVERRIDE_EMRAM_RET__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES5__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES6 [expr $CMSDK_PSEQ_BASE + 0xd0]
+set CMSDK_PSEQ_EMRAM_OVERRIDES6_OVERRIDE_EMRAM_PSD_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES6_OVERRIDE_EMRAM_PSD__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES6__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES7 [expr $CMSDK_PSEQ_BASE + 0xd4]
+set CMSDK_PSEQ_EMRAM_OVERRIDES7_BLOCK_EMRAM_VDDCUT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES7__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES8 [expr $CMSDK_PSEQ_BASE + 0xd8]
+set CMSDK_PSEQ_EMRAM_OVERRIDES8_BLOCK_EMRAM_PSD__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_EMRAM_OVERRIDES8__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNTER_CONTROL [expr $CMSDK_PSEQ_BASE + 0xdc]
+set CMSDK_PSEQ_COUNTER_CONTROL_HALT_REAL_TIME_COUNTER__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNTER_CONTROL_LOAD_COUNT_DOWN_TIMER__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_COUNTER_CONTROL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CURRENT_REAL_TIME [expr $CMSDK_PSEQ_BASE + 0xe0]
+set CMSDK_PSEQ_CURRENT_REAL_TIME_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CURRENT_REAL_TIME__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CURRENT_COUNT_DOWN_TIME [expr $CMSDK_PSEQ_BASE + 0xe4]
+set CMSDK_PSEQ_CURRENT_COUNT_DOWN_TIME_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CURRENT_COUNT_DOWN_TIME__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_INIT_COUNT_DOWN [expr $CMSDK_PSEQ_BASE + 0xe8]
+set CMSDK_PSEQ_INIT_COUNT_DOWN_VAL__RESET_VALUE 0x00000fff
+set CMSDK_PSEQ_INIT_COUNT_DOWN__RESET_VALUE 0x00000fff
+set CMSDK_PSEQ_INST_PENDING [expr $CMSDK_PSEQ_BASE + 0xec]
+set CMSDK_PSEQ_INST_PENDING_CNTDWN_TIMER_LOAD__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_INST_PENDING__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_STATUS [expr $CMSDK_PSEQ_BASE + 0xf0]
+set CMSDK_PSEQ_STATUS_IN_ACTIVE_STATE__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_STATUS_IN_CPU_ACTIVE_STATE__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_STATUS_IN_HIBERNATE_STATE__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_STATUS_TIMER_TRIGGERED__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_STATUS_GPIO_TRIGGERED__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_STATUS_WURX0_TRIGGERED__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_STATUS_WURX1_TRIGGERED__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_STATUS_QDEC_TRIGGERED__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_STATUS_KSM_TRIGGERED__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_STATUS_DBG_TRIGGERED__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_STATUS_SHUB_TRIGGERED__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_STATUS__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_PERSISTENT0 [expr $CMSDK_PSEQ_BASE + 0xf4]
+set CMSDK_PSEQ_PERSISTENT0_DATA__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_PERSISTENT0__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SENSOR_HUB_CONTROL [expr $CMSDK_PSEQ_BASE + 0xf8]
+set CMSDK_PSEQ_SENSOR_HUB_CONTROL_ENABLE_FUNC__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SENSOR_HUB_CONTROL_SHUB_RESET__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SENSOR_HUB_CONTROL_SHUB_RUNNING_VAL__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SENSOR_HUB_CONTROL_SHUB_RUNNING_OVRD__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SENSOR_HUB_CONTROL_SHUB_CLKEN__RESET_VALUE 0x00000001
+set CMSDK_PSEQ_SENSOR_HUB_CONTROL_SHUB_ISO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SENSOR_HUB_CONTROL_SHUB_VDDCUT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_SENSOR_HUB_CONTROL__RESET_VALUE 0x00000010
+set CMSDK_PSEQ_KSMQDEC_CONTROL [expr $CMSDK_PSEQ_BASE + 0xfc]
+set CMSDK_PSEQ_KSMQDEC_CONTROL_KSMQDEC_CLKEN__RESET_VALUE 0x00000001
+set CMSDK_PSEQ_KSMQDEC_CONTROL_KSMQDEC_FRST__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_KSMQDEC_CONTROL_KSMQDEC_ISO__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_KSMQDEC_CONTROL_KSMQDEC_VDDCUT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_KSMQDEC_CONTROL__RESET_VALUE 0x00000001
+set CMSDK_PSEQ_PMU_STATUS [expr $CMSDK_PSEQ_BASE + 0x100]
+set CMSDK_PSEQ_PMU_STATUS_ENERGY4CPU__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_PMU_STATUS_ENERGY4TX__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_PMU_STATUS_ENDOFLIFE__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_PMU_STATUS_BROWNOUT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_PMU_STATUS_SOC_OFF_WKUP_DET__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_PMU_STATUS__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_FLASH_CONTROL [expr $CMSDK_PSEQ_BASE + 0x104]
+set CMSDK_PSEQ_FLASH_CONTROL_POWER_CYCLE_EN__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_FLASH_CONTROL_RPD_HAS_CLOCK__RESET_VALUE 0x00000001
+set CMSDK_PSEQ_FLASH_CONTROL_MODE__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_FLASH_CONTROL_OPCODE__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_FLASH_CONTROL__RESET_VALUE 0x00000002
+set CMSDK_PSEQ_PMU_INTERRUPT [expr $CMSDK_PSEQ_BASE + 0x108]
+set CMSDK_PSEQ_PMU_INTERRUPT_INTMASK__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_PMU_INTERRUPT_CLEAR_RE_INDICATOR__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_PMU_INTERRUPT_CLEAR_FE_INDICATOR__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_PMU_INTERRUPT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_INTERRUPT_STATUS [expr $CMSDK_PSEQ_BASE + 0x10c]
+set CMSDK_PSEQ_INTERRUPT_STATUS_RETURNED_FROM_LOW_POWER_STATE__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_INTERRUPT_STATUS__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_INTERRUPT_MASK [expr $CMSDK_PSEQ_BASE + 0x110]
+set CMSDK_PSEQ_INTERRUPT_MASK_INTRPT_MASK__RESET_VALUE 0x00000001
+set CMSDK_PSEQ_INTERRUPT_MASK__RESET_VALUE 0x00000001
+set CMSDK_PSEQ_RESET_INTERRUPT [expr $CMSDK_PSEQ_BASE + 0x114]
+set CMSDK_PSEQ_RESET_INTERRUPT_INTRPT_RESET__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_RESET_INTERRUPT__RESET_VALUE 0x00000000
+set CMSDK_PSEQ_CORE_ID [expr $CMSDK_PSEQ_BASE + 0xffc]
+set CMSDK_PSEQ_CORE_ID_ID__RESET_VALUE 0x50534551
+set CMSDK_PSEQ_CORE_ID__RESET_VALUE 0x50534551
diff --git a/platform/atm2/ATM22xx-x1x/openocd/regs/qspi.tcl b/platform/atm2/ATM22xx-x1x/openocd/regs/qspi.tcl
new file mode 100644
index 0000000..46ab80c
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/regs/qspi.tcl
@@ -0,0 +1,87 @@
+set CMSDK_QSPI_BASE 0x4000f000
+set CMSDK_QSPI_TRANSACTION_SETUP [expr $CMSDK_QSPI_BASE + 0x0]
+set CMSDK_QSPI_TRANSACTION_SETUP_SAMPLE_DIN__RESET_VALUE 0x00000000
+set CMSDK_QSPI_TRANSACTION_SETUP_DOUT_0_CTRL__RESET_VALUE 0x00000000
+set CMSDK_QSPI_TRANSACTION_SETUP_DOUT_1_CTRL__RESET_VALUE 0x00000000
+set CMSDK_QSPI_TRANSACTION_SETUP_DOUT_2_CTRL__RESET_VALUE 0x00000000
+set CMSDK_QSPI_TRANSACTION_SETUP_DOUT_3_CTRL__RESET_VALUE 0x00000000
+set CMSDK_QSPI_TRANSACTION_SETUP_CLK_VAL__RESET_VALUE 0x00000000
+set CMSDK_QSPI_TRANSACTION_SETUP_CSN_VAL__RESET_VALUE 0x00000001
+set CMSDK_QSPI_TRANSACTION_SETUP_REMOTE_AHB_QSPI_HAS_CONTROL__RESET_VALUE 0x00000000
+set CMSDK_QSPI_TRANSACTION_SETUP_REMOTE_SPI_HAS_CONTROL__RESET_VALUE 0x00000001
+set CMSDK_QSPI_TRANSACTION_SETUP__RESET_VALUE 0x22000000
+set CMSDK_QSPI_READ_DATA [expr $CMSDK_QSPI_BASE + 0x4]
+set CMSDK_QSPI_READ_DATA_RDATA__RESET_VALUE 0x00000000
+set CMSDK_QSPI_READ_DATA__RESET_VALUE 0x00000000
+set CMSDK_QSPI_OVERRIDE_DIN [expr $CMSDK_QSPI_BASE + 0x8]
+set CMSDK_QSPI_OVERRIDE_DIN_DIN_OVERRIDE_VAL__RESET_VALUE 0x00000000
+set CMSDK_QSPI_OVERRIDE_DIN_OVERRIDE_DIN__RESET_VALUE 0x00000000
+set CMSDK_QSPI_OVERRIDE_DIN__RESET_VALUE 0x00000000
+set CMSDK_QSPI_MODE [expr $CMSDK_QSPI_BASE + 0xc]
+set CMSDK_QSPI_MODE_IS_DUAL__RESET_VALUE 0x00000000
+set CMSDK_QSPI_MODE_IS_QUAD__RESET_VALUE 0x00000001
+set CMSDK_QSPI_MODE__RESET_VALUE 0x00000002
+set CMSDK_QSPI_REMOTE_AHB_SETUP [expr $CMSDK_QSPI_BASE + 0x10]
+set CMSDK_QSPI_REMOTE_AHB_SETUP_DUMMY_CYCLES__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_MODE__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_IS_OPCODE__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_OPCODE__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_CLKDIVSEL__RESET_VALUE 0x00000003
+set CMSDK_QSPI_REMOTE_AHB_SETUP_RDATA_BYTE_SWAP__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_IS_MACRONIX__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_WDATA_BYTE_SWAP__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_WDATA_HALFWORD_SWAP__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_WDATA_WORD_SWAP__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_ENABLE_CLOCKS__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_ENABLE_CACHE__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_ENABLE_FINE_CLOCK_GATING__RESET_VALUE 0x00000001
+set CMSDK_QSPI_REMOTE_AHB_SETUP_INVALIDATE_ENTIRE_CACHE__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_SERIALIZE_PP_ADDRESS__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_SKEW_CSN_ACT_WEN__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_HYPER__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_SLIP_HALF_CYCLE__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP__RESET_VALUE 0x02030000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_2 [expr $CMSDK_QSPI_BASE + 0x14]
+set CMSDK_QSPI_REMOTE_AHB_SETUP_2_OPCODE_WE__RESET_VALUE 0x00000006
+set CMSDK_QSPI_REMOTE_AHB_SETUP_2_OPCODE_PP__RESET_VALUE 0x00000002
+set CMSDK_QSPI_REMOTE_AHB_SETUP_2_OPCODE_WIP__RESET_VALUE 0x00000005
+set CMSDK_QSPI_REMOTE_AHB_SETUP_2_OPCODE_SE__RESET_VALUE 0x00000020
+set CMSDK_QSPI_REMOTE_AHB_SETUP_2__RESET_VALUE 0x20050206
+set CMSDK_QSPI_REMOTE_AHB_SETUP_3 [expr $CMSDK_QSPI_BASE + 0x18]
+set CMSDK_QSPI_REMOTE_AHB_SETUP_3_ENABLE_PERFORMANCE_MODE__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_3_EXPM__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_3_WLE_POLARITY__RESET_VALUE 0x00000001
+set CMSDK_QSPI_REMOTE_AHB_SETUP_3_WLE_BIT__RESET_VALUE 0x00000001
+set CMSDK_QSPI_REMOTE_AHB_SETUP_3_WIP_POLARITY__RESET_VALUE 0x00000001
+set CMSDK_QSPI_REMOTE_AHB_SETUP_3_WIP_BIT__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_3_CHECK_WLE__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_3__RESET_VALUE 0x01300000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_4 [expr $CMSDK_QSPI_BASE + 0x1c]
+set CMSDK_QSPI_REMOTE_AHB_SETUP_4_INVERT_ADDR__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_4__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_SETUP_5 [expr $CMSDK_QSPI_BASE + 0x20]
+set CMSDK_QSPI_REMOTE_AHB_SETUP_5_PP_STALL_WIP__RESET_VALUE 0x00000200
+set CMSDK_QSPI_REMOTE_AHB_SETUP_5_STALL_WLE__RESET_VALUE 0x00000020
+set CMSDK_QSPI_REMOTE_AHB_SETUP_5_STALL_WE2PP__RESET_VALUE 0x00000020
+set CMSDK_QSPI_REMOTE_AHB_SETUP_5__RESET_VALUE 0x02008200
+set CMSDK_QSPI_REMOTE_AHB_SETUP_6 [expr $CMSDK_QSPI_BASE + 0x24]
+set CMSDK_QSPI_REMOTE_AHB_SETUP_6_SE_STALL_WIP__RESET_VALUE 0x00001fff
+set CMSDK_QSPI_REMOTE_AHB_SETUP_6__RESET_VALUE 0x00001fff
+set CMSDK_QSPI_REMOTE_AHB_WLE_CNT [expr $CMSDK_QSPI_BASE + 0x28]
+set CMSDK_QSPI_REMOTE_AHB_WLE_CNT_WLE_CNT__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_WLE_CNT__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_WIP_CNT [expr $CMSDK_QSPI_BASE + 0x2c]
+set CMSDK_QSPI_REMOTE_AHB_WIP_CNT_WIP_CNT__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_WIP_CNT__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_DBG0 [expr $CMSDK_QSPI_BASE + 0x30]
+set CMSDK_QSPI_REMOTE_AHB_DBG0_DBG0__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_DBG0__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_DBG1 [expr $CMSDK_QSPI_BASE + 0x34]
+set CMSDK_QSPI_REMOTE_AHB_DBG1_DBG1__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_DBG1__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_DBG2 [expr $CMSDK_QSPI_BASE + 0x38]
+set CMSDK_QSPI_REMOTE_AHB_DBG2_DBG2__RESET_VALUE 0x00000000
+set CMSDK_QSPI_REMOTE_AHB_DBG2__RESET_VALUE 0x00000000
+set CMSDK_QSPI_CORE_ID [expr $CMSDK_QSPI_BASE + 0xffc]
+set CMSDK_QSPI_CORE_ID_ID__RESET_VALUE 0x51535049
+set CMSDK_QSPI_CORE_ID__RESET_VALUE 0x51535049
diff --git a/platform/atm2/ATM22xx-x1x/openocd/regs/radio.tcl b/platform/atm2/ATM22xx-x1x/openocd/regs/radio.tcl
new file mode 100644
index 0000000..901a45e
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/regs/radio.tcl
@@ -0,0 +1,43 @@
+set CMSDK_RADIO_BASE 0x50005000
+set CMSDK_RADIO_TRANSACTION_SETUP [expr $CMSDK_RADIO_BASE + 0x0]
+set CMSDK_RADIO_TRANSACTION_SETUP_START__RESET_VALUE 0x00000000
+set CMSDK_RADIO_TRANSACTION_SETUP_NUM_DATA_BYTES__RESET_VALUE 0x00000000
+set CMSDK_RADIO_TRANSACTION_SETUP_RWB__RESET_VALUE 0x00000000
+set CMSDK_RADIO_TRANSACTION_SETUP_CLKDIV__RESET_VALUE 0x00000000
+set CMSDK_RADIO_TRANSACTION_SETUP_OPCODE__RESET_VALUE 0x00000000
+set CMSDK_RADIO_TRANSACTION_SETUP_LOOPBACK__RESET_VALUE 0x00000000
+set CMSDK_RADIO_TRANSACTION_SETUP_CSN_STAYS_LOW__RESET_VALUE 0x00000000
+set CMSDK_RADIO_TRANSACTION_SETUP_DUMMY_CYCLES__RESET_VALUE 0x00000000
+set CMSDK_RADIO_TRANSACTION_SETUP__RESET_VALUE 0x00000000
+set CMSDK_RADIO_TRANSACTION_STATUS [expr $CMSDK_RADIO_BASE + 0x4]
+set CMSDK_RADIO_TRANSACTION_STATUS_DONE__RESET_VALUE 0x00000000
+set CMSDK_RADIO_TRANSACTION_STATUS_RUNNING__RESET_VALUE 0x00000000
+set CMSDK_RADIO_TRANSACTION_STATUS_OPCODE_STATUS__RESET_VALUE 0x00000000
+set CMSDK_RADIO_TRANSACTION_STATUS__RESET_VALUE 0x00000000
+set CMSDK_RADIO_DATA_BYTES_LOWER [expr $CMSDK_RADIO_BASE + 0x8]
+set CMSDK_RADIO_DATA_BYTES_LOWER_BYTE0__RESET_VALUE 0x00000000
+set CMSDK_RADIO_DATA_BYTES_LOWER_BYTE1__RESET_VALUE 0x00000000
+set CMSDK_RADIO_DATA_BYTES_LOWER_BYTE2__RESET_VALUE 0x00000000
+set CMSDK_RADIO_DATA_BYTES_LOWER_BYTE3__RESET_VALUE 0x00000000
+set CMSDK_RADIO_DATA_BYTES_LOWER__RESET_VALUE 0x00000000
+set CMSDK_RADIO_DATA_BYTES_UPPER [expr $CMSDK_RADIO_BASE + 0xc]
+set CMSDK_RADIO_DATA_BYTES_UPPER_BYTE4__RESET_VALUE 0x00000000
+set CMSDK_RADIO_DATA_BYTES_UPPER_BYTE5__RESET_VALUE 0x00000000
+set CMSDK_RADIO_DATA_BYTES_UPPER_BYTE6__RESET_VALUE 0x00000000
+set CMSDK_RADIO_DATA_BYTES_UPPER_BYTE7__RESET_VALUE 0x00000000
+set CMSDK_RADIO_DATA_BYTES_UPPER__RESET_VALUE 0x00000000
+set CMSDK_RADIO_INTERRUPT_MASK [expr $CMSDK_RADIO_BASE + 0x10]
+set CMSDK_RADIO_INTERRUPT_MASK_PASSTHRU0__RESET_VALUE 0x00000000
+set CMSDK_RADIO_INTERRUPT_MASK__RESET_VALUE 0x00000000
+set CMSDK_RADIO_INTERRUPT_STATUS [expr $CMSDK_RADIO_BASE + 0x14]
+set CMSDK_RADIO_INTERRUPT_STATUS_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_RADIO_INTERRUPT_STATUS__RESET_VALUE 0x00000000
+set CMSDK_RADIO_SET_INTERRUPT [expr $CMSDK_RADIO_BASE + 0x18]
+set CMSDK_RADIO_SET_INTERRUPT_SET_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_RADIO_SET_INTERRUPT__RESET_VALUE 0x00000000
+set CMSDK_RADIO_RESET_INTERRUPT [expr $CMSDK_RADIO_BASE + 0x1c]
+set CMSDK_RADIO_RESET_INTERRUPT_RESET_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_RADIO_RESET_INTERRUPT__RESET_VALUE 0x00000000
+set CMSDK_RADIO_CORE_ID [expr $CMSDK_RADIO_BASE + 0xffc]
+set CMSDK_RADIO_CORE_ID_ID__RESET_VALUE 0x53504920
+set CMSDK_RADIO_CORE_ID__RESET_VALUE 0x53504920
diff --git a/platform/atm2/ATM22xx-x1x/openocd/regs/regs_for_program.tcl b/platform/atm2/ATM22xx-x1x/openocd/regs/regs_for_program.tcl
new file mode 100644
index 0000000..7ef8b30
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/regs/regs_for_program.tcl
@@ -0,0 +1,10 @@
+source [find regs/spi0.tcl]
+source [find regs/spi1.tcl]
+source [find regs/spi2.tcl]
+source [find regs/radio.tcl]
+source [find regs/pmu.tcl]
+source [find regs/wrpr.tcl]
+source [find regs/wrpr1.tcl]
+source [find regs/nvm.tcl]
+source [find regs/qspi.tcl]
+source [find regs/pseq.tcl]
diff --git a/platform/atm2/ATM22xx-x1x/openocd/regs/spi0.tcl b/platform/atm2/ATM22xx-x1x/openocd/regs/spi0.tcl
new file mode 100644
index 0000000..7e9efa7
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/regs/spi0.tcl
@@ -0,0 +1,43 @@
+set CMSDK_SPI0_BASE 0x40007000
+set CMSDK_SPI0_TRANSACTION_SETUP [expr $CMSDK_SPI0_BASE + 0x0]
+set CMSDK_SPI0_TRANSACTION_SETUP_START__RESET_VALUE 0x00000000
+set CMSDK_SPI0_TRANSACTION_SETUP_NUM_DATA_BYTES__RESET_VALUE 0x00000000
+set CMSDK_SPI0_TRANSACTION_SETUP_RWB__RESET_VALUE 0x00000000
+set CMSDK_SPI0_TRANSACTION_SETUP_CLKDIV__RESET_VALUE 0x00000000
+set CMSDK_SPI0_TRANSACTION_SETUP_OPCODE__RESET_VALUE 0x00000000
+set CMSDK_SPI0_TRANSACTION_SETUP_LOOPBACK__RESET_VALUE 0x00000000
+set CMSDK_SPI0_TRANSACTION_SETUP_CSN_STAYS_LOW__RESET_VALUE 0x00000000
+set CMSDK_SPI0_TRANSACTION_SETUP_DUMMY_CYCLES__RESET_VALUE 0x00000000
+set CMSDK_SPI0_TRANSACTION_SETUP__RESET_VALUE 0x00000000
+set CMSDK_SPI0_TRANSACTION_STATUS [expr $CMSDK_SPI0_BASE + 0x4]
+set CMSDK_SPI0_TRANSACTION_STATUS_DONE__RESET_VALUE 0x00000000
+set CMSDK_SPI0_TRANSACTION_STATUS_RUNNING__RESET_VALUE 0x00000000
+set CMSDK_SPI0_TRANSACTION_STATUS_OPCODE_STATUS__RESET_VALUE 0x00000000
+set CMSDK_SPI0_TRANSACTION_STATUS__RESET_VALUE 0x00000000
+set CMSDK_SPI0_DATA_BYTES_LOWER [expr $CMSDK_SPI0_BASE + 0x8]
+set CMSDK_SPI0_DATA_BYTES_LOWER_BYTE0__RESET_VALUE 0x00000000
+set CMSDK_SPI0_DATA_BYTES_LOWER_BYTE1__RESET_VALUE 0x00000000
+set CMSDK_SPI0_DATA_BYTES_LOWER_BYTE2__RESET_VALUE 0x00000000
+set CMSDK_SPI0_DATA_BYTES_LOWER_BYTE3__RESET_VALUE 0x00000000
+set CMSDK_SPI0_DATA_BYTES_LOWER__RESET_VALUE 0x00000000
+set CMSDK_SPI0_DATA_BYTES_UPPER [expr $CMSDK_SPI0_BASE + 0xc]
+set CMSDK_SPI0_DATA_BYTES_UPPER_BYTE4__RESET_VALUE 0x00000000
+set CMSDK_SPI0_DATA_BYTES_UPPER_BYTE5__RESET_VALUE 0x00000000
+set CMSDK_SPI0_DATA_BYTES_UPPER_BYTE6__RESET_VALUE 0x00000000
+set CMSDK_SPI0_DATA_BYTES_UPPER_BYTE7__RESET_VALUE 0x00000000
+set CMSDK_SPI0_DATA_BYTES_UPPER__RESET_VALUE 0x00000000
+set CMSDK_SPI0_INTERRUPT_MASK [expr $CMSDK_SPI0_BASE + 0x10]
+set CMSDK_SPI0_INTERRUPT_MASK_PASSTHRU0__RESET_VALUE 0x00000000
+set CMSDK_SPI0_INTERRUPT_MASK__RESET_VALUE 0x00000000
+set CMSDK_SPI0_INTERRUPT_STATUS [expr $CMSDK_SPI0_BASE + 0x14]
+set CMSDK_SPI0_INTERRUPT_STATUS_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_SPI0_INTERRUPT_STATUS__RESET_VALUE 0x00000000
+set CMSDK_SPI0_SET_INTERRUPT [expr $CMSDK_SPI0_BASE + 0x18]
+set CMSDK_SPI0_SET_INTERRUPT_SET_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_SPI0_SET_INTERRUPT__RESET_VALUE 0x00000000
+set CMSDK_SPI0_RESET_INTERRUPT [expr $CMSDK_SPI0_BASE + 0x1c]
+set CMSDK_SPI0_RESET_INTERRUPT_RESET_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_SPI0_RESET_INTERRUPT__RESET_VALUE 0x00000000
+set CMSDK_SPI0_CORE_ID [expr $CMSDK_SPI0_BASE + 0xffc]
+set CMSDK_SPI0_CORE_ID_ID__RESET_VALUE 0x53504920
+set CMSDK_SPI0_CORE_ID__RESET_VALUE 0x53504920
diff --git a/platform/atm2/ATM22xx-x1x/openocd/regs/spi1.tcl b/platform/atm2/ATM22xx-x1x/openocd/regs/spi1.tcl
new file mode 100644
index 0000000..d5b161a
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/regs/spi1.tcl
@@ -0,0 +1,43 @@
+set CMSDK_SPI1_BASE 0x4000d000
+set CMSDK_SPI1_TRANSACTION_SETUP [expr $CMSDK_SPI1_BASE + 0x0]
+set CMSDK_SPI1_TRANSACTION_SETUP_START__RESET_VALUE 0x00000000
+set CMSDK_SPI1_TRANSACTION_SETUP_NUM_DATA_BYTES__RESET_VALUE 0x00000000
+set CMSDK_SPI1_TRANSACTION_SETUP_RWB__RESET_VALUE 0x00000000
+set CMSDK_SPI1_TRANSACTION_SETUP_CLKDIV__RESET_VALUE 0x00000000
+set CMSDK_SPI1_TRANSACTION_SETUP_OPCODE__RESET_VALUE 0x00000000
+set CMSDK_SPI1_TRANSACTION_SETUP_LOOPBACK__RESET_VALUE 0x00000000
+set CMSDK_SPI1_TRANSACTION_SETUP_CSN_STAYS_LOW__RESET_VALUE 0x00000000
+set CMSDK_SPI1_TRANSACTION_SETUP_DUMMY_CYCLES__RESET_VALUE 0x00000000
+set CMSDK_SPI1_TRANSACTION_SETUP__RESET_VALUE 0x00000000
+set CMSDK_SPI1_TRANSACTION_STATUS [expr $CMSDK_SPI1_BASE + 0x4]
+set CMSDK_SPI1_TRANSACTION_STATUS_DONE__RESET_VALUE 0x00000000
+set CMSDK_SPI1_TRANSACTION_STATUS_RUNNING__RESET_VALUE 0x00000000
+set CMSDK_SPI1_TRANSACTION_STATUS_OPCODE_STATUS__RESET_VALUE 0x00000000
+set CMSDK_SPI1_TRANSACTION_STATUS__RESET_VALUE 0x00000000
+set CMSDK_SPI1_DATA_BYTES_LOWER [expr $CMSDK_SPI1_BASE + 0x8]
+set CMSDK_SPI1_DATA_BYTES_LOWER_BYTE0__RESET_VALUE 0x00000000
+set CMSDK_SPI1_DATA_BYTES_LOWER_BYTE1__RESET_VALUE 0x00000000
+set CMSDK_SPI1_DATA_BYTES_LOWER_BYTE2__RESET_VALUE 0x00000000
+set CMSDK_SPI1_DATA_BYTES_LOWER_BYTE3__RESET_VALUE 0x00000000
+set CMSDK_SPI1_DATA_BYTES_LOWER__RESET_VALUE 0x00000000
+set CMSDK_SPI1_DATA_BYTES_UPPER [expr $CMSDK_SPI1_BASE + 0xc]
+set CMSDK_SPI1_DATA_BYTES_UPPER_BYTE4__RESET_VALUE 0x00000000
+set CMSDK_SPI1_DATA_BYTES_UPPER_BYTE5__RESET_VALUE 0x00000000
+set CMSDK_SPI1_DATA_BYTES_UPPER_BYTE6__RESET_VALUE 0x00000000
+set CMSDK_SPI1_DATA_BYTES_UPPER_BYTE7__RESET_VALUE 0x00000000
+set CMSDK_SPI1_DATA_BYTES_UPPER__RESET_VALUE 0x00000000
+set CMSDK_SPI1_INTERRUPT_MASK [expr $CMSDK_SPI1_BASE + 0x10]
+set CMSDK_SPI1_INTERRUPT_MASK_PASSTHRU0__RESET_VALUE 0x00000000
+set CMSDK_SPI1_INTERRUPT_MASK__RESET_VALUE 0x00000000
+set CMSDK_SPI1_INTERRUPT_STATUS [expr $CMSDK_SPI1_BASE + 0x14]
+set CMSDK_SPI1_INTERRUPT_STATUS_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_SPI1_INTERRUPT_STATUS__RESET_VALUE 0x00000000
+set CMSDK_SPI1_SET_INTERRUPT [expr $CMSDK_SPI1_BASE + 0x18]
+set CMSDK_SPI1_SET_INTERRUPT_SET_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_SPI1_SET_INTERRUPT__RESET_VALUE 0x00000000
+set CMSDK_SPI1_RESET_INTERRUPT [expr $CMSDK_SPI1_BASE + 0x1c]
+set CMSDK_SPI1_RESET_INTERRUPT_RESET_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_SPI1_RESET_INTERRUPT__RESET_VALUE 0x00000000
+set CMSDK_SPI1_CORE_ID [expr $CMSDK_SPI1_BASE + 0xffc]
+set CMSDK_SPI1_CORE_ID_ID__RESET_VALUE 0x53504920
+set CMSDK_SPI1_CORE_ID__RESET_VALUE 0x53504920
diff --git a/platform/atm2/ATM22xx-x1x/openocd/regs/spi2.tcl b/platform/atm2/ATM22xx-x1x/openocd/regs/spi2.tcl
new file mode 100644
index 0000000..e341c6e
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/regs/spi2.tcl
@@ -0,0 +1,43 @@
+set CMSDK_SPI2_BASE 0x4000b000
+set CMSDK_SPI2_TRANSACTION_SETUP [expr $CMSDK_SPI2_BASE + 0x0]
+set CMSDK_SPI2_TRANSACTION_SETUP_START__RESET_VALUE 0x00000000
+set CMSDK_SPI2_TRANSACTION_SETUP_NUM_DATA_BYTES__RESET_VALUE 0x00000000
+set CMSDK_SPI2_TRANSACTION_SETUP_RWB__RESET_VALUE 0x00000000
+set CMSDK_SPI2_TRANSACTION_SETUP_CLKDIV__RESET_VALUE 0x00000000
+set CMSDK_SPI2_TRANSACTION_SETUP_OPCODE__RESET_VALUE 0x00000000
+set CMSDK_SPI2_TRANSACTION_SETUP_LOOPBACK__RESET_VALUE 0x00000000
+set CMSDK_SPI2_TRANSACTION_SETUP_CSN_STAYS_LOW__RESET_VALUE 0x00000000
+set CMSDK_SPI2_TRANSACTION_SETUP_DUMMY_CYCLES__RESET_VALUE 0x00000000
+set CMSDK_SPI2_TRANSACTION_SETUP__RESET_VALUE 0x00000000
+set CMSDK_SPI2_TRANSACTION_STATUS [expr $CMSDK_SPI2_BASE + 0x4]
+set CMSDK_SPI2_TRANSACTION_STATUS_DONE__RESET_VALUE 0x00000000
+set CMSDK_SPI2_TRANSACTION_STATUS_RUNNING__RESET_VALUE 0x00000000
+set CMSDK_SPI2_TRANSACTION_STATUS_OPCODE_STATUS__RESET_VALUE 0x00000000
+set CMSDK_SPI2_TRANSACTION_STATUS__RESET_VALUE 0x00000000
+set CMSDK_SPI2_DATA_BYTES_LOWER [expr $CMSDK_SPI2_BASE + 0x8]
+set CMSDK_SPI2_DATA_BYTES_LOWER_BYTE0__RESET_VALUE 0x00000000
+set CMSDK_SPI2_DATA_BYTES_LOWER_BYTE1__RESET_VALUE 0x00000000
+set CMSDK_SPI2_DATA_BYTES_LOWER_BYTE2__RESET_VALUE 0x00000000
+set CMSDK_SPI2_DATA_BYTES_LOWER_BYTE3__RESET_VALUE 0x00000000
+set CMSDK_SPI2_DATA_BYTES_LOWER__RESET_VALUE 0x00000000
+set CMSDK_SPI2_DATA_BYTES_UPPER [expr $CMSDK_SPI2_BASE + 0xc]
+set CMSDK_SPI2_DATA_BYTES_UPPER_BYTE4__RESET_VALUE 0x00000000
+set CMSDK_SPI2_DATA_BYTES_UPPER_BYTE5__RESET_VALUE 0x00000000
+set CMSDK_SPI2_DATA_BYTES_UPPER_BYTE6__RESET_VALUE 0x00000000
+set CMSDK_SPI2_DATA_BYTES_UPPER_BYTE7__RESET_VALUE 0x00000000
+set CMSDK_SPI2_DATA_BYTES_UPPER__RESET_VALUE 0x00000000
+set CMSDK_SPI2_INTERRUPT_MASK [expr $CMSDK_SPI2_BASE + 0x10]
+set CMSDK_SPI2_INTERRUPT_MASK_PASSTHRU0__RESET_VALUE 0x00000000
+set CMSDK_SPI2_INTERRUPT_MASK__RESET_VALUE 0x00000000
+set CMSDK_SPI2_INTERRUPT_STATUS [expr $CMSDK_SPI2_BASE + 0x14]
+set CMSDK_SPI2_INTERRUPT_STATUS_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_SPI2_INTERRUPT_STATUS__RESET_VALUE 0x00000000
+set CMSDK_SPI2_SET_INTERRUPT [expr $CMSDK_SPI2_BASE + 0x18]
+set CMSDK_SPI2_SET_INTERRUPT_SET_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_SPI2_SET_INTERRUPT__RESET_VALUE 0x00000000
+set CMSDK_SPI2_RESET_INTERRUPT [expr $CMSDK_SPI2_BASE + 0x1c]
+set CMSDK_SPI2_RESET_INTERRUPT_RESET_INTERRUPT0__RESET_VALUE 0x00000000
+set CMSDK_SPI2_RESET_INTERRUPT__RESET_VALUE 0x00000000
+set CMSDK_SPI2_CORE_ID [expr $CMSDK_SPI2_BASE + 0xffc]
+set CMSDK_SPI2_CORE_ID_ID__RESET_VALUE 0x53504920
+set CMSDK_SPI2_CORE_ID__RESET_VALUE 0x53504920
diff --git a/platform/atm2/ATM22xx-x1x/openocd/regs/wrpr.tcl b/platform/atm2/ATM22xx-x1x/openocd/regs/wrpr.tcl
new file mode 100644
index 0000000..bf4062b
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/regs/wrpr.tcl
@@ -0,0 +1,256 @@
+set CMSDK_WRPR_BASE 0x40003000
+set CMSDK_WRPR_APB0_CTRL [expr $CMSDK_WRPR_BASE + 0x0]
+set CMSDK_WRPR_APB0_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB0_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB0_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_APB1_CTRL [expr $CMSDK_WRPR_BASE + 0x4]
+set CMSDK_WRPR_APB1_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB1_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB1_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_APB2_CTRL [expr $CMSDK_WRPR_BASE + 0x8]
+set CMSDK_WRPR_APB2_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB2_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB2_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_APB3_CTRL [expr $CMSDK_WRPR_BASE + 0xc]
+set CMSDK_WRPR_APB3_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB3_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB3_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_APB4_CTRL [expr $CMSDK_WRPR_BASE + 0x10]
+set CMSDK_WRPR_APB4_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB4_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB4_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_APB5_CTRL [expr $CMSDK_WRPR_BASE + 0x14]
+set CMSDK_WRPR_APB5_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB5_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB5_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_APB6_CTRL [expr $CMSDK_WRPR_BASE + 0x18]
+set CMSDK_WRPR_APB6_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB6_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB6_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_APB7_CTRL [expr $CMSDK_WRPR_BASE + 0x1c]
+set CMSDK_WRPR_APB7_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB7_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB7_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_APB8_CTRL [expr $CMSDK_WRPR_BASE + 0x20]
+set CMSDK_WRPR_APB8_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB8_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB8_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_APB9_CTRL [expr $CMSDK_WRPR_BASE + 0x24]
+set CMSDK_WRPR_APB9_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB9_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB9_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_APB10_CTRL [expr $CMSDK_WRPR_BASE + 0x28]
+set CMSDK_WRPR_APB10_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB10_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB10_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_APB11_CTRL [expr $CMSDK_WRPR_BASE + 0x2c]
+set CMSDK_WRPR_APB11_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB11_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB11_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_APB12_CTRL [expr $CMSDK_WRPR_BASE + 0x30]
+set CMSDK_WRPR_APB12_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB12_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB12_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_APB13_CTRL [expr $CMSDK_WRPR_BASE + 0x34]
+set CMSDK_WRPR_APB13_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB13_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB13_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_APB14_CTRL [expr $CMSDK_WRPR_BASE + 0x38]
+set CMSDK_WRPR_APB14_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB14_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB14_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_APB15_CTRL [expr $CMSDK_WRPR_BASE + 0x3c]
+set CMSDK_WRPR_APB15_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR_APB15_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR_APB15_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR_CLK_HPC_PIN_OUT_CTRL [expr $CMSDK_WRPR_BASE + 0x40]
+set CMSDK_WRPR_CLK_HPC_PIN_OUT_CTRL_CLK_HPC_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_CLK_HPC_PIN_OUT_CTRL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_CLK_HMC_PIN_OUT_CTRL [expr $CMSDK_WRPR_BASE + 0x44]
+set CMSDK_WRPR_CLK_HMC_PIN_OUT_CTRL_CLK_MPC_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_CLK_HMC_PIN_OUT_CTRL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_CLK_LMC_PIN_OUT_CTRL [expr $CMSDK_WRPR_BASE + 0x48]
+set CMSDK_WRPR_CLK_LMC_PIN_OUT_CTRL_CLK_LPC_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_CLK_LMC_PIN_OUT_CTRL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_DBG_CTRL [expr $CMSDK_WRPR_BASE + 0x4c]
+set CMSDK_WRPR_DBG_CTRL_BLE_DBG_SEL__RESET_VALUE 0x00000005
+set CMSDK_WRPR_DBG_CTRL_EM_BLOCK_WDATA__RESET_VALUE 0x00000000
+set CMSDK_WRPR_DBG_CTRL_EM_BLOCK_ADDR__RESET_VALUE 0x00000000
+set CMSDK_WRPR_DBG_CTRL__RESET_VALUE 0x00000005
+set CMSDK_WRPR_PIN_SELECTION_A [expr $CMSDK_WRPR_BASE + 0x50]
+set CMSDK_WRPR_PIN_SELECTION_A_P5_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_A_P4_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_A_P3_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_A_P2_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_A_P1_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_A_P0_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_A__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_B [expr $CMSDK_WRPR_BASE + 0x54]
+set CMSDK_WRPR_PIN_SELECTION_B_P11_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_B_P10_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_B_P9_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_B_P8_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_B_P7_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_B_P6_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_B__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_C [expr $CMSDK_WRPR_BASE + 0x58]
+set CMSDK_WRPR_PIN_SELECTION_C_P17_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_C_P16_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_C_P15_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_C_P14_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_C_P13_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_C_P12_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_C__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_D [expr $CMSDK_WRPR_BASE + 0x5c]
+set CMSDK_WRPR_PIN_SELECTION_D_P23_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_D_P22_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_D_P21_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_D_P20_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_D_P19_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_D_P18_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_D__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_E [expr $CMSDK_WRPR_BASE + 0x60]
+set CMSDK_WRPR_PIN_SELECTION_E_P29_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_E_P28_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_E_P27_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_E_P26_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_E_P25_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_E_P24_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_E__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_F [expr $CMSDK_WRPR_BASE + 0x64]
+set CMSDK_WRPR_PIN_SELECTION_F_P33_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_F_P32_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_F_P31_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_F_P30_SEL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_SELECTION_F__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_A [expr $CMSDK_WRPR_BASE + 0x68]
+set CMSDK_WRPR_PIN_PU_A_P7_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_A_P6_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_A_P5_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_A_P4_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_A_P3_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_A_P2_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_A_P1_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_A_P0_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_A__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_B [expr $CMSDK_WRPR_BASE + 0x6c]
+set CMSDK_WRPR_PIN_PU_B_P15_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_B_P14_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_B_P13_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_B_P12_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_B_P11_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_B_P10_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_B_P9_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_B_P8_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_B__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_C [expr $CMSDK_WRPR_BASE + 0x70]
+set CMSDK_WRPR_PIN_PU_C_P23_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_C_P22_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_C_P21_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_C_P20_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_C_P19_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_C_P18_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_C_P17_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_C_P16_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_C__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_D [expr $CMSDK_WRPR_BASE + 0x74]
+set CMSDK_WRPR_PIN_PU_D_P31_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_D_P30_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_D_P29_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_D_P28_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_D_P27_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_D_P26_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_D_P25_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_D_P24_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_D__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_E [expr $CMSDK_WRPR_BASE + 0x78]
+set CMSDK_WRPR_PIN_PU_E_P33_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_E_P32_PU__RESET_VALUE 0x00000000
+set CMSDK_WRPR_PIN_PU_E__RESET_VALUE 0x00000000
+set CMSDK_WRPR_INTRPT_CFG_0 [expr $CMSDK_WRPR_BASE + 0x7c]
+set CMSDK_WRPR_INTRPT_CFG_0_INTRPT0_MASK__RESET_VALUE 0x00000001
+set CMSDK_WRPR_INTRPT_CFG_0__RESET_VALUE 0x00000001
+set CMSDK_WRPR_INTRPT_CFG_1 [expr $CMSDK_WRPR_BASE + 0x80]
+set CMSDK_WRPR_INTRPT_CFG_1_INTRPT1_MASK__RESET_VALUE 0x00000002
+set CMSDK_WRPR_INTRPT_CFG_1__RESET_VALUE 0x00000002
+set CMSDK_WRPR_INTRPT_CFG_2 [expr $CMSDK_WRPR_BASE + 0x84]
+set CMSDK_WRPR_INTRPT_CFG_2_INTRPT2_MASK__RESET_VALUE 0x00000004
+set CMSDK_WRPR_INTRPT_CFG_2__RESET_VALUE 0x00000004
+set CMSDK_WRPR_INTRPT_CFG_3 [expr $CMSDK_WRPR_BASE + 0x88]
+set CMSDK_WRPR_INTRPT_CFG_3_INTRPT3_MASK__RESET_VALUE 0x00000008
+set CMSDK_WRPR_INTRPT_CFG_3__RESET_VALUE 0x00000008
+set CMSDK_WRPR_INTRPT_CFG_4 [expr $CMSDK_WRPR_BASE + 0x8c]
+set CMSDK_WRPR_INTRPT_CFG_4_INTRPT4_MASK__RESET_VALUE 0x00002000
+set CMSDK_WRPR_INTRPT_CFG_4__RESET_VALUE 0x00002000
+set CMSDK_WRPR_INTRPT_CFG_5 [expr $CMSDK_WRPR_BASE + 0x90]
+set CMSDK_WRPR_INTRPT_CFG_5_INTRPT5_MASK__RESET_VALUE 0x00000000
+set CMSDK_WRPR_INTRPT_CFG_5__RESET_VALUE 0x00000000
+set CMSDK_WRPR_INTRPT_CFG_6 [expr $CMSDK_WRPR_BASE + 0x94]
+set CMSDK_WRPR_INTRPT_CFG_6_INTRPT6_MASK__RESET_VALUE 0x01ff0000
+set CMSDK_WRPR_INTRPT_CFG_6__RESET_VALUE 0x01ff0000
+set CMSDK_WRPR_INTRPT_CFG_7 [expr $CMSDK_WRPR_BASE + 0x98]
+set CMSDK_WRPR_INTRPT_CFG_7_INTRPT7_MASK__RESET_VALUE 0x02000010
+set CMSDK_WRPR_INTRPT_CFG_7__RESET_VALUE 0x02000010
+set CMSDK_WRPR_INTRPT_CFG_8 [expr $CMSDK_WRPR_BASE + 0x9c]
+set CMSDK_WRPR_INTRPT_CFG_8_INTRPT8_MASK__RESET_VALUE 0x00000020
+set CMSDK_WRPR_INTRPT_CFG_8__RESET_VALUE 0x00000020
+set CMSDK_WRPR_INTRPT_CFG_9 [expr $CMSDK_WRPR_BASE + 0xa0]
+set CMSDK_WRPR_INTRPT_CFG_9_INTRPT9_MASK__RESET_VALUE 0x00000040
+set CMSDK_WRPR_INTRPT_CFG_9__RESET_VALUE 0x00000040
+set CMSDK_WRPR_INTRPT_CFG_10 [expr $CMSDK_WRPR_BASE + 0xa4]
+set CMSDK_WRPR_INTRPT_CFG_10_INTRPT10_MASK__RESET_VALUE 0x00000080
+set CMSDK_WRPR_INTRPT_CFG_10__RESET_VALUE 0x00000080
+set CMSDK_WRPR_INTRPT_CFG_11 [expr $CMSDK_WRPR_BASE + 0xa8]
+set CMSDK_WRPR_INTRPT_CFG_11_INTRPT11_MASK__RESET_VALUE 0x00000100
+set CMSDK_WRPR_INTRPT_CFG_11__RESET_VALUE 0x00000100
+set CMSDK_WRPR_INTRPT_CFG_12 [expr $CMSDK_WRPR_BASE + 0xac]
+set CMSDK_WRPR_INTRPT_CFG_12_INTRPT12_MASK__RESET_VALUE 0x00000200
+set CMSDK_WRPR_INTRPT_CFG_12__RESET_VALUE 0x00000200
+set CMSDK_WRPR_INTRPT_CFG_13 [expr $CMSDK_WRPR_BASE + 0xb0]
+set CMSDK_WRPR_INTRPT_CFG_13_INTRPT13_MASK__RESET_VALUE 0x00000400
+set CMSDK_WRPR_INTRPT_CFG_13__RESET_VALUE 0x00000400
+set CMSDK_WRPR_INTRPT_CFG_14 [expr $CMSDK_WRPR_BASE + 0xb4]
+set CMSDK_WRPR_INTRPT_CFG_14_INTRPT14_MASK__RESET_VALUE 0x00000800
+set CMSDK_WRPR_INTRPT_CFG_14__RESET_VALUE 0x00000800
+set CMSDK_WRPR_INTRPT_CFG_15 [expr $CMSDK_WRPR_BASE + 0xb8]
+set CMSDK_WRPR_INTRPT_CFG_15_INTRPT15_MASK__RESET_VALUE 0x3c001000
+set CMSDK_WRPR_INTRPT_CFG_15__RESET_VALUE 0x3c001000
+set CMSDK_WRPR_REMAP [expr $CMSDK_WRPR_BASE + 0xbc]
+set CMSDK_WRPR_REMAP_QSPI_DROP__RESET_VALUE 0x00000000
+set CMSDK_WRPR_REMAP__RESET_VALUE 0x00000000
+set CMSDK_WRPR_AHB_INTERPOSERS [expr $CMSDK_WRPR_BASE + 0xc0]
+set CMSDK_WRPR_AHB_INTERPOSERS_QSPI_INTP_ENABLE__RESET_VALUE 0x00000001
+set CMSDK_WRPR_AHB_INTERPOSERS_QSPI_INTP_LOW_CEILING__RESET_VALUE 0x00000000
+set CMSDK_WRPR_AHB_INTERPOSERS__RESET_VALUE 0x00000001
+set CMSDK_WRPR_SCRATCHPAD_A [expr $CMSDK_WRPR_BASE + 0xc4]
+set CMSDK_WRPR_SCRATCHPAD_A_MISC__RESET_VALUE 0x00000000
+set CMSDK_WRPR_SCRATCHPAD_A__RESET_VALUE 0x00000000
+set CMSDK_WRPR_SCRATCHPAD_B [expr $CMSDK_WRPR_BASE + 0xc8]
+set CMSDK_WRPR_SCRATCHPAD_B_MISC__RESET_VALUE 0x00000000
+set CMSDK_WRPR_SCRATCHPAD_B__RESET_VALUE 0x00000000
+set CMSDK_WRPR_SCRATCHPAD_C [expr $CMSDK_WRPR_BASE + 0xcc]
+set CMSDK_WRPR_SCRATCHPAD_C_MISC__RESET_VALUE 0x00000000
+set CMSDK_WRPR_SCRATCHPAD_C__RESET_VALUE 0x00000000
+set CMSDK_WRPR_SCRATCHPAD_D [expr $CMSDK_WRPR_BASE + 0xd0]
+set CMSDK_WRPR_SCRATCHPAD_D_MISC__RESET_VALUE 0x00000000
+set CMSDK_WRPR_SCRATCHPAD_D__RESET_VALUE 0x00000000
+set CMSDK_WRPR_CHIPID1 [expr $CMSDK_WRPR_BASE + 0xff0]
+set CMSDK_WRPR_CHIPID1_CHAR3__RESET_VALUE 0x0000006e
+set CMSDK_WRPR_CHIPID1_CHAR2__RESET_VALUE 0x00000064
+set CMSDK_WRPR_CHIPID1_CHAR1__RESET_VALUE 0x00000079
+set CMSDK_WRPR_CHIPID1_CHAR0__RESET_VALUE 0x00000053
+set CMSDK_WRPR_CHIPID1__RESET_VALUE 0x5379646e
+set CMSDK_WRPR_CHIPID2 [expr $CMSDK_WRPR_BASE + 0xff4]
+set CMSDK_WRPR_CHIPID2_CHAR7__RESET_VALUE 0x00000000
+set CMSDK_WRPR_CHIPID2_CHAR6__RESET_VALUE 0x00000000
+set CMSDK_WRPR_CHIPID2_CHAR5__RESET_VALUE 0x00000079
+set CMSDK_WRPR_CHIPID2_CHAR4__RESET_VALUE 0x00000065
+set CMSDK_WRPR_CHIPID2__RESET_VALUE 0x65790000
+set CMSDK_WRPR_CHIPREV [expr $CMSDK_WRPR_BASE + 0xff8]
+set CMSDK_WRPR_CHIPREV_MINOR__RESET_VALUE 0x00000002
+set CMSDK_WRPR_CHIPREV_MAJOR__RESET_VALUE 0x00000002
+set CMSDK_WRPR_CHIPREV_RUNNING_OFF_32KHZ_XTAL__RESET_VALUE 0x00000000
+set CMSDK_WRPR_CHIPREV__RESET_VALUE 0x00000202
+set CMSDK_WRPR_CORE_ID [expr $CMSDK_WRPR_BASE + 0xffc]
+set CMSDK_WRPR_CORE_ID_ID__RESET_VALUE 0x57525052
+set CMSDK_WRPR_CORE_ID__RESET_VALUE 0x57525052
diff --git a/platform/atm2/ATM22xx-x1x/openocd/regs/wrpr1.tcl b/platform/atm2/ATM22xx-x1x/openocd/regs/wrpr1.tcl
new file mode 100644
index 0000000..07908a5
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/regs/wrpr1.tcl
@@ -0,0 +1,68 @@
+set CMSDK_WRPR1_BASE 0x50003000
+set CMSDK_WRPR1_APB0_CTRL [expr $CMSDK_WRPR1_BASE + 0x0]
+set CMSDK_WRPR1_APB0_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB0_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB0_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_APB1_CTRL [expr $CMSDK_WRPR1_BASE + 0x4]
+set CMSDK_WRPR1_APB1_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB1_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB1_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_APB2_CTRL [expr $CMSDK_WRPR1_BASE + 0x8]
+set CMSDK_WRPR1_APB2_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB2_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB2_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_APB3_CTRL [expr $CMSDK_WRPR1_BASE + 0xc]
+set CMSDK_WRPR1_APB3_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB3_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB3_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_APB4_CTRL [expr $CMSDK_WRPR1_BASE + 0x10]
+set CMSDK_WRPR1_APB4_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB4_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB4_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_APB5_CTRL [expr $CMSDK_WRPR1_BASE + 0x14]
+set CMSDK_WRPR1_APB5_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB5_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB5_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_APB6_CTRL [expr $CMSDK_WRPR1_BASE + 0x18]
+set CMSDK_WRPR1_APB6_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB6_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB6_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_APB7_CTRL [expr $CMSDK_WRPR1_BASE + 0x1c]
+set CMSDK_WRPR1_APB7_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB7_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB7_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_APB8_CTRL [expr $CMSDK_WRPR1_BASE + 0x20]
+set CMSDK_WRPR1_APB8_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB8_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB8_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_APB9_CTRL [expr $CMSDK_WRPR1_BASE + 0x24]
+set CMSDK_WRPR1_APB9_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB9_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB9_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_APB10_CTRL [expr $CMSDK_WRPR1_BASE + 0x28]
+set CMSDK_WRPR1_APB10_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB10_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB10_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_APB11_CTRL [expr $CMSDK_WRPR1_BASE + 0x2c]
+set CMSDK_WRPR1_APB11_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB11_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB11_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_APB12_CTRL [expr $CMSDK_WRPR1_BASE + 0x30]
+set CMSDK_WRPR1_APB12_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB12_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB12_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_APB13_CTRL [expr $CMSDK_WRPR1_BASE + 0x34]
+set CMSDK_WRPR1_APB13_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB13_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB13_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_APB14_CTRL [expr $CMSDK_WRPR1_BASE + 0x38]
+set CMSDK_WRPR1_APB14_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB14_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB14_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_APB15_CTRL [expr $CMSDK_WRPR1_BASE + 0x3c]
+set CMSDK_WRPR1_APB15_CTRL_CLK_ENABLE__RESET_VALUE 0x00000000
+set CMSDK_WRPR1_APB15_CTRL_SRESET__RESET_VALUE 0x00000001
+set CMSDK_WRPR1_APB15_CTRL__RESET_VALUE 0x00000002
+set CMSDK_WRPR1_CORE_ID [expr $CMSDK_WRPR1_BASE + 0xffc]
+set CMSDK_WRPR1_CORE_ID_ID__RESET_VALUE 0x57525052
+set CMSDK_WRPR1_CORE_ID__RESET_VALUE 0x57525052
diff --git a/platform/atm2/ATM22xx-x1x/openocd/servers.tcl b/platform/atm2/ATM22xx-x1x/openocd/servers.tcl
new file mode 100644
index 0000000..e7360a0
--- /dev/null
+++ b/platform/atm2/ATM22xx-x1x/openocd/servers.tcl
@@ -0,0 +1,8 @@
+
+gdb_port 3333
+telnet_port 4444
+tcl_port 6666
+
+bindto 0.0.0.0
+
+source [find http/openocd_http.tcl]