Line 26... |
Line 26... |
#
|
#
|
# Author(s):
|
# Author(s):
|
# - Olivier Girard, olgirard@gmail.com
|
# - Olivier Girard, olgirard@gmail.com
|
#
|
#
|
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
# $Rev: 15 $
|
# $Rev: 74 $
|
# $LastChangedBy: olivier.girard $
|
# $LastChangedBy: olivier.girard $
|
# $LastChangedDate: 2009-08-04 22:41:47 +0200 (Tue, 04 Aug 2009) $
|
# $LastChangedDate: 2010-08-28 21:53:08 +0200 (Sat, 28 Aug 2010) $
|
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
#
|
#
|
# Description: Main utility functions for the openMSP430 serial debug
|
# Description: Main utility functions for the openMSP430 serial debug
|
# interface.
|
# interface.
|
#
|
#
|
Line 56... |
Line 56... |
# The following have been added:
|
# The following have been added:
|
#
|
#
|
# - ExecutePOR_Halt ()
|
# - ExecutePOR_Halt ()
|
# - GetCPU_ID ()
|
# - GetCPU_ID ()
|
# - GetCPU_ID_SIZE ()
|
# - GetCPU_ID_SIZE ()
|
# - VerifyCPU_ID (CPU_ID)
|
# - VerifyCPU_ID ()
|
# - WriteReg (Addr, Data)
|
# - WriteReg (Addr, Data)
|
# - WriteRegAll (DataArray)
|
# - WriteRegAll (DataArray)
|
# - ReadReg (Addr)
|
# - ReadReg (Addr)
|
# - ReadRegAll ()
|
# - ReadRegAll ()
|
# - WriteMemQuick8 (StartAddr, DataArray)
|
# - WriteMemQuick8 (StartAddr, DataArray)
|
Line 101... |
Line 101... |
# Remove PUC, clear break after reset
|
# Remove PUC, clear break after reset
|
set cpu_ctl_org [expr 0x5f & $cpu_ctl_org]
|
set cpu_ctl_org [expr 0x5f & $cpu_ctl_org]
|
dbg_uart_wr CPU_CTL $cpu_ctl_org
|
dbg_uart_wr CPU_CTL $cpu_ctl_org
|
|
|
# Check CPU ID
|
# Check CPU ID
|
if {![VerifyCPU_ID 0x4d5350]} {
|
if {![VerifyCPU_ID]} {
|
set result 0
|
set result 0
|
}
|
}
|
|
|
# Check status: make sure a PUC occured
|
# Check status: make sure a PUC occured
|
set cpu_stat_val [dbg_uart_rd CPU_STAT]
|
set cpu_stat_val [dbg_uart_rd CPU_STAT]
|
Line 218... |
Line 218... |
|
|
# Get number of hardware breakpoints
|
# Get number of hardware breakpoints
|
set hw_break(num) [InitBreakUnits]
|
set hw_break(num) [InitBreakUnits]
|
|
|
# Check CPU ID
|
# Check CPU ID
|
if {[VerifyCPU_ID 0x4d5350]} {
|
if {[VerifyCPU_ID]} {
|
return 1
|
return 1
|
} else {
|
} else {
|
return 0
|
return 0
|
}
|
}
|
}
|
}
|
Line 375... |
Line 375... |
dbg_uart_wr MEM_ADDR $StartAddr
|
dbg_uart_wr MEM_ADDR $StartAddr
|
dbg_uart_wr MEM_CTL 0x0001
|
dbg_uart_wr MEM_CTL 0x0001
|
|
|
set mem_val [dbg_uart_rx 0 [expr [llength $DataArray]*2]]
|
set mem_val [dbg_uart_rx 0 [expr [llength $DataArray]*2]]
|
|
|
return [string equal $DataArray $mem_val]
|
set return_val [string equal $DataArray $mem_val]
|
|
|
|
#if {$return_val==0} {
|
|
# puts $DataArray
|
|
# puts $mem_val
|
|
#}
|
|
|
|
return $return_val
|
}
|
}
|
|
|
#=============================================================================#
|
#=============================================================================#
|
# ExecutePOR_Halt () #
|
# ExecutePOR_Halt () #
|
#-----------------------------------------------------------------------------#
|
#-----------------------------------------------------------------------------#
|
Line 397... |
Line 404... |
set cpu_ctl_new [expr 0x60 | $cpu_ctl_org]
|
set cpu_ctl_new [expr 0x60 | $cpu_ctl_org]
|
dbg_uart_wr CPU_CTL $cpu_ctl_new
|
dbg_uart_wr CPU_CTL $cpu_ctl_new
|
dbg_uart_wr CPU_CTL $cpu_ctl_org
|
dbg_uart_wr CPU_CTL $cpu_ctl_org
|
|
|
# Check CPU ID
|
# Check CPU ID
|
if {![VerifyCPU_ID 0x4d5350]} {
|
if {![VerifyCPU_ID]} {
|
set result 0
|
set result 0
|
}
|
}
|
|
|
# Check status: make sure a PUC occured and that the CPU is halted
|
# Check status: make sure a PUC occured and that the CPU is halted
|
set cpu_stat_val [dbg_uart_rd CPU_STAT]
|
set cpu_stat_val [dbg_uart_rd CPU_STAT]
|
Line 436... |
Line 443... |
#-----------------------------------------------------------------------------#
|
#-----------------------------------------------------------------------------#
|
# Description: Returns the ROM and RAM sizes of the connected device. #
|
# Description: Returns the ROM and RAM sizes of the connected device. #
|
# Arguments : None. #
|
# Arguments : None. #
|
# Result : Return "ROM_SIZE RAM_SIZE" in byte. #
|
# Result : Return "ROM_SIZE RAM_SIZE" in byte. #
|
#=============================================================================#
|
#=============================================================================#
|
proc GetCPU_ID_SIZE { } {
|
proc GetCPU_ID_SIZE {} {
|
|
|
set cpu_id_full [GetCPU_ID]
|
set cpu_id_full [GetCPU_ID]
|
regexp {(.)(.)$} $cpu_id_full match rom_width ram_width
|
regexp {(....)(....)$} $cpu_id_full match rom_width ram_width
|
|
|
set rom_size [expr (1<<0x$rom_width)*2]
|
set rom_size [expr 0x$rom_width]
|
set ram_size [expr (1<<0x$ram_width)*2]
|
set ram_size [expr 0x$ram_width]
|
|
|
return "$rom_size $ram_size"
|
return "$rom_size $ram_size"
|
}
|
}
|
|
|
#=============================================================================#
|
#=============================================================================#
|
# VerifyCPU_ID (uint32 CPU_ID) #
|
# VerifyCPU_ID () #
|
#-----------------------------------------------------------------------------#
|
#-----------------------------------------------------------------------------#
|
# Description: Read and check the CPU_ID from the target device. #
|
# Description: Read and check the CPU_ID from the target device. #
|
# Arguments : None. #
|
# Arguments : None. #
|
# Result : 0 if error, 1 otherwise. #
|
# Result : 0 if error, 1 otherwise. #
|
#=============================================================================#
|
#=============================================================================#
|
proc VerifyCPU_ID {cpu_id} {
|
proc VerifyCPU_ID {} {
|
|
|
set cpu_id_full [GetCPU_ID]
|
set cpu_id_full [GetCPU_ID]
|
regsub {..$} $cpu_id_full {} cpu_id_hi
|
|
|
|
if {[string eq $cpu_id $cpu_id_hi]} {
|
if {[string eq "0x00000000" $cpu_id_full]} {
|
set result 1
|
|
} else {
|
|
set result 0
|
set result 0
|
|
} else {
|
|
set result 1
|
}
|
}
|
return $result
|
return $result
|
}
|
}
|
|
|
#=============================================================================#
|
#=============================================================================#
|