UV_K5_playground/.vscode/clone_stm32g0x.cfg

84 wiersze
2.7 KiB
INI

transport select swd
adapter speed 100
# Create a new dap, with name chip and role CPU, -enable let's OpenOCD to know to add it to the scan
swd newdap chip cpu -enable
# Create the DAP instance, this must be explicitly created according to the OpenOCD docs
dap create chip.dap -chain-position chip.cpu
# Set up the GDB target for the CPU, cortex_m is the CPU type,
target create chip.cpu cortex_m -dap chip.dap
# init reads out all of the necessary information from the DAP, kicks off the debugging session, etc
init
# Read out the information from the DAP, including the ROM table
dap info
reset halt
proc uv_clear_flash_sector {sector_number} {
echo [format "Eerasing sector 0x%02x = offset 0x%04x" [expr {$sector_number}] [expr {$sector_number*512}] ]
write_memory 0x4006F000 32 {0x09} ;#set erasing mode
write_memory 0x4006F004 32 [expr {$sector_number << 6}]
write_memory 0x4006F01c 32 {0xAA} ;#unlock flash
write_memory 0x4006F010 32 {0x01} ;#set OPSTART=1
read_memory 0x4006F014 32 1 ;#check status for 0x02
write_memory 0x4006F018 32 {0x55} ;#lock flash
}
proc uv_clear_whole_flash {} {
for {set i 0} {$i < 0x100} {incr i} {
uv_clear_flash_sector $i
}
}
proc uv_flash_unlock {} {
write_memory 0x4006F01c 32 {0xAA} ;#unlock flash
}
proc uv_flash_lock {} {
write_memory 0x4006F018 32 {0x55} ;#lock flash
}
proc uv_flash_write {address value} {
echo [format "Writing 0x%04x to address 0x%04x (FLASH_ADDR_REG=0x%04x)" $value $address [expr {($address>>2)+0xC000}] ]
write_memory 0x4006F000 32 {0x05} ;#set writing mode
write_memory 0x4006F004 32 [expr {($address>>2)+0xC000}] ;#set address in flash
write_memory 0x4006F008 32 $value ;#set data
write_memory 0x4006F010 32 {0x01} ;#set OPSTART=1
while {1} {
set status [read_memory 0x4006F014 32 1]
if {($status & 0x4) != 0} {
break
}
}
proc program {filename address} {
global _CHIPNAME
# Odblokuj flash
uv_flash_unlock
# Otwórz plik i odczytaj jego zawartość
set fd [open $filename "rb"]
set data [read $fd]
close $fd
# Zapisz każde słowo do flasha
set addr $address
foreach word [split $data " "] {
uv_flash_write $addr $word
incr addr 4
}
# Zablokuj flash
uv_flash_lock
}
# proc program {filename {address 0x0} {pre-verify {true}} {verify {true}} {reset {true}} {exit {true}}} {
# global _CHIPNAME
# my_program $filename $address
# }