From 1dc7241e3a32635b3e3563fd5ddae482478dd92c Mon Sep 17 00:00:00 2001 From: Randall Spangler Date: Fri, 13 Jul 2012 14:08:35 -0700 Subject: [PATCH] Use openocd auto-erase when writing flash, and use sysresetreq to reset According to its datasheet, LM4 doesn't support vectreset, but does support sysresetreq. Using sysresetreq properly resets all peripherals and cleanly resets the LM4. Auto-erase makes the flash command faster. BUG=none TEST=flash_link_ro, flash_link_a, flash_link, all with different images Change-Id: I80b72de2ee0f42cee1b0f2f2a53062384d2c29aa Signed-off-by: Randall Spangler Reviewed-on: https://gerrit.chromium.org/gerrit/27416 --- chip/lm4/openocd/lm4x.cfg | 3 +++ chip/lm4/openocd/lm4x_cmds.tcl | 12 ++++-------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/chip/lm4/openocd/lm4x.cfg b/chip/lm4/openocd/lm4x.cfg index e9df0ad8d6..9c979c7dda 100644 --- a/chip/lm4/openocd/lm4x.cfg +++ b/chip/lm4/openocd/lm4x.cfg @@ -27,6 +27,9 @@ target create $_TARGETNAME cortex_m3 -chain-position $_CHIPNAME.cpu -variant lm3 # 12k working area at base of ram, not backed up $_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size 0x3000 +# Use system reset request, since LM4 doesn't support vectreset +cortex_m3 reset_config sysresetreq + # Ensure that the watchdog is properly disabled when doing flashing $_TARGETNAME configure -event reset-init { # Unlock watchdog0 diff --git a/chip/lm4/openocd/lm4x_cmds.tcl b/chip/lm4/openocd/lm4x_cmds.tcl index 9a3630552d..3f1c93e29a 100644 --- a/chip/lm4/openocd/lm4x_cmds.tcl +++ b/chip/lm4/openocd/lm4x_cmds.tcl @@ -7,14 +7,10 @@ # Program internal flash proc flash_lm4 {path offset size} { - set firstsect [expr {$offset / 1024}]; - set lastsect [expr {($offset + $size) / 1024 - 1}]; - reset init; - flash erase_sector internal $firstsect $lastsect; - # Note erase_sector silently fails sometimes; see crosbug.com/p/8632 - # Dump a few words as a diagnostic for whether erase succeeded - mdw 0 16 - flash write_image $path $offset; + #set firstsect [expr {$offset / 1024}]; + #set lastsect [expr {($offset + $size) / 1024 - 1}]; + reset halt; + flash write_image erase $path $offset; reset }